0

Challenger RP2040 WiFi with U.FL connector

The Challenger RP2040 WiFi is an Arduino/Micropython compatible Adafruit Feather format micro controller board based on the Raspberry Pico chip.

When we designed this board we took our existing Challenger M0 WiFi board and replaced the SAMD21 micro controller with the extremely powerful dual core RP2040 Cortex-M0 device. So the main controller of this board is the RP2040 which has 264KByte of SRAM internally and 8MByte of external FLASH memory.

WiFi

Just like the Challenger M0 WiFi it has a  ESP8285 WiFi chip. For those of you that is unfamiliar with this device, it is basically an ESP8266 device with an integrated 1MByte of flash memory. This allows us to have an AT command interpreter inside this chip that the main controller can talk to and connect to you local WiFi network. The communications channel between the two devices is an unused UART on the main controller and the standard UART on the ESP8285. As simple as it can be.

The ESP8285 chip comes pre-flashed with Espressif’s AT command interpreter stored in the internal 1MByte of the ESP8285. This interpreter support most of the operating and sleep modes of the standard ESP8266 framework which makes it easy to work with. Talking to the device is as easy as opening the second serial port (Serial2), resetting the ESP8285 and start listening for events and sending commands

USB Type C

In the recent years we have noticed that we are seeing more and more USB Type C cable laying around the lab due to the fact that all new phones and accessories use them. As of yet we haven’t seen any shortage of micro USB cables but we are not getting any new ones any more and old ones do break occasionally. So we decided to go for a USB Type C connector for this board. A bonus of this is that they are quite bit more durable and you don’t have to fiddle with the cable before plugging it in.

Pinout

On board antenna or U.FL ?

This board is available in two different antenna option versions. The most common version is with an on board chip antenna which just works straight out of the box. The second version has a U.FL connector on board which requires you to add an external antenna for your system. You can basically use any 50ohm 2.45GHz antenna and it will work just fine.

Weight 0.009 kg
Dimensions 5.07 × 2.28 × 0.72 cm

Using the Arduino environment

We’ve teamed up with Earle F. Philhower over at his Github page to provide Arduino support for our RP2040 based boards. You can follow the instructions on Earle’s github page or you can check out our instructions here on how to install the package.

MicroPython

The Challenger RP2040 WiFi board is fully compatible with both the micropython package found at the Raspberry Pi site as well as Adafruits CircuitPython. Instruction are available on how to install the python interpreter of your choice is available on respective web site.

Short initialization example

To simplify the hardware aspect of the WiFi modem we have included a small helper class in the Arduino IDE that is always available to you as a developer. 

The first thing you need to do in your sketch is to include the HW support library and the WiFi library by entering:

#include <ChallengerWiFi.h>
#include <WiFiEspAT.h>

After this basically all you need to do before starting the WiFi manager is the following:

if (Challenger2040WiFi.reset())
    Serial.println(F("WiFi Chip reset OK !"));
else
    Serial.println(F("Could not reset WiFi chip !"));

After these step the modem is initialized and is ready to accept your commands. The reset() function of the built in Challenger2040WiFi library will perform a HW reset of the WiFi modem and wait for it to return the “ready” prompt. After this a WiFi manager can be started and start communicating with the modem. Here at iLabs we use the WiFiEspAT library and initializing the stack is as easy as

WiFi.init(Serial2);

Make sure the library is included at the top of the file with:  #include <WiFiEspAT.h>

At this point you can also do a check to make sure that the data link is setup properly.

if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
}

You are now good to go, so doing something like this:

Serial.println("Waiting for connection to WiFi");
while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print('.');
}
Serial.println();
Serial.println("Connected to WiFi network.");

will work as expected.

Changing the baudrate

The default baudrate between the RP2040 micro controller and the ESP8285 WiFi modem is 115200 and while this is probably good for most IoT applications that normally don’t send very much data it can sometimes be useful to increase the baudrate. The Challenger2040WiFi contains a method for doing this and again it is super simple to use. Just do the following and the baud rate will be altered on both systems and the devices will be synced up.

Challenger2040WiFi.changeBaudRate(921600);

After this you can proceed to communicate with the device as normal.

Sending and AT command

After the modem has been initialized and it has reported that it is ready you can now send a command to it. Here’s an example on how a simple command can be sent.

Serial2.println("ATE0");

This command simply tells the modem not to repeat everything back that you send to it. If you want to enable this again you would simply send the following command:

Serial2.println("ATE1");

Pass through example

This example Arduino program creates a USB2Serial pass through to the ESP8285. This can be used to flash the ESP with new upgraded software or you can write your own code and use this short snippet to flash the device.

CircuitPython by Adafruit

The Challenger boards fully supports circuitpython and should be supported shortly by the official releases. But until then we have created a beta release of the circuitpython image which can be downloaded from here.

Please go ahead and put it through its paces and feel free to report back any issues that you may find.

How do I use it

Basically it works as any other circuitpython board but we have included relevant board parameters for simplify accessing specific pins and other special IO’s. The board help function lists the following functions:

object <module 'board'> is of type module
__name__ -- board
board_id -- challenger_rp2040_wifi
SDA -- board.SDA
GP0 -- board.SDA
SCL -- board.SCL
GP1 -- board.SCL
D5 -- board.D5
GP2 -- board.D5
D6 -- board.D6
GP3 -- board.D6
ESP_TX -- board.ESP_TX
GP4 -- board.ESP_TX
ESP_RX -- board.ESP_RX
GP5 -- board.ESP_RX
D9 -- board.D9
GP6 -- board.D9
D10 -- board.D10
GP7 -- board.D10
D11 -- board.D11
GP8 -- board.D11
D12 -- board.D12
GP9 -- board.D12
D13 -- board.D13
GP10 -- board.D13
NEOPIXEL -- board.NEOPIXEL
GP11 -- board.NEOPIXEL
LED -- board.LED
GP12 -- board.LED
WIFI_MODE -- board.WIFI_MODE
WIFI_RESET -- board.WIFI_RESET
D0 -- board.D0
TX -- board.D0
GP16 -- board.D0
D0 -- board.D0
TX -- board.D0
GP17 -- board.D0
SCK -- board.SCK
GP22 -- board.SCK
MOSI -- board.MOSI
GP23 -- board.MOSI
MISO -- board.MISO
GP24 -- board.MISO
A0 -- board.A0
GP26 -- board.A0
A1 -- board.A1
GP27 -- board.A1
A2 -- board.A2
GP28 -- board.A2
A3 -- board.A3
GP29 -- board.A3
A4 -- board.A4
GP25 -- board.A4
A5 -- board.A5
GP21 -- board.A5
I2C -- <function>
SPI -- <function>
UART -- <function>

Using these defines it is now simple to access the serial port that interfaces to the WiFi modem.

import board
import busio
import digitalio

wifi=busio.UART(board.ESP_TX, board.ESP_RX, baudrate=115200, receiver_buffer_size=2048)
wrst = digitalio.DigitalInOut(board.WIFI_RESET)
wmde = digitalio.DigitalInOut(board.WIFI_MODE)
wrst.direction = digitalio.Direction.OUTPUT
wmde.direction = digitalio.Direction.OUTPUT
wrst.value = 0
wmde.value = 1
wrst.value = 1

Reading from the serial line at this point will read in a garbage string generated by the WiFi modem. So typing this:

print (wifi.read())

Will produce a bytearray that looks like this:

b'sx88x03x00lx9cxc8sOx80Flxe0xf1o@x03Fxf0x06x8cxc6x0cx8ex83xecx8exx8cxbex8fx83Ox80vx9cx81x9bO|x13cx8cx8epx0cx88x0cxf3ooxf6x03Fxefxf9oxc6x93Nxf3x06cx1cpx84x8fxb1l`tx9b`tx83ggxe0Ao@x03Gxf8x83Gxe06x87xc0x0cx8ex80x0cx8ex80'

You can discard this string as it is simply a startup message from the modem that looks like garbage. If we now instead send a simple AT command to the modem like this:

wifi.write(bytearray('ATrn'))

You should now receive a valid response back from the modem when reading. It should look like this:

print (wifi.read())
b'ATrnrnOKrn'

Initializing the board in circuitpython using Adafruit espatcontrol library

The following piece of startup code is taken from Adafruits espatcontrol python library examples and modified to support our board. You

if board.board_id == "challenger_rp2040_wifi":
RX = board.ESP_RX
TX = board.ESP_TX
resetpin = DigitalInOut(board.WIFI_RESET)
rtspin = False
uart = busio.UART(TX, RX, baudrate=11520, receiver_buffer_size=2048)
esp_boot = DigitalInOut(board.WIFI_MODE)
esp_boot.direction = Direction.OUTPUT
esp_boot.value = True
else:
RX = board.ESP_TX
TX = board.ESP_RX
resetpin = DigitalInOut(board.ESP_WIFI_EN)
rtspin = DigitalInOut(board.ESP_CTS)
uart = busio.UART(TX, RX, timeout=0.1)
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
esp_boot.direction = Direction.OUTPUT
esp_boot.value = True
# For Boards that do not have an rtspin like challenger_rp2040_wifi set rtspin to False.
esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=debugflag
)
print("Resetting ESP module")
esp.hard_reset()

And you are good to go. Happy snaking around the system and feel free to report any bugs that you may find.


Download CircuitPython

Documentation for the Challenger RP2040 WiFi board.

Check out this informative video with detailed information about the board.

You can always get our products from your local reseller if you like. Here is a list of current resellers.

  • The Pi Hut Raspberry Pi Superstore
  • The largest maker shop in Switzerland

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

You may also like…