In modern digital electronics, we often deal with finite states of
LOW, which represent digital
Off, respectively. However, there are many sensors or other integrations that communicate not in binary, but in a range of voltages. For instance, a TMP35 analog temp sensor might output
0V when it’s reading an ambient temperature of
Analog ports are specifically design for this scenario, and are able to operate throughout a specified range of voltages, in both an input (reading) and output (writing) capacity.
On the Meadow F7 Micro, Analog signals are written or read with a 12-bit resolution, which means that they can have 4,096 steps of resolution.
Meadow has the capabilities to both read and write analog signals, but presently only the input/read functionality is exposed via API.
Analog input is converted to a digital value via the onboard Analog to Digital Converter (ADC), which is accessed via an
AnalogInputPort, and created from an
IAnalogInputPort analogIn = Device.CreateAnalogInputPort(Device.Pins.A02);
From there, the voltage can be read via the
float voltage = analogIn.Read();
NOTE: Only analog pins
A3 are currently configured.
A5 will not currently work.
Events and IObservable API
As with other input APIs, the Analog input APIs support both events and the
IObservable pattern, for advanced notification filtering. For more information, see the Events and IObservable guide.
Input Voltage Tolerance
It’s important to note that unlike the digital inputs (which are
5V tolerant), the analog inputs on the F7 Micro are only
3.3V tolerant, meaning any input signals above
3.3V may damage the chip. If you expect input signals to exceed
3.3V, there are two ways to protect the input.
If your sensor regularly operates at a higher voltage range, for instance, if it’s a
5V sensor, a two resistor voltage divider should be used to “divide” the voltage down from
Analog output can be generated via the Digital to Analog Converter (DAC) on the Meadow device. This feature is not currently exposed, and these docs will be updated when we ship it.