Difference between revisions of "How to use ESP32 as a webserver"
Jump to navigation
Jump to search
Nicholas w (talk | contribs) |
Nicholas w (talk | contribs) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 22: | Line 22: | ||
* 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. | * 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 hdc1010== |
+ | |||
+ | * I used a HDC1010 with the ESP which measures temperature and humidity - it is superb. | ||
+ | * it needs an include which you put in the same folder as the arduino file. | ||
+ | * [https://www.arduinolibraries.info/libraries/closed-cube-hdc1010 maybe here?] | ||
+ | * [http://www.esp32learning.com/code/esp32-and-hdc1080-humidity-and-temperature-sensor.php for a slightly different chip] | ||
+ | * [https://learn.adafruit.com/adafruit-hdc1008-temperature-and-humidity-sensor-breakout/wiring-and-test also not quite right, but helpful] | ||
+ | |||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! 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. | * 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. | ||
+ | * [https://www.arduinolibraries.info/libraries/closed-cube-hdc1010 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. | * 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 [https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html 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. | * as per [https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html 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. | ||
Line 29: | Line 55: | ||
* so now i'm stuck using [https://www.aliexpress.com/item/32786781036.html?spm=a2g0s.9042311.0.0.27424c4d7hbbJp 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. | * so now i'm stuck using [https://www.aliexpress.com/item/32786781036.html?spm=a2g0s.9042311.0.0.27424c4d7hbbJp 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 [http://danyk.cz/lm35_en.html LM35DZ work] is gonna require some electronic components... | * damn, making the [http://danyk.cz/lm35_en.html LM35DZ work] is gonna require some electronic components... | ||
+ | * [https://randomnerdtutorials.com/esp32-ds18b20-temperature-arduino-ide/ this looks like a better sensor] - ds18b20 | ||
==ESP32 has on-board permenant data storage== | ==ESP32 has on-board permenant data storage== | ||
* [https://randomnerdtutorials.com/esp32-flash-memory/ this tutorial] says you can write to the flash memory (like USB stick) | * [https://randomnerdtutorials.com/esp32-flash-memory/ this tutorial] says you can write to the flash memory (like USB stick) | ||
* 512 bytes (512 numbers up to 255) | * 512 bytes (512 numbers up to 255) |
Latest revision as of 20:51, 8 October 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
Contents
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.
- Then this video and link give you code to make the webserver.
- wow, you can even get it to send data to some web-site to save data for you.
temperature sensor hdc1010
- I used a HDC1010 with the ESP which measures temperature and humidity - it is superb.
- it needs an include which you put in the same folder as the arduino file.
- maybe here?
- for a slightly different chip
- also not quite right, but helpful
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)