Pico ESP8266

From Waveshare Wiki
Jump to: navigation, search
Pico ESP8266
Pico ESP8266
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

The Pico-ESP8266 is a WiFi expansion module designed for Raspberry Pi Pico, which can be controlled via UART AT command, and supports TCP/UDP communication protocol. It is an easy solution to enable WiFi feature for Raspberry Pi Pico, suitable for sorts of IoT communication projects.

Features

  • Standard Raspberry Pi Pico header supports Raspberry Pi Pico series.
  • UART communication, controlled via AT command, helps you get started quickly.
  • Supports STA, AP, and STA+AP three WiFi operating modes, embedded LWIP protocol stack, supports TCP/UDP communication.
  • Based on ESP8266 module, four-layers process, enhanced impedance matching, stronger signal, more stable connection.
  • 2 x functional buttons, convenient for the user to update AT firmware through Raspberry Pi Pico.
  • Comes with online development resources and manual (Raspberry Pi Pico C/C++ and MicroPython examples).

Specification

  • Communication interface: UART
  • UART baud rate: 115200 bps
  • WIFI standard: IEEE 802.11b/g/n
  • Frequency range: 2400 ~ 2483.5MHz
  • WIFI operating mode: WiFi STA, WiFi AP, WiFi STA+AP
  • Antenna: PCB antenna
  • Operating voltage: 3.3V
  • Operating temperature: -40°C ~ 85°C
  • Dimensions: 58 x 25mm

Pinout

Pico-ESP8266-details-inter.jpg

Dimensions

Pico ESP8266 Spec02.jpg

Quick start

Hardware connection

  1. Press and hold the BOOTSEL button of Pico, the pico will be recognized as a movable disk, copy the dev_cdc_ports.uf2 file from demo codes to the Pico, the Pico will automatically restart and work as the USB to serial adapter.
  2. Connect the Pico_EPS8266 board to Pico, then connect the Pico to PC by USB cable.
  3. Open an SSCOM software, choose the correct COM port, and set the baud rate to 115200.
  4. Test the module by AT command.

Pico-ESP8266-01.png

AT commands

  • 1. AT:
AT
Response:
AT

OK
  • 2. AT+RST Restart device:
AT+RST
Response:
AT+RST

OK
  • 3. AT+GMR Check version:
AT+GMR
Response:
AT+GMR
AT version:1.2.0.0(Jul  1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co. Ltd.
v1.5.4.1-a Nov 30 2017 15:54:29
OK

TCP Client

  • 1. Configure WiFi mode.
AT+CWMODE=3	//softAP+station mode
Response: :
OK
  • 2. Connect to the router.
AT+CWJAP="SSID","password"	//SSID and password of the router
Response: :
AT+CWJAP="SSID","password"
OK
If it succeeds in connecting the WIFI, it will respond and get an IP address.
WIFI CONNECTED
WIFI GOT IP
  • 3. Check the IP address of ESP8266.
AT+CIFSR
Response: :
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:a5:8d:c6"
+CIFSR:STAIP,"192.168.3.133"
+CIFSR:STAMAC,"18:fe:34:a5:8d:c6"

OK
  • 4. PC and ESP8266 are connected to the same router, use the network debugging tool on the PC end, and establish a TCP server.
For example, build a server on a PC with IP address 192.168.3.116 and port 8080.
  • 5. ESP8266 works as a TCP client and connects to the server.
AT+CIPSTART="TCP","192.168.3.116",8080		 //protocol, server IP and port
Response :
CONNECT

OK
  • 6. ESP8266 device ends data of a specified length to the server.
AT+CIPSEND=4                            //set date length which will be sent, such as 4 bytes	
>test                                   //enter the data, no CR
Response :
Recv 4 bytes
SEND OK
  • 7. The data is printed if ESP8266 receives data from the server.
+IPD,n:xxxxxxxxxx				//received n bytes, data=xxxxxxxxxxx
  • 8. Enable the transparent transmission mode, data can be directly transmitted
AT+CIPMODE=1
Response :
OK
  • 9. If the transparent transmission mode is enabled, data can be directly transmitted
AT+CIPSEND	

>	 //From now on, data received from UART will be	transmitted to	the server automatically.
  • 10. Exit sending data:

If +++ is detected in a single packet of data during transparent transmission, the system stops transparent transmission.

- If you use the keyboard to type +++, it may take too long and is not considered as three consecutive + s. You are advised to use a serial port tool to send +++ at a time and not carry invisible characters such as Spaces or newlines.
- Please send the next AT command AT least one second later
  • 11. Exit the transparent transmission mode.
AT+CIPMODE=0
Response :
OK
  • 12. Disconnect TCP.
AT+CIPCLOSE
Response :
CLOSED
OK

TCP Server

  • 1. Configure WiFi mode:
AT+CWMODE=3	//softAP+station mode
Response :
OK
  • 2. Connect to router:
AT+CWJAP="SSID","password"	//SSID and password of the router
Response :
OK
  • 3. Check the IP address of the ESP8266 device:
AT+CIFSR
Response :
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:a5:8d:c6"
+CIFSR:STAIP,"192.168.3.133"
+CIFSR:STAMAC,"18:fe:34:a5:8d:c6"
OK
  • 4. Enable multiple connection:
AT+CIPMUX=1
Response :
OK

Note: If "IPMODE must be 0" appears, it is necessary to disconnect ESP8266 and then enter the command. If not, press the button or power off to restart the module and then operate it again.

  • 5. Build TCP server
AT+CIPSERVER=1	 	 //	default	port	=	333
Response :
OK
  • 6. The PC and THE ESP8266 are connected to the same router. Use the network debugging tool on the PC to establish a TCP client and connect to the TCP server of the ESP8266.
  • 7. Send data:
//ID number of connection is	defaulted	to be 0.
AT+CIPSEND=0,4   //send 4	bytes to connection NO.0
>test            //enter the	data, no CR
Response :
Recv 4 bytes

SEND OK
  • 8. When the ESP8266 device receives data from the server, the following message is displayed:
+IPD,0,n:xxxxxxxxxx	 //received n bytes,	 data=xxxxxxxxxxx
  • 9. Disconnect TCP:
AT+CIPCLOSE
Response :
CLOSED
OK

UDP

UDP transmission does not distinguish between server and client and is established by the AT+CIPSTART command.

  • 1. Configure WiFi mode.
AT+CWMODE=3	//softAP+station mode
Response :
OK
  • 2. Connect to the router.
AT+CWJAP="SSID","password"	//SSID and password of router
Response :
AT+CWJAP="SSID","password"
OK
If the connection is normal, it may prompt you to connect to WIFI and obtain the IP address.
WIFI CONNECTED
WIFI GOT IP
  • 3. Example Query the IP address of the ESP8266.
AT+CIFSR
Response :
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:a5:8d:c6"
+CIFSR:STAIP,"192.168.3.133"
+CIFSR:STAMAC,"18:fe:34:a5:8d:c6"

OK
  • 4. The PC and the ESP8266 are connected to the same router. Use the network debugging tool on the PC to set up a TCP server.
For example, build a server on a PC with IP 192.168.3.116, and the port is set as 8080.
  • 5. Enable multiple connections.
AT+CIPMUX=1
Response :
OK

Note: If "IPMODE must be 0" appears, it is necessary to disconnect ESP8266 and then enter the command. If not, press the button or power off to restart the module and then operate it again.

  • 6. Create a UDP transport. For example, to assign a joined number of 4, the instruction is as follows:
AT+CIPSTART=4,"UDP","192.168.101.110",8080,1112,0
Response :
4, CONNECT	

OK

Note:
About the command:

  • "192.168.101.110", 8080 is the remote IP and port transmitted, that is the UDP port built in step 4;
  • 1112 is the local UDP port of ESP8266, it is configurable, or a random port
  • 0 Indicates that after the current UDP transmission is established, the UDP remote device will not be changed by other devices. Even if other devices send data to ESP8266 UDP port 1112 through UDP protocol, the remote end of THE UDP transmission no. 4 of ESP8266 will not be replaced. If the command "AT+CIPSEND=4, X" is used to send data, the current PC will still receive the data.
  • 7. Send data
AT+CIPSEND=4,7	 //Send 7 bytes to transmission NO.4	
>UDPtest  // enter the data, no CR
Response :
Recv 7 bytes

SEND OK

Note:

• When sending data, if the number of bytes entered exceeds the set length(n):
- The system prompts BUSY, sends the first N bytes of data, and responds SEND OK when the sending is complete.
- The data that exceeds the length is considered invalid and is not accepted.
  • 8. Receive data. When the ESP8266 device receives data from the server, the following information is displayed:
+IPD,4,n:xxxxxxxxxx		 //received n bytes,	data=xxxxxxxxxxx
  • 9. If the transparent transmission mode is enabled, data can be directly transmitted.
AT+CIPMODE=1
Response :
OK
  • 10. The ESP8266 device transmits data to the server through transmission
AT+CIPSEND	

>	 //From now on, data received from UART will be	transmitted to the server automatically.
  • 11. Exit sending data:

If +++ is detected in a single packet of data during transparent transmission, the system stops transparent transmission.

- If you use the keyboard to type +++, it may take too long and is not considered as three consecutive + s. You are advised to use a serial port tool to send +++ at a time and not carry invisible characters such as Spaces or newlines.
- After that, send the next AT command AT least one second later.
  • 12. Exit the transparent transmission mode
AT+CIPMODE=0
Response :
OK
  • 13. Disconnect UDP transmission
AT+CIPCLOSE=4
Response :
4, CLOSED

OK

MicroPython Example

Before Pico can run MicroPython programs, you need to download the MicroPython firmware, install the Thonny IDE, and configure the motherboard environment with the Rasberry Pi option.

TCP Client

  • Open the TCP&UDP test tool, create the server, and start the server.

Pico-ESP8266-TCP-1.png

  • Open tcp_client.py in Thonny IDE and change the SSID and password to the actual WiFi account and password. Change the values of ServerIP and Port in the program to the IP and Port of the actual TCP server.

Pico-ESP8266-02.png

  • Click run program. After running, the program will connect to WiFi and send data to the server. The information sent by the server is displayed in the shell.

TCP Server

  • Open the tcp_server.py program in Thonny IDE and change SSID and password values to the actual WiFi account password.
  • Click to run the program. After the program runs, it will connect to WiFi and start the server. The SHELL displays the STAIP address of ESP8266.

Pico-ESP8266-05.png

  • Open the TCP&UDP test tool, create a connection, set the type to TCP, and target IP to the STAIP address displayed in the shell, port 8080.

Pico-ESP8266-06.png

  • Click the "connect" button to connect to the server. After a normal connection, the icon changes from a blue dot to a green triangle.

UDP

  • Open the TCP&UDP test tool, create a connection, and select UDP as the type, the destination IP address is the STAIP address displayed in the shell after running the program, the port is 1112, and the local port is 8087. Select Create and Connect.

Pico-ESP8266-04.png

  • Open the tcp_server.py program in Thonny IDE and change the SSID and password to the actual WiFi account and password. Set remote_IP to the actual IP address of the computer

Pico-ESP8266-08.png

  • After the program runs, it will connect to WiFi and send data to UDP on the computer side. Enter a string in the send area and send it. ESP8266 receives the message and sends it back for display in the receiving area. The shell port will also display the received information.

C/C++ codes

  • C/C++ is compiled in Raspberry PI. This step can be skipped if the Pico compilation environment has been configured for Raspberry PI. If the Pico compilation environment has not been configured, perform the following operations.
wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
chmod +x pico_setup.sh
./pico_setup.sh
  • Download the demo codes:
cd ~
wget  https://files.waveshare.com/upload/4/41/Pico-ESP8266.zip
unzip Pico-ESP8266.zip
cp -r Pico-ESP8266/c/pico-esp8266  pico
  • Before compiling the program, you need to modify the program and change the values of SSID and password to the actual WiFi account password. Change the values of ServerIP and Port in the program to the IP and Port of the actual TCP server.
  • Compiler:
cd pico/pico-esp8266/build
cmake ..
make

Download AT Firmware

  • Hold the Pico's BOOTSEL button and power on. The computer will recognize a USB flash drive and copy the dev_CDC_ports.uf2 file from the sample program to the flash drive to download the program. The Pico will become a USB-to-serial device.
  • Run the flash_download_tool software.

Pico-ESP8266-11.png

  • The factory default of the module is C1.5.4.1 AT firmware 32Mbit version. Select ai-thinker_esp8266_dout_32mbit_V1.5.4.1 -a_20171130.bin and set the address to 0x0. Set SPI SPEED to 40MHz, SPI MODE to DOUT, and FLASH SIZE to 32Mb-C1.

Pico-ESP8266-12.png

  • Hold the IO0 button of the PICo-ESP8266 and then press the RESET button to enter download mode. Select the corresponding serial port and set the baud rate to 115200. Click START and wait for the download to complete.
  • To set the AT firmware for nonOS_AT_BIN_V1.7.4, follow the following figure.

Pico-ESP8266-013.png

Resource

Document

Examples

Software

Pico Getting Started

Firmware Download

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Introduction

Raspberry Pi Pico Basics

MicroPython Series

Install Thonny IDE

In order to facilitate the development of Pico/Pico2 boards using MicroPython on a computer, it is recommended to download the Thonny IDE

  • Download Thonny IDE and follow the steps to install, the installation packages are all Windows versions, please refer to Thonny's official website for other versions
  • After installation, the language and motherboard environment need to be configured for the first use. Since we are using Pico/Pico2, pay attention to selecting the Raspberry Pi option for the motherboard environment

Pico-R3-Tonny1.png

  • Configure MicroPython environment and choose Pico/Pico2 port
    • Connect Pico/Pico2 to your computer first, and in the lower right corner of Thonny left-click on the configuration environment option --> select Configture interpreter
    • In the pop-up window, select MicroPython (Raspberry Pi Pico), and choose the corresponding port

700px-Raspberry-Pi-Pico-Basic-Kit-M-2.png
700px-Raspberry-Pi-Pico-Basic-Kit-M-3.png

Flash Firmware

  • Click OK to return to the Thonny main interface, download the corresponding firmware library and burn it to the device, and then click the Stop button to display the current environment in the Shell window
  • Note: Flashing the Pico2 firmware provided by Micropython may cause the device to be unrecognized, please use the firmware below or in the package
  • How to download the firmware library for Pico/Pico2 in windows: After holding down the BOOT button and connecting to the computer, release the BOOT button, a removable disk will appear on the computer, copy the firmware library into it
  • How to download the firmware library for RP2040/RP2350 in windows: After connecting to the computer, press the BOOT key and the RESET key at the same time, release the RESET key first and then release the BOOT key, a removable disk will appear on the computer, copy the firmware library into it (you can also use the Pico/Pico2 method)

Raspberry-Pi-Pico2-Python.png

MicroPython Series

【MicroPython】 machine.Pin class function details
【MicroPython】machine.PWM class function details
【MicroPython】machine.ADC class function details
【MicroPython】machine.UART class function details
【MicroPython】machine.I2C class function details
【MicroPython】machine.SPI class function details
【MicroPython】rp2.StateMachine class function details

C/C++ Series

For C/C++, it is recommended to use Pico VS Code for development. This is a Microsoft Visual Studio Code extension designed to make it easier for you to create, develop, and debug projects for the Raspberry Pi Pico series development boards. No matter if you are a beginner or an experienced professional, this tool can assist you in developing Pico with confidence and ease. Here's how to install and use the extension.

  • Official website tutorial: https://www.raspberrypi.com/news/pico-vscode-extension/
  • This tutorial is suitable for Raspberry Pi Pico, Pico2 and the RP2040 and RP2350 series development boards developed by Waveshare
  • The development environment defaults to Windows. For other environments, please refer to the official tutorial for installation

Install VSCode

  1. First, click to download pico-vscode package, unzip and open the package, double-click to install VSCode
    Pico-vscode-1.JPG
    Note: If vscode is installed, check if the version is v1.87.0 or later
    Pico-vscode-2.JPG
    Pico-vscode-3.JPG

Install Extension

  1. Click Extensions and select Install from VSIX
    Pico-vscode-4.JPG
  2. Select the package with the vsix suffix and click Install
    Pico-vscode-5.JPG
  3. Then vscode will automatically install raspberry-pi-pico and its dependency extensions, you can click Refresh to check the installation progress
    Pico-vscode-6.JPG
  4. The text in the right lower corner shows that the installation is complete. Close VSCode
    Pico-vscode-7.JPG

Configure Extension

  1. Open directory C:\Users\username and copy the entire .pico-sdk to that directory
    Pico-vscode-8.JPG
  2. The Copy is completed
    Pico-vscode-9.JPG
  3. Open vscode and configure the paths for the Raspberry Pi Pico extensions
    Pico-vscode-10.JPG
    The configuration is as follows:
    Cmake Path:
    ${HOME}/.pico-sdk/cmake/v3.28.6/bin/cmake.exe
    
    Git Path:
    ${HOME}/.pico-sdk/git/cmd/git.exe    
    
    Ninja Path:
    ${HOME}/.pico-sdk/ninja/v1.12.1/ninja.exe
    
    Python3 Path:
    ${HOME}/.pico-sdk/python/3.12.1/python.exe             
    

New Project

  1. The configuration is complete, create a new project, enter the project name, select the path, and click Create to create the project
    To test the official example, you can click on the Example next to the project name to select
    Pico-vscode-11.JPG
  2. The project is created successfully
    Pico-vscode-12.JPG
  3. Select the SDK version
    Pico-vscode-13.JPG
  4. Select Yes for advanced configuration
    Pico-vscode-14.JPG
  5. Choose the cross-compilation chain, 13.2.Rel1 is applicable for ARM cores, RISCV.13.3 is applicable for RISCV cores. You can select either based on your requirements
    Pico-vscode-15.JPG
  6. Select default for CMake version (the path configured earlier)
    Pico-vscode-16.JPG
  7. Select default for Ninjaversion
    Pico-vscode-17.JPG
  8. Select the development board
    Pico-vscode-18.JPG
  9. Click Complie to compile
    Pico-vscode-19.JPG
  10. The uf2 format file is successfully compiled
    Pico-vscode-20.JPG

Import Project

  1. The Cmake file of the imported project cannot have Chinese (including comments), otherwise the import may fail
  2. To import your own project, you need to add a line of code to the Cmake file to switch between pico and pico2 normally, otherwise even if pico2 is selected, the compiled firmware will still be suitable for pico
    Pico-vscode-21.JPG set(PICO_BOARD pico CACHE STRING "Board type")

Update Extension

  1. The extension version in the offline package is 0.15.2, and you can also choose to update to the latest version after the installation is complete
    Pico-vscode-22.JPG

Arduino IDE Series

Install Arduino IDE

  1. First, go to Arduino official website to download the installation package of the Arduino IDE.
    600px-Arduino下载2.0版本.jpg
  2. Here, you can select Just Download.
    仅下载不捐赠.png
  3. Once the download is complete, click Install.
    IDE安装水印-1.gif
    Notice: During the installation process, it will prompt you to install the driver, just click Install
    600px

Arduino IDE Interface

  1. After the first installation, when you open the Arduino IDE, it will be in English. You can switch to other languages in File --> Preferences, or continue using the English interface.
    首选项-简体中文.jpg
  2. In the Language field, select the language you want to switch to, and click OK.
    600px-首选项-简体中文ok.jpg

Install Arduino-Pico Core in the Arduino IDE

  1. Open the Arduino IDE, click on the file in the top left corner, and select Preferences
    RoArm-M1 Tutorial04.jpg
  2. Add the following link to the attached board manager URL, and then click OK
    https://github.com/earlephilhower/arduino-pico/releases/download/4.0.2/package_rp2040_index.json

    RoArm-M1 Tutorial II05.jpg
    Note: If you already have an ESP32 board URL, you can use a comma to separate the URLs as follows:

    https://dl.espressif.com/dl/package_esp32_index.json,https://github.com/earlephilhower/arduino-pico/releases/download/4.0.2/package_rp2040_index.json
  3. Click Tools > Development Board > Board Manager > Search pico, as my computer has already been installed, it shows that it is installed
    Pico Get Start 05.png
    Pico Get Start 06.png

Upload Demo at the First Time

  1. Press and hold the BOOTSET button on the Pico board, connect the pico to the USB port of the computer via the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
    Pico Get Start.gif
  2. Download the program and open D1-LED.ino under the arduino\PWM\D1-LED path
  3. Click Tools --> Port, remember the existing COM, do not click this COM (the COM displayed is different on different computers, remember the COM on your own computer)
    UGV1 doenload02EN.png
  4. Connect the driver board to the computer using a USB cable. Then, go to Tools > Port. For the first connection, select uf2 Board. After uploading, when you connect again, an additional COM port will appear
    UGV1 doenload03EN.png
  5. Click Tools > Development Board > Raspberry Pi Pico > Raspberry Pi Pico or Raspberry Pi Pico 2
    Pico Get Start02.png
  6. After setting it up, click the right arrow to upload the program
    Pico Get Start03.png
  • If issues arise during this period, and if you need to reinstall or update the Arduino IDE version, it is necessary to uninstall the Arduino IDE completely. After uninstalling the software, you need to manually delete all contents within the C:\Users\[name]\AppData\Local\Arduino15 folder (you need to show hidden files to see this folder). Then, proceed with a fresh installation.

Open Source Demos

MircoPython video demo (github)
MicroPython firmware/Blink demos (C)
Raspberry Pi official C/C++ demo (github)
Raspberry Pi official micropython demo (github)
Arduino official C/C++ demo (github)


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)