ADC Xbee
Closed this issue · 2 comments
Hello,
I have the module Xbee3 and the resolution is 10 bits. Using the ADC module of Micropython, I want to use the "ADC.width(bit)" and set it to 10 bits. But it seems it isn't yet implemented. Will it be included in future releases?
Hi,
From reviewing the recent upstream MicroPython docs, and looking at the related pull requests (such as micropython/micropython#7788), it appears the only MicroPython implementation which supports configurable width is the ESP32.
XBee 3 does not have configurable ADC width -- it is defined by hardware as 12 bits -- so no, the ADC.width
method will not be implemented. However, to get a 10-bit value equivalent to setting the width to 10 bits, would it suffice to divide the reading by 4/right-shift by 2? This would downscale the reading to effectively 10 bits.
>>> adc = machine.ADC(1)
>>> reading = adc.read()
>>> reading_10bit = (adc.read() >> 2)
Hello,
Thank you for the quick response! I ended up inheriting from the initial class and tweaking the method.