-
Notifications
You must be signed in to change notification settings - Fork 11
Description
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 :
- 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
- 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
- Below Line for serial monitor
Serial.begin(9600);
- Uncomment below line for debugging.
lora.DebugPrint(true);
- 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.