That specific nano has A4-A7 being fed in from the onboard WIFININA chip. I am sure some voltage (~1.6 V) is being applied. The WIFINina firmware has been updated.
I mainly am unsure because I was getting this behavior on multiple boards, but the code seems so simple I don’t know where it could be wrong.
Not sure about the pin mode. Doesn’t seem to matter one way or the other.
Are you using the latest firmware? I was running into problems using the C++ standard firmware, but the latest MicroPython firmware ( https://docs.arduino.cc/micropython/#firmware ) does not have these issues. You still need to calibrate things if you are using all the A# pins but:
import machine
import time
from machine import Pin
adc_pin = [machine.Pin(23), machine.Pin(24),machine.Pin(25),machine.Pin(26),machine.Pin(27),machine.Pin(28),machine.Pin(19),machine.Pin(22)]
adc=[machine.ADC('A0'),machine.ADC('A1'),machine.ADC('A2'),machine.ADC('A3'),machine.ADC('A4'),machine.ADC('A5'),machine.ADC('A6'),machine.ADC('A7')]
led = Pin(6, Pin.OUT)
readings = 0
file=open("data.csv","w")
file.write("data"+"\n")
while True:
q=0
t=str(time.time_ns())
for sen in adc:
led.value(1)
reading = sen.read_u16()
logger=t+' '+str(q)+' '+str(reading)+'\n'
print(logger)
time.sleep_ms(10)
file.write(t+' '+str(q)+' '+str(reading)+'\n')
led.value(0)
time.sleep_ms(10)
q+=1
readings += 1
if readings >= 5:
file.close()
break
works fine (A6 & A7 may have some issues (usually shows all 0s), but at least they don't crash the board the way it used to)
Sorry, I completely miss-read (more ignored🙄) what you are actually asking (my answer is the answer to the problem which brought me to find this post from the search engine). I'll keep this up just in case.