Skip to content

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x00) When connect ESP32 to RN2483 #3054

@uceekji

Description

@uceekji

` * Uart TX -- GPIO3

  • Uart RX -- GPIO1
  • Reset -- GPIO15
  • Vcc -- 3.3V
  • Gnd -- Gnd

*/
#include <rn2xx3.h>
#include <SoftwareSerial.h>

#define RESET 15
SoftwareSerial mySerial(3, 1); // RX, TX !! labels on relay board is swapped !!

//create an instance of the rn2xx3 library,
//giving the software UART as stream to use,
//and using LoRa WAN
rn2xx3 myLora(mySerial);

// the setup routine runs once when you press reset:
void setup() {
// LED pin is GPIO2 which is the ESP8266's built in LED
pinMode(2, OUTPUT);
led_on();

// Open serial communications and wait for port to open:
Serial.begin(57600);
mySerial.begin(57600);

delay(1000); //wait for the arduino ide's serial console to open

Serial.println("Startup");

initialize_radio();

//transmit a startup message
myLora.tx("TTN Mapper on ESP8266 node");

led_off();
delay(2000);
}

void initialize_radio()
{
//reset RN2xx3
pinMode(RESET, OUTPUT);
digitalWrite(RESET, LOW);
delay(100);
digitalWrite(RESET, HIGH);

delay(100); //wait for the RN2xx3's startup message
mySerial.flush();

//check communication with radio
String hweui = myLora.hweui();
while(hweui.length() != 16)
{
Serial.println("Communication with RN2xx3 unsuccessful. Power cycle the board.");
Serial.println(hweui);
delay(10000);
hweui = myLora.hweui();
}

//print out the HWEUI so that we can register it via ttnctl
Serial.println("When using OTAA, register this DevEUI: ");
Serial.println(hweui);
Serial.println("RN2xx3 firmware version:");
Serial.println(myLora.sysver());

//configure your keys and join the network
Serial.println("Trying to join TTN");
bool join_result = false;

//ABP: initABP(String addr, String AppSKey, String NwkSKey);
join_result = myLora.initABP("02017201", "8D7FFEF938589D95AAD928C2E2E7E48F", "AE17E567AECC8787F749A62F5541D522");

//OTAA: initOTAA(String AppEUI, String AppKey);
//join_result = myLora.initOTAA("70B3D57ED00001A6", "A23C96EE13804963F8C2BD6285448198");

while(!join_result)
{
Serial.println("Unable to join. Are your keys correct, and do you have TTN coverage?");
delay(60000); //delay a minute before retry
join_result = myLora.init();
}
Serial.println("Successfully joined TTN");

}

// the loop routine runs over and over again forever:
void loop() {
led_on();

Serial.println("TXing");
myLora.tx("!"); //one byte, blocking function

led_off();
delay(200);

}

void led_on()
{
digitalWrite(2, 1);
}

void led_off()
{
digitalWrite(2, 0);
}`

When I run this code, it said
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x00)
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x00)

I have tried the way to press boot button but nothing happened. But when I disconnect my MCU to the chip, the uploaded can be completed. It seems like something wrong with RX and TX connection. But there is no results in monitor then.

I want to know whats the problem and how to solve it.

Thank you.

Kai

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions