pythonodroidwiringpi

WiringPi ODROID C2 Python reading analogue input


The ODROID C2 is a board similar to the Raspberry PI. I have installed and configured WiringPi as specified by the website for my board. Running gpio readall returns the table:

 +------+-----+----------+------+ Model  ODROID-C2 +------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode |   Name   | wPi | GPIO |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 |      |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |      |
 |      |   8 |    SDA.1 |      |   |  3 || 4  |   |      | 5V       |     |      |
 |      |   9 |    SCL.1 |      |   |  5 || 6  |   |      | 0v       |     |      |
 |  249 |   7 | GPIO.249 |   IN | 1 |  7 || 8  |   |      | TxD1     | 15  |      |
 |      |     |       0v |      |   |  9 || 10 |   |      | RxD1     | 16  |      |
 |  247 |   0 | GPIO.247 |   IN | 1 | 11 || 12 | 1 | IN   | GPIO.238 | 1   |  238 |
 |  239 |   2 | GPIO.239 |   IN | 1 | 13 || 14 |   |      | 0v       |     |      |
 |  237 |   3 | GPIO.237 |   IN | 1 | 15 || 16 | 1 | IN   | GPIO.236 | 4   |  236 |
 |      |     |     3.3v |      |   | 17 || 18 | 1 | IN   | GPIO.233 | 5   |  233 |
 |  235 |  12 | GPIO.235 |   IN | 1 | 19 || 20 |   |      | 0v       |     |      |
 |  232 |  13 | GPIO.232 |   IN | 1 | 21 || 22 | 1 | IN   | GPIO.231 | 6   |  231 |
 |  230 |  14 | GPIO.230 |   IN | 1 | 23 || 24 | 1 | IN   | GPIO.229 | 10  |  229 |
 |      |     |       0v |      |   | 25 || 26 | 1 | OUT  | GPIO.225 | 11  |  225 |
 |      |  30 |    SDA.2 |      |   | 27 || 28 |   |      | SCL.2    | 31  |      |
 |  228 |  21 | GPIO.228 |   IN | 1 | 29 || 30 |   |      | 0v       |     |      |
 |  219 |  22 | GPIO.219 |   IN | 1 | 31 || 32 | 1 | IN   | GPIO.224 | 26  |  224 |
 |  234 |  23 | GPIO.234 |   IN | 0 | 33 || 34 |   |      | 0v       |     |      |
 |  214 |  24 | GPIO.214 |   IN | 1 | 35 || 36 | 1 | IN   | GPIO.218 | 27  |  218 |
 |      |  25 |    AIN.1 |      |   | 37 || 38 |   |      | 1v8      | 28  |      |
 |      |     |       0v |      |   | 39 || 40 |   |      | AIN.0    | 29  |      |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+

I am attempting to read input from the analogue pin #25 for the wiring pi column (second from the bottom on the left).

Here is the code for the script:

#!/usr/bin/python
import wiringpi2 as wpi
import time

wpi.wiringPiSetup()

while True:
    print(wpi.analogRead(25))

#use pin 25 for analogue input

Why is it only returning 0? My phone is connected via auxiliary splice to the analogue pin. Left and right audio cables are spliced together and connected to wiringpi pin #25.

I have confirmed wiringpi is working. I was able to control a LED. The circuit works as confirmed with an oscilloscope.

Thanks for your help.


Solution

  • An answer on the ODROID forum detailed that the pins seem to be addressed by pin type. Since the ODROID C2 has only two analogue input pins, they are addressed as pins #0 and #1 respectively. Changing the pin number to #1 fixed the problem (I later moved the analogue input pin to the other side of the header).

    The entire post can be read.