Created ADC (markdown)

blakadder 2019-10-31 13:45:49 +01:00
parent 5d7ce3217f
commit 5679bd0e12
1 changed files with 32 additions and 0 deletions

32
ADC.md Normal file

@ -0,0 +1,32 @@
ESP chips have one ADC pin that can read analog signals. When referring to the ADC pin these terms are used interchangeably: ADC (Analog-to-digital Converter), TOUT, Pin6, A0 or Analog Pin 0.
By default Tasmota allows the ADC pin to be used as an external input and assigned to a component. The signal can be interpreted as Lux, Temperature, a Button or a "generic" analog voltage signal.
The reading will show in web UI's sensor section as "Analog0 %value%" and published in `tele/%topic%/SENSOR` JSON response as `"ANALOG":{"A0":%value%}`. The pin has a 10-bit resolution, which means _%value%_ can be between `0` and `1024`.
### Rule triggers
To use ADC in rules use these triggers:
`on ANALOG#A0div10 do ...` - when the A0 input changes by more than 1% it provides a value between 0 and 100
`on Tele-ANALOG#A0 do ...` - triggers on tele messages with Analog object
> `MQT: tele/tasmota/SENSOR = {"Time":"2019-01-14T19:36:51","ANALOG":{"A0":1024}}`
Rule example: [using a potentiometer on analog pin](Rule-Cookbook#use-a-potentiometer).
## ADC_VCC
Instead of an input, ADC pin can be used to measure internal voltage of the ESP chip. To enable this feature you need to [compile your own build](Compile-your-build):
**If you enable ADC_VCC you cannot use the pin as analog input anymore. More precisely, it is used as an analog input but for internal voltage only.**
user_config_override.h flag:
```
// -- Internal Analog input -----------------------
#define USE_ADC_VCC // Display Vcc in Power status
```
Internal voltage is published in `tele/%topic%/STATE` under `"Vcc":` in mV:
```
11:14:59 MQT: tele/tasmota/STATE = {"Time":"2019-10-31T11:14:59","Uptime":"0T18:36:12","UptimeSec":66972,"Vcc":3.423,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":6,"POWER":"OFF","Wifi":{"AP":1,"SSId":"Tasmota","BSSId":"00:00:00:00:00:00","Channel":13,"RSSI":100,"LinkCount":1,"Downtime":"0T00:00:06"}}
```