How to use ESP32 as a webserver

From Norwich Hackspace
Jump to navigation Jump to search

£10 ESP32 is a 240mhz dual-CPU computer (with 4mb ram or 512kb not sure) and can run a webserver - so can be controlled from your phone/computer. Amazing. also amazingly, you can run nintendo NES games on it


ESP32

These are the steps I took to get it working:

  • download current arduino IDE from arduino.cc
  • the one I bought from the Hackspace shop was this one:
  • CANADUINO ESP32 Devkit Wi-Fi Bluetooth BLE - Ultra Low
  • the IC chip (which controls the USB interface with the computer?) is: CP2104
  • my mac, is running an older system, so I needed this driver for the CP2104:
  • after that, in the arduino IDE, you need to add a URL to the preferences in order to download the ESP32 board:
  • as per this youtube video
  • this is the URL to type: "https://dl.espressif.com/dl/package_esp32_index.json"


As web-server

You can use your phone/computer to view 'a web page' and control the device that way.

temperature sensor hdc1010


ESP32 connection
3v3 3v3
GND GND
SDA pin 21
SCL pin 22


lM35DZ

  • Some places say the ESP32 has an on-board temperature sensor, but it seems that this is not the case any more, either due to firmware or hardware. You just get MAX reading. Which I did.
  • they have a library, I think I used code of github? and it worked great. One had a typo in...
  • go got some lM35DZ chips (50p each from china). They seem to return roughly 2.5v (with 3.3v input). 2.4v was in the freezer, and 2.5 under a mug of tea. I could not get the esp32 to read anything useful.
  • as per the ESP32 docs, you can only use ADC (analogue to digital converter) channels form "bank 1" (ADC1 not ADC2), if you're using the wifi. So I used pin 32.
  • this page has this graph which shows the analogue response to various voltages. I read elsewhere (cant find) that above 2.5v the chip can't see much. Though this reddit post seems to say you can just use the LM35DZ straight on the ESP32. But, this page suggests you need a separate chip to read it. I didn't manage to get anywhere.
  • so now i'm stuck using ShengYang Thermal sensor module temperature sensor module Thermistor Sensor for arduino which is just a digital 'is it warmer than X' sensor, which you can twiddle with a screwdriver. nng.
  • damn, making the LM35DZ work is gonna require some electronic components...
  • this looks like a better sensor - ds18b20

ESP32 has on-board permenant data storage

  • this tutorial says you can write to the flash memory (like USB stick)
  • 512 bytes (512 numbers up to 255)