Error Compiling for board Arduino MKR1000

Hello everybody, newbie here. I'm following this tutorial on Arduino Create called Plant Communicator and encountered a problem where the board has an error compiling it.

So far I have tried running other test examples such as the " SimpleWebServerWiFi.ino" and Blink ones and they work fine. I have also tried uploading the code when the board is attached to the breadboard like the schematic and without, the problem still persists.

layout_simple_kkIX3wtyAi

Is the problem somewhere in the code then?
(What I have tried)

Much help is appreciated!

Russell

Code on Arduino IDE 1.8.15

#include <WiFiNINA.h>
#include<WiFiSSLClient.h>
const char* ssid = "blah blah";    //  your network SSID (name)
const char* password = "blah blah blah";  // your network password
String httpsRequest = "https://hooks.zapier.com/hooks/catch/10758811/buvi9lw/?temperature=0&moisture=0&light=0&warning=0"; // your Zapier URL
const char* host = "hooks.zapier.com";
WiFiSSLClient client;
void setup() {
  Serial.begin(9600);
  while (!Serial);
  delay(2000);
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  while (WiFi.begin(ssid, password) != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
}
void loop() {
  float temperature = 22;
  int moisture = 150;
  int light = 40;
  String warning = "This is a warning message";
  warning.replace(" ", "%20");
  send_email(temperature, moisture, light, warning );
  delay(20000);
}
void send_email(float temperature, int moisture, int light, String warning) {
  // convert values to String
  String _temperature = String(temperature);
  String _moisture = String(moisture);
  String _light = String(light);
  String _warning = warning;
  if (client.connect(host, 443)) {
    client.println("POST " + httpsRequest + "?temperature=" + _temperature + "&moisture=" + _moisture + "&light=" + _light + "&warning=" + _warning + " HTTP/1.1");
    client.println("Host: " + String(host));
    client.println("Connection: close");
    client.println();
    delay(1000);
    while (client.available()) { // Print on the console the answer of the server
      char c = client.read();
      Serial.write(c);
    }
    client.stop();  // Disconnect from the server
  }
  else {
    Serial.println("Failed to connect to client");
  }
}```


**The error message is below:**

Arduino: 1.8.15 (Mac OS X), Board: "Arduino MKR1000"

/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp: In static member function 'static void SpiDrv::begin()':
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:103:15: error: 'NINA_GPIO0' was not declared in this scope
pinMode(NINA_GPIO0, OUTPUT);
^~~~~~~~~~
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:103:15: note: suggested alternative: 'NINA_GPIOIRQ'
pinMode(NINA_GPIO0, OUTPUT);
^~~~~~~~~~
NINA_GPIOIRQ
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp: In static member function 'static int SpiDrv::available()':
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:66:25: error: 'NINA_GPIO0' was not declared in this scope
#define NINA_GPIOIRQ NINA_GPIO0
^
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:597:25: note: in expansion of macro 'NINA_GPIOIRQ'
return (digitalRead(NINA_GPIOIRQ) != LOW);
^~~~~~~~~~~~
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:66:25: note: suggested alternative: 'NINA_GPIOIRQ'
#define NINA_GPIOIRQ NINA_GPIO0
^
/Users/russell01px2015/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:597:25: note: in expansion of macro 'NINA_GPIOIRQ'
return (digitalRead(NINA_GPIOIRQ) != LOW);
^~~~~~~~~~~~
exit status 1
Error compiling for board Arduino MKR1000.

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

Start by looking at your compiler errors. 'NINA_GPIO0' was not declared in this scope

This error is listed for file /WiFiNINA/src/utility/spi_drv.cpp

Looks like you might be missing a .h file or a library for spi_drv

Look in spi_drv.cpp and see if there is a delectation for NINA_GPIO0, If no deceleration then look to see if there is a .h file included in the .cpp file.

Hi @beefmuck. As mentioned in the tutorial, this sketch is written for the Arduino MKR WiFi 1010. You are compiling it for the Arduino MKR 1000 board. Even though they have similar features, these two board use different WiFi radios and there is a different library for each of those radios. For this reason, sketches that use the WiFiNINA library of the MKR WiFi 1010's radio can't be compiled for the MKR 1000, thus the error.

If you actually own a MKR WiFi 1010, simply select Tools > Board > Arduino SAMD (32-bits ARM Cortex-M0+) Boards > Arduino MKR 1000 from the Arduino IDE's menus.

If you truly are using a MKR 1000, you will need to adapt the sketch to work for that board. Fortunately, the two WiFi libraries have compatible APIs for the most part. I think you will be able to use the sketch with only a single very small modification.

Change this line:

#include <WiFiNINA.h>

to this:

#include <WiFi101.h>

Now try uploading the sketch to your board again.

@beefmuck, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

I strongly suggest that you remove your WiFi credentials (I think that they are real) from the code that you posted.

const char* ssid = "******";    //  your network SSID (name)
const char* password = "******";  // your network password

If your neighbours are following this thread, they have one hurdle less to go through when trying to hack into your WiFi :slight_smile:

Thanks everybody for the help! I've managed to get it working without any errors, however now I just need to make sense of what I am reading from the sensors.

Thanks again!