Show Temperature and Humidity as WiFi SSID with ESP8266 and HTU21D Sensor
Since I started playing with ESP8266 WiFi microcontroller in 2016, I had a TMP36 temperature sensor. TMP36 is an analog sensor: it uses a voltage between 0.00V and 1.75V to represent a temperature reading between -50℃ and 125℃. The ESP8266 has an analog-to-digital converter (ADC) capable of reading voltages up to 1.00V. To read a temperature from TMP36 into ESP8266, I need to use a pair of resistors as a voltage divider, so that the resulting voltage does not exceed ADC's limit. However, I feel the temperature reading is very inaccurate: is my room really 19℃ when @TheTucsonHeat is in town? I once replaced the carbon resistors with metal film resistors, and the temperature reading instantly changed by as much as 8℃.
I need an upgrade to the temperature sensor! The new sensor must output digital signal, so that my lousy resistors wouldn't affect its accuracy. After comparing DHT11, DHT22, DS18B20, and several others, I eventually chose HTU21D-F because it has an I2C interface, which can be added directly to my LCD kit.
The HTU21D sensor arrives in the mail a few weeks later. It needs a bit of soldering to add the pin headers onto the breakout board; ImmodderNation has a soldering video to get you started. Afterwards, wiring is simple: just add it into the existing I2C bus! As long as you don't short the wires, you won't burn down the office.
A quick test with Adafruit's library confirms the HTU21D sensor is working correctly. Temperature and humidity readings are showing up on the serial console. However, I don't want to tug around the laptop to measure temperature around the house, and don't want to program the LCD or connect to Losant or NDN right away. I thought up a quick and easy way: let's create a Wi-Fi hotspot from the ESP8266, and show temperature and humidity as the WiFi network name (SSID)!