Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

Grand Central M4 fails to connect using "AdafruitIO_WiFi.h"
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.

Grand Central M4 fails to connect using "AdafruitIO_WiFi.h"

by ahoadley on Mon Mar 09, 2020 7:47 pm

I am converting several Arduino projects over to use Adafruit IO, using Arduino IDE 1.8.12 and upgraded boards. I have my Metro M4 Airlift Lite boards up and running. My problem is with updating an Arduino Mega to a Metro M4 Grand Central connected to a Airlift ESP32 WiFi Co-Processor SPI Interface. I can run the connection test in the WiFiNINA library, including the WiFiSSLClient on the Metro M4 Grand Central. I figure this indicates the hardware is at least wired correctly. I wrote a test sketch to try to narrow down my issue, which I will include below. This sketch works on my Metro M4 Airlift Lite board and will compile OK on my Metro M4 Grand Central, but the sketch gets stuck in the "while (io.status() < AIO_CONNECTED) {" loop, generating a stream of:

18:41:58.972 -> *!1
18:41:59.491 -> *!1

I also found that upgrading the WiFiNINA library to 1.5 from 1.4 caused compiling error for both boards.

Any help on this will be appreciated.

Art

Code: Select all | TOGGLE FULL SIZE
#define IO_USERNAME   "##############"
#define IO_KEY        "####################"

#define WIFI_SSID "###############"
#define WIFI_PASS "##################"

#define USE_AIRLIFT
#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
/*
  //AirLift Setup for the Adafruit Metro M4 Airlift Lite
    #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
*/
  //AirLift Setup for the Adafruit Metro M4 Grand Central using Airlift ESP32 WiFi SPI Interface
    #define SPIWIFI SPI
    #define SPIWIFI_SS 27 // Chip select pin
    #define NINA_ACK 25    // a.k.a BUSY or READY pin
    #define NINA_RESETN 23 // 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

/*
//AirLift Setup for the Adafruit Metro M4 Airlift Lite
#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


AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
                   NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
*/
const long CycleTime = 1000;      // Time in ms between each program loop
long int counter = 0;
int CycleIndicatorPin = 13;
int NotificationControl = 0;
String ReturnStr = " ";

AdafruitIO_Time *iso = io.time(AIO_TIME_ISO);

String AdafruitTime;
String AdafruitHour;
String AdafruitMin;

AdafruitIO_Feed *output = io.feed("analog-test");
AdafruitIO_Feed *control = io.feed("test-on-off");

void setup()
{

  control->onMessage(handleMessage);

  // initialize the Motion pins as an input:
  pinMode(CycleIndicatorPin, OUTPUT);
  digitalWrite(CycleIndicatorPin, HIGH);

  // start the serial connection
  Serial.begin(9600);
  // wait to allow serial monitor to open
  delay(500);

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

  io.connect();

  // wait for a connection
  while (io.status() < AIO_CONNECTED) {
    Serial.println (io.status());
    Serial.print("*!");
    delay(500);
  }
  // attach a message handler for the ISO feed
  iso->onMessage(handleISO);

  // we are connected
  Serial.println();
  Serial.println(io.statusText());

  control->get();

  while(io.mqttStatus() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
}

void loop()
{
  io.run();
  // check for a reading no more than 200ms.
  if (millis() - CycleIndicatorPin > CycleTime)
  {
   
    digitalWrite(CycleIndicatorPin, HIGH);
    delay (1000);

    // read Data
    counter++;

    if (NotificationControl == 1) {
      Serial.println("Uploading Data*******************");
      output->save(counter);
    }
 
  digitalWrite(CycleIndicatorPin, LOW);
  }
}


void handleMessage(AdafruitIO_Data *data) {

  Serial.print("received <- *");
  ReturnStr = data->value();
  Serial.print(ReturnStr);
  Serial.print("*");

  // since we are using the same function to handle
  // messages for two feeds, we can use feedName() in
  // order to find out which feed the message came from.
 
  if(ReturnStr == "ON")
  {
    Serial.println("ON");
    NotificationControl = 1;
  }
  else
  {
    Serial.println("OFF");
    NotificationControl = 0;
  }
}


// message handler for the ISO-8601 feed
void handleISO(char *data, uint16_t len) {
  AdafruitTime = String(data);
  Serial.print("ISO Feed: ");
  Serial.println(data);
}

ahoadley
 
Posts: 6
Joined: Sun Sep 21, 2014 11:36 am

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by brubell on Tue Mar 10, 2020 11:41 am

Could you modify your code to force the Grand Central configuration and let me know if that works?
Code: Select all | TOGGLE FULL SIZE
  //AirLift Setup for the Adafruit Metro M4 Grand Central using Airlift ESP32 WiFi SPI Interface
    #define SPIWIFI SPI
    #define SPIWIFI_SS 27 // Chip select pin
    #define NINA_ACK 25    // a.k.a BUSY or READY pin
    #define NINA_RESETN 23 // Reset pin
    #define NINA_GPIO0 -1 // Not connected

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
                   NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);

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

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by ahoadley on Tue Mar 10, 2020 6:38 pm

I removed my board configuration code and inserted the code you provided and got the same results.

ahoadley
 
Posts: 6
Joined: Sun Sep 21, 2014 11:36 am

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by brubell on Thu Mar 12, 2020 11:41 am

I can run the connection test in the WiFiNINA library, including the WiFiSSLClient on the Metro M4 Grand Central.

Given this, are you able to run this example: https://github.com/adafruit/Adafruit_MQ ... irlift.ino

Make sure to change the pins here: https://github.com/adafruit/Adafruit_MQ ... ft.ino#L23

to match the configuration you used in the WiFiSSLClient example.

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

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by ahoadley on Thu Mar 12, 2020 8:35 pm

That code works using WiFiNINA library 1.4.0, which is great. I upgraded to WiFiNINA 1.5.0 to see if it still had that issue and got the following compiler error. I am not sure this is tied to why my Grand Central setup is not able to use the AdafruitIO_WiFi library, but thought it might be a clue.

*********************
Arduino: 1.8.12 (Windows 10), Board: "Adafruit Grand Central M4 (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"

C:\D_Drive\Arduino_Adafruit_Versions\adafruitio_secure_airlift_awh\adafruitio_secure_airlift_awh.ino: In function 'void setup()':

adafruitio_secure_airlift_awh:75:10: error: 'class WiFiClass' has no member named 'setPins'

WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);

^~~~~~~

Multiple libraries were found for "WiFiNINA.h"
Used: C:\D_Drive\Arduino_Adafruit_Versions\libraries\WiFiNINA
Not used: C:\D_Drive\Arduino_Adafruit_Versions\libraries\WiFiNINA-master
exit status 1
'class WiFiClass' has no member named 'setPins'

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

ahoadley
 
Posts: 6
Joined: Sun Sep 21, 2014 11:36 am

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by brubell on Fri Mar 13, 2020 9:43 am

Are you using the Adafruit fork of the Nina library, or the arduino one?

Please uninstall the Arduino library and install the adafruit one here: https://github.com/adafruit/WiFiNINA

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

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by ahoadley on Fri Mar 13, 2020 5:30 pm

I removed the Arduino library and added the Adafruit library in your link and then tested the sketch you previously had me run for testing. The Grand Central and the Airlift lite run just fine. I will just ignore the Arduino IDE update advisory.

I still cannot use the Adafruit_IO_WIFI library, which I also updated, on the Grand Central but can run on the Airlift Lite. There seems to be a difference between the two boards that the Adafruit_IO libary is not handling. Can you setup a Grand Central and uses the Adafruit_IO library to see if the problem is in my system or an issue with the Adafruit_IO library.

For reference the parts I am using are part of Order #2256396-7424321996.

ahoadley
 
Posts: 6
Joined: Sun Sep 21, 2014 11:36 am

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by ahoadley on Fri Mar 13, 2020 6:04 pm

Just on a whim I moved the pin assignments to 10, 9, 6 as they are on Airlift Lite. Sadly no change in the results.

ahoadley
 
Posts: 6
Joined: Sun Sep 21, 2014 11:36 am

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by brubell on Tue Mar 17, 2020 11:15 am

I still cannot use the Adafruit_IO_WIFI library, which I also updated, on the Grand Central but can run on the Airlift Lite. There seems to be a difference between the two boards that the Adafruit_IO libary is not handling.


After installing the Adafruit Nina-Fw, are you getting the same "adafruitio_secure_airlift_awh:75:10: error: 'class WiFiClass' has no member named 'setPins'" error as before?

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

Re: Grand Central M4 fails to connect using "AdafruitIO_WiFi

by ahoadley on Tue Mar 17, 2020 12:38 pm

I am getting no compiling errors now for either board. The Metro M4 Airlift Lite board runs successfully, with the following output:

12:11:55.345 ->
12:11:55.382 -> Adafruit IO connected.
12:11:56.497 -> received <- *OFF*OFF
12:11:56.497 -> ISO Feed: 2020-03-17T16:11:55.141Z
12:11:56.532 -> ISO Feed: 2020-03-17T16:11:56.142Z
12:11:57.635 -> ISO Feed: 2020-03-17T16:11:57.142Z
12:11:58.763 -> ISO Feed: 2020-03-17T16:11:58.142Z

The Grand Central has the same repeating output listed earlier.

18:41:58.972 -> *!1
18:41:59.491 -> *!1

The sketch is the original one I included, with the simplified pin assignment section you recommended earlier. I am also using the default pin assignments used on the Metro M4 Airlift Lite board ( 10, 9, 6 ) on the Grand Central with the appropriate wire changes. Thus the same sketch is run on both boards, with only the board designation and com port changed, as appropriate.

ahoadley
 
Posts: 6
Joined: Sun Sep 21, 2014 11:36 am

Please be positive and constructive with your questions and comments.