Using the expansion board 3.0 to read external battery voltage
Hi all, newbie here.
Looking to use a Pycom over sigfox, to record a battery voltage on a vehicle in storage, and upload readings to the cloud. Does the expansion board 3.0 have an A/D input that will allow it to read the battery voltage from a vehicle battery?
robert-hh last edited by robert-hh
@Graham-Blackwell P13 to P18 are indeed the ADC input pins. As long as you do not set an attenuation, the range is 0.03 - 1V. For setting the attenutaion, used attn keyword argument on the adc.channel call. See: https://docs.pycom.io/firmwareapi/pycom/machine/adc/#class-adc--analog-to-digital-conversion
With ADC.ATTN_11DB the range is 0.1 - 3.3V. The best linearity is achieved with ADC.ATTN_6DB, which has a range of 0.07 - 2V. Irrespective of the attenuation setting, the safe input range is 0-3.3V. However beyond the range of the ADC input the reading will be 4096.
To reduce noise, add a small low impedance capacitor between the adc input and GND. 10nF is sufficient. Still the readings are noisy. You may decide to take an average over a set of readings.
Programming is going well. It now posts data to mysql using JSON, and I'm now attempting to read analogue voltages. Am I right in thinking that Pin 13-18 are the analogue inputs for the WiPy 2.0 on an expansion board 3.0?
adc = machine.ADC()
lbatv = adc.channel(pin='P13') #van battery
vbatv = adc.channel(pin='P14') #leisure battery
batt1 = vbatv()
batt2 = lbatv()
Will return voltages for connections to pin 13 and pin 14? I've not tried connecting the voltage divider until I'm sure that 13 and 14 are the correct analogue input pins
Expansion board has arrived from RS this morning. I'll whip a voltage divider up and get coding :D
@Graham-Blackwell thanks Robert. I'll get an expansion board ordered.
robert-hh last edited by
@Graham-Blackwell The xxPy board have several A/D inputs, which are accessible at t he expansion board. The input range is 0-1V up to 0-3.3V, depending on the attenuation. See. https://docs.pycom.io/tutorials/hardware/adc/
The voltage of a car battery is in the range up to 15V for a 12V systems and up to 30V for a 24V system. And it may carry higher spikes and noise. So you have to add an external voltage divider and some filtering.