No video

ESP32 MicroPython Web Server

This tutorial demonstrates how to set up a MicroPython web server on an ESP32. A web page will show the temperature and humidity from a DHT22 sensor connected to an ESP32. Another web page will provide remote color and brightness control of a NeoPixel RGB LED.
All the code, schematics, notes and updates are available on my website: www.rototron.i...
This is the 3rd in a series of MicroPython ESP32 tutorials. The prior 2 videos demonstrate how to load the MicroPython firmware, manipulate files, run code, use MQTT, work with sensors and NeoPixels.
Playlist for all videos: • ESP32 MicroPython Tuto...
UPDATE: Jean-Christophe released version 2.0 of microWebSrv which is more robust, more efficient and faster: github.com/jcz...

Пікірлер: 99

  • @rdagger
    @rdagger4 жыл бұрын

    UPDATE: Jean-Christophe released version 2.0 of microWebSrv which is more robust, more efficient and faster: github.com/jczic/MicroWebSrv2

  • @rogrevs
    @rogrevs6 жыл бұрын

    Really great series of tutorials. I keep thinking "this looks complicated", but I follow your instructions and everything works! Thanks for taking the time to put the videos together.

  • @RCTurbine
    @RCTurbine6 жыл бұрын

    Great tutorial, really enjoying your ESP32 videos... Thanks so much for helping out us newbies!

  • @GmanBB
    @GmanBB3 жыл бұрын

    Amazing job, thank you for recording that.

  • @capiberra4118
    @capiberra41184 жыл бұрын

    Well, my head is spinning but I'm learning. Thanks!

  • @cokegen
    @cokegen6 жыл бұрын

    Awesome tutorial, thanks for taking the time to do it.

  • @tlschreur
    @tlschreur6 жыл бұрын

    Great tutorial as are you others. Keep them coming. I especially like the ESP32 / Micropython tutorials. Could you do a tutorial using the internal ADCs and DACs and other builtin functions of the ESP32.

  • @ae808692
    @ae8086926 жыл бұрын

    Looking forward to your new videos on Raspberry PI, MicroPython, ESP32 topics...

  • @davidmarks509
    @davidmarks5092 жыл бұрын

    Super amazing tutorial. Ty for sharing I am looking to make complex dynamic server that monitors sensors and runs a pump for a garden watering system, that at the moment handles over 40 potted plants. I hope you post again as its really nice, and full of detail. I subbed too :)

  • @cad3175
    @cad31756 жыл бұрын

    ...wow great video, great exposure for micropython, well done and thanks for sharing, amazing :)

  • @TOMTOM-nh3nl
    @TOMTOM-nh3nl Жыл бұрын

    Thank You

  • @rednassie1101
    @rednassie11016 жыл бұрын

    Omfg, thanks a ton, I couldn't get picoweb working but this did work

  • @PepeSi7via
    @PepeSi7via5 жыл бұрын

    You are the man!

  • @heltonritter
    @heltonritter5 жыл бұрын

    Fantastic! Thanks for sharing

  • @Electromaniaworld
    @Electromaniaworld6 жыл бұрын

    great tutorial

  • @explorerofinfinity722
    @explorerofinfinity7222 жыл бұрын

    How to use ESP32 as a client and Windows desktop PC as a Web Server to control ESP32?

  • @eriklaken1025
    @eriklaken10256 жыл бұрын

    So very good, i can,t wait to try to make this, One problem ... I am dylectisch, but i wil try. : first i order a led, the OTHER suf i acidential dit Bey and is coming soon.

  • @omarkhelfa9488
    @omarkhelfa94885 жыл бұрын

    very helpful video

  • @CollinBaillie
    @CollinBaillie2 жыл бұрын

    Do you think an ESP32 could be used for your Tracer MPPT Dashboard? Could your mobile app be modified to use bluetooth?

  • @rdagger

    @rdagger

    2 жыл бұрын

    I wrote the code to use the ESP32 and MicroPython with my solar controller. I’m using it in my automated vegetable garden: www.rototron.info/projects/micropython-vegetable-garden-automation-tutorial/ However, I’m using MQTT with HomeAssistant rather than a proprietary GUI. It took too much time maintaining a React Native/Expo app with all the breaking changes. Expo support for Bluetooth was not great the last time I checked. I think they added support but I’m not sure if you have to detach to make it work. There are probably better alternatives now such as Flutter or .Net Maui but I have not tried them.

  • @MikeNewham
    @MikeNewham5 жыл бұрын

    Enjoying the tutorials. Come up against a problem using a DFRobot FireBeetle ESP32. When I tried using the command 'rsync . /pyboard' or indeed attempt to copy the 'www' folder over to the ESP32 I get the error 'timed out or error in transfer to remote'. The 'rsync' command works fine with other ESP32's like the Lolin32 or the DevKitV1 - just a problem with The DFRobot Firebeetle. It has 16MB of flash on board and the flash was wiped with the latest MicroPython firmware copied over using ESPTool - so I don't know what's wrong.

  • @rdagger

    @rdagger

    5 жыл бұрын

    I don't have a FireBeetle. I would submit an issue to the rshell repo: github.com/dhylands/rshell/issues Rsync is pretty slow. In my OLED video I show how to use FTP which works better: www.rototron.info/raspberry-pi-esp32-micropython-oled-tutorial/ Also in my WebSocket video I use the LoBo build which comes with FTP, telnet and mDNS: www.rototron.info/raspberry-pi-esp32-micropython-websockets-tutorial/

  • @alexbokhankovich4716
    @alexbokhankovich47165 жыл бұрын

    Great tutorial. Thank you a lot. Is there a way to increase rshell connection speed? I'm transferring 2.9 Mb web app to esp32 board, it takes ages to finish using rsync.

  • @rdagger

    @rdagger

    5 жыл бұрын

    Part 4 of this series shows how to use FTP which is much faster: kzread.info/dash/bejne/k2t41KiqodiTZ5s.html I don't know of any tips to improve the speed of rshell. I suggest you ask Dave (the author): github.com/dhylands/rshell

  • @erwinschrodinger8877
    @erwinschrodinger8877 Жыл бұрын

    This should work with any pc running linux, not necessarily a rasberry?

  • @rdagger

    @rdagger

    Жыл бұрын

    There are tools to program MicroPython devices on Linux, Mac and Windows. Thonny is very popular. There is also a plugin for VS Code called pymakr.

  • @ugetridofit
    @ugetridofit6 жыл бұрын

    Excellent videos on the ESP32!! Keep them coming. Just curious, is there another way to upload files and such to the ESP32 without using a Linux system, Would like to use my PC instead.

  • @rdagger

    @rdagger

    6 жыл бұрын

    I haven't tried using Windows but Mpfshell is supposed to have basic support for Windows: github.com/wendlers/mpfshell Adafruit Ampy might also work on Windows: github.com/adafruit/ampy There is also a minimal MicroPython FTP server for the ESP8266 (not sure if it works with the ESP32): github.com/cpopp/MicroFTPServer You can always use a Windows telnet client like PuTTY to access the REPL: www.putty.org/

  • @HughDangerfield

    @HughDangerfield

    6 жыл бұрын

    On a PC I use uPyCraft ( www.gitbook.com/book/dfrobot/upycraft/details) as well as ampy.

  • @rdagger

    @rdagger

    6 жыл бұрын

    I have a new video that demonstrates FTP file transfers on an ESP32 running MicroPython: kzread.info/dash/bejne/k2t41KiqodiTZ5s.html I've been using the RemoteFTP plugin for Atom to program ESP32's in MicroPython on a Windows PC. Most of the popular editors such as Atom, Sublime and VC Code have FTP plugins so you can program on your favorite platform and have the code automatically uploaded to the ESP32.

  • @juanvalverde2166
    @juanvalverde21663 жыл бұрын

    rshell doesn't return ip address for ESP32 after resetting. Any suggestions?

  • @rdagger

    @rdagger

    3 жыл бұрын

    You need to create a main.py file with code to connect to your WiFi network. See my website for an example (link in video description).

  • @clownzfeet
    @clownzfeet5 жыл бұрын

    File "start.py", line 2, in MemoryError: memory allocation failed, allocating 72 bytes ???? any ideas???

  • @ElHyperion

    @ElHyperion

    4 жыл бұрын

    Have you solved it already?

  • @clownzfeet

    @clownzfeet

    4 жыл бұрын

    @@ElHyperion did you have the same issue?

  • @ElHyperion

    @ElHyperion

    4 жыл бұрын

    @@clownzfeet Yeah, already solved it on my own by learning how to freeze modules into the firmware and freezing the MWS in. Just make sure to set it to embedded config before starting it, with SetEmbeddedConfig

  • @jdcrunchman999
    @jdcrunchman9995 жыл бұрын

    I'm using an ESP32-WROOM-32 board . - It does NOT have a reset button. I'm using it with Thonny IDE does a "Start/Restart backend" function which does not use REPL. So I'm not getting any startup messages that conveniently reveal the IP address of the network it creates. You instantiate the network by.... station = network.WLAN(network.STA_IF) station.active(True) station.connect("aWhisper", "my-password") This did NOT create a hot spot, as it never showed up in my WIFI SSID listings. So was this a mistake? Should you have used... station = network.WLAN(network.AP_IF) instead, to create the hot spot? I thought that to create a hot spot, I would do the following....ap = network.WLAN(network.AP_IF) ap.active(True) ap.config(essid='aWhisper', authmode=network.AUTH_WPA_WPA2_PSK, password='my-password') ap.ifconfig(('192.168.84.1', '255.255.255.0', '192.168.4.1', '192.168.4.1')) # ip, netmask, gateway, dns NOTE: then, when I went to my ifconfig, it came in on en1, inet 192.168.84.2 netmask 0xffffff00 broadcast 192.168.84.255 Which is correct. I think this might have been an error.

  • @rdagger

    @rdagger

    5 жыл бұрын

    I've never used Thonny, but _network.STA_IF_ is used to connect to a hotspot and _network.AP_IF_ is used to create a hotspot.

  • @dash2212
    @dash22122 жыл бұрын

    is theire also a tutorial for the ESP32-2S chip?

  • @rdagger

    @rdagger

    2 жыл бұрын

    No but I have some basic MicroPython set up and usage notes regarding the ESP32-S2 on my website: www.rototron.info/raspberry-pi-esp32-micropython-tutorial/#S2

  • @johnmoore4248
    @johnmoore42486 жыл бұрын

    Hi rdagger68, I got errors when I wrote the code to set station mode (station = network.WLAN(network.STA_IF)). So I also try to import bluetooth. It neither works and shows like this (no attribute "Bluetooth"). What should I do? Is it firmware problem? Cheers John

  • @rdagger

    @rdagger

    6 жыл бұрын

    I don't see anything wrong with station = network.WLAN(network.STA_IF). What error message are you getting? MicroPython on the ESP32 doesn't yet support Bluetooth. Please see Github issue #222 for more info: github.com/micropython/micropython-esp32/issues/222

  • @johnmoore4248

    @johnmoore4248

    6 жыл бұрын

    Finally, I found the problem which the power from Ri's USB port can't provide enough power to ESP when wifi is enabling on ESP.

  • @svenscheil902
    @svenscheil9022 жыл бұрын

    I like this tutorial and the microWebSrv! I've tried to install the microWebSrv/microWebSrv2 on a ESP8266-12f with 4MB and get a memory error, when starting main.py. As the ESP32 (you are using for the tutorial) also has 4MB I don't understand where this memory error comes from. I already stripped the microWebSrv down to just one module and removed the www-folder. Any idea how to get it running. I don't like the idea of baking a new micropython image with a frozen microWebSrv, while I'm in an early evaluation and testing phase of my project.

  • @rdagger

    @rdagger

    2 жыл бұрын

    I haven't done much with ESP8266's but I don't think you'll have enough free RAM. You can check in the REPL using: import gc gc.mem_free() You could also ask the author of MicroWebSrv by posting an issue on his GitHub repo. He might have more insight. The MicroPython forum is also a great resource.

  • @svenscheil902

    @svenscheil902

    2 жыл бұрын

    @@rdagger Thx for your feedback. I was wondering why 4MB on the ESP32 is not the same like 4MB on the ESP8266. I already tried to contact the author of microwebsrv. Thx again. Looking forward to see your next post.

  • @henryskinner8495
    @henryskinner84956 жыл бұрын

    Is there a way to connect to monitor the sensors when away from home? The [ip_address]/dht.html works when on connected to the same WiFi as the ESP32 but when I switch to 4G on my mobile it does not work. This probably sounds stupid to someone who knows about these things.

  • @rdagger

    @rdagger

    6 жыл бұрын

    Putting an IOT device on the public Internet is sketchy in terms of security. The risky approach would be to set up DDNS on your Internet router, poke a hole in your firewall and expose the IP and port of the ESP32. I think this is a very bad idea. I prefer to use a VPN such as OpenVPN. There are OpenVPN client apps for both Android and IOS. Many Internet routers have built-in OpenVPN server support. If your Internet router doesn’t support OpenVPN you might be able to upgrade it with the dd-wrt.com firmware. Otherwise, there are OpenVPN servers available for the Raspberry Pi and for NAS devices such as Synology which are relatively easy to deploy. Another approach is to use a service such as Ngrok. It lets you set up secure tunnels behind NAT’s and firewalls to the public Internet. You could install Ngrok on a Raspberry Pi and use it to expose the ESP32. Ngrok supports HTTPS, TLS and password protected tunnels. I demonstrate Ngrok in my Solar REST API Tutorial: www.rototron.info/raspberry-pi-solar-serial-rest-api-tutorial/

  • @mrIceblink
    @mrIceblink6 жыл бұрын

    Thanks for these very useful tutorials. This works well, but the "rsync . /pyboard" command takes a few minutes to copy all the files in the MicroWebSrv directory - is that normal? Any way to speed it up?

  • @rdagger

    @rdagger

    6 жыл бұрын

    Make sure you delete the hidden .git folder because it contains a lot of subfolders and files. However, rshell is pretty slow. During slow transfers, I speed up the video so viewers don't have to wait. The actual copy time for the rsync command used in the video was about 2 - 3 minutes. A much faster approach is to use FTP for transfers. The same copy job would take only a few seconds. I recommend _ftp_ by robert-hh which also works on the ESP32: github.com/robert-hh/ESP8266-FTP-Server

  • @mrIceblink

    @mrIceblink

    6 жыл бұрын

    Thanks, that is much faster! edit: (use "import ftp" in repl session to start ftp server on esp32, then you can transfer files from a remote ftp connection to the esp32 at over 20 Kbytes/sec)

  • @filipedias781
    @filipedias7816 жыл бұрын

    Its possible to put multiple sensor readings on the same page?thanks

  • @rdagger

    @rdagger

    6 жыл бұрын

    Yes, you can specify multiple data lines and you can use JSON format. Here is a good article with examples: www.html5rocks.com/en/tutorials/eventsource/basics/ My next video will probably be about WebSockets which is another great way to stream sensor data.

  • @fetchdcode9759
    @fetchdcode97596 жыл бұрын

    Any reason why rshell hangs at "Connecting to /dev/ttyUSB0..."? Tried flashing the micropython firmware at both 0x0000 and 0x1000 addresses but still no luck. I'm using an ESP8266 but I don't know if that would make any significant differences (other than the micropython firmware being used).

  • @rdagger

    @rdagger

    6 жыл бұрын

    You would use address 0x0 when writing the firmware to an ESP8266. I verified that Rshell works with an ESP8266. Please make sure you erase the chip prior to writing. Does _dmesg | grep ttyUSB_ show "cp210x converter now attached to ttyUSB0"?

  • @fetchdcode9759

    @fetchdcode9759

    6 жыл бұрын

    rdagger68 I figured it out actually. Apparently I was touching the USB to serial chip while I was plugging in, causing it to short temporarily and lose connection.

  • @OflahertyChris
    @OflahertyChris4 жыл бұрын

    How would i close the webserver? I am trying to close the webserver after i retrieve information

  • @rdagger

    @rdagger

    4 жыл бұрын

    You can use the stop method to stop the web server. I recommend you take a look at the documentation for the latest version. There is a link in the video description.

  • @shukhratdad9891
    @shukhratdad98913 жыл бұрын

    Please help. I got some attribute errors: ' pin' object has no attribute 'on' or 'high' on esp32 micropython

  • @rdagger

    @rdagger

    3 жыл бұрын

    Please make sure you are using the latest release of MicroPython. On the esp32, the on() and off() methods first appeared in release v1.10.

  • @shukhratdad9891

    @shukhratdad9891

    3 жыл бұрын

    @@rdagger yes. I checked versions 1.10-1.14 but result was the same

  • @rdagger

    @rdagger

    3 жыл бұрын

    @@shukhratdad9891 what line of code is causing the error?

  • @rdagger

    @rdagger

    3 жыл бұрын

    You're still running a very old firmware. Please try loading the latest stable release. Also what ESP32 board are you using?

  • @dardanshatri
    @dardanshatri6 жыл бұрын

    Hello can you add SSL or Https auth to the server. Thanks

  • @rdagger

    @rdagger

    6 жыл бұрын

    Sorry, I don't know. You'd have to ask Jean-Christophe. He is the author of the MicroWebSrv library: github.com/jczic/MicroWebSrv

  • @m.f.abouhashem4285
    @m.f.abouhashem42856 жыл бұрын

    great tutorial but how to send json data to json file with microwebserver i try this many time but i couldn't

  • @rdagger

    @rdagger

    6 жыл бұрын

    What are you trying to do?

  • @m.f.abouhashem4285

    @m.f.abouhashem4285

    6 жыл бұрын

    i have spo2 (pulse oximeter)sensor that send regular array of data(from another microcontroller) to esp32 and i would like to plot live graph by canvas java script library that include data from json file which will updated by microwebserver thanks for your concern

  • @rdagger

    @rdagger

    6 жыл бұрын

    Take a look at my WebSockets tutorial: kzread.info/dash/bejne/p66NmMOMl5yyqZs.html

  • @Calucig
    @Calucig6 жыл бұрын

    Will I be able to code the ESP32 in C and use a Raspberry Pi as the web server but code it in micropython?

  • @rdagger

    @rdagger

    6 жыл бұрын

    You could use the Arduino IDE to program the ESP32 which is similar to C/C++. You could use Python to create a web server on a Raspberry Pi. MicroPython is for microcontrollers such as the ESP32.

  • @Calucig

    @Calucig

    6 жыл бұрын

    Thank you for the answer. I'm trying to use ESP-IDF using Visual Studio Code, at least for the esp32. Have you use VS Code?

  • @rdagger

    @rdagger

    6 жыл бұрын

    Yes. I think it's an excellent editor. IDE’s is one of the few things Microsoft still does well in my opinion. I usually use Atom even though it’s not as good. VS Code is faster, has great Intellisense, better debugging and is less buggy. I’ll probably switch to VS Code if they ever add real-time linting.

  • @Calucig

    @Calucig

    6 жыл бұрын

    rdagger68 im looking forward for that tutorial. I want to see how to use micropython using vscode

  • @kkkk2951
    @kkkk29516 жыл бұрын

    I want matlab output gives to raspberry pi

  • @rdagger

    @rdagger

    6 жыл бұрын

    Sorry I don't understand your question. Is this what you are looking for? www.mathworks.com/hardware-support/raspberry-pi-matlab.html

  • @allentoyski
    @allentoyski4 жыл бұрын

    How to become like you? I don't understand anything

  • @rdagger

    @rdagger

    4 жыл бұрын

    I think the best way to learn anything is to pick a fun project and just dive in. I taught myself coding by writing video games. I learned woodworking by building an arcade cabinet.

  • @clownzfeet
    @clownzfeet5 жыл бұрын

    I'm getting and error message that I can NOT find what is wrong with the code line. prntscr.com/p070xg any help would be appreciated thank you

  • @rdagger

    @rdagger

    5 жыл бұрын

    What micropython board are you using? MicroWebSrv is only compatible with the ESP32, Pycom, and Pyboard D-series. When using an ESP32, PSRAM is recommended. Also your version of MicroPython looks old.

  • @3dmixer552
    @3dmixer5525 жыл бұрын

    Can i do this on mac os instead pi?

  • @rdagger

    @rdagger

    5 жыл бұрын

    Yes.

  • @kkkk2951
    @kkkk29516 жыл бұрын

    Pla I want help

  • @marcojimenez9327
    @marcojimenez93275 жыл бұрын

    Is there a way to read and write from the same web page?

  • @rdagger

    @rdagger

    5 жыл бұрын

    I don't understand the question. What are you trying to accomplish?

  • @marcojimenez9327

    @marcojimenez9327

    5 жыл бұрын

    ​@@rdagger I'm trying to turn some GPIO pins ON and OFF and also read the status of other GPIO pins, I managed to make it work in separate web servers (one server to write, and other server to read) but can't combine them to do it all from a single web server.

  • @rdagger

    @rdagger

    5 жыл бұрын

    You can use _gets_ to return data such as status and _posts_ to change state such as GPIO pins. However, for real time applications you might be better off using Web Sockets. I have another tutorial: kzread.info/dash/bejne/p66NmMOMl5yyqZs.html

  • @marcojimenez9327

    @marcojimenez9327

    5 жыл бұрын

    @@rdagger Thank you. Regards.

  • @joshielexable
    @joshielexable5 жыл бұрын

    Why not arduino?

  • @rdagger

    @rdagger

    5 жыл бұрын

    Faster development, more intuitive syntax, less code, no compiling/uploading, REPL for immediate testing and debugging, Python is the fastest-growing major programming language, Adafruit is investing heavily in the Python microcontroller ecosystem and surveys indicate Python is one the most loved programming languages.

  • @joshielexable

    @joshielexable

    5 жыл бұрын

    @@rdagger hi, thanks a lot for quick ans. I am familiar with arduino and hence micropython process looks somewhat longer.. that's why i ask it... :-) any way i'll try microphython...

  • @rdagger

    @rdagger

    5 жыл бұрын

    You might also want to look at CircuitPython which is very friendly in terms of set up and the integrated Mu IDE. I have an intro video: kzread.info/dash/bejne/lKeZ1NpuZL2wgLA.html

  • @artbecker5618
    @artbecker56186 жыл бұрын

    No link to your web site

  • @rdagger

    @rdagger

    6 жыл бұрын

    The link is now in the description. Thanks.

  • @artbecker5618

    @artbecker5618

    6 жыл бұрын

    Thank you for the prompt response and the videos.

  • @zxi4772
    @zxi4772 Жыл бұрын

    niubility 牛逼

  • @abeeconstable7877
    @abeeconstable78776 жыл бұрын

    Cant stand the 'vocal fry'...