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

Arduino Uno Ethernet Shield connect to AIO
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.

Arduino Uno Ethernet Shield connect to AIO

by Weather411 on Thu Feb 06, 2020 5:23 pm

Hello all,

Been working this problem for several days and after many 'Google' searches, I'm still stumped.

As subject heading suggests, I'm trying to get my Arduino Uno w/ Ethernet Shield (W5500) connected with my Adafruit IO+ account. I have lots of feeds that update with a combination of ESP32 and ESP8266 boards with no problems using the Adafruit IO library.

Note: I built a simple local web server with a DHT22 using the Ethernet shield and it works perfectly.

Adafruit IO v3.4.0
Arduino AVR Boards v1.8.2
Ethernet v2.0.0 (I'm aware that Ethernet2 is now obsolete)

Sketch: example "adafruitio_00_publish"

Within the config.h tab, after I include my IO_USERNAME and IO_KEY, comment out the WIFI and FONA sections but include the Ethernet section (#include "AdafruitIO_Ethernet.h", AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);) I keep getting the same compile error:

Code: Select all | TOGGLE FULL SIZE
virtual void _disconnect() = 0;

                ^~~~~~~~~~~

exit status 1
cannot declare variable 'io' to be of abstract type 'AdafruitIO_Ethernet'


Is this a known bug? Can somebody test and confirm this result (possible fix?)...thank you in advance!
Mike

Weather411
 
Posts: 7
Joined: Fri Sep 15, 2017 7:38 pm

Re: Arduino Uno Ethernet Shield connect to AIO

by brubell on Fri Feb 07, 2020 10:31 am

Could you try it with the Arduino Ethernet library (not adafruit ethernet2)

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

Re: Arduino Uno Ethernet Shield connect to AIO

by Weather411 on Fri Feb 07, 2020 5:46 pm

Hello brubell

The example sketch from Adafruit IO does not include the Ethernet library, only "AdafruitIO_Ethernet.h" .... this is where the problem lies (look at the error code again)

I only mentioned the Ethernet library since I have other projects with my Uno ethernet shield (using the Ethernet library, not Ethernet2) and it works fine. Hardware is good.

I can attempt to re-write the code without using the Adafruit library (to post to AIO) using just the Ethernet library but that will take a lot of time (learning curve).

Weather411
 
Posts: 7
Joined: Fri Sep 15, 2017 7:38 pm

Re: Arduino Uno Ethernet Shield connect to AIO

by brubell on Tue Feb 11, 2020 11:48 am

Weather411 wrote:Hello brubell

The example sketch from Adafruit IO does not include the Ethernet library, only "AdafruitIO_Ethernet.h" .... this is where the problem lies (look at the error code again)

I only mentioned the Ethernet library since I have other projects with my Uno ethernet shield (using the Ethernet library, not Ethernet2) and it works fine. Hardware is good.

I can attempt to re-write the code without using the Adafruit library (to post to AIO) using just the Ethernet library but that will take a lot of time (learning curve).


I'm able to replicate this issue. I added a bug/issue for it on the library and will get to it in the next two weeks: https://github.com/adafruit/Adafruit_IO ... issues/110

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

Re: Arduino Uno Ethernet Shield connect to AIO

by Weather411 on Wed Feb 12, 2020 11:46 am

Great thank you!

Weather411
 
Posts: 7
Joined: Fri Sep 15, 2017 7:38 pm

Re: Arduino Uno Ethernet Shield connect to AIO

by WiddeA on Sun Mar 15, 2020 5:10 am

Hi, I ran into this problem last night, is there any update?
Greetings from Stockholm

WiddeA
 
Posts: 4
Joined: Sun Mar 31, 2019 6:03 am

Re: Arduino Uno Ethernet Shield connect to AIO

by The_Bucho on Thu Mar 19, 2020 4:51 pm

Same here. Here's my Config.h

Though there are more lines that I feel should be commented out, I followed exactly the instructions at https://learn.adafruit.com/adafruit-io-basics-digital-input/arduino-network-config first. Then I experimented with commenting out everything else, too. No luck.



Code: Select all | TOGGLE FULL SIZE
/************************ 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 "☐"
#define IO_KEY "☐"

/******************************* 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 HUZZAH ESP32 -> https://www.adafruit.com/product/3405
//   - Feather M0 WiFi -> https://www.adafruit.com/products/3010
//   - Feather WICED -> https://www.adafruit.com/products/3056
//   - Adafruit PyPortal -> https://www.adafruit.com/product/4116
//   - Adafruit Metro M4 Express AirLift Lite ->
//   https://www.adafruit.com/product/4000
//   - Adafruit AirLift Breakout -> https://www.adafruit.com/product/4201
//   - Adafruit AirLift Shield -> https://www.adafruit.com/product/4285
//   - Adafruit AirLift FeatherWing -> https://www.adafruit.com/product/4264

// #define WIFI_SSID "your_ssid"
// #define WIFI_PASS "your_pass"

// uncomment the following line if you are using airlift
// #define USE_AIRLIFT

// uncomment the following line if you are using winc1500
// #define USE_WINC1500

// comment out the following lines if you are using fona or ethernet
//#include "AdafruitIO_WiFi.h"

#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) ||         \
    defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define NINA_ACK 9    // a.k.a BUSY or READY pin
#define NINA_RESETN 6 // Reset pin
#define NINA_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
                   NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
#else
//AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
/******************************* 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);




And here's the error I get on compile:

Code: Select all | TOGGLE FULL SIZE

In file included from /var/folders/w9/_tsz01hx45vft50xkn3mn6800000gn/T/arduino_modified_sketch_463362/adafruitio_06_digital_in.ino:19:0:
config.h:70:22: 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:69:0,
                 from /var/folders/w9/_tsz01hx45vft50xkn3mn6800000gn/T/arduino_modified_sketch_463362/adafruitio_06_digital_in.ino:19:
/Users/themaestro/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/themaestro/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO_Ethernet.h:28:0,
                 from sketch/config.h:69,
                 from /var/folders/w9/_tsz01hx45vft50xkn3mn6800000gn/T/arduino_modified_sketch_463362/adafruitio_06_digital_in.ino:19:
/Users/themaestro/Documents/Arduino/libraries/Adafruit_IO_Arduino/src/AdafruitIO.h:136:16: note:    virtual void AdafruitIO::_disconnect()
   virtual void _disconnect() = 0;
                ^
Multiple libraries were found for "WiFi.h"
 Used: /Users/themaestro/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
exit status 1
cannot declare variable 'io' to be of abstract type 'AdafruitIO_Ethernet'

The_Bucho
 
Posts: 5
Joined: Thu Dec 20, 2018 6:14 pm

Re: Arduino Uno Ethernet Shield connect to AIO

by WiddeA on Fri Mar 20, 2020 2:47 am

Hi,
I've now managed to make the code compile and function OK using the following library versions:
* ArduinoHttpClient 0.3.1
* Adafruit MQTT Library 1.01
* Adafruit IO Arduino 3.3.0

The final trick was to comment out this #ifdef in Adafruit_MQTT.cpp:

Code: Select all | TOGGLE FULL SIZE
//#if defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_ARCH_SAMD)
static char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
 char fmt[20];
 sprintf(fmt, "%%%d.%df", width, prec);
 sprintf(sout, fmt, val);
 return sout;
}
//#endif


Take care,
WiddeA

WiddeA
 
Posts: 4
Joined: Sun Mar 31, 2019 6:03 am

Re: Arduino Uno Ethernet Shield connect to AIO

by The_Bucho on Wed Mar 25, 2020 4:37 pm

@widdleA, can I get you to comment on this:

Am I correct in assuming that I need to download the .zip from GH of the MQTT library, edit it locally to comment out those lines in the .ccp, then upload the library as a .zip to my IDE with another name or version...then include that version? I just don't see how else you get access to the actual lines of the library.

Do I have this right?

The_Bucho
 
Posts: 5
Joined: Thu Dec 20, 2018 6:14 pm

Re: Arduino Uno Ethernet Shield connect to AIO

by WiddeA on Thu Mar 26, 2020 3:30 am

Hi,
>download the .zip from GH
you could, but what I did was actually using the library manager of the Adafruit IDE to download the libraries of the versions I mentioned. The file you need to find and modify on your computer is "Adafruit_MQTT.cpp". On my PC I found it at the location "whatever_path\libraries\arduino_264042\Adafruit_MQTT.cpp". Pls let me know if you need a better step-by-step description of what to do. Though if you manage to make it compile and work you could maybe share how, I admit my description wan't the best :-)

WiddeA
 
Posts: 4
Joined: Sun Mar 31, 2019 6:03 am

Re: Arduino Uno Ethernet Shield connect to AIO

by brubell on Tue Mar 31, 2020 11:39 am

The final trick was to comment out this #ifdef in Adafruit_MQTT.cpp:


This #ifdef isn't commented in the latest version of Adafruit MQTT: https://github.com/adafruit/Adafruit_MQ ... TT.cpp#L24

Please make sure you've updated to the latest version of the Adafruit MQTT library.

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

Re: Arduino Uno Ethernet Shield connect to AIO

by The_Bucho on Tue Mar 31, 2020 11:44 am

Sorry...clarifying.

You're saying that I won't need to comment out that ifdef when I use the latest version....or you're saying I WILL need to comment that out?

The_Bucho
 
Posts: 5
Joined: Thu Dec 20, 2018 6:14 pm

Re: Arduino Uno Ethernet Shield connect to AIO

by WiddeA on Tue Mar 31, 2020 11:54 am

When I commented out the "#ifdef" it compiled and worked using the following versions:
- ArduinoHttpClient 0.4.0, **the latest version**.
- Adafruit MQTT Library 1.03, **the latest version**.
- Adafruit IO Arduino 3.3.1, **the second last version**.

WiddeA
 
Posts: 4
Joined: Sun Mar 31, 2019 6:03 am

Please be positive and constructive with your questions and comments.