Difference between revisions of "How to use ESP32 as a webserver"

From Norwich Hackspace
Jump to navigation Jump to search
Line 20: Line 20:
  
 
* Then [https://www.youtube.com/watch?v=ApGwxX6VVzk this video] [https://randomnerdtutorials.com/esp32-web-server-arduino-ide/ and link] give you code to make the webserver.
 
* Then [https://www.youtube.com/watch?v=ApGwxX6VVzk this video] [https://randomnerdtutorials.com/esp32-web-server-arduino-ide/ and link] give you code to make the webserver.
 +
* wow, you can even [https://randomnerdtutorials.com/visualize-esp32-esp8266-sensor-readings-from-anywhere/ get it to send data] to some web-site to save data for you.
  
 
==temperature sensor==
 
==temperature sensor==

Revision as of 12:15, 29 September 2020

£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

  • 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.
  • 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.

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)