🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

Arduino Wifi Rev2 support AdafruitIO
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 Wifi Rev2 support AdafruitIO

by SKuppens on Thu Nov 28, 2019 11:32 am

Hi,

I encountered the same problems as stated in a previous topic that has been locked.
I didn't get to upload my code with the help of the posts I got from that topic.

I did try 3 different libraries but none of them would work.
I used the one from the topic, used one from a guide (https://www.woolseyworkshop.com/2019/06/06/adafruit-io-connecting-your-arduino-to-the-outside-world/) and also tried another one of AdafruitIO but with no succes.

I was not able to install the library AdafruitIO_Wifi.h.
It seems it is included in the Adafruit IO Arduino library... (it is installed, but the library in this skecth does not get recognised)

I Include my code for review:
Code: Select all | TOGGLE FULL SIZE

// DHT22 AIO Connection
//
// Description:
// Interfaces a DHT22 sensor on an Arduino Uno WiFi Rev2 with the
// Adafruit IO service.
// Note: Must use Adafruit's modified version of the WiFiNINA library
// (https://github.com/adafruit/WiFiNINA), define USE_AIRLIFT, and instantiate
// AdafruitIO_WiFi with pin connections for Arduino Uno WiFi Rev2 compatability.
// NOTE: The sketch sometimes gets stuck initially connecting to the service and
// needs to be reuploaded.
//
// Circuit:
// DHT22 sensor connected to PIN2
//
// Created by John Woolsey on 05/29/2019. Adapted
// Copyright © 2019 Woolsey Workshop.  All rights reserved.


// Defines
#define AIO_USERNAME  "USN"
#define AIO_KEY       "USRKEY"
#define AIO_DHT_FEED    "AdaIOFeed"
#define WIFI_SSID       "SSID"
#define WIFI_PASS       "SSIDPWD"
#define USE_AIRLIFT     // required for Arduino Uno WiFi R2 board compatability


// Libraries
#include <AdafruitIO_WiFi.h>
#include <WiFiNINA.h>
#include <DHT.h>


// Pin Mapping
#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
// Constructors
AdafruitIO_WiFi aio(AIO_USERNAME, AIO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS, SPIWIFI_ACK, SPIWIFI_RESET, NINA_GPIO0, &SPI);
AdafruitIO_Feed *dhtFeed = aio.feed(AIO_DHT_FEED);

void setup() {
    // Serial bus initialization (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);  // wait for serial connection

  // Adafruit IO connection and configuration
  Serial.print("Connecting to Adafruit IO");
  aio.connect();  // connect to Adafruit IO service
  while(aio.status() < AIO_CONNECTED) {
     Serial.print(".");
     delay(1000);  // wait 1 second between checks
  }
  Serial.println();
  Serial.println(aio.statusText());  // print AIO connection status
  // Set up message handler that calls function when messages are received
  // redLEDFeed->onMessage(redLEDMessageHandler);

  // Synchronize current state
  // redLEDFeed->get();  // request feed value (message) from AIO
 
  dht.begin();
}


void loop() {
  float dhtValue = dht.readTemperature();
  aio.run();  // keep client connected to AIO service
   
  dhtFeed->save(dhtValue);  // send tempreading value to AIO
  Serial.print("Temp feed sent <- ");  Serial.println(dhtValue);
  delay(5000);  // limit AIO updates (30 per minute on free tier)
}


// Handles Red LED feed message received from AIO
//void redLEDMessageHandler(AdafruitIO_Data *data) {
//   String value = data->toString();  // capture feed value from AIO
//   Serial.print("Red LED feed received -> ");  Serial.println(value);
//   digitalWrite(RedLED, value == "ON" ? HIGH : LOW);
//}


I'm not sure what the problem could be.
The lines I commented out are not relevant to me. Maybe I made an error there?
At this point I got this error as you can see below:

Code: Select all | TOGGLE FULL SIZE
Arduino: 1.8.10 (Windows 10), Board:"Arduino Uno WiFi Rev2, ATMEGA328"

In file included from C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.h:15:0,

                 from C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:12:

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp: In member function 'const __FlashStringHelper* AdafruitIO::statusText()':

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:146:27: note: in expansion of macro 'F'

     case AIO_IDLE: return F("Idle. Waiting for connect to be called...");

                           ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:147:39: note: in expansion of macro 'F'

     case AIO_NET_DISCONNECTED: return F("Network disconnected.");

                                       ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:148:35: note: in expansion of macro 'F'

     case AIO_DISCONNECTED: return F("Disconnected from Adafruit IO.");

                                   ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:151:41: note: in expansion of macro 'F'

     case AIO_NET_CONNECT_FAILED: return F("Network connection failed.");

                                         ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:152:37: note: in expansion of macro 'F'

     case AIO_CONNECT_FAILED: return F("Adafruit IO connection failed.");

                                     ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:153:42: note: in expansion of macro 'F'

     case AIO_FINGERPRINT_INVALID: return F("Adafruit IO SSL fingerprint verification failed.");

                                          ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:154:34: note: in expansion of macro 'F'

     case AIO_AUTH_FAILED: return F("Adafruit IO authentication failed.");

                                  ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:157:36: note: in expansion of macro 'F'

     case AIO_NET_CONNECTED: return F("Network connected.");

                                    ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:158:32: note: in expansion of macro 'F'

     case AIO_CONNECTED: return F("Adafruit IO connected.");

                                ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:159:41: note: in expansion of macro 'F'

     case AIO_CONNECTED_INSECURE: return F("Adafruit IO connected. **THIS CONNECTION IS INSECURE** SSL/TLS not supported for this platform.");

                                         ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:160:46: note: in expansion of macro 'F'

     case AIO_FINGERPRINT_UNSUPPORTED: return F("Adafruit IO connected over SSL/TLS. Fingerprint verification unsupported.");

                                              ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:161:40: note: in expansion of macro 'F'

     case AIO_FINGERPRINT_VALID: return F("Adafruit IO connected over SSL/TLS. Fingerprint valid.");

                                        ^

C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\cores\arduino/Arduino.h:30:20: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return

 #define F(str) (str)

                    ^

Meerdere bibliotheken gevonden voor "WiFiNINA.h"
Gebruikt: C:\Users\stijn\Documents\Arduino\libraries\WiFiNINA-master
C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino\src\AdafruitIO.cpp:163:21: note: in expansion of macro 'F'

Meerdere bibliotheken gevonden voor "SPI.h"
     default: return F("Unknown status code");

Gebruikt: C:\Users\stijn\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI
                     ^

Meerdere bibliotheken gevonden voor "DHT.h"
Gebruikt: C:\Users\stijn\Documents\Arduino\libraries\DHT_sensor_library_DHT
Meerdere bibliotheken gevonden voor "Adafruit_Sensor.h"
Gebruikt: C:\Users\stijn\Documents\Arduino\libraries\Adafruit_Unified_Sensor
Meerdere bibliotheken gevonden voor "AdafruitIO_WiFi.h"
Gebruikt: C:\Users\stijn\Documents\Arduino\libraries\Adafruit_IO_Arduino
Meerdere bibliotheken gevonden voor "Adafruit_MQTT.h"
Gebruikt: C:\Users\stijn\Documents\Arduino\libraries\Adafruit_MQTT_Library
Meerdere bibliotheken gevonden voor "ArduinoHttpClient.h"
Gebruikt: C:\Users\stijn\Documents\Arduino\libraries\ArduinoHttpClient
exit status 1
Fout bij het compileren voor board Arduino Uno WiFi Rev2



Is there anybody who can shed some light onto this?

Kindest regards,
Thank you for looking in to this.

Stijn

SKuppens
 
Posts: 3
Joined: Thu Nov 28, 2019 10:19 am

Re: Arduino Wifi Rev2 support AdafruitIO

by woolsey on Sat Nov 30, 2019 3:05 pm

Hi Stijn,

It appears the 1.8.5 version of the megaAVR board changes the way the F (flash based strings) macro works, which is being used by the various libraries being included. If you revert back to the 1.8.4 version, your program should compile.

- Open the Arduino IDE.
- Open the Boards Manager (Main Menu > Tools > Board: “Arduino Uno WiFi Rev2” > Boards Manager …)
- Find Arduino megaAVR Boards by Arduino.
- Change the version to 1.8.4.
- Retry compiling your program.

woolsey
 
Posts: 7
Joined: Wed Apr 03, 2019 4:09 pm

Re: Arduino Wifi Rev2 support AdafruitIO

by SKuppens on Sun Dec 01, 2019 6:57 pm

Thanks for investigating.

I was able to compile succesfully with your guideline.
Tomorrow I'll be able to hook up the device and see the outcome.
Keep you posted!

Already a big thank you!

SKuppens
 
Posts: 3
Joined: Thu Nov 28, 2019 10:19 am

Re: Arduino Wifi Rev2 support AdafruitIO

by SKuppens on Mon Dec 02, 2019 4:40 pm

Hi,

Everything works fine.
Thank you for the help!

Regards,

SKuppens
 
Posts: 3
Joined: Thu Nov 28, 2019 10:19 am

Please be positive and constructive with your questions and comments.