adafruit / Adafruit_IO_Arduino

Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Other
209 stars 108 forks source link

Adafruit IO Servo Example compile error #80

Closed stephenvowell closed 5 years ago

stephenvowell commented 5 years ago

The Adafruit_IO Servo example will not compile with out error using Arduino 1.8.8 and an adafruit huzzah esp8266 , I attempted to compile sample code no changes at all and I get compile error.

here is the code // Adafruit IO Servo Example // Adafruit IO Servo Example // Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-servo // // 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-2017 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 ***/

if defined(ARDUINO_ARCH_ESP32)

// ESP32Servo Library (https://github.com/madhephaestus/ESP32Servo) // installation: library manager -> search -> "ESP32Servo"

include

else

include

endif

// pin used to control the servo

define SERVO_PIN 2

// create an instance of the servo class Servo servo;

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

void setup() {

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

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

// tell the servo class which pin we are using servo.attach(SERVO_PIN);

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

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

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

// we are connected Serial.println(); Serial.println(io.statusText()); servo_feed->get();

}

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 a 'servo' message // is received from Adafruit IO. it was attached to // the servo feed in the setup() function above. void handleMessage(AdafruitIO_Data *data) {

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

// make sure we don't exceed the limit // of the servo. the range is from 0 // to 180. if(angle < 0) angle = 0; else if(angle > 180) angle = 180;

servo.write(angle);

}

error log below

Arduino: 1.8.8 (Mac OS X), Board: "Adafruit Feather HUZZAH ESP8266, 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

/Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP8266.cpp: In constructor 'AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char, const char, const char, const char)': /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP8266.cpp:22:53: error: cannot allocate an object of abstract type 'HttpClient' _http = new HttpClient(*_client, _host, _http_port); ^ In file included from /Users/stephenvowell/Documents/Arduino/libraries/ArduinoHttpClient/src/ArduinoHttpClient.h:8:0, from /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO.h:23, from /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP8266.h:18, from /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP8266.cpp:14: /Users/stephenvowell/Documents/Arduino/libraries/ArduinoHttpClient/src/HttpClient.h:41:7: note: because the following virtual functions are pure within 'HttpClient': class HttpClient : public Client ^ In file included from /Users/stephenvowell/Documents/Arduino/libraries/ArduinoHttpClient/src/HttpClient.h:10:0, from /Users/stephenvowell/Documents/Arduino/libraries/ArduinoHttpClient/src/ArduinoHttpClient.h:8, from /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO.h:23, from /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP8266.h:18, from /Users/stephenvowell/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/wifi/AdafruitIO_ESP8266.cpp:14: /Users/stephenvowell/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/Client.h:29:21: note: virtual int Client::connect(const IPAddress&, uint16_t) virtual int connect(CONST IPAddress& ip, uint16_t port) =0; ^ /Users/stephenvowell/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/Client.h:37:22: note: virtual bool Client::flush(unsigned int) virtual bool flush(unsigned int maxWaitMs = 0) = 0; ^ /Users/stephenvowell/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/Client.h:38:22: note: virtual bool Client::stop(unsigned int) virtual bool stop(unsigned int maxWaitMs = 0) = 0; ^ Multiple libraries were found for "Servo.h" Used: /Users/stephenvowell/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/Servo Not used: /Applications/Arduino.app/Contents/Java/libraries/Servo exit status 1 Error compiling for board Adafruit Feather HUZZAH ESP8266.

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

ladyada commented 5 years ago

@brentru

ladyada commented 5 years ago

@stephenvowell hi stephen, please open up an issue here https://github.com/arduino-libraries/ArduinoHttpClient/issues since the error is not in our library and we can't fix it without their help. thanks!

stephenvowell commented 5 years ago

Thanks Just did

brentru commented 5 years ago

Firmware 2.5.0 for the ESP8266 breaks compatibility with ArduinoHttpClient, which is used by Adafruit IO Arduino.

As a workaround, you'll need to downgrade the firmware on the ESP8266 from 2.5.0 to 2.4.2. For information on how to do this, follow these instructions: https://learn.adafruit.com/adafruit-io-basics-esp8266-arduino/arduino-io-library#receiving-an-error-when-compiling-your-sketch