Site icon Renzo Mischianti

EByte LoRa Communication encode/decode, crypt/decrypt

I have two LoRa modules, the transmitter is E32-900T20D (with ESP32 DevKitC V4) and the receiver is LoRa32U4II. The problem is that the receiver is not receiving anything from the transmitter. Here is the code of configuration (E32-900T20D) : / * E32 ----- esp32 * M0 ----- 3.3v * M1 ----- 3.3v * RX ----- TX2 (PullUP) * TX ----- RX2 (PullUP) * AUX ----- not connected * VCC ----- 3.3v * GND ----- GND * */ #define FREQUENCY_868 #include "Arduino.h" #include "LoRa_E32.h" LoRa_E32 e32ttl100(&Serial2,UART_BPS_RATE_9600 ); void printParameters(struct Configuration configuration); void printModuleInformation(struct ModuleInformation moduleInformation); void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e32ttl100.begin(); ResponseStructContainer c; c = e32ttl100.getConfiguration(); // It's important get configuration pointer before all other operation Configuration configuration = *(Configuration*) c.data; Serial.println(c.status.getResponseDescription()); Serial.println(c.status.code); printParameters(configuration); configuration.ADDL = 0x0; configuration.ADDH = 0x1; configuration.CHAN = 0x6; configuration.OPTION.fec = FEC_0_OFF; configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS; configuration.OPTION.transmissionPower = POWER_20; configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250; configuration.SPED.airDataRate = AIR_DATA_RATE_000_03; configuration.SPED.uartBaudRate = UART_BPS_9600; configuration.SPED.uartParity = MODE_00_8N1; // Set configuration changed and set to not hold the configuration ResponseStatus rs = e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); Serial.println(rs.getResponseDescription()); Serial.println(rs.code); printParameters(configuration); c.close(); } void loop() { } void printParameters(struct Configuration configuration) { Serial.println("----------------------------------------"); Serial.print(F("HEAD : ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX); Serial.println(F(" ")); Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, BIN); Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, BIN); 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("----------------------------------------"); } ` Here is the code of transmission (E32-900T20D) : / * E32 ----- esp32 * M0 ----- GND * M1 ----- GND * RX ----- TX2 (PullUP) * TX ----- RX2 (PullUP) * AUX ----- not connected * VCC ----- 3.3v * GND ----- GND * */ #include "LoRa_E32.h" LoRa_E32 e32ttl100(&Serial2,UART_BPS_RATE_9600 ); void setup() { Serial.begin(9600); delay(500); // Startup all pins and UART e32ttl100.begin(); Serial.println("Hi, I'm going to send messages every second!"); // Send first message ResponseStatus rs = e32ttl100.sendMessage("Hello, world?"); // Check if message was sent successfully if (rs.code == 1) { Serial.println("Message sent successfully"); } else { Serial.println("Failed to send message"); } } void loop() { delay(1000); // Send message ResponseStatus rs = e32ttl100.sendMessage("Hello, world?"); // Check if message was sent successfully if (rs.code == 1) { Serial.println("Message sent successfully"); } else { Serial.println("Failed to send message"); } } here is the result of the transmitter (E32-900T20D): ` Hi, I'm going to send messages every second! Message sent successfully Message sent successfully Message sent successfully ` here is the code of the receiver (LoRa32U4): #include <LoRa.h> #define ss 8 #define reset 4 #define dio0 7 void setup() { Serial.begin(9600); LoRa.setPins(ss, reset, dio0); if (!LoRa.begin(868E6)) { Serial.println("Starting LoRa failed!"); while (1); } // Set signal bandwidth to 125kHz LoRa.setSignalBandwidth(125E3); // Set TX power to 20dBm LoRa.setTxPower(20); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, HIGH); } void loop() { int packetSize = LoRa.parsePacket(); if (packetSize) { // received a packet Serial.print("Received packet with RSSI "); Serial.print(LoRa.packetRssi()); Serial.print(": "); while (LoRa.available()) { Serial.write(LoRa.read()); } digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); } }
Exit mobile version