Arduino Analog Input Data Sent To Python

To retrieve analog data from an Arduino and send it back into Python for further processing the following script should work.

On every pin value change event a new Pin object is sent from Arduino to Python.

The is the number of the pin whose value has changed - this is necessary so you map poll multiple pins at the same time.

pin.value is the value from the pin - for analog pins its 0-1023

pin.source is the Arduino's name for which the pin came from (if there are multiple Arduinos)

pin.value - is the type of pin - digital = 1, pwm = 2, analog = 3


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Darek's picture

something is bad

when I connected to analog input 3  : 

3,3V   I received in python log -  3 7 2 arduino

0V     I received  -  3 0 2 arduino.

But when I connected sonar LV-EZ1 then script give me only

3 0 2 arduino.This sonar should  give back 9,8mV  for every 1 cal of distance.


Afterthat I switched to osciloscope tab, to check the analog signal. When I marked A5 input I see correct graph and in the same time, pyton log changed pin value to the correct value:

5 85 2 arduino
19 86 3 arduino   
Now I  see correct value depending on distance and some mishmash  related to analog pin name - 5 and 19.
So, summarize my post this script is working correct if I mark A5 in osciloscope tab.
GroG's picture

Hmmm... Thanks for the


Thanks for the information Darek,

I'll need to get something setup here to test...

I appreciate you looking into this :)