Adafruit Trinket m0- AnalogRead

Thread Starter

tylerman666

Joined Aug 14, 2019
3
I've been working on trying to get a voltage reading from an input to the Trinket m0. Was feeding in about .5 V to one of the I/O ports, and was getting a voltage reading of about 40,000 out of the 65535 scale that the device outputs voltages in. Converted voltage reading is about 2V out of 3.3 V device can handle. However, even when disconnecting the voltage input and just reading the voltage of the pin while the device isn't connected to a signal- still getting around this same voltage reading. Is there an issue with noise of the devices? Would assume voltage should be around 0V . Any help on the Analog In function, alternate ways of getting voltage readings, noise troubleshooting, etc. would be helpful.

This is code I'm using:

import board
import analogio
import time

adc0 = analogio.AnalogIn(board.A2)
adc1 = analogio.AnalogIn(board.A0)
adc2 = analogio.AnalogIn(board.A1)

print(adc0.value)
print(adc1.value)
print(adc2.value)


I shorted pin 0 and pin 1~ to ground, no connection to pin 2-

returned voltage values are:

53664
31488
41360
 

danadak

Joined Mar 10, 2018
4,057
Floating inputs will take on a V that is controlled by leakage.

upload_2019-8-14_10-19-43.png

I think the pins you want to be using are PB1, PB3, PB4.


Regards, Dana.
 

danadak

Joined Mar 10, 2018
4,057
I can't tell from that. Get the datasheet for the processor part and map
its A/D capable pins to that pinout diagram you posted. That way you
know what analog pins are A/D capable. It may be all of them but do the
check.

Regards, Dana.
 
Top