Generic analog sensor
One component for several sensors with an analog output: choose the profile (MQ-type gas, capacitive or resistive soil moisture, ACS712 current or custom) and move the slider. AO gives a fraction of the VCC voltage (ratiometric output); DO is the module comparator, with threshold and hysteresis. A 5 V module with AO straight on the GPIO can go above 3.6 V: the simulator warns you before the board burns out.
Pinout
| Pin | Connect to | Note |
|---|---|---|
| VCC | 3V3 or VIN (5 V), depending on the module | the AO output follows this voltage |
| GND | GND | |
| DO | input GPIO (e.g. 13) | only in the profiles with a digital output |
| AO | GPIO with ADC (e.g. 34) | with a 5 V VCC, use a voltage divider |
From the syllabus to a planned semester
- Teaching plan and calendar built automatically
- Class diary ready to paste into SIGA
- Slides and exercise lists with answer keys
Free Community edition · Windows
MicroPython example
from machine import ADC, Pin
import time
sensor = ADC(Pin(34)) # sensor AO
sensor.atten(ADC.ATTN_11DB)
while True:
print(sensor.read_uv() / 1000000, "V")
time.sleep(0.5)
Specifications
| Item | Value | Source |
|---|---|---|
| ACS712: sensitivity | 185 mV/A (5 A), 100 mV/A (20 A), 66 mV/A (30 A), with a 5 V VCC | ACS712 datasheet (Allegro MicroSystems), tables "Common Operating Characteristics" and "x05B/x20A/x30A Performance Characteristics" |
| ACS712: output at zero current | VCC × 0.5 (2.5 V at 5 V) | ACS712 datasheet (Allegro MicroSystems), tables "Common Operating Characteristics" and "x05B/x20A/x30A Performance Characteristics" |
| ACS712: supply | 4.5 to 5.5 V | ACS712 datasheet (Allegro MicroSystems), tables "Common Operating Characteristics" and "x05B/x20A/x30A Performance Characteristics" |
| MQ-type gas: curve | logarithmic (teaching approximation) | Under review: Rs/R0 curve from the Hanwei datasheet and the module RL |
| Soil moisture: curve | inverse: wetter, lower voltage (teaching approximation) | Under review: measure the module dry and in water |
| Noise, drift and warm-up | off by default (0) | Under review: measure on the board |
| Pin order | VCC, GND, DO, AO | Under review: it varies between modules; check the silkscreen on yours |
Values marked "Under review" will still be checked against the parts in the lab.