Giter VIP home page Giter VIP logo

pi_pico_wifi_driver's Introduction

MicroPython Raspberry Pi Pico WiFi Driver

  • This project was forked and modified from: https://github.com/kfricke/micropython-esp8266uart
  • This driver for MicroPython intends to be useable on any MicroPython platform which implements a serial UART interface.
  • I tested this on Raspberry Pi Pico, together with an ESP-01 module (with AT command UART interface).
  • Since Pi-Pico has no radio built-in, it is good to get a cheap WiFi module like ESP-01 for it.
+-------------------+                +-------------------+
|                   |                |                   |
|   Raspberry Pi    |                |      ESP-01       |
|      Pico         |                |                   |
|                   |                |                   |
|               IO4 +----------------> RXD               |
|                   |                |                   |
|               IO5 <----------------+ TXD               |
|                   |                |                   |
|               GND +----------------+ GND               |
|                   |                |                   |
|                   |                |                   |
|      HOST         |                |    WIFI MODULE    |
|                   |                |                   |
|   (MicroPython)   |                |   (AT Firmware)   |
|                   |                |                   |
+-------------------+                +-------------------+

Usage

  • Upload these script files onto your Pico board, using Thonny or mpfs, etc.:

    • esp_at_uart.py
    • uart_timeout_any.py
    • test.py
  • On the repl shell, run with:

import test

Note

  • So far there is no "timeout" for uart's read/readline, thus we have to use "uart_timeout_any" as a temporally hotfix. See: https://github.com/raspberrypi/micropython/blob/pico/ports/rp2/machine_uart.c

  • It seems the Pi Pico is quite slow in processing incoming UART bytes, and we are unable to set the RX buffer at this moment. So we lost some bytes while receiving bulk message from ESP-01, a quick fix here is to set the ESP-01 to use 9600bps instead. You may connect the ESP-01 to your PC's console and use AT+UART_DEF=9600,8,1,0,0 to setup it first (default to 115200bps).

Example Output

>>> import test
UART(1, baudrate=9600, bits=8, parity=None, stop=1, tx=4, rx=5)
Testing Generic Methods
=======================
AT startup...
Success!
Another AT startup...
Success!
Version...
       1 - TX: b'AT+GMR\r\n'
      29 - RX: b'AT+GMR\r\n'
      83 - RX: b'AT version:2.1.0.0(883f7f2 - Jul 24 2020 11:50:07)\r\n'
     117 - RX: b'SDK version:v4.0.1-193-ge7ac221\r\n'
     163 - RX: b'compile time(0ad6331):Jul 28 2020 02:47:21\r\n'
     193 - RX: b'Bin version:2.1.0(WROOM-32)\r\n'
     198 - RX: b'\r\n'
     202 - RX: b'OK\r\n'
     205 - 'OK' received!
Success!

Testing WIFI Methods
====================
Testing get_mode/set_mode of value 'STATION'(1)...
Success!
Connecting WLAN...
Success!
Checking if connected WLAN SYNCSIGN_2.4G
Success!
Disconnecting from WLAN...
Success!
Checking if not connected WLAN...
Success!
Setting Station mode...
Success!
Scanning for WLANs...
[{'mac': b'"********"', 'rssi': -52, 'encryption_protocol': 3, 'ssid': b'"SYNCSIGN_2.4G"', 'channel': 6}, {'mac': b'"********"', 'rssi': -53, 'encryption_protocol': 3, 'ssid': b'"******"', 'channel': 6}, {'mac': b'"********"', 'rssi': -67, 'encryption_protocol': 4, 'ssid': b'"******"', 'channel': 11}]
Setting AP + Station mode...
Success!
Reading access point configuration
{'max_conn': 4, 'ssid_hidden': 0, 'ssid': b'"ESP_8283B1"', 'channel': 1, 'password': b'""', 'encryption_protocol': 0}
Listing all stations connected to the module in access point mode...
[]
Read DHCP client and server settings:
{'softAP': False, 'station': False}
Checking DHCP client and server settings...
    Enable Station DHCP...
    Enable SoftAP DHCP...
Setting autoconnect to access point in station mode...
Reading the station IP...
b'+CIPSTA:ip:"0.0.0.0"'
Reading the access point IP...
b'+CIPAP:ip:"192.168.4.1"'
>>>

pi_pico_wifi_driver's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pi_pico_wifi_driver's Issues

Baudrate, Timeout

If I reduce the baudrate to 9600 I get a lot of timeout errors. With 115200 it is better. A higher timeout will get fewer errors.
Is there anything dependant from ESP-01 firmware version?

Furthermore I get command errors:
...
Setting AP + Station mode...
Success!
Listing all stations connected to the module in access point mode...
[]
Read DHCP client and server settings:
{'softAP': False, 'station': True}
Checking DHCP client and server settings...
Disable Station DHCP & Setting static IP...
Enable SoftAP DHCP...
Traceback (most recent call last):
File "", line 1, in
File "test.py", line 124, in
File "esp_at_uart.py", line 497, in set_dhcp_config
File "esp_at_uart.py", line 279, in _set_command
File "esp_at_uart.py", line 183, in _send_command
CommandError: Command error!

Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.