Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Adafruit IO Publish example not compiling. Cannot declare va
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Adafruit IO Publish example not compiling. Cannot declare va

by Robert_Beatty on Sun Jun 07, 2020 5:10 pm

I am getting an error when I attempt to compile the example "IO Publish" sketch provided in the Adafruit IO Arduino library:

cannot declare variable 'io' to be of abstract type 'AdafruitIO_Ethernet'


I am using a w5500 ethernet module not WIFI, so as per the instructions in the example, I uncommented the Ethernet-related lines in the config.h and took out the wifi-related lines. (I have also tried the examples with WIFI, but I get the same sort of "cannot declare variable' errors.)

Here is the main sketch code, the simplified config.h, and the full error text.

Code: Select all | TOGGLE FULL SIZE
// Adafruit IO Publish Example

#include "config.h"

// this int will hold the current count for our sketch
int count = 0;

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

void setup() {

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

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

  Serial.print("Connecting to Adafruit IO");

  // connect to io.adafruit.com
  io.connect();

  // 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();

  // save count to the 'counter' feed on Adafruit IO
  Serial.print("sending -> ");
  Serial.println(count);
  counter->save(count);

  // increment the count by 1
  count++;

  // Adafruit IO is rate limited for publishing, so a delay is required in
  // between feed->save events. In this example, we will wait three seconds
  // (1000 milliseconds == 1 second) during each loop.
  delay(3000);

}


Code: Select all | TOGGLE FULL SIZE
/************************ Adafruit IO Config *******************************/

#define IO_USERNAME    "Robert_Beatty"
#define IO_KEY         "600e39c9e725c55593bb9cfa9dcb48220df00efc"

#include "AdafruitIO_Ethernet.h"
AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);


FULL ERROR TEXT

Arduino: 1.8.12 (Mac OS X), Board: "Adafruit Grand Central M4 (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"

In file included from /Users/robertbeatty/Documents/Arduino/AIO_TEST/AIO_TEST.ino:3:0:
config.h:7:21: error: cannot declare variable 'io' to be of abstract type 'AdafruitIO_Ethernet'
AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);
^~
In file included from sketch/config.h:6:0,
from /Users/robertbeatty/Documents/Arduino/AIO_TEST/AIO_TEST.ino:3:
/Users/robertbeatty/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO_Ethernet.h:35:7: note: because the following virtual functions are pure within 'AdafruitIO_Ethernet':
class AdafruitIO_Ethernet : public AdafruitIO {
^~~~~~~~~~~~~~~~~~~
In file included from /Users/robertbeatty/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO_Ethernet.h:28:0,
from sketch/config.h:6,
from /Users/robertbeatty/Documents/Arduino/AIO_TEST/AIO_TEST.ino:3:
/Users/robertbeatty/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO.h:136:16: note: virtual void AdafruitIO::_disconnect()
virtual void _disconnect() = 0;
^~~~~~~~~~~
exit status 1
cannot declare variable 'io' to be of abstract type 'AdafruitIO_Ethernet'

Robert_Beatty
 
Posts: 55
Joined: Sun Jun 12, 2011 9:29 pm

Re: Adafruit IO Publish example not compiling. Cannot declar

by brubell on Mon Jun 08, 2020 11:34 am

Hi Robert, I'm fixing this issue today and will update with a link when it's ready.

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Adafruit IO Publish example not compiling. Cannot declar

by Robert_Beatty on Mon Jun 08, 2020 11:39 am

Excellent. Thank you.

Robert_Beatty
 
Posts: 55
Joined: Sun Jun 12, 2011 9:29 pm

Re: Adafruit IO Publish example not compiling. Cannot declar

by brubell on Mon Jun 08, 2020 12:34 pm

Ok, I just updated and bumped the library. You should be able to download the latest version of Adafruit IO Arduino which fixes this issue here:

https://github.com/adafruit/Adafruit_IO ... /tag/3.6.3

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Re: Adafruit IO Publish example not compiling. Cannot declar

by Robert_Beatty on Mon Jun 08, 2020 12:42 pm

OK. Thank you. I'll try it now.

Robert_Beatty
 
Posts: 55
Joined: Sun Jun 12, 2011 9:29 pm

Re: Adafruit IO Publish example not compiling. Cannot declar

by Robert_Beatty on Mon Jun 08, 2020 1:19 pm

Success!

I deleted the older library folder, dropped in the new one, re-started Arduino, and tried compiling the test program. It compiled with no errors. I also compiled my actual project sketch with no errors. So, I think you got it. Thank you.

I'll now move forward to the next step to see if I can get my sketch to feed data up to the IO platform.

Thanks for the help,

—Robert

Robert_Beatty
 
Posts: 55
Joined: Sun Jun 12, 2011 9:29 pm

Re: Adafruit IO Publish example not compiling. Cannot declar

by brubell on Tue Jun 09, 2020 11:32 am

no problem - thanks for reporting the issue.

brubell
 
Posts: 946
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.