ESP32 web server for Time, Temperature, Humidity and Light Levels - Page 1
Forum section: electronics / projects

author: wnorcott
author_rank: Regular Contributor
timestamp: November 27, 2017, 02:32:31 am
content: This is one of my first posts here. Here is a project I have been working on and pretty much finished, it uses and Espressif ESP32 microcontroller board to create a web server that displays current time, temperature, humidity and light levels.Here's a picture of it.The particular board is the ESP32 DOIT Devkit that I bought on Aliexpress.com. It is mounted to a RadioShack General-Purpose printed circuit board, part number 276-168B. The peripherals are a DS3231 real time clock with battery backup, a HTU21D temperature and humidity sensor, and a CDS photoresistor I bought from Electronics Goldmine part number G19038 that reads from low ohms to megaohms. The two sensors are digital and use one of the I2C bus channels on the ESP32. The LDR I have connected to a voltage divider network and a current limiting resistor and it feeds into one of the analog to digital converter input pins. That is necessary because although the ESP32 board runs of of 3.3 volts, the analog input maxes out at 1V.Here is the main webpage a screen grab from my phone.When you click on the link it displays like thisI also put in a page that shows the date/time that the web server was started, and another command that reboots the web server by doing a restart on the ESP32. There are some well known glitches in the DS3231 RTC whereby it can get out of sync with the microcontroller and basically locks up the I2C bus and just prints garbage. Well, I did some research on that too and have it detect the pattern of corruption in the time reading and that triggers it to reset the I2C bus and continues. It has run for days with no glitches.The code I integrated several bits of demo code and other libraries from other users in the ESP32 community.The 3 attachments are the board itself, the main page, and the page that displays the time, temp, etc.Later I will upload a layout I put together and a schematic of the photoresistor network, an finally, the source code which is written using the ESP32 board type in the Arduino IDE

author: wnorcott
author_rank: Regular Contributor
timestamp: November 27, 2017, 02:49:00 am
content: Here is the schematic for the photoresistor it divides the output from 3.3V down to a range from 0.2V to 1.09V to keep the analog/digital converter on the ESP32 happy. I put a current limiting resistor on the tail end in case the ESP32 boots up with that pin set to ground which is unlikely, but anyway it would only sink 2.5 mA of current which is 'safe'.It is drawn the Medieval technique called "pencil and paper" since I am old school.

author: wnorcott
author_rank: Regular Contributor
timestamp: November 27, 2017, 03:06:55 am
content: Here is the front of the board layout. The ESP32 DOIT is 15 pins on each side, shown as green dots.

author: wnorcott
author_rank: Regular Contributor
timestamp: November 27, 2017, 03:12:32 am
content: I had to go to the copper side to do two things: First I added external 10K ohm pullup resistors to the I2C signals data (SDA) and clock (SCL). The ESP32 has internal pullups but I never trust those things. Second, I extended the actual SDA and SCL pins to several other female headers that I use to install the realtime clock and the temp/humidity sensor.

author: hamster_nz
author_rank: Super Contributor
timestamp: November 27, 2017, 06:38:29 am
content: Are you using Arduino or ESP-LDF?(Bonus qn, why that one?)

author: wnorcott
author_rank: Regular Contributor
timestamp: November 27, 2017, 11:46:34 am
content: Answers:1. The code was developed using the Arduino IDE and it uses Arduino libraries. Also the setup(), loop() paradigm.2. I bought several different ESP32 boards just to see what is out there. The DOIT board takes up less real estate and I did not need the full 38 pins the full sized Devkit board has. It is not a battery project so did not use a LoLin32 or the new LoLin32 Lite which I also have. Those have the builtin LiPo charger and 2.0 mm battery header. I keep telling myself I will use Micropython and played around with the Lolin32 Lite but it is note quite baked yet IMO and a scripting language is not the best fit for this app. Micropython chews up memory you are OOM real fast at runtime.One thing I like about the DOIT is it has 2 different colored LED and the user internal LED is bright blue. Red power LED is always on so no battery or deep sleep projects for this one. I do find the pinouts differ on these various ESP32 boards you really need the schematic. Another plus of the DOIT is the silkscrren is on top so I can read the pins labels after soldering it to the proto board. The DOIT Esp32 has decent build quality not covered in stray rosin and the pin headers were presoldered. WiFi range is good.The new WeMos Lolin32 Lite is the best of breed IMO and is much smaller, I will burn one to Arduino. I have a web server in Micropython with Picoweb but no love for it.