Esp8266 Web Server

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
User avatar
Frenk.98K
Posts: 6
Joined: Thu May 05, 2022 8:07 pm

Esp8266 Web Server

Post by Frenk.98K » Tue Jul 26, 2022 11:26 pm

Hi everyone,
I have a rp2040-zero connected to a esp8266 wifi chip.
I want to turn it into a web server to activate a switch from the webpage and i actually found a few examples lying around...

The main problem starts at the imports, as with every example i try to implement, i always get the same result:
"Umport esp" doesn't work,
"import network" doesn't work,
"from network import WLAN" doesn't work
And also "import socket" doesn't work.

From my googling I come to think that my micropython should already have these libraries, while my board for some reason doesn't....

I've teied to look for the ".py" files it was missing, updating firmware from thonny, updating firmware manually to the latest version, but nothing.

Still stuck and I hope I'm not alone and that there's someone who can help me out here.
Thank you in advance!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Esp8266 Web Server

Post by Roberthh » Wed Jul 27, 2022 6:31 am

When you say: "does not work", which error do you get. The heap size of the ESP8266 is very small. So you can run only short scripts, like <200 lines of code. You can extend that by using pre-compiled code or embedding it as frozen bytecode. But the latter requires building your own firmware.

User avatar
Frenk.98K
Posts: 6
Joined: Thu May 05, 2022 8:07 pm

Re: Esp8266 Web Server

Post by Frenk.98K » Wed Jul 27, 2022 11:24 am

Hi,
Doesn't work means I get the following error:

Code: Select all

ImportError: no module named 'network'
And the same for all the other libraries mentioned...
It's not the esp8266 module the problem, but rather my rp2040-zero not having the libraries that i should need to then interface with the WiFi chip.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Esp8266 Web Server

Post by Roberthh » Wed Jul 27, 2022 11:59 am

The RP2040-zero has no network (e.g. WiFi, LAN, or BT) interface, and thus no network module.

User avatar
Frenk.98K
Posts: 6
Joined: Thu May 05, 2022 8:07 pm

Re: Esp8266 Web Server

Post by Frenk.98K » Wed Jul 27, 2022 12:31 pm

Yes, but with the power of gpio pins, I've added a esp8266 chip... Picture below, only imagine it's a rp2040-zero on port 0 and 1 instead of a pico

There must be a way to use WiFi and the network library if these esp boards exist and all say are compatible with pi and arduino, right?
3q5l5e4jhnf61.png
3q5l5e4jhnf61.png (127.51 KiB) Viewed 17377 times

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Esp8266 Web Server

Post by Roberthh » Wed Jul 27, 2022 1:27 pm

There must be a way to use WiFi and the network library if these esp boards exist and all say are compatible with pi and arduino, right?
Sure. Something like that is the Arduino 2040 Nano connect, which combines a RP2040 with a NINAW10 module, which is ESP32 based. But it requires a completely different Firmware for the RP2040, with all the network stuff integrated.
Using an ESP8266 as a WiFi interface would require similar work.
There was once a Python lib which uses a serially attached WIFi device. Traces of that must be in the Forum.
maybe this one: viewtopic.php?f=21&t=9664&hilit=esp8266+serial+wifi

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: Esp8266 Web Server

Post by karfas » Wed Jul 27, 2022 1:39 pm

Frenk.98K wrote:
Tue Jul 26, 2022 11:26 pm
Hi everyone,
I have a rp2040-zero connected to a esp8266 wifi chip.
I want to turn it into a web server to activate a switch from the webpage and i actually found a few examples lying around...
As we now know what you are trying to accomplish, I would recommend to create the web server on the 8266 and set your contact from there.
If the Pico also needs control, you could connect one ESP output to a Pico input.
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

User avatar
Frenk.98K
Posts: 6
Joined: Thu May 05, 2022 8:07 pm

Re: Esp8266 Web Server

Post by Frenk.98K » Wed Jul 27, 2022 3:55 pm

Ok so if I'm understanding this correctly, the esp8266 in the picture it's actually it's own thing?
Like I can connect with some serial to USB and put code in that through my computer?
And so in this case it would then become the wifi module doing it's own wifi thing and then exchanging data and commands with the rp2040 through UART?

User avatar
Frenk.98K
Posts: 6
Joined: Thu May 05, 2022 8:07 pm

Re: Esp8266 Web Server

Post by Frenk.98K » Wed Jul 27, 2022 3:59 pm

Roberthh wrote:
Wed Jul 27, 2022 1:27 pm
There was once a Python lib which uses a serially attached WIFi device. Traces of that must be in the Forum.
Also thank you, I'll try to pull on this thread to see what I'll find!

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: Esp8266 Web Server

Post by karfas » Wed Jul 27, 2022 6:53 pm

Frenk.98K wrote:
Wed Jul 27, 2022 3:55 pm
Ok so if I'm understanding this correctly, the esp8266 in the picture it's actually it's own thing?
I have no idea what the "esp8266 on the picture" is. And yes, they are normally (even in some cheap network-enabled wall plugs) programmable when you attach a usb/uart or rs232/uart converter.
To use the ESP network from the pico (as in your picture) you need most likely special firmware on both sides, as others also pointed out.
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

Post Reply