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?
How to read analog data from GPIO, Android-things
Asked Answered
Can specify which pins are you using and paste your code? –
Fermata
For example BCM13 (Rpi 3), but there is no code, just can't find how to read from there with non boolean value –
Steading
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. –
Fermata
Covering 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 –
Steading
Awesome! Will try that tomorrow! –
Fermata
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.
For Raspberry Pi you will need to use an analog-to-digital converter such as the ADS1115.
What about boards, such as the Edison with Arduino breakout, that do have analog input pins? –
Firm
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: developer.android.com/things/sdk/drivers/sensors.html. To use the analog outputs check out: developer.android.com/things/sdk/pio/pwm.html –
Selhorst
Actually the Edison with the Arduino breakout has a built in ADC that currently isn't supported by Android Things per code.google.com/p/android/issues/detail?id=230568 So right now you can only write drivers for digital input sensors, not analog. –
Firm
If you're still looking, I wrote a class and sample for the Adafruit MCP3008 ADC
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? –
Trouveur
@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. –
Firm
© 2022 - 2024 — McMap. All rights reserved.