0

Support for MKR WiFi 1010 - Halfway there!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Mon Sep 10, 2018 10:28 pm

I've been using MKR 1000s for .io projects with success. Adafruit.io has been very easy to use, and it's been great.

However, I recently purchased a couple MKR Wifi 1010s recently, which I'm not having much luck with. It would appear that there is not yet written support for the new boards.

Ultimately, I wish that Arduino would maintain consistency and backwards compatibility a little better, but since I'm stuck with unsupported hardware, can someone help me understand how to adapt the existing adafruit.io libraries to support my board?

Thanks!
Last edited by chrisbuck on Tue Sep 11, 2018 9:33 pm, edited 1 time in total.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010

by brubell on Tue Sep 11, 2018 10:54 am

While the Adafruit IO Arduino library doesn't officially support the MKR WiFi 1010, but it does support the Feather Huzzah ESP32 (same WiFi module exists on the MKR WiFi 1010).

You might want to first try the Adafruit MQTT Library (https://github.com/adafruit/Adafruit_MQTT_Library) with your board, it's compatible with the Arduino client interface.

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

Re: Support for MKR WiFi 1010

by chrisbuck on Tue Sep 11, 2018 1:42 pm

Hi there,

The example Publish sketch for AIO uses the MQTT library, so I've already got that included. Here's what I've done so far in trying to adapt for the MKR Wifi 1010:

There are a number of locations where the board type definition is checked. I think this must be set by the IDE. I concluded that the board name for the MKR WIFI 1010 is, as expected, ARDUINO_SAMD_MKRWIFI1010 from the boards.h file.
I duplicated the 'ArduinoIO_MKR1000.cpp & .h files, and renamed them appropriately for the MKRWIFI1010.
- Find & replace in the .cpp to have references to MKRWIFI1010.
- Find & replace in the .h to include WiFiNINA.h instead of WiFi101.h
Add an evaluation for MKRWIFI1010 in Adafruit_MQTT.cpp so it includes the dtostrf function.
There's probably a couple other smaller tweaks that I'm not thinking of.

At this point, I can get my board online successfully and see it listed as a connected device on my router, but it disconnects from Adafruit.io. Using the following from the troubleshooting guide:

Code: Select all | TOGGLE FULL SIZE
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.println(io.statusText());
delay(500);
}


I get a message that just says "Disconnected from Adafruit IO." which is the default for this switch from AdafruitIO.cpp (note I modified the ban return so I could check for that as a problem):

Code: Select all | TOGGLE FULL SIZE
aio_status_t AdafruitIO::mqttStatus()
{
  // if the connection failed,
  // return so we don't hammer IO
  if(_status == AIO_CONNECT_FAILED)
  {
    AIO_ERROR_PRINT("mqttStatus() failed to connect");
    AIO_ERROR_PRINTLN(_mqtt->connectErrorString(_status));
    return _status;
  }

  if(_mqtt->connected())
    return AIO_CONNECTED;

  switch(_mqtt->connect(_username, _key)) {
    case 0:
      return AIO_CONNECTED;
    case 1:   // invalid mqtt protocol
    case 2:   // client id rejected
    case 4:   // malformed user/pass
    case 5:   // unauthorized
      return AIO_CONNECT_FAILED;
    case 3:   // mqtt service unavailable
    case 6:   // throttled
    case 7:   // banned -> all MQTT bans are temporary, so eventual retry is permitted
      // delay to prevent fast reconnects
      delay(AIO_THROTTLE_RECONNECT_INTERVAL);
      return AIO_DISCONNECTED_BAN;
    default:
      return AIO_DISCONNECTED;
  }
}


At this point, I can't figure out how to troubleshoot further so any tips in that direction would be helpful.
Last edited by chrisbuck on Fri Sep 14, 2018 8:48 am, edited 3 times in total.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010

by chrisbuck on Tue Sep 11, 2018 1:43 pm

I should also mention that I can successfully use the examples from the WiFiNINA library that is supposed to be used with the 1010 in lieu of WiFi101.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010 - Halfway there!

by brubell on Wed Sep 12, 2018 10:21 am

Have you tried using the Adafruit IO Monitor to double-check if your client is connecting, then disconnecting - https://io.adafruit.com/monitor

Image

I should also mention that I can successfully use the examples from the WiFiNINA library that is supposed to be used with the 1010 in lieu of WiFi101.

Thanks for mentioning this, I'm following this thread for future (possible) updates to AIOArduino.

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

Re: Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Wed Sep 12, 2018 9:53 pm

I did check there, but there's nothing that shows under connections, nor under errors. I sort of assumed it was because the connection, if there was one, was only momentary.

I did notice in Adafruit_MQTT.h there's a #define for MQTT_DEBUG that instructs that you should be able to uncomment to print debugging info, but when I did that it made the board vanish from my COM port list after loading the sketch. I needed to put the board in bootloader mode and load blink to get it back again.

I also found this in Adafruit_MQTT.cpp but I'm not sure where/how to call connectErrorString() from.

Code: Select all | TOGGLE FULL SIZE
const __FlashStringHelper* Adafruit_MQTT::connectErrorString(int8_t code) {
   switch (code) {
      case 1: return F("The Server does not support the level of the MQTT protocol requested");
      case 2: return F("The Client identifier is correct UTF-8 but not allowed by the Server");
      case 3: return F("The MQTT service is unavailable");
      case 4: return F("The data in the user name or password is malformed");
      case 5: return F("Not authorized to connect");
      case 6: return F("Exceeded reconnect rate limit. Please try again later.");
      case 7: return F("You have been banned from connecting. Please contact the MQTT server administrator for more details.");
      case -1: return F("Connection failed");
      case -2: return F("Failed to subscribe");
      default: return F("Unknown error");
   }
Last edited by chrisbuck on Fri Sep 14, 2018 8:47 am, edited 1 time in total.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Wed Sep 12, 2018 10:49 pm

I was able to print the results of AdafruitIO::mqttStatus, which returned '2', or "client ID rejected". I can't figure that out though.

(This from AdafruitIO.cpp)

Code: Select all | TOGGLE FULL SIZE
aio_status_t AdafruitIO::mqttStatus()
{
  // if the connection failed,
  // return so we don't hammer IO
  if(_status == AIO_CONNECT_FAILED)
  {
    AIO_ERROR_PRINT("mqttStatus() failed to connect");
    AIO_ERROR_PRINTLN(_mqtt->connectErrorString(_status));
    return _status;
  }

  if(_mqtt->connected())
    return AIO_CONNECTED;

  switch(_mqtt->connect(_username, _key)) {
    case 0:
      return AIO_CONNECTED;
    case 1:   // invalid mqtt protocol
    case 2:   // client id rejected
    case 4:   // malformed user/pass
    case 5:   // unauthorized
      return AIO_CONNECT_FAILED;
    case 3:   // mqtt service unavailable
    case 6:   // throttled
    case 7:   // banned -> all MQTT bans are temporary, so eventual retry is permitted
      // delay to prevent fast reconnects
      delay(AIO_THROTTLE_RECONNECT_INTERVAL);
      return AIO_DISCONNECTED_BAN;
    default:
      return AIO_DISCONNECTED;
  }
}

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Fri Sep 14, 2018 9:06 am

Adafruit_MQTT.cpp includes calls to "DEBUG_PRINTLN()" but I can't figure out how to get those to print in the serial monitor. Any direction there? Seems like it's the #define for MQTT_DEBUG but that makes my board disconnect from my com port.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Wed Sep 26, 2018 7:20 pm

I never did figure this out. If anyone has any last suggestions or tips on continuing my debug efforts I'd appreciate them, otherwise I'll use the MKR1010 for something else and go back to the MKR1000.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Mon Oct 01, 2018 3:42 pm

In case someone else runs into this issue, it turned out to be that the MKR1010 currently ships without a root certificate required for the SSL connection to Adafruit, and there's not yet a fw update tool ready to load one. Use the MKR1000 instead.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Re: Support for MKR WiFi 1010 - Halfway there!

by brubell on Tue Oct 02, 2018 10:00 am

chrisbuck wrote:In case someone else runs into this issue, it turned out to be that the MKR1010 currently ships without a root certificate required for the SSL connection to Adafruit, and there's not yet a fw update tool ready to load one. Use the MKR1000 instead.

Thanks for the update!

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

Re: Support for MKR WiFi 1010 - Halfway there!

by chrisbuck on Mon Nov 26, 2018 10:08 am

This is resolved-ish with a FW update available for the MKRwifi1010 to 1.1.0 and WiFiNINA to 1.2. You'll need to add support to the adafruit library by modifying AdafruitIO_WiFi.h to call out the MKRWifi and making MKRWifi versions of the device config files (in AdafruitIO_Arduino/src/wifi) to include WifiNINA instead of WiFi101.

chrisbuck
 
Posts: 9
Joined: Mon Sep 10, 2018 9:52 pm

Please be positive and constructive with your questions and comments.