Open fivdi opened 2 years ago
The Arduino and Adafruit versions of NINA have diverged somewhat, particularly with the specific customizations for the Arduino RP2040 Nano Connect, including conditionals for pin definitions and use.
There was an issue opened in April 2019 in the Arduino repo to add Digital Read, which was closed as wontfix
in September 2019, but added with the RP2040 Nano Connect merge. There was an issue opened in May 2019 in the Arduino repo to add Analog Read, which was closed with the RP2040 Nano Connect merge. These two features were added to the Adafruit repo in October 2019.
The ESP32SPI library would need some board detection code to determine if it is an RP 2040 Connect (or possibly other boards in the future), to avoid the AssertionError: Please update nina-fw to 1.5.0 or above.
A6 & A7 do seem to map to GPIO36 and GPIO35 on the p.3 version of the schematic (not clear why there are multiple schematics):
ADC3 GPIO39
ADC4 GPIO36
ADC34 GPIO35
However GPIO36 & GPIO39 are the Hall Effect sensor. In general, GPIO35 should be fine to use, but the ADC34
naming for GPIO35 makes me wonder if it is also used in some way in this instance for the Hall Effect sensor. I didn't dig in too deeply into the documentation to resolve this question. Without knowing more, I would not use these pins for general purpose analog or digital input.
I'll leave it to others to comment on the RuntimeError: buffer size must match format
situation.
When working with CircuitPython 7.1.1 on an Arduion Nano RP2040 Connect it should be possible to access a number of pins on the ESP32. However, accessing two of these pins results in errors being thrown. The pins on the ESP32 that can't be successfully accessed are pins A6 and A7, both of which are broken out to the GPIO header on the Arduino. A6 and A7 correspond to GPIO36 and GPIO35 on the ESP32 respectively (see page 3 of this document).
Issue With Digital Read
Attempting to use GPIO35 as a digital input with the following program:
results in the following error being thrown:
The error message suggests updating to nina-fw 1.5.0 or above. This issue is occuring on a Arduino Nano RP2040 Connect which uses the Arduino version of nina-fw and not the Adafruit fork of nina-fw. Today, the latest version of the Arduino version of nina-fw is 1.4.8 so the error is suggesting an update to the Adafruit fork, 1.5.0 or above. However, according to this issue the Adafruit fork of nina-fw isn't compatible with the Arduino Nano RP2040 Connect.
This issue can be resolved by removing these two lines of method
set_digital_read
. Version 1.4.8 of the Arduino version of nina-fw has everything that is needed to perform digital reads successfully.Issue With Analog Read
There is a similar issue with analog read. Attempting to use GPIO35 (A7) as an analog input with the following program:
results in the following error being thrown:
This issue can be resolved by removing these two lines of method
set_analog_read
. Version 1.4.8 of the Arduino version of nina-fw has everything that is needed to perform analog reads successfully.Now a new error is thrown:
This issue can be resolved by changing this line:
to this:
This change is needed because the Arduino version of nina-fw uses a 2-byte uint16_t to store analog values and the Adafruit fork uses a 4 byte int to store analog values. I don't know if this change would break things for other boards.
As can be seen, the implementation details of the Arduino and Adafruit versions of nina-fw are drifting apart in ways that can make things difficult for people using CircuitPython on the Arduion Nano RP2040 Connect. If would be good if these issues were resolved.