Github Repo | C Header | C source | JS source |
---|---|---|---|
mongoose-os-libs/adc | mgos_adc.h | api_adc.js |
This library implements a analog-to-digital conversion for Mongoose OS.
bool mgos_adc_enable(int pin);
Configure and enable ADC
int mgos_adc_read(int pin);
Read from the analog pin. Returns raw value.
int mgos_adc_read_voltage(int pin);
Read from the specified analog pin. Returns voltage on the pin, in mV.
ADC.enable(pin)
Configure and enable ADC for a pin
,
return 1 if success, 0 otherwise.
ADC.read(pin)
Read pin
analog value, return an integer.
Note for ESP8266 platform: with this function, you can also measure the power voltage of VDD33 pin 3 and 4. Then: