Hi,
i struggle to use analogRead() for my Nano rp2040 board while using BLE.
I included <WiFiNINA.h> to use the A0-A7 pins.
I included <ArduinioBLE.h> for the use of BLE.
It seems it comes to a conflict as soon as i initialise the BLE. The readings are then always "0". If i do not initialise BLE, the analogRead(A7) readings work perfectly fine...
Any ideas? Workarounds how i can read analog values AND make use of the BLE functionality?
Note: I first tried not to use the <WiFiNINA.h> but in this case A0-A7 are not recognised. If i use the number of the digital pin (14-21) the program freezes...
Thanks! Help appreciated!
Sebastian
Version 2.2.0 of the Arduino Mbed OS Nano board is available and it made some changes to the analog pins with the #include <WiFiNINA .h >.
Try updating to 2.2.0 if you are not already using it.
Note: I first tried not to use the <WiFiNINA.h> but in this case A0-A7 are not recognised. If i use the number of the digital pin (14-21) the program freezes...
I don't understand this. A0,A1,A2,A3 should be available is you are not using WiFiNINA.h.
Thanks!
I am running the 2.2.0 Mbed OS Nano.
You are correct. A0 - A3 seem to be available without <WiFiNINA.h>.
Only A4 - A7 are not recognised.
As i designed a PCB in which i connected pin A7 - any way how i can get my reading from this one?
Thanks!
Sebastian
You are deep into the swamp on this one.
If you explore around in the WiFiNINA library you can find this path
src/utility/nano_rp2040_support.cpp
and it is the piece of wifiNINA which lets you access A6,A7.
The file has these two # includes
#include "nina_pins.h" /* variants/NANO_RP2040_CONNECT/ninaPins.h */
#include "wifi_drv.h"
nina_pins.h is part of "variants" in the standard core so should be ok
wifi_drv.h and wifi_drv.cpp are also part of the WiFiNINA utility file. Perhaps you can include them as tabs in your sketch.
I do not have a nano rp2040 and can't do any testing, so you're on your own from here.
I played a bit with the RP2040 Connect and found that the RGB LED pins (connected to the NINA module) did not work when I used BLE or it crashed BLE when I configured the pins after the BLE initialization.
I did not have time to investigate this further. I suspect this is a bug or incomplete implementation.
I recommend you try your analog code without any BLE stuff first. If you have an example and like me to confirm/test something please post your sketch.
We can create an issue on Github and ask the developers.