Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Raspberry Pi Pico Web Server with ESP8266 & MicroPython
Raspberry Pi Raspberry Pi Pico Projects

Raspberry Pi Pico Web Server with ESP8266 & MicroPython

Mamtaz AlamBy Mamtaz AlamUpdated:May 28, 20235 Comments4 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Raspberry Pi Pico ESP8266
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this post, we will learn how to use ESP8266 WiFi Module with RP2040 Raspberry Pi Pico Board using MicroPython Code and create our own Web Server.

Raspberry Pi Pico RP2040 board features a dual-core Arm Cortex-M0+ processor with 264KB internal RAM & up to 16MB of off-chip Flash. The RP2040 is much faster compared to Arduino but it has a limitation of wireless network connectivity. This is the reason why Raspberry Pi Pico alone can’t be used for wireless & IoT-related applications. Hence a low-cost ESP8266 WiFi module could be a good choice to add wireless connectivity to Raspberry Pi Pico.

Here in this tutorial, we will demonstrate the Raspberry Pi Pico simple web server functionality using the ESP8266 WiFi module. The set of AT commands is preloaded into the program memory of ESP8266 and does not require additional programming. We will be sending these specific commands through the serial port (UART) of Raspberry Pi Pico. The coding is done in MicroPython & the device is programmed using the Thonny IDE. The Web Server displays the on-chip temperature sensor reading on a web page running on the web browser.


Bill of Materials

S.N.Components NameQuantityPurchase Links
1Raspberry Pi Pico Board1Amazon | AliExpress
2ESP8266-01 WiFi Module1Amazon | AliExpress
3Connecting Wires15Amazon | AliExpress
4Breadboard1Amazon | AliExpress




Circuit Diagram & Connections

Now, let us see how we can connect the ESP8266 WiFi Module to RP2040 Raspberry Pi Pico Board. Here is a simple connection diagram.

ESP8266 Raspberry Pi Pico

The Raspberry Pi Pico has two inbuilt UART. In this design, we will use UART-0. Similarly, the default baud rate of the ESP8266 is 115200. We need to configure the Raspberry Pi Pico with the same baud rate in order to maintain synchronization with the ESP8266.

Connect the VCC and EN Pin of ESP8266 to Pico 3.3V pin & connect GND to GND. Similarly, connect the Tx and RX of ESP8266 to Pico UART-O Pin, i.e Rx & Tx.


Source Code/Program

Here is the complete MicroPython Code for RP2040 Raspberry Pi Pico Web Server with ESP8266.There is no need to modify the code as we are not connecting to any WiFi Network, rather we are creating the Web Server through access point created by ESP module.

We will read the temperature data from the internal temperature sensor and send it over a webpage which can be retrieved from any web browser.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Code for Simple Rasberry Pi PICO Web server
#Using ESP8266 wifi module
from machine import UART
import machine
import _thread
import time
uart = UART(0,115200)
print('UART Serial')
print('>', end='')
def uartSerialRxMonitor(command):
    recv=bytes()
    while uart.any()>0:
        recv+=uart.read(1)
    res=recv.decode('utf-8')
    erase_len=len(command)+5
    res = res[erase_len:]
    return res
#configure as SoftAP+station mode
send='AT+CWMODE=3'
uart.write(send+'\r\n')
time.sleep(1)
#Set SoftAP name
send='AT+CWSAP="pos_softap","",11,0,3'
uart.write(send+'\r\n')
time.sleep(1)
res=uartSerialRxMonitor(send)
print(res)
#enable multi connection mode
send='AT+CIPMUX=1'
uart.write(send+'\r\n')
time.sleep(1)
res=uartSerialRxMonitor(send)
print("Configured as Dual mode ->" + res)
# Enable the TCP server with port 80,
send='AT+CIPSERVER=1,80'
uart.write(send+'\r\n')
time.sleep(2)
res=uartSerialRxMonitor(send)
print("Server configured successfully-> "+res)
#temperature reading
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)
#Here the code runs indefinitely
while True:
    #temperature reading
    reading_temp = sensor_temp.read_u16() * conversion_factor
    temperature = 27 - (reading_temp - 0.706)/0.001721
    #Place basic code for HTML page display
    val='<head><title>Pi Pico Server</title></head><body><p>Temperature: '+str(int(temperature))+' deg'+'</p></body>'
    print(val)
    length=str(len(val))
    
    send='AT+CIPSEND=1,'+length
    uart.write(send+'\r\n')
    time.sleep(2)
    res=uartSerialRxMonitor(send)
    print("Data sent-> "+res)
    send=val
    uart.write(send+'\r\n')
    time.sleep(10)




Code Explanation

First we need to import required libraries.

1
2
3
4
from machine import UART
import machine
import _thread
import time

Then we configure UART-0 of Raspberry Pi Pico with a baud rate of 115200 & print status in a serial terminal.

1
2
3
uart = UART(1,115200)
print('UART Serial')
print('>', end='')

Then we configure the ESP8266 in Soft AP+ Station mode using the command ‘AT+CWMODE=3‘. This command is sent through the UART of Pico. To set the name of the Access point we use ‘AT+CWSAP’. No password is set for the current configuration.

1
2
3
4
5
6
7
8
9
send='AT+CWMODE=3'
uart.write(send+'\r\n')
time.sleep(1)
#Set SoftAP name
send='AT+CWSAP="pos_softap","",11,0,3'
uart.write(send+'\r\n')
time.sleep(1)
res=uartSerialRxMonitor(send)
print(res)

Using ‘AT+CIPMUX=1‘ enable multi-connection for ESP module.

1
2
3
4
5
send='AT+CIPMUX=1'
uart.write(send+'\r\n')
time.sleep(1)
res=uartSerialRxMonitor(send)
print("Configured as Dual mode ->" + res)

Then start the server which will run on Port 80. Also, print the status on the serial terminal.

1
2
3
4
5
send='AT+CIPSERVER=1,80'
uart.write(send+'\r\n')
time.sleep(2)
res=uartSerialRxMonitor(send)
print("Server configured successfully-> "+res)

Read internal temperature sensor data of Pico board and convert it into 16bit unsigned integer using Python’s inbuilt function. You can learn in detail about Internal Temperature Sensor in previous post.

1
2
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

Then we start the infinite loop. The time.sleep() function provides some halt/waiting before execution of the next line. The command “AT+CIPSEND” will initiate data transmission. After sending this command to ESP, next the string of data is sent. The HTML code is inside ‘val’ will display data on a web page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
while True:
    #temperature reading
    reading_temp = sensor_temp.read_u16() * conversion_factor
    temperature = 27 - (reading_temp - 0.706)/0.001721
    #Place basic code for HTML page display
    val='<head><title>Rasberry Pi Pico Server</title></head><body><p>Temperature is: '+str(int(temperature))+' deg'+'</p></body>'
    print(val)
    length=str(len(val))
    
    send='AT+CIPSEND=1,'+length
    uart.write(send+'\r\n')
    time.sleep(2)
    res=uartSerialRxMonitor(send)
    print("Data sent-> "+res)
    send=val
    uart.write(send+'\r\n')
    time.sleep(10)



Testing Raspberry Pi Pico & ESP8266 based Web Server

Run the code on Thonny IDE, save it into Pi Pico as main.py. The Serial Terminal will display the following messages.

Then open Google Chrome, type 192.168.4.1 in the address field. Then press Enter. The browser will start to display the temperature data. Since the connection of the server is not closed, it will continuously print data on the page.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleQR Code Scanner with ESP32 CAM Module & OpenCV
Next Article Raspberry Pi 4 Model B comparison & what’s inside the box

Related Posts

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

Updated:July 24, 2025
Interface BMI160 with Raspberry Pi Pico & MicroPython

Interface BMI160 with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Updated:February 2, 202513K
Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Modbus RTU with Raspberry Pi Pico & Micropython

Modbus RTU with Raspberry Pi Pico & MicroPython

Updated:February 2, 20258K
Fever Detector with MLX90640 & OpenCV Raspberry Pi

Thermal Fever Detector with MLX90640 & OpenCV Raspberry Pi

Updated:February 2, 20256K
View 5 Comments

5 Comments

  1. mfarooqi on March 24, 2022 3:23 AM

    Thank you for the tutorial.
    is there any way to show input fields and store data from user’s input?

    Thank you

    Reply
  2. cagancelik on June 19, 2022 2:30 PM

    I get this error message:

    Pi Pico Server

    Temperature: 17 deg

    Data sent-> Server

    Temperature: 17 deg

    ERROR
    AT+CIPSEND=1,81
    link is not valid

    Reply
  3. Ganga on June 20, 2022 12:38 AM

    I’m also getting the same error, link is not valid.

    Someone can you help me to resolve this issue.

    Thanks

    Reply
  4. JJ on March 15, 2023 9:42 AM

    For those wondering why the “link is not valid” error is showing, it happens becase AT+CIPMUX=1 means the ESP should allow multiple connections. Each connection has an ID, and the ID is what’s been used here AT+CIPSEND=1,81 (the “1” is the ID). That should read AT+CIPSEND=0,81 to send to the first connection (“0”).

    Reply
  5. Yasin on March 20, 2023 12:50 PM

    i couldnt fix it like that can u explain more pls

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Interfacing PN532 NFC RFID Module with Arduino
    Interfacing PN532 NFC RFID Module with Arduino
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.