In modern digital electronics, we often deal with finite states of HIGH or LOW, which represent digital 1/0, or On/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 0ºC, 1.6V @ 50ºC, and 3.3V @ 100ºC.

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

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 IIODevice:

IAnalogInputPort analogIn = Device.CreateAnalogInputPort(Device.Pins.A02);

From there, the voltage can be read via the Read() method:

float voltage = analogIn.Read();

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 5V to 3.3V.

For occasional voltage spikes that can be ignored, the input should be protected with a Zener diode and a resistor as illustrated in this tutorial.

Analog Reference (AREF)

The analog reference (AREF) pin provides a reference voltage for the Analog to Digital Converter (ADC) to compare against. Typically, this should be supplied with 3.3V, so as a convenience, the AREF pin is actually connected to the 3.3V rail via resistor that is located next to the D08 pin, just below the main MCU:

Image showing the location of the AREF 0Ω resistor, which is just below the F7 MCU, and on the right side, when the board is turned so that the USB connector is on top. The resistor is immediately to the left of the D08 header pin.

If you need to provide a different analog reference voltage, make sure to remove that resistor before hooking AREF to your voltage reference.

Analog Output

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.


These docs are open source. If you find an issue, please file a bug, or send us a pull request. And if you want to contribute, we'd love that too!