Tried to read analog data from gpio, but only see a way which returns signal strength as LOW or HIGH (boolean). Couldn't find any solution in the documentation and in code references. Is it even possible for now?
Asked
Active
Viewed 1,985 times
7
-
Can specify which pins are you using and paste your code? – Jan Slominski Dec 27 '16 at 10:03
-
For example BCM13 (Rpi 3), but there is no code, just can't find how to read from there with non boolean value – Markiyan Antonyuk Dec 27 '16 at 12:05
-
I added interesting blogpost to my original answer, showing how to build your own ADC module for Android Things (the author of the post included Android library to use it). You might find that useful. – Jan Slominski Jan 03 '17 at 10:53
-
1Covering my issue: you can connect Arduino if you have one to the RPI and use analog input/ouput translated via UART, made an article regarding that: [article link](https://medium.com/@bastermark3/connecting-raspberry-pi-3-with-android-things-to-arduino-51d202006379#.6zey1ccvm) – Markiyan Antonyuk Jan 05 '17 at 19:11
-
Awesome! Will try that tomorrow! – Jan Slominski Jan 05 '17 at 19:13
3 Answers
3
Raspberry Pi 3 doesn't have analog-to-digital converter so you can only get boolean values (high/low) from its GPIO. So in order to get analog data you need to use external ADC module in your project.
EDIT: I found this interesting blogpost showing how to measure analog input on Android Things.

Jan Slominski
- 2,968
- 4
- 35
- 61
1
For Raspberry Pi you will need to use an analog-to-digital converter such as the ADS1115.

diazdeteran
- 1,144
- 1
- 13
- 25
-
What about boards, such as the Edison with Arduino breakout, that do have analog input pins? – Paul Ruiz Dec 28 '16 at 01:27
-
The Intel Edison has 6 analog inputs (pins A0-A5) and 6 analog (PWM) outputs (pins ~3,~ 5,~ 6, ~9, ~10, ~11). In order to read a sensor from an analog input take a look at this: https://developer.android.com/things/sdk/drivers/sensors.html. To use the analog outputs check out: https://developer.android.com/things/sdk/pio/pwm.html – diazdeteran Dec 28 '16 at 14:08
-
Actually the Edison with the Arduino breakout has a built in ADC that currently isn't supported by Android Things per https://code.google.com/p/android/issues/detail?id=230568 So right now you can only write drivers for digital input sensors, not analog. – Paul Ruiz Dec 29 '16 at 15:48
1
If you're still looking, I wrote a class and sample for the Adafruit MCP3008 ADC

Paul Ruiz
- 2,396
- 3
- 27
- 47
-
Hi Paul,with TMP36, channel 0 read is giving reading 257, I think which is incorrect as per my room temperature, I just used your code for MCP3008 with same pin configurations. Any suggestions what may be wrong? – Mahendra Chhimwal Aug 06 '17 at 07:54
-
1@MahendraChhimwal If that's the direct reading, you probably need to convert it to a temperature. You'll probably want (value - 50) / 10, which should give you 20.7C, which is about 70F. – Paul Ruiz Aug 17 '17 at 17:05