Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read analog data from GPIO, Android-things

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?

like image 355
Markiyan Antonyuk Avatar asked Dec 27 '16 09:12

Markiyan Antonyuk


People also ask

How do you read analog values in ESP32?

The ESP32 DEVKIT V1 DOIT board (version with 30 pins) has 15 ADC pins you can use to read analog inputs. These pins have a resolution of 12 bits, which means you can get values from 0 to 4095. To read a value in the Arduino IDE, you simply use the analogRead() function. The ESP32 ADC pins don't have a linear behavior.

How do you read analog values on Raspberry Pi?

In order to read analog data we need to use the following pins: VDD (power) and DGND (digital ground) to power the MCP3008 chip. We also need four "SPI" data pins: DOUT (Data Out from MCP3008), CLK (Clock pin), DIN (Data In from Raspberry Pi), and /CS (Chip Select). Finally of course, a source of analog data.

Does ESP32 have ADC?

ADC in ESP32 have a maximum resolution of ADC of 12-bits and yes, the resolution of ADC is configurable with possible values include 9-bit, 10-bit, 11-bit and 12-bit. Usually, the resolution is set to 12-bit, if not changed.

How do you use ADC in ESP32?

The ESP32 integrates two 12-bit SAR (“Successive Approximation Register”) ADC (Analog to Digital Converters) and supports measurements on 18 channels (analog enabled pins). Some of these pins can be used to build a programmable gain amplifier which is used for the measurement of small analog signals.


1 Answers

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.

like image 100
Jan Slominski Avatar answered Sep 21 '22 12:09

Jan Slominski