KrisKasprzak / EBYTE

Libraries to program and use UART-based EBYTE wireless data transceivers
239 stars 75 forks source link

Encountring Issue for Configuring LoRa Parameters with Provided Library for Ebyte Module #77

Closed krishank652 closed 5 months ago

krishank652 commented 5 months ago

Dear @KrisKasprzak

I want to express my gratitude for providing the library. Thankyou. Your work is greatly appreciated, and it's been instrumental in getting my Ebyte E220-400T22S module up and running.

However, I'm encountering some difficulties in constructing a proper prototype project. Could you please assist me in resolving these issues?

Below are my inquiries. I would greatly appreciate your expert advice. Thank you.

Question No.1: If I utilize this library, do I still need to configure the LoRa parameters using the software provided by the manufacturer, Ebyte? (Please refer to the screenshot below for the software interface.)

Question No.2:
Through software we can settings for Address, Channel, and Key. Are these settings are same to those in the library, specifically:

   Address: Transceiver.SetAddressH(0),
   Key: Transceiver.SetAddressL(0);
   Channel: Transceiver.SetChannel(Chan);

If not, then how should I go about addressing each device, or what are the limitations regarding addressing? Please advise.

Question No.3: I noticed in the manual that there's a Fixed Transmission Mode that allows communication with predefined receivers, where the transmitter holds the receiver's address. In this mode, even with multiple devices nearby, the modules should not interfere with each other and only contact the predefined transmitters and receivers. How can I configure this using the library? I'm struggling to grasp this concept and would appreciate your guidance. (Please refer to the screenshot below for the Fixed Transmission.)

Question No.4: Is it possible to forego the utilization of the M0 and M1 terminals? I'm considering grounding these terminals with puting resistance 300 ohms in series , as suggested in the manual, if they are unnecessary.

Question No.5: Could you please review the code I've provided below? I've set different parameters for both the transmitter (Tx) device and the receiver (Rx) device. However, they are still communicating, which is perplexing to me. I am confused regarding the addressing aspect. Your assistance in this matter would be greatly appreciated.

Transmitter Code for Send:

#include <SoftwareSerial.h>
#include "EBYTE.h"

#define PIN_M0 2
#define PIN_M1 3
#define PIN_TX 4
#define PIN_RX 5
#define PIN_AX 6

struct DATA {
  unsigned long Count;
  int Bits;
  float Volts;
  float Amps;

};

int Chan;
DATA MyData;

// you will need to define the pins to create the serial port
SoftwareSerial ESerial(PIN_RX, PIN_TX);

// create the transceiver object, passing in the serial and pins
EBYTE Transceiver(&ESerial, PIN_M0, PIN_M1, PIN_AX);

void setup() {

  Serial.begin(9600);
  ESerial.begin(9600);

  Serial.println("Starting Sender");

  Transceiver.init();

   Serial.println(Transceiver.GetAirDataRate());
   Serial.println(Transceiver.GetChannel());

   Transceiver.SetAddressH(100);
   Transceiver.SetAddressL(0);
   Chan = 23;
   Transceiver.SetChannel(Chan);
   Transceiver.SaveParameters(PERMANENT);

  Transceiver.PrintParameters();

}

void loop() {

  // measure some data and save to the structure
  MyData.Count++;
  MyData.Bits = analogRead(A0);
  MyData.Volts = MyData.Bits * ( 5.0 / 1024.0 );

  // i highly suggest you send data using structures and not
  // a parsed data--i've always had a hard time getting reliable data using
  // a parsing method
  Transceiver.SendStruct(&MyData, sizeof(MyData));

  // You only really need this library to program these EBYTE units. 
  // for writing data structures you can call write directly on the EBYTE Serial object
  // ESerial.write((uint8_t*) &Data, PacketSize );

  // let the use know something was sent
  Serial.print("Sending: "); Serial.println(MyData.Count);
  delay(1000);

}

Debug for TX:

16:54:31.914 -> ----------------------------------------
16:54:31.961 -> Model no.: FF
16:54:31.961 -> Version  : FF
16:54:32.008 -> Features : 0
16:54:32.008 ->  
16:54:32.008 -> Mode (HEX/DEC/BIN): 0/0/0
16:54:32.055 -> AddH (HEX/DEC/BIN): 64/100/1100100
16:54:32.055 -> AddL (HEX/DEC/BIN): 0/0/0
16:54:32.101 -> Sped (HEX/DEC/BIN): 0/0/0
16:54:32.148 -> Chan (HEX/DEC/BIN): 17/23/10111
16:54:32.148 -> Optn (HEX/DEC/BIN): 0/0/0
16:54:32.195 -> Addr (HEX/DEC/BIN): 6400/25600/110010000000000
16:54:32.242 ->  
16:54:32.242 -> SpeedParityBit (HEX/DEC/BIN)    : 0/0/0
16:54:32.289 -> SpeedUARTDataRate (HEX/DEC/BIN) : 0/0/0
16:54:32.336 -> SpeedAirDataRate (HEX/DEC/BIN)  : 0/0/0
16:54:32.383 -> OptionTrans (HEX/DEC/BIN)       : 0/0/0
16:54:32.430 -> OptionPullup (HEX/DEC/BIN)      : 0/0/0
16:54:32.476 -> OptionWakeup (HEX/DEC/BIN)      : 0/0/0
16:54:32.524 -> OptionFEC (HEX/DEC/BIN)         : 0/0/0
16:54:32.524 -> OptionPower (HEX/DEC/BIN)       : 0/0/0
16:54:32.570 -> ----------------------------------------
16:54:32.899 -> Sending: 1
16:54:34.235 -> Sending: 2
16:54:35.532 -> Sending: 3
16:54:36.833 -> Sending: 4
16:54:38.141 -> Sending: 5
16:54:39.454 -> Sending: 6
16:54:40.791 -> Sending: 7
16:54:42.104 -> Sending: 8
16:54:43.393 -> Sending: 9
16:54:44.747 -> Sending: 10
16:54:46.027 -> Sending: 11
16:54:47.356 -> Sending: 12
16:54:48.669 -> Sending: 13
16:54:50.012 -> Sending: 14
16:54:51.309 -> Sending: 15
16:54:52.638 -> Sending: 16
16:54:53.920 -> Sending: 17
16:54:55.264 -> Sending: 18
16:54:56.549 -> Sending: 19
16:54:57.893 -> Sending: 20
16:54:59.215 -> Sending: 21

Receiver code for Receive:

#include <SoftwareSerial.h>
#include "EBYTE.h"

#define PIN_M0 2
#define PIN_M1 3
#define PIN_TX 4
#define PIN_RX 5
#define PIN_AX 6

struct DATA {
  unsigned long Count;
  int Bits;
  float Volts;
  float Amps;

};

int Chan;
DATA MyData;
unsigned long Last;

SoftwareSerial ESerial(PIN_RX, PIN_TX);

EBYTE Transceiver(&ESerial, PIN_M0, PIN_M1, PIN_AX);

void setup() {

  Serial.begin(9600);
  ESerial.begin(9600);
  Serial.println("Starting Reader");

  Transceiver.init();

   Serial.println(Transceiver.GetAirDataRate());
   Serial.println(Transceiver.GetChannel());

   Transceiver.SetAddressH(1);
   Transceiver.SetAddressL(0);
   Chan = 5;
   Transceiver.SetChannel(Chan);
   Transceiver.SaveParameters(PERMANENT);

  Transceiver.PrintParameters();

}

void loop() {

  // if the transceiver serial is available, proces incoming data
  // you can also use Transceiver.available()

  if (ESerial.available()) {

    // i highly suggest you send data using structures and not
    // a parsed data--i've always had a hard time getting reliable data using
    // a parsing method

    Transceiver.GetStruct(&MyData, sizeof(MyData));
  // You only really need this library to program these EBYTE units. 
  // For reading data structures, you can call readBytes directly on the EBYTE Serial object
  // ESerial.readBytes((uint8_t*)& MyData, (uint8_t) sizeof(MyData));

    // dump out what was just received
    Serial.print("Count: "); Serial.println(MyData.Count);
    Serial.print("Bits: "); Serial.println(MyData.Bits);
    Serial.print("Volts: "); Serial.println(MyData.Volts);
    // if you got data, update the checker
    Last = millis();

  }
  else {
    // if the time checker is over some prescribed amount
    // let the user know there is no incoming data
    if ((millis() - Last) > 1000) {
      Serial.println("Searching: ");
      Last = millis();
    }

  }
}

Debug for Receiver:

16:54:49.684 -> ----------------------------------------
16:54:49.731 -> Model no.: FF
16:54:49.731 -> Version  : FF
16:54:49.731 -> Features : 0
16:54:49.731 ->  
16:54:49.777 -> Mode (HEX/DEC/BIN): FF/255/11111111
16:54:49.777 -> AddH (HEX/DEC/BIN): 1/1/1
16:54:49.824 -> AddL (HEX/DEC/BIN): 0/0/0
16:54:49.871 -> Sped (HEX/DEC/BIN): 0/0/0
16:54:49.871 -> Chan (HEX/DEC/BIN): 5/5/101
16:54:49.918 -> Optn (HEX/DEC/BIN): 0/0/0
16:54:49.918 -> Addr (HEX/DEC/BIN): 100/256/100000000
16:54:49.965 ->  
16:54:49.965 -> SpeedParityBit (HEX/DEC/BIN)    : 0/0/0
16:54:50.012 -> SpeedUARTDataRate (HEX/DEC/BIN) : 0/0/0
16:54:50.059 -> SpeedAirDataRate (HEX/DEC/BIN)  : 0/0/0
16:54:50.106 -> OptionTrans (HEX/DEC/BIN)       : 0/0/0
16:54:50.152 -> OptionPullup (HEX/DEC/BIN)      : 0/0/0
16:54:50.199 -> OptionWakeup (HEX/DEC/BIN)      : 0/0/0
16:54:50.246 -> OptionFEC (HEX/DEC/BIN)         : 0/0/0
16:54:50.293 -> OptionPower (HEX/DEC/BIN)       : 0/0/0
16:54:50.340 -> ----------------------------------------
16:54:50.387 -> Count: 14
16:54:50.387 -> Bits: 1023
16:54:50.387 -> Volts: 5.00
16:54:51.356 -> Count: 15
16:54:51.356 -> Bits: 1023
16:54:51.404 -> Volts: 5.00
16:54:52.357 -> Searching: 
16:54:52.685 -> Count: 16
16:54:52.685 -> Bits: 1023
16:54:52.685 -> Volts: 5.00
16:54:53.686 -> Searching: 
16:54:54.014 -> Count: 17
16:54:54.014 -> Bits: 1023
16:54:54.014 -> Volts: 5.00
16:54:54.982 -> Searching: 
16:54:55.311 -> Count: 18
16:54:55.311 -> Bits: 1023
16:54:55.358 -> Volts: 5.00
16:54:56.299 -> Searching: 
16:54:56.612 -> Count: 19
16:54:56.658 -> Bits: 1023
16:54:56.658 -> Volts: 5.00
16:54:57.658 -> Searching: 
16:54:57.933 -> Count: 20
16:54:57.981 -> Bits: 1023
16:54:57.981 -> Volts: 5.00
16:54:58.933 -> Searching: 
16:54:59.261 -> Count: 21
16:54:59.261 -> Bits: 1023
16:54:59.309 -> Volts: 5.00

Your assistance in clarifying these points would be immensely helpful. Thank you for your support.

Best regards, Krishan

Software UI Screenshot:

image

Fixed Transmission Screenshot:

image

My Device: Connections Details:

image

image

KrisKasprzak commented 5 months ago

This library will definitely NOT work with these newer E220 series units. This library is for older units (E32, E51, E44). The programming byte definition is slightly different between the E220 and what this library expects

Answer No.1: What are you trying to do 1) change settings once then use or 2) change settings during run time?

Answer No.2: Key is a new concept for encryption found only in these new E220 units.

Answer No.3: I'm not sure what you are trying to do. have one sender many receivers, many senders one receiver, other?

Question No.4: Depends. do you want to change the configuration during run time? If so you will to control these lines otherwise, I think you can just pull them low

Question No.5: This doesn't surprise me. This library is reading and writing bytes per a different format. I'm guessing when you SetChannel, it's not really setting the channel since the lib is sending programming data in a different format. The PrintParameters call will print something, but it surely is not what is on the units SaveParameters saves something but since this lib is sending the programming bytes that is not consistent with the E220, who knows what it's sending

Have a look at the rate parameters for the E220 (which is NOT what this library is written for) UART is 7-6-5 bits image

Look at the E49 (which is what this library is written for)

UART is bits 5-4-3 image