SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By scspark
#194755
Hello,

I'm trying to learn how to push data to IO using my SparkFun ESP8266 Wifi Shield. To do so, I made sure to install the following libraries:

* ArduinoHttpClient (from within IDE)
* Adafruit ESP8266 (from within IDE)
* Adafruit IO Arduino (from within IDE)
* Adafruit MQTT Library (from within IDE)
* Sparkfun ESP8266 (from github link)

Then using the adafruitio_09_analog_out example file, I set up my IO account name and key, and modified the wifi settings to use the SparkFun wifi code. I tried uninstalling arduino IDE, deleting the libraries, and the reinstalling the libraries in the same way as above. When I try to compile the code, I get the following errors:
Code: Select all
Arduino: 1.8.2 (Windows 10), Board: "Arduino/Genuino Uno"

adafruitio_09_analog_out:27: error: 'AdafruitIO_Feed' does not name a type

 AdafruitIO_Feed *analog = io.feed("analog");

 ^

adafruitio_09_analog_out:72: error: variable or field 'handleMessage' declared void

 void handleMessage(AdafruitIO_Data *data) {

                    ^

adafruitio_09_analog_out:72: error: 'AdafruitIO_Data' was not declared in this scope

adafruitio_09_analog_out:72: error: 'data' was not declared in this scope

 void handleMessage(AdafruitIO_Data *data) {

                                     ^

C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_571705\adafruitio_09_analog_out.ino: In function 'void setup()':

adafruitio_09_analog_out:39: error: 'io' was not declared in this scope

   io.connect();

   ^

adafruitio_09_analog_out:45: error: 'analog' was not declared in this scope

   analog->onMessage(handleMessage);

   ^

adafruitio_09_analog_out:45: error: 'handleMessage' was not declared in this scope

   analog->onMessage(handleMessage);

                     ^

adafruitio_09_analog_out:48: error: 'AIO_CONNECTED' was not declared in this scope

   while(io.status() < AIO_CONNECTED) {

                       ^

C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_571705\adafruitio_09_analog_out.ino: In function 'void loop()':

adafruitio_09_analog_out:65: error: 'io' was not declared in this scope

   io.run();

   ^

C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_571705\adafruitio_09_analog_out.ino: At global scope:

adafruitio_09_analog_out:72: error: variable or field 'handleMessage' declared void

 void handleMessage(AdafruitIO_Data *data) {

                    ^

adafruitio_09_analog_out:72: error: 'AdafruitIO_Data' was not declared in this scope

adafruitio_09_analog_out:72: error: 'data' was not declared in this scope

 void handleMessage(AdafruitIO_Data *data) {

                                     ^

exit status 1
'AdafruitIO_Feed' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Some Googling suggests that "does not name a type" usually means I'm missing a library. Any ideas? The example code is:
Code: Select all
// Adafruit IO Analog Out Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-analog-output
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"

/************************ Example Starts Here *******************************/

// this should correspond to a pin with PWM capability
#define LED_PIN 5

// set up the 'analog' feed
AdafruitIO_Feed *analog = io.feed("analog");

void setup() {

  // start the serial connection
  Serial.begin(115200);

  // wait for serial monitor to open
  while(! Serial);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");
  io.connect();

  // set up a message handler for the 'analog' feed.
  // the handleMessage function (defined below)
  // will be called whenever a message is
  // received from adafruit io.
  analog->onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());

}

void loop() {

  // io.run(); is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  // io.adafruit.com, and processes any incoming data.
  io.run();

}

// this function is called whenever an 'analog' message
// is received from Adafruit IO. it was attached to
// the analog feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {

  // convert the data to integer
  int reading = data->toInt();

  Serial.print("received <- ");
  Serial.println(reading);
  analogWrite(LED_PIN, reading);

}
And the modified config.h code:
Code: Select all
/************************ Adafruit IO Config *******************************/

// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME    "scada"
#define IO_KEY         "MYKEY"

/******************************* WIFI **************************************/

// the AdafruitIO_WiFi client will work with the following boards:
//   - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
//   - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
//   - Feather M0 WiFi -> https://www.adafruit.com/products/3010
//   - Feather WICED -> https://www.adafruit.com/products/3056

#include <SoftwareSerial.h>
#include <SparkFunESP8266Client.h>
#include <SparkFunESP8266Server.h>
#include <SparkFunESP8266WiFi.h>

const char mySSID[] = "MYSSID";
const char myPSK[] = "MYPW";
ESP8266Server server = ESP8266Server(80);

// comment out the following two lines if you are using fona or ethernet
//#include "AdafruitIO_WiFi.h"
//AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

/******************************* FONA **************************************/

// the AdafruitIO_FONA client will work with the following boards:
//   - Feather 32u4 FONA -> https://www.adafruit.com/product/3027

// uncomment the following two lines for 32u4 FONA,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_FONA.h"
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);


/**************************** ETHERNET ************************************/

// the AdafruitIO_Ethernet client will work with the following boards:
//   - Ethernet FeatherWing -> https://www.adafruit.com/products/3201

// uncomment the following two lines for ethernet,
// and comment out the AdafruitIO_WiFi client in the WIFI section
// #include "AdafruitIO_Ethernet.h"
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);