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 pin.pin 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

[[Arduino.analog.input.py]]

Darek

11 years 2 months ago

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

11 years 2 months ago

Hmmm...

Thanks for the information Darek,

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

I appreciate you looking into this :)