Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable Behavior in EBYTE E220-400M22S Setup with ATTINY804 #15

Open
krishank652 opened this issue Feb 6, 2024 · 9 comments
Open

Unstable Behavior in EBYTE E220-400M22S Setup with ATTINY804 #15

krishank652 opened this issue Feb 6, 2024 · 9 comments

Comments

@krishank652
Copy link

I am seeking assistance in the library GitHub to address an issue I'm encountering.

My challenge involves establishing communication between the Ebyte LoRa E220-400M22S and the MCU ATTINY804 IC. Below is the code snippet I'm utilizing:

#include <Ra01S.h>

#define RF_FREQUENCY                                433000000 // Hz  center frequency
//#define RF_FREQUENCY                                866000000 // Hz  center frequency
//#define RF_FREQUENCY                                915000000 // Hz  center frequency
#define TX_OUTPUT_POWER                             22        // dBm tx output power
#define LORA_BANDWIDTH                              4         // bandwidth
                                                              // 2: 31.25Khz
                                                              // 3: 62.5Khz
                                                              // 4: 125Khz
                                                              // 5: 250KHZ
                                                              // 6: 500Khz                                                               
#define LORA_SPREADING_FACTOR                       7         // spreading factor [SF5..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]

#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_PAYLOADLENGTH                          0         // 0: Variable length packet (explicit header)
                                                              // 1..255  Fixed length packet (implicit header)
#if 1

SX126x  lora(0,               //Port-Pin Output: SPI select
             1,               //Port-Pin Output: Reset 
             2                //Port-Pin Input:  Busy
             );
#endif // ATmega328/2560

#if 0

SX126x  lora(0,                 //Port-Pin Output: SPI select
             1,                 //Port-Pin Output: Reset 
             2                 //Port-Pin Input:  Busy
             );
#endif // ESP8266

void setup() 
{
  delay(1000);
  Serial.begin(9600);

  lora.DebugPrint(true);

 /*
  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER);          //tx power in dBm
*/

// UPDATED BELOW CODE AS PER INSTRUCTION ON LIBRARY PAGE

  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER,           //tx power in dBm
                           3.3,                       //use TCXO
                           true);                     //use TCXO



                           
  if (ret != ERR_NONE) while(1) {delay(1);}

  lora.LoRaConfig(LORA_SPREADING_FACTOR, 
                  LORA_BANDWIDTH, 
                  LORA_CODINGRATE, 
                  LORA_PREAMBLE_LENGTH, 
                  LORA_PAYLOADLENGTH, 
                  true,               //crcOn  
                  false);             //invertIrq

}

void loop() 
{
  uint8_t txData[255];
  sprintf((char *)txData, "Hello World %lu", millis());
  uint8_t len = strlen((char *)txData);

  // Wait for transmission to complete
  if (lora.Send(txData, len, SX126x_TXMODE_SYNC)) {
    //Serial.println("Send success");
  } else {
    Serial.println("Send fail");
  }

  // Do not wait for the transmission to be completed
  //lora.Send(txData, len, SX126x_TXMODE_ASYNC );

  delay(1000);
}

I used above code from the library Example: example/Ra01S-TX/Ra01S-TX.ino and changes are done by me :

  1. Uncomment the 433MHz Line and Comment the 915MHz line.
#define RF_FREQUENCY                                433000000 // Hz  center frequency
//#define RF_FREQUENCY                                866000000 // Hz  center frequency
//#define RF_FREQUENCY                                915000000 // Hz  center frequency
  1. Updated below as per my connections I am using ATTINY804 connections details are in the below.
#if 1

SX126x  lora(0,               //Port-Pin Output: SPI select
             1,               //Port-Pin Output: Reset 
             2                //Port-Pin Input:  Busy
             );
#endif // ATmega328/2560

#if 0

SX126x  lora(0,                 //Port-Pin Output: SPI select
             1,                 //Port-Pin Output: Reset 
             2                 //Port-Pin Input:  Busy
             );
#endif // ESP8266
  1. Below Line for serial monitor
    Serial.begin(9600);
  2. Uncomment below line for debugging.
    lora.DebugPrint(true);
  3. As per instruction given on the library page I am using Ebyte module So I updated below code:
/*
 int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                          TX_OUTPUT_POWER);          //tx power in dBm
*/

// UPDATED BELOW CODE AS PER INSTRUCTION ON LIBRARY PAGE

 int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                          TX_OUTPUT_POWER,           //tx power in dBm
                          3.3,                       //use TCXO
                          true);                     //use TCXO

During the initial startup, the Serial Monitor output is as follows:

21:25:27.203 -> begin
21:25:27.203 -> debugPrint=1
21:25:27.203 -> SX126x_SPI_SELECT=0
21:25:27.250 -> SX126x_RESET=1
21:25:27.250 -> SX126
21:25:27.250 -> 
21:25:27.250 -> 
21:25:28.187 -> ut: 7-->A2 0-->A2 1-->A2 40-->A2 
21:25:28.234 -> WriteCommand:  CMD=0x89  DatD
21:25:28.282 -> 
21:25:28.282 -> 
21:25:29.219 -> =0x8  DataOut: 3-->A2 FF-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A
21:25:29.266 -> 
21:25:29.266 ->

However, subsequent startups after a power restore yield different results, suggesting an inconsistency issue:

21:26:56.403 -> ⸮
21:26:56.403 -> 
21:26:56.403 -> 
21:26:57.402 -> begin
21:26:57.402 -> debugPrint=1
21:26:57.449 -> SX126x_SPI_SELECT=0
21:26:57.449 -> SX126x_RESET=1
21:26:57.496 -> SX126
21:26:57.496 -> 
21:26:57.496 -> 
21:26:58.402 -> 0x1424
21:26:58.449 -> SX126x installed
21:26:58.449 -> WriteCommand:  CMD=0x80  DataOut: 0--
21:26:58.496 -> 
21:26:58.496 ->

These inconsistencies occur with subsequent startups, implying a problem with the setup.

The connections between ATTINY804 and E220-400M22S are as follows:

  • SCK <> SCK
  • MOSI <> MOSI
  • MISO <> MISO
  • 0 <> NSS
  • 1 <> NRST
  • 2 <> BUSY

For power supply, I'm using the AMS1117 3.3V Power Supply Module, drawing input from Arduino 5V and GND, then supplying it to the circuit via the AMS1117 3.3V Power supply.

For ATTINY804 programming, I'm utilizing the megaTinyCore Library and referring to the ATTINY804 pinout details.

I'm reaching out to the library developer and the community for assistance in resolving this issue. Any guidance or suggestions would be greatly appreciated. Thank you in advance.

@nopnop2002
Copy link
Owner

It looks like Serial.print is not working correctly.

@krishank652
Copy link
Author

It looks like Serial.print is not working correctly.

Thanks for the reply.
For this what I need to do? Is I need to change baud rate or anything other things?

@nopnop2002
Copy link
Owner

nopnop2002 commented Feb 7, 2024

I've never used ATTINY804, so I don't know.

This is not directly related to the problem, but why would you want to use ATTINY804?

@krishank652
Copy link
Author

I've never used ATTINY804, so I don't know.

This is not directly related to the problem, but why would you want to use ATTINY804?

I am building a wirless water level indicator device, and want to use AA type battery in transmitter device, I choosen ATTINY804 MCU because its power consumption is low, also I am able to program it.

I tried with Arduino UNO But still facing problem.

Components Using:

  1. Arduino UNO
  2. Ebyte Lora E220-400M22S
  3. Logic Level Shifter
  4. AMS1117 3.3V Power Supply Module

Wiring Connection that I am using.:

Arduino-E220

Transmitter Device Code:


#include <Ra01S.h>

#define RF_FREQUENCY                                433000000 // Hz  center frequency
//#define RF_FREQUENCY                                866000000 // Hz  center frequency
//#define RF_FREQUENCY                                915000000 // Hz  center frequency
#define TX_OUTPUT_POWER                             22        // dBm tx output power
#define LORA_BANDWIDTH                              4         // bandwidth
                                                              // 2: 31.25Khz
                                                              // 3: 62.5Khz
                                                              // 4: 125Khz
                                                              // 5: 250KHZ
                                                              // 6: 500Khz                                                               
#define LORA_SPREADING_FACTOR                       7         // spreading factor [SF5..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]

#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_PAYLOADLENGTH                          0         // 0: Variable length packet (explicit header)
                                                              // 1..255  Fixed length packet (implicit header)
#if 1
/*
 * for ATmega328/2560
 * VCC    3V3/3V3
 * GND    GND/GND
 * SCK    13/52
 * MISO   12/50
 * MOSI   11/51
 * NSS     5/5
 * RST     6/6
 * BUSY    7/7
 */

SX126x  lora(10,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7                //Port-Pin Input:  Busy
             );
#endif // ATmega328/2560

// #if 0
/*
 * for ESP8266
 * VCC    3V3
 * GND    GND
 * SCK    GPIO14
 * MISO   GPIO12
 * MOSI   GPIO13
 * NSS    GPIO2
 * RST    GPIO0
 * BUSY   GPIO16
 */
 
//SX126x  lora(10,                 //Port-Pin Output: SPI select
 //            6,                 //Port-Pin Output: Reset 
 //            7                 //Port-Pin Input:  Busy
 //            );
//#endif // ESP8266

void setup() 
{
  delay(1000);
  Serial.begin(115200);

  lora.DebugPrint(true);

  /*
  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER);          //tx power in dBm
*/

  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER,           //tx power in dBm
                           3.3,                       //use TCXO
                           true);                     //use TCXO

                           
  if (ret != ERR_NONE) while(1) {delay(1);}

  lora.LoRaConfig(LORA_SPREADING_FACTOR, 
                  LORA_BANDWIDTH, 
                  LORA_CODINGRATE, 
                  LORA_PREAMBLE_LENGTH, 
                  LORA_PAYLOADLENGTH, 
                  true,               //crcOn  
                  false);             //invertIrq

}

void loop() 
{
  uint8_t txData[255];
  sprintf((char *)txData, "Hello World %lu", millis());
  uint8_t len = strlen((char *)txData);

  // Wait for transmission to complete
  if (lora.Send(txData, len, SX126x_TXMODE_SYNC)) {
    //Serial.println("Send success");
  } else {
    Serial.println("Send fail");
  }

  // Do not wait for the transmission to be completed
  //lora.Send(txData, len, SX126x_TXMODE_ASYNC );

  delay(1000);
}

Serial Monitor Data:

I uncommented the lora.Debut.Print(true); line. Got Serial Monitor Result:

17:34:18.828 -> begin
17:34:18.828 -> debugPrint=1
17:34:18.828 -> SX126x_SPI_SELECT=10
17:34:18.828 -> SX126x_RESET=6
17:34:18.828 -> SX126x_BUSY=7
17:34:18.828 -> SX126x_TXEN=-1
17:34:18.828 -> SX126x_RXEN=-1
17:34:18.874 -> Reset
17:34:18.874 -> ReadRegister:  REG=0x740  DataIn: 14 24 
17:34:18.874 -> syncWord=0x1424
17:34:18.874 -> SX126x installed
17:34:18.874 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
17:34:18.874 -> WriteCommand:  CMD=0x9D  DataOut: 1-->A2 
17:34:18.874 -> tcxoVoltage=3.30
17:34:18.874 -> WriteCommand:  CMD=0x97  DataOut: 7-->A2 0-->A2 1-->A2 40-->A2 
17:34:18.874 -> WriteCommand:  CMD=0x89  DataOut: 7F-->A2 
17:34:18.874 -> useRegulatorLDO=1
17:34:18.874 -> WriteCommand:  CMD=0x96  DataOut: 0-->AA 
17:34:18.874 -> SPI Transaction error:10
17:34:18.874 -> WriteCommand:  CMD=0x96  DataOut: 0-->A2 
17:34:18.874 -> WriteCommand:  CMD=0x8F  DataOut: 0-->A2 0-->A2 
17:34:18.921 -> WriteCommand:  CMD=0x95  DataOut: 4-->A2 7-->A2 0-->A2 1-->A2 
17:34:18.921 -> WriteRegister: REG=0x8E7  DataOut: 18 
17:34:18.921 -> WriteCommand:  CMD=0x8E  DataOut: 16-->A2 4-->A2 
17:34:18.921 -> WriteCommand:  CMD=0x98  DataOut: 6B-->A2 6F-->A2 
17:34:18.921 -> WriteCommand:  CMD=0x86  DataOut: 1B-->AA 
17:34:18.921 -> SPI Transaction error:10
17:34:18.921 -> WriteCommand:  CMD=0x86  DataOut: 1B-->A2 10-->A2 0-->A2 0-->A2 
17:34:18.921 -> WriteCommand:  CMD=0x9F  DataOut: 0-->A2 
17:34:18.921 -> WriteCommand:  CMD=0xA0  DataOut: 0-->A2 
17:34:18.921 -> WriteCommand:  CMD=0x8A  DataOut: 1-->A2 
17:34:18.921 -> WriteCommand:  CMD=0x8B  DataOut: 7-->A2 4-->A2 1-->A2 0-->A2 
17:34:18.921 -> ReadRegister:  REG=0x736  DataIn: D 
17:34:18.968 -> WriteRegister: REG=0x736  DataOut: 9 
17:34:18.968 -> WriteCommand:  CMD=0x8C  DataOut: 0-->A2 8-->A2 0-->A2 FF-->A2 1-->A2 0-->A2 
17:34:18.968 -> WriteCommand:  CMD=0x8  DataOut: 3-->A2 FF-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 
17:34:18.968 -> ----- SetRx timeout=16777215
17:34:18.968 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
17:34:18.968 -> SetRxEnable:SX126x_TXEN=-1 SX126x_RXEN=-1
17:34:18.968 -> WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
17:34:18.968 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:18.968 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:18.968 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:18.968 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
17:34:19.016 -> SetRx Illegal Status

Receiver Device Code:

#include <Ra01S.h>

#define RF_FREQUENCY                                433000000 // Hz  center frequency
//#define RF_FREQUENCY                                866000000 // Hz  center frequency
//#define RF_FREQUENCY                                915000000 // Hz  center frequency
#define TX_OUTPUT_POWER                             22        // dBm tx output power
#define LORA_BANDWIDTH                              4         // bandwidth
                                                              // 2: 31.25Khz
                                                              // 3: 62.5Khz
                                                              // 4: 125Khz
                                                              // 5: 250KHZ
                                                              // 6: 500Khz 
#define LORA_SPREADING_FACTOR                       7         // spreading factor [SF5..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]

#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_PAYLOADLENGTH                          0         // 0: Variable length packet (explicit header)
                                                              // 1..255  Fixed length packet (implicit header)


                                                             
#if 1
/*
 * for ATmega328/2560
 * VCC    3V3
 * GND    GND
 * SCK    13
 * MISO   12
 * MOSI   11
 * NSS    5
 * RST    6
 * BUSY   7
 */

SX126x  lora(10,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7                //Port-Pin Input:  Busy
             );
#endif // ATmega328/2560

//#if 0
/*
 * for ESP8266
 * VCC    3V3
 * GND    GND
 * SCK    GPIO14
 * MISO   GPIO12
 * MOSI   GPIO13
 * NSS    GPIO2
 * RST    GPIO0
 * BUSY   GPIO16
 */
 
//SX126x  lora(2,                 //Port-Pin Output: SPI select
 //            0,                 //Port-Pin Output: Reset 
 //            16                 //Port-Pin Input:  Busy
 //            );
// #endif // ESP8266

void setup() 
{
  delay(1000);
  Serial.begin(115200);

  lora.DebugPrint(true);

  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER);          //tx power in dBm
  if (ret != ERR_NONE) while(1) {delay(1);}

  lora.LoRaConfig(LORA_SPREADING_FACTOR, 
                  LORA_BANDWIDTH, 
                  LORA_CODINGRATE, 
                  LORA_PREAMBLE_LENGTH, 
                  LORA_PAYLOADLENGTH, 
                  true,               //crcOn  
                  false);             //invertIrq

}

void loop() 
{
  uint8_t rxData[255];
  uint8_t rxLen = lora.Receive(rxData, 255);
  if ( rxLen > 0 )
  { 
    Serial.print("Receive rxLen:");
    Serial.println(rxLen);
    for(int i=0;i< rxLen;i++) {
      Serial.print(rxData[i], HEX);
      Serial.print(" ");
    }
    Serial.println();
    for(int i=0;i< rxLen;i++) {
      if (rxData[i] > 0x19 && rxData[i] < 0x7F) {
        char myChar = rxData[i];
        Serial.print(myChar);
      } else {
        Serial.print("?");
      }
    }
    Serial.println();

    int8_t rssi, snr;
    lora.GetPacketStatus(&rssi, &snr);
    Serial.print("rssi: ");
    Serial.print(rssi, DEC);
    Serial.println(" dBm");
    Serial.print("snr: ");
    Serial.print(snr, DEC);
    Serial.println(" dB");
  }
  delay(1);
}

Serial Monitor of Receiver Device:

17:37:15.392 -> begin
17:37:15.392 -> debugPrint=1
17:37:15.392 -> SX126x_SPI_SELECT=10
17:37:15.392 -> SX126x_RESET=6
17:37:15.392 -> SX126x_BUSY=7
17:37:15.392 -> SX126x_TXEN=-1
17:37:15.392 -> SX126x_RXEN=-1
17:37:15.438 -> Reset
17:37:15.438 -> ReadRegister:  REG=0x740  DataIn: 14 24 
17:37:15.438 -> syncWord=0x1424
17:37:15.438 -> SX126x installed
17:37:15.438 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
17:37:15.438 -> WriteCommand:  CMD=0x9D  DataOut: 1-->A2 
17:37:15.438 -> tcxoVoltage=0.00
17:37:15.438 -> WriteCommand:  CMD=0x89  DataOut: 7F-->A2 
17:37:15.485 -> useRegulatorLDO=0
17:37:15.485 -> WriteCommand:  CMD=0x96  DataOut: 1-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x8F  DataOut: 0-->A2 0-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x95  DataOut: 4-->A2 7-->A2 0-->A2 1-->A2 
17:37:15.485 -> WriteRegister: REG=0x8E7  DataOut: 18 
17:37:15.485 -> WriteCommand:  CMD=0x8E  DataOut: 16-->A2 4-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x98  DataOut: 6B-->A2 6F-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x86  DataOut: 1B-->A2 10-->A2 0-->A2 0-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x9F  DataOut: 0-->A2 
17:37:15.485 -> WriteCommand:  CMD=0xA0  DataOut: 0-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x8A  DataOut: 1-->A2 
17:37:15.485 -> WriteCommand:  CMD=0x8B  DataOut: 7-->A2 4-->A2 1-->A2 0-->A2 
17:37:15.532 -> ReadRegister:  REG=0x736  DataIn: D 
17:37:15.532 -> WriteRegister: REG=0x736  DataOut: 9 
17:37:15.532 -> WriteCommand:  CMD=0x8C  DataOut: 0-->A2 8-->A2 0-->A2 FF-->A2 1-->A2 0-->A2 
17:37:15.532 -> WriteCommand:  CMD=0x8  DataOut: 3-->A2 FF-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 
17:37:15.532 -> ----- SetRx timeout=16777215
17:37:15.532 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
17:37:15.532 -> SetRxEnable:SX126x_TXEN=-1 SX126x_RXEN=-1
17:37:15.532 -> WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
17:37:15.532 -> ReadCommand:   CMD=0xC0  DataIn: 52 
17:37:15.532 -> ReadCommand:   CMD=0xC0  DataIn: 52 
17:37:15.532 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.579 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 
17:37:15.626 -> ReadCommand:   CMD=0x12  DataIn: D2 0 0 

Note: Last Line is repeating continue........

@nopnop2002
Copy link
Owner

nopnop2002 commented Feb 12, 2024

Thank you for the report.

There were missing changes when using the EBYTE module.

If you use the EBYTE module, the following changes are required.

I've updated the sample sketch.

/*
SX126x  lora(5,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7                //Port-Pin Input:  Busy
             );

int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                         TX_OUTPUT_POWER);          //tx power in dBm
*/

SX126x  lora(5,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7                //Port-Pin Input:  Busy
             8                //Port-Pin Output: TXEN
             9                //Port-Pin Output: RXEN
             );

int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                         TX_OUTPUT_POWER,           //tx power in dBm
                         3.3,                       //use TCXO
                         true);                     //use TCXO

Two additional wires are required.

EBYTE UNO MEGA ESP8266
TXEN -- 8(*3) 8(*3) D4
RXEN -- 9(*3) 9(*3) D5

(*3)
SX126x is not 5V tolerant.
You need level shift from 5V to 3.3V.

@krishank652
Copy link
Author

Thanks for the update....

I have again taken trial but still unable to work. Can You please see the again. this help will make me happy😄

I updated following things:

  1. Circuit Updated.
  2. Library Updated.
  3. Used New Tx and Rx Code.

New Circuit
Schematic_New-Project_2024-02-24 (1)

Transmitter Code:

#include <Ra01S.h>

#define RF_FREQUENCY                                433000000 // Hz  center frequency
//#define RF_FREQUENCY                                866000000 // Hz  center frequency
//#define RF_FREQUENCY                                915000000 // Hz  center frequency
#define TX_OUTPUT_POWER                             22        // dBm tx output power
#define LORA_BANDWIDTH                              4         // bandwidth
                                                              // 2: 31.25Khz
                                                              // 3: 62.5Khz
                                                              // 4: 125Khz
                                                              // 5: 250KHZ
                                                              // 6: 500Khz                                                               
#define LORA_SPREADING_FACTOR                       7         // spreading factor [SF5..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]

#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_PAYLOADLENGTH                          0         // 0: Variable length packet (explicit header)
                                                              // 1..255  Fixed length packet (implicit header)

#define USE_EBYTE

#if 1
/*
 * for ATmega328/2560
 * VCC    3V3/3V3
 * GND    GND/GND
 * SCK    13/52
 * MISO   12/50
 * MOSI   11/51
 * NSS     5/5
 * RST     6/6
 * BUSY    7/7
 * TXEN    8/8 for EBYTE
 * RXEN    9/9 for EBYTE
 */

#ifdef USE_EBYTE
SX126x  lora(10,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7,               //Port-Pin Input:  Busy
             2,               //Port-Pin Output: TXEN
             3                //Port-Pin Output: RXEN
             );

#else
SX126x  lora(5,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7                //Port-Pin Input:  Busy
             );
#endif // USE_EBYTE

#endif // ATmega328/2560

#if 0
/*
 * for ESP8266
 * VCC    3V3
 * GND    GND
 * SCK    GPIO14
 * MISO   GPIO12
 * MOSI   GPIO13
 * NSS    GPIO2
 * RST    GPIO0
 * BUSY   GPIO16
 * TXEN   GPIO4 for EBYTE
 * RXEN   GPIO5 for EBYTE
 */

#ifdef USE_EBYTE
SX126x  lora(10,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7,               //Port-Pin Input:  Busy
             2,               //Port-Pin Output: TXEN
             3                //Port-Pin Output: RXEN
             );
#else
SX126x  lora(2,               //Port-Pin Output: SPI select
             0,               //Port-Pin Output: Reset 
             16               //Port-Pin Input:  Busy
             );
#endif // USE_EBYTE

#endif // ESP8266

void setup() 
{
  delay(1000);
  Serial.begin(115200);

  lora.DebugPrint(true);

#ifdef USE_EBYTE
  Serial.println("Enable TCXO");
  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER,           //tx power in dBm
                           3.3,                       //use TCXO
                           true);                     //use TCXO
  if (ret != ERR_NONE) while(1) {delay(1);}
#else
  Serial.println("Disable TCXO");
  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER);          //tx power in dBm
  if (ret != ERR_NONE) while(1) {delay(1);}
#endif // USE_EBYTE

  lora.LoRaConfig(LORA_SPREADING_FACTOR, 
                  LORA_BANDWIDTH, 
                  LORA_CODINGRATE, 
                  LORA_PREAMBLE_LENGTH, 
                  LORA_PAYLOADLENGTH, 
                  true,               //crcOn  
                  false);             //invertIrq

}

void loop() 
{
  uint8_t txData[255];
  sprintf((char *)txData, "Hello World %lu", millis());
  uint8_t len = strlen((char *)txData);

  // Wait for transmission to complete
  if (lora.Send(txData, len, SX126x_TXMODE_SYNC)) {
    Serial.println("Send success");
  } else {
    Serial.println("Send fail");
  }

  // Do not wait for the transmission to be completed
  //lora.Send(txData, len, SX126x_TXMODE_ASYNC );

  delay(1000);
}

Serial Monitor Result

21:40:23.825 -> Enable TCXO
21:40:23.825 -> begin
21:40:23.825 -> debugPrint=1
21:40:23.825 -> SX126x_SPI_SELECT=10
21:40:23.825 -> SX126x_RESET=6
21:40:23.825 -> SX126x_BUSY=7
21:40:23.825 -> SX126x_TXEN=2
21:40:23.825 -> SX126x_RXEN=3
21:40:23.872 -> Reset
21:40:23.872 -> ReadRegister:  REG=0x740  DataIn: 14 24 
21:40:23.872 -> syncWord=0x1424
21:40:23.872 -> SX126x installed
21:40:23.872 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
21:40:23.872 -> WriteCommand:  CMD=0x9D  DataOut: 1-->A2 
21:40:23.872 -> tcxoVoltage=3.30
21:40:23.872 -> WriteCommand:  CMD=0x97  DataOut: 7-->A2 0-->A2 1-->A2 40-->A2 
21:40:23.872 -> WriteCommand:  CMD=0x89  DataOut: 7F-->A2 
21:40:23.919 -> useRegulatorLDO=1
21:40:23.919 -> WriteCommand:  CMD=0x96  DataOut: 0-->AA 
21:40:23.919 -> SPI Transaction error:10
21:40:23.919 -> WriteCommand:  CMD=0x96  DataOut: 0-->A2 
21:40:23.919 -> WriteCommand:  CMD=0x8F  DataOut: 0-->A2 0-->A2 
21:40:23.919 -> WriteCommand:  CMD=0x95  DataOut: 4-->A2 7-->A2 0-->A2 1-->A2 
21:40:23.919 -> WriteRegister: REG=0x8E7  DataOut: 18 
21:40:23.919 -> WriteCommand:  CMD=0x8E  DataOut: 16-->A2 4-->A2 
21:40:23.919 -> WriteCommand:  CMD=0x98  DataOut: 6B-->A2 6F-->A2 
21:40:23.919 -> WriteCommand:  CMD=0x86  DataOut: 1B-->AA 
21:40:23.919 -> SPI Transaction error:10
21:40:23.919 -> WriteCommand:  CMD=0x86  DataOut: 1B-->A2 10-->A2 0-->A2 0-->A2 
21:40:23.919 -> WriteCommand:  CMD=0x9F  DataOut: 0-->A2 
21:40:23.965 -> WriteCommand:  CMD=0xA0  DataOut: 0-->A2 
21:40:23.965 -> WriteCommand:  CMD=0x8A  DataOut: 1-->A2 
21:40:23.965 -> WriteCommand:  CMD=0x8B  DataOut: 7-->A2 4-->A2 1-->A2 0-->A2 
21:40:23.965 -> ReadRegister:  REG=0x736  DataIn: D 
21:40:23.965 -> WriteRegister: REG=0x736  DataOut: 9 
21:40:23.965 -> WriteCommand:  CMD=0x8C  DataOut: 0-->A2 8-->A2 0-->A2 FF-->A2 1-->A2 0-->A2 
21:40:23.965 -> WriteCommand:  CMD=0x8  DataOut: 3-->A2 FF-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 
21:40:23.965 -> ----- SetRx timeout=16777215
21:40:23.965 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
21:40:23.965 -> SetRxEnable:SX126x_TXEN=2 SX126x_RXEN=3
21:40:23.965 -> WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:40:24.013 -> SetRx Illegal Status

Receiver Code:

#include <Ra01S.h>

#define RF_FREQUENCY                                433000000 // Hz  center frequency
//#define RF_FREQUENCY                                866000000 // Hz  center frequency
//#define RF_FREQUENCY                                915000000 // Hz  center frequency
#define TX_OUTPUT_POWER                             22        // dBm tx output power
#define LORA_BANDWIDTH                              4         // bandwidth
                                                              // 2: 31.25Khz
                                                              // 3: 62.5Khz
                                                              // 4: 125Khz
                                                              // 5: 250KHZ
                                                              // 6: 500Khz 
#define LORA_SPREADING_FACTOR                       7         // spreading factor [SF5..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]

#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_PAYLOADLENGTH                          0         // 0: Variable length packet (explicit header)
                                                              // 1..255  Fixed length packet (implicit header)

#define USE_EBYTE
                                                             
#if 1
/*
 * for ATmega328/2560
 * VCC    3V3/3V3
 * GND    GND/GND
 * SCK    13/52
 * MISO   12/50
 * MOSI   11/51
 * NSS     5/5
 * RST     6/6
 * BUSY    7/7
 * TXEN    8/8 for EBYTE
 * RXEN    9/9 for EBYTE
 */

#ifdef USE_EBYTE
SX126x  lora(10,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7,               //Port-Pin Input:  Busy
             2,               //Port-Pin Output: TXEN
             3                //Port-Pin Output: RXEN
             );

#else
SX126x  lora(5,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7                //Port-Pin Input:  Busy
             );
#endif // USE_EBYTE

#endif // ATmega328/2560

#if 0
/*
 * for ESP8266
 * VCC    3V3
 * GND    GND
 * SCK    GPIO14
 * MISO   GPIO12
 * MOSI   GPIO13
 * NSS    GPIO2
 * RST    GPIO0
 * BUSY   GPIO16
 * TXEN   GPIO4 for EBYTE
 * RXEN   GPIO5 for EBYTE
 */
 
#ifdef USE_EBYTE
SX126x  lora(10,               //Port-Pin Output: SPI select
             6,               //Port-Pin Output: Reset 
             7,               //Port-Pin Input:  Busy
             2,               //Port-Pin Output: TXEN
             3                //Port-Pin Output: RXEN
             );
#else
SX126x  lora(2,               //Port-Pin Output: SPI select
             0,               //Port-Pin Output: Reset 
             16               //Port-Pin Input:  Busy
             );
#endif // USE_EBYTE

#endif // ESP8266

void setup() 
{
  delay(1000);
  Serial.begin(115200);

  lora.DebugPrint(true);

#ifdef USE_EBYTE
  Serial.println("Enable TCXO");
  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER,           //tx power in dBm
                           3.3,                       //use TCXO
                           true);                     //use TCXO
  if (ret != ERR_NONE) while(1) {delay(1);}
#else
  Serial.println("Disable TCXO");
  int16_t ret = lora.begin(RF_FREQUENCY,              //frequency in Hz
                           TX_OUTPUT_POWER);          //tx power in dBm
  if (ret != ERR_NONE) while(1) {delay(1);}
#endif // USE_EBYTE

  lora.LoRaConfig(LORA_SPREADING_FACTOR, 
                  LORA_BANDWIDTH, 
                  LORA_CODINGRATE, 
                  LORA_PREAMBLE_LENGTH, 
                  LORA_PAYLOADLENGTH, 
                  true,               //crcOn  
                  false);             //invertIrq

}

void loop() 
{
  uint8_t rxData[255];
  uint8_t rxLen = lora.Receive(rxData, 255);
  if ( rxLen > 0 )
  { 
    Serial.print("Receive rxLen:");
    Serial.println(rxLen);
    for(int i=0;i< rxLen;i++) {
      Serial.print(rxData[i], HEX);
      Serial.print(" ");
    }
    Serial.println();
    for(int i=0;i< rxLen;i++) {
      if (rxData[i] > 0x19 && rxData[i] < 0x7F) {
        char myChar = rxData[i];
        Serial.print(myChar);
      } else {
        Serial.print("?");
      }
    }
    Serial.println();

    int8_t rssi, snr;
    lora.GetPacketStatus(&rssi, &snr);
    Serial.print("rssi: ");
    Serial.print(rssi, DEC);
    Serial.println(" dBm");
    Serial.print("snr: ");
    Serial.print(snr, DEC);
    Serial.println(" dB");
  }
  delay(1);
}

Serial Montor Result:

21:44:29.804 -> Enable TCXO
21:44:29.804 -> begin
21:44:29.804 -> debugPrint=1
21:44:29.804 -> SX126x_SPI_SELECT=10
21:44:29.804 -> SX126x_RESET=6
21:44:29.804 -> SX126x_BUSY=7
21:44:29.804 -> SX126x_TXEN=2
21:44:29.804 -> SX126x_RXEN=3
21:44:29.850 -> Reset
21:44:29.850 -> ReadRegister:  REG=0x740  DataIn: 14 24 
21:44:29.850 -> syncWord=0x1424
21:44:29.850 -> SX126x installed
21:44:29.850 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
21:44:29.850 -> WriteCommand:  CMD=0x9D  DataOut: 1-->A2 
21:44:29.850 -> tcxoVoltage=3.30
21:44:29.850 -> WriteCommand:  CMD=0x97  DataOut: 7-->A2 0-->A2 1-->A2 40-->A2 
21:44:29.850 -> WriteCommand:  CMD=0x89  DataOut: 7F-->A2 
21:44:29.897 -> useRegulatorLDO=1
21:44:29.897 -> WriteCommand:  CMD=0x96  DataOut: 0-->AA 
21:44:29.897 -> SPI Transaction error:10
21:44:29.897 -> WriteCommand:  CMD=0x96  DataOut: 0-->A2 
21:44:29.897 -> WriteCommand:  CMD=0x8F  DataOut: 0-->A2 0-->A2 
21:44:29.897 -> WriteCommand:  CMD=0x95  DataOut: 4-->A2 7-->A2 0-->A2 1-->A2 
21:44:29.897 -> WriteRegister: REG=0x8E7  DataOut: 18 
21:44:29.897 -> WriteCommand:  CMD=0x8E  DataOut: 16-->A2 4-->A2 
21:44:29.897 -> WriteCommand:  CMD=0x98  DataOut: 6B-->A2 6F-->A2 
21:44:29.897 -> WriteCommand:  CMD=0x86  DataOut: 1B-->AA 
21:44:29.897 -> SPI Transaction error:10
21:44:29.897 -> WriteCommand:  CMD=0x86  DataOut: 1B-->A2 10-->A2 0-->A2 0-->A2 
21:44:29.944 -> WriteCommand:  CMD=0x9F  DataOut: 0-->A2 
21:44:29.944 -> WriteCommand:  CMD=0xA0  DataOut: 0-->A2 
21:44:29.944 -> WriteCommand:  CMD=0x8A  DataOut: 1-->A2 
21:44:29.944 -> WriteCommand:  CMD=0x8B  DataOut: 7-->A2 4-->A2 1-->A2 0-->A2 
21:44:29.944 -> ReadRegister:  REG=0x736  DataIn: D 
21:44:29.944 -> WriteRegister: REG=0x736  DataOut: 9 
21:44:29.944 -> WriteCommand:  CMD=0x8C  DataOut: 0-->A2 8-->A2 0-->A2 FF-->A2 1-->A2 0-->A2 
21:44:29.944 -> WriteCommand:  CMD=0x8  DataOut: 3-->A2 FF-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 0-->A2 
21:44:29.944 -> ----- SetRx timeout=16777215
21:44:29.944 -> WriteCommand:  CMD=0x80  DataOut: 0-->A2 
21:44:29.944 -> SetRxEnable:SX126x_TXEN=2 SX126x_RXEN=3
21:44:29.991 -> WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> ReadCommand:   CMD=0xC0  DataIn: 2A 
21:44:29.991 -> SetRx Illegal Status

Please see again and please help me to build my device. thanks.

One thing is that: I see this line: SX126x installed it means my LoRa device is working?

Please help me.

@nopnop2002
Copy link
Owner

nopnop2002 commented Feb 24, 2024

I see this line: SX126x installed it means my LoRa device is working?

Yes.
This indicates that you are successfully communicating with your device.

I had the same error on E220-900M22S(LLCC68)
I do not know the cause

SetRxEnable:SX126x_TXEN=8 SX126x_RXEN=9
WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
ReadCommand:   CMD=0xC0  DataIn: 2A 
SetRx Illegal Status

This is E22-900M22S(SX1262) logging.
As far as I know, SX1262 and LLCC68 are compatible.

SetRxEnable:SX126x_TXEN=8 SX126x_RXEN=9
WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
ReadCommand:   CMD=0xC0  DataIn: 52 
ReadCommand:   CMD=0xC0  DataIn: 52 
Send rv=1
Send success

This is E22-400M22S(SX1268) logging.

SetRxEnable:SX126x_TXEN=8 SX126x_RXEN=9
WriteCommand:  CMD=0x82  DataOut: FF-->A2 FF-->A2 FF-->A2 
ReadCommand:   CMD=0xC0  DataIn: 52 
ReadCommand:   CMD=0xC0  DataIn: 52 

@krishank652
Copy link
Author

Dear,
Can you please solve the problem. I have E220-400M22S module. Can you please solve the error with the library.
Thanks

@nopnop2002
Copy link
Owner

I also have an E220-400M22S, but I don't know the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants