I managed to get the Wio RP2040 MicroPython wifi code to work after correcting the example code to use SPI instead of UART. (see post ‘Latest firmware for Wio RP2040’ for this fix)
I have been unable to get the Arduino IDE (C/C++) example to work which is using UART. Here is the code.
UART _UART2_(p8,p9,NC,NC);
_UART2_.begin(115200);
delay(3000);
cmd_send("AT+CWJAP=\"YourWiFi\",\"Password\"");
Serial.println("send wifi name");
wait_result();
display_ap();
Full example code for this from SeeedStudio is here
I think the UART code is not working where SPI does. However I don’t know what SPI pins are used and there is no open source for the firmware to be able to discover this. To fix this I need to know which SPI or UART pins are connecting the Pico to the ESP module. Is there a detailed datasheet which has this information?
Has anyone been able to get this Arduino example code to work?
Many thanks for your help.
1 Like
Hello!
These codes is written for UART mode NOT SPI mode, we will update the codes for SPI later.
If you want to have a try, here is the SPI Pin:
MISO:8
MOSI:11
CLK:10
CS:9
HandShake:21
Thanks for your help. I will try to get the SPI approach to work.
Just to be clear on the problem I am experiencing. I do understand the code is using UART. The code above sends the UART ‘AT+CWJAP’ command, the debug serial port posts a message ‘send wifi name’ and then the ESP wifi device never responds. So the example code waits forever in a loop. I tried simpler AT commands to this UART port but the device is not responding to any command.
I know my wifi module works because when I made this change below to the LAN example everything worked.
NOT WORKING
N1 = network.WLAN_UART(network.STA_IF)
WORKING
N1 = network.WLAN_SPI(network.STA_IF)
There are only 2 forum posts about these devices (at time of posting) and both of them had this UART issue. It might be a good idea to update the example code to avoid other people having this issue.
I also tried UART with Arduino IDE. It did not work for me either.
1 Like
Hello again. The wifi module is not working for any C/C++ or Arduino code I have tried. It seems UART is needed to configure the ESP 8265 in the WIO RP2040. Can you publish the MicroPython source code for the WIO RP2040 ‘network’ module?
I wrote this Arduino program to show clearly what is happening with the UART.
#define BAUD_RATE 115200
#define UART_TX_PIN 8
#define UART_RX_PIN 9
UART esp(UART_TX_PIN,UART_RX_PIN,NC,NC);
void setup() {
Serial.begin(115200); // Open serial communications to host computer and wait for port to open:
while (!Serial);// wait for serial port to connect. Needed for native USB port only
Serial.println("USB Serial initialized.");
// Initialize the UART to the ESP 8265
esp.begin(BAUD_RATE);
}
void loop()
{
Serial.println("Sending AT command 'AT\\r\\n' ");
esp.print("AT\r\n");
delay(100);
int avail = esp.available();
while (avail) {
uint8_t data = esp.read();
Serial.print("Available ");
Serial.print(avail);
Serial.print(" Received unit8=");
Serial.print(data);
Serial.println("");
avail = esp.available();
}
Serial.println(" done.");
delay(10000);
}
The program above outputs the following. The first time the AT command is sent it does get a single null character back. Subsequent writes to the UART return nothing.
USB Serial initialized.
Sending AT command 'AT\r\n'
Available 1 Received unit8=0
done.
Sending AT command 'AT\r\n'
done.
Any help gratefully received.