WiFiNiNa issues

I need help!!! I’m no programming Guru so I downloaded a code for MKR1010 and i’m having lots of issues trying to compile it. The code is supposed to help me replace the radio in an RC car with two MKR1010 s as the controllers. Please see the sketch attached. Anyone…?

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino MKR1000”

C:\xxxxxxx\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp: In static member function ‘static void SpiDrv::begin()’:

C:\xxxxxxx\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:97:15: error: ‘NINA_GPIO0’ was not declared in this scope

pinMode(NINA_GPIO0, OUTPUT);

^~~~~~~~~~

C:\xxxxxxx\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:97:15: note: suggested alternative: ‘PIN_PB10’

pinMode(NINA_GPIO0, OUTPUT);

^~~~~~~~~~

PIN_PB10

C:\xxxxxxx\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp: In static member function ‘static int SpiDrv::available()’:

C:\xxxxxxx\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:565:25: error: ‘NINA_GPIO0’ was not declared in this scope

return (digitalRead(NINA_GPIO0) != LOW);

^~~~~~~~~~

C:\xxxxxxx\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:565:25: note: suggested alternative: ‘PIN_PB10’

return (digitalRead(NINA_GPIO0) != LOW);

^~~~~~~~~~

PIN_PB10

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.

FPVCarUDPHost.ino (6.06 KB)

New Text Document.txt (10.1 KB)

I downloaded a code for MKR1010

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino MKR1000"

Which board have you got selected in the IDE ?

MKR1010 on comm7

jkarum200:
MKR1010 on comm7

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino MKR1000"

I am not familiar with either board so am not sure whether the difference is important

Those two boards use different WiFi arrangements.

The sketch will compile fine for the 1010 but NOT for the 1000.

Make sure you select the 1010 and NOT the 1000.

Bob.

PS I uploaded it to my 1010 with no issue.

I recently purchased a MKR1010 and I have had a hard time finding codes/sketches that are written for the MKR1010. Most of the time I have to select a different board and hope it works…

JAMES007MOORE:
I have had a hard time finding codes/sketches that are written for the MKR1010.

You don’t necessarily need to find code written specifically for the MKR WiFi 1010.

The Arduino framework provides a high level of portability, so a large amount of Arduino code will work on any board.

It is true that there is a quite a bit of architecture-specific Arduino code, but even then it’s not about the code needing to be written for the MKR WiFi 1010, but about being written for the SAMD architecture. That includes the Arduino Zero (which has been around at least 5 years), the MKR boards, the Nano 33 IoT, as well as 3rd party boards (most prominently the Adafruit boards).

Now, if you are looking at WiFi code, it will need to be written for the MKR WiFi 1010’s NINA module, which means using the WiFiNINA library. In addition to the MKR WiFi 1010, the Nano 33 IoT, Uno WiFi Rev2, and MKR Vidor 4000 also use the NINA module. Also, any properly written code written to use a different networking library can easily be adapted to work with the WiFiNINA library. Sometimes that’s as easy as just changing the filename of the #include directive. For example, change:

#include <WiFi101.h>

to:

#include <WiFiNINA.h>

JAMES007MOORE:
Most of the time I have to select a different board and hope it works…

I strongly recommend against doing that. I can’t imagine a case where selecting a different board would be helpful. On the other hand, it could be harmful. For example, if I select the Nano 33 BLE board and upload to my MKR WiFi 1010 it “bricks” my board. You can’t recover it with the double reset trick. The only fix is to burn the bootloader, which in my experience is a quite complex process requiring special hardware.