xreef / LoRa_E32_Series_Library

Arduino LoRa EBYTE E32 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico (rp2040 boards). sx1278/sx1276
https://www.mischianti.org
Other
357 stars 73 forks source link

I am unable to change device configuration for e34-2G4D20D #56

Closed gbaranedavid closed 11 months ago

gbaranedavid commented 11 months ago

Hello xreef, I trust you are doing well.

First of all, I want to express my appreciation to you for creating such a concise and working library. I took a leap of faith and tried using it for e34-2G4D20D and ESP32, giving no regard to library compatibly and it worked well after a few tweak. so at the moment, I want to reconfigure my e34-2G4D20D and increase the air data rate and UART_BPS_RATE but the message I get on my serial monitor keeps saying "-----:No response from device! (Check wiring)". But I am able to send and receive with both transceivers.

I also observed that the parameters I set to e34-2G4D20D using Configuration object is not applied when I print configuration.

I am using e34-2G4D20D on ESP32

below is my code:

/*
 * EBYTE LoRa E32
 * send a transparent message, you must check that the transmitter and receiver have the same
 * CHANNEL ADDL and ADDH
 *
 *
 * https://mischianti.org
 *
 * E32        ----- esp32
 * M0         ----- 19 (or GND)
 * M1         ----- 21 (or GND)
 * RX         ----- TX2 (PullUP)
 * TX         ----- RX2 (PullUP)
 * AUX        ----- 15  (PullUP)
 * VCC        ----- 3.3v/5v
 * GND        ----- GND
 *
 */

#include "Arduino.h"
#include "LoRa_E32.h"

// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(RX, TX, AUX, M0, M1);  // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E32 e32ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1
//LoRa_E32 e32ttl(D2, D3); // Config without connect AUX and M0 M1

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6); // AUX M0 M1
// -------------------------------------

// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(4, 5, 3, 7, 6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1
//LoRa_E32 e32ttl(4, 5); // Config without connect AUX and M0 M1

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E32 e32ttl(&mySerial, 3, 7, 6); // AUX M0 M1
// -------------------------------------

// ------------- Arduino MKR WiFi 1010 -------------
// LoRa_E32 e220ttl(&Serial1, 1, 2, 3); //  RX AUX M0 M1
// -------------------------------------------------

// ---------- esp32 pins --------------
LoRa_E32 e32ttl100(&Serial2, 15, 21, 19); //  RX AUX M0 M1

//LoRa_E32 e32ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); //  esp32 RX <-- e22 TX, esp32 TX --> e22 RX AUX M0 M1
// -------------------------------------

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

  // Startup all pins and UART
  e32ttl100.begin();
   ResponseStructContainer c2;
    c2 = e32ttl100.getConfiguration();

    printDeviceConfig(e32ttl100.getConfiguration());

    Configuration configuration2 = *(Configuration*) c2.data;
    Serial.print("-----:");
    Serial.println(c2.status.getResponseDescription());
    configuration2.CHAN = 0x17;
    configuration2.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
    configuration2.SPED.airDataRate = AIR_DATA_RATE_000_03;
    configuration2.SPED.uartBaudRate = UART_BPS_115200;
    e32ttl100.setConfiguration(configuration2, WRITE_CFG_PWR_DWN_SAVE);

  Serial.println("Hi, I'm going to send message!");

  // Send message
  ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());

  printDeviceConfig(e32ttl100.getConfiguration());

}
void printDeviceConfig(ResponseStructContainer c){
Serial.println("===============================-----==============================");
   Configuration configuration = *(Configuration*) c.data;

  Serial.print(F("Chan : ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription());
Serial.println(F(" "));
Serial.print(F("SpeedParityBit : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription());
Serial.print(F("SpeedUARTDatte : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRate());
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate());
Serial.print(F("OptionTrans : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription());
Serial.print(F("OptionPullup : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription());
Serial.print(F("OptionWakeup : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription());
Serial.print(F("OptionFEC : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription());
Serial.print(F("OptionPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());

Serial.println("============================-----===================================");
}

As can be be observed in the codes above, I tried to fetch configuration from e34-2G4D20D module after setting it programmatically it returned configuration parameters different from the ones I set. Please see output below:

17:58:48.311 -> SpeedUARTDatte : 100 -> 19200bps
17:58:48.311 -> SpeedAirDataRate : 101 -> 19.2kbps
17:58:48.311 -> OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
17:58:48.311 -> OptionPullup : 0 -> TXD, RXD, AUX are open-collectors
17:58:48.311 -> OptionWakeup : 100 -> 1250ms
17:58:48.311 -> OptionFEC : 1 -> Turn on Forward Error Correction Switch (Default)
17:58:48.344 -> OptionPower : 1 -> 17dBm
17:58:48.344 -> ============================-----===================================
17:58:48.344 -> -----:No response from device! (Check wiring)
17:58:48.608 -> Hi, I'm going to send message!
17:58:48.608 -> Success
17:58:49.874 -> ===============================-----==============================
17:58:49.874 -> Chan : 101 -> 511MHz
17:58:49.874 ->  
17:58:49.874 -> SpeedParityBit : 1 -> 8O1
17:58:49.874 -> SpeedUARTDatte : 110 -> 57600bps
17:58:49.874 -> SpeedAirDataRate : 10 -> 2.4kbps (default)
17:58:49.874 -> OptionTrans : 0 -> Transparent transmission (default)
17:58:49.874 -> OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
17:58:49.874 -> OptionWakeup : 110 -> 1750ms
17:58:49.874 -> OptionFEC : 0 -> Turn off Forward Error Correction Switch
17:58:49.919 -> OptionPower : 11 -> 10dBm
17:58:49.919 -> ============================-----===================================

Please advice on how to resolve this issue.

My goal is to further increase the speed of transmission and size of byte. Thanks

xreef commented 11 months ago

Hi, I check the e34 datasheet and it's different from e32, so I need to implement new library for that. Ask to the EByte to sponsor that library, in other occasion they moved to support and new library (like e220) was born. Bye Renzo