automated-ch / esp32-temperature-and-voltage-ssl

Meassure temperature and battery voltage. The temperature is meassured with a ds18b20 tmperature sensor and send the data to a remote server. The identity of the remote server is verified by its root certificate and https is used to secure the communication.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

esp32 temperature measurement with ds18b20 including battery status

Meassure temperature with a ds18b20 tmperature sensor and send the data to a remote server. The identity of the remote server is verified by its root certificate and https is used to secure the communication withe remote server.

The battery voltage is also measured via ADC and sent to the server.

measure temperature with a ds18B20

To meassure the temperature with a ds18b20 sensor you need a pullup resistor with 4.7K Ohm.

References:

measure battery voltage (without calibration)

Since LiPo batteries (usually) supply a voltage between ~4.2 and ~3.2 volts it is necessary to convert the voltage to match the ADC input voltage range. To meassure the battery voltage via ADC you will need a voltage divider.

choose attenuation

The 0dB attenuation showed the most accurate results for the uesed esp32 device in the lower voltage range, so I choose this attenuation.

Your esp32 might behave differently. So some testing will be necessary.

attenuation input voltage range
analogSetAttenuation(ADC_0db); input voltage between 0V and 1.1V
analogSetAttenuation(ADC_2_5db); input voltage between 0V and 1.5V
analogSetAttenuation(ADC_6db); input voltage between 0V and 2.2V
analogSetAttenuation(ADC_11db); input voltage between 0V and 3.3V

References and further reading:

voltage divider for battery voltage meassuerment

For the voltage divider following resistors are used:

BAT (+) --- 51 K -- 5.1 K --- ADC PIN --- 20K --- GND (-)

image

About

Meassure temperature and battery voltage. The temperature is meassured with a ds18b20 tmperature sensor and send the data to a remote server. The identity of the remote server is verified by its root certificate and https is used to secure the communication.

License:GNU General Public License v3.0


Languages

Language:C++ 100.0%