-
Hi fellows, I am trying to integrate a new sensor and would like to see the actual value of set_pin_mode_analog_input from the analog input port? Currently it seems like the examples somehow scales the signal to 100 and calculates a relative distance from those values? Is there an easy way to convert the values to 0-5V? (https://github.com/MrYsLab/telemetrix/blob/master/examples/analog_input.py#L67) Thank you. As always greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
For the Arduino, with or without telemetrix, the value returned from an analog read is between 0 and 1023 and is not expressed as a voltage value. To convert the value to a value between 0v and 5v, this article explains how to do that. If I misunderstand your question or the article does not help you resolve your question, please let me know. |
Beta Was this translation helpful? Give feedback.
-
@nildude Lastly, the conversion to a voltage would be done in the callback method of your application for the analog input pin. You could modify the Arduino/STM32/ESP8266 to do the conversion, but doing things on the Python side keeps things very flexible. |
Beta Was this translation helpful? Give feedback.
@nildude
A couple of other things. If you are using an STM32 or ESP8266, the values measure from 0 to 3.3 v and not 0 to 5v as the Arduino AVR does. Also, the range of values returned for the STM32 is 0 to 4095. For the ESP8266, the range of values is 0 to 1023.
Lastly, the conversion to a voltage would be done in the callback method of your application for the analog input pin. You could modify the Arduino/STM32/ESP8266 to do the conversion, but doing things on the Python side keeps things very flexible.