I started out trying
Code: Select all
tempPin = Pin(Pin.board.X11,Pin.ANALOG)
So I tried using py.ADC
in arduino I read and convert to celcius like this:
Code: Select all
int tempReading = analogRead(tempPin);
float tempVolts = tempReading * 5.0 / 1024.0;
float tempC = (tempVolts - 0.5) * 100.0;
Code: Select all
>>> tempPin = pyb.ADC(pyb.Pin.board.X11)
>>> tempReading = tempPin.read()
>>> tempVolts = tempReading * 5.0 / 4096.0 # the docs said this .read() returns a value between 0 and 4095
>>> tempC = (tempVolts - 0.5) * 100.0
I'm still alive, so I'm sure that is not correct. Could someone help me out with what I'm doing wrong?
By the way, I do have the TMP36 sensor plugged into the vin so it should be getting 5v from the usb.