Skip to content

ADAfruit , io Adruino example "adafruitio_16servo example" will not compile without error. #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stephenvowell opened this issue Feb 27, 2019 · 2 comments

Comments

@stephenvowell
Copy link

ADAfruit io Adruino example adafruitio_16servo example will not compile without error.
I am using Arduino 1.8.8 ide and have the latest libraries and correct usb cable. code is below

// 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 <ESP32Servo.h>
#else
#include <Servo.h>
#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);

}

Compile error message 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.

@stephenvowell stephenvowell changed the title Adafruit Feather HUZZAH ESP8266 ADAfruit , io Adruino example "adafruitio_16servo example" will not compile without error. Feb 27, 2019
@Jvejvad
Copy link

Jvejvad commented Mar 28, 2019

Hi.

I have similar problem.

using IDE 1.8.9
and compiling to a ESP8266.

  • code has been running earlier, but will not compile at the moment.

Arduino: 1.8.9 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled, ck, 26 MHz, 40MHz, DIO, 512K (no SPIFFS), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src\wifi\AdafruitIO_ESP8266.cpp: In constructor 'AdafruitIO_ESP8266::AdafruitIO_ESP8266(const char*, const char*, const char*, const char*)':

C:\Users\20438\OneDrive\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 C:\Users\20438\OneDrive\Arduino\libraries\ArduinoHttpClient\src/ArduinoHttpClient.h:8:0,

             from C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src/AdafruitIO.h:23,

             from C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src\wifi\AdafruitIO_ESP8266.h:18,

             from C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src\wifi\AdafruitIO_ESP8266.cpp:14:

C:\Users\20438\OneDrive\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 C:\Users\20438\OneDrive\Arduino\libraries\ArduinoHttpClient\src/HttpClient.h:10:0,

             from C:\Users\20438\OneDrive\Arduino\libraries\ArduinoHttpClient\src/ArduinoHttpClient.h:8,

             from C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src/AdafruitIO.h:23,

             from C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src\wifi\AdafruitIO_ESP8266.h:18,

             from C:\Users\20438\OneDrive\Arduino\libraries\Adafruit_IO_Arduino\src\wifi\AdafruitIO_ESP8266.cpp:14:

C:\Users\20438\AppData\Local\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;

                 ^

C:\Users\20438\AppData\Local\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;

                  ^

C:\Users\20438\AppData\Local\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;

                  ^

exit status 1
Error compiling for board Generic ESP8266 Module.

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

@Jvejvad
Copy link

Jvejvad commented Apr 8, 2019

try this !
ESP8266 board manager v. 2.5.0 seems to be causing this - switch back to before the beta editions.

https://forums.adafruit.com/viewtopic.php?f=8&t=145524

v. 2.4.2 solved my problems and all my old code is now running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants