6 Replies Latest reply on Dec 16, 2014 11:03 PM by loffenauer

    analog read using python and mraa is not working for me

    krull

      Hello,

       

      I have been trying for the last couple of days to get analog read working.

      Here is my setup:

      I have an Edison with arduino breakout kit.

      I connect 5.0V to Analog pin #0.

      Then I run the example programs given in the MRAA library documentation as is, without any modifications.

      Here is what I see when using different approaches for analog read:

      Case #1) When I run C/C++ example code with 5.0V on Analog pin #0, the program prints out "4095" which is what I would expect from a 12-bit ADC. On applying 3.3V, it prints out "2780"

      Case #2) When I run the python example code with 5.0V on Analog pin #0, the program prints out "15". On applying 3.3V, it prints out "10".

      Case #3) When I directly read the file "/sys/bus/iio/devices/iio:device0/in_voltage0_raw", I see "4095" and "2780" for 5.0V and 3.3V respectively.

       

      Here is the interesting part.

      In Case #2, 5.0V gives "15" which happens to be 4095 right shifted by 8-bits (4095 >> 8 in python).

      Also, in case #2, 3.3V gives "10" which happens to be 2780 right shifted by 8-bits. (2780 >> 8 in python).

       

      My question here is, what am I missing? Is there something I should be doing that is not in MRAA documentation?

      Is there something wrong with the MRAA python bindings?

      The python documentation for MRAA is very brief. Nothing much to read there. I would really appreciate some help here.

       

      Thanks,

      Nischal