Hi, i have two LoRa E32 modules and 2 Arduino Unos.
Transmitter Output:
----------------------------------------
HEAD : 11000000 192 C0
AddH : 10
AddL : 1
Chan : 23 -> 433MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 111 -> 115200bps
SpeedAirDataRate : 11 -> 4.8kbps
OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
OptionWakeup : 100 -> 1250ms
OptionFEC : 0 -> Turn off Forward Error Correction Switch
OptionPower : 1 -> 17dBm
----------------------------------------
Receiver Output:
17:40:12.657 -> ----------------------------------------
17:40:12.690 -> HEAD : 11000000 192 C0
17:40:12.723 ->
17:40:12.723 -> AddH : 0
17:40:12.723 -> AddL : 3
17:40:12.723 -> Chan : 23 -> 433MHz
17:40:12.755 ->
17:40:12.755 -> SpeedParityBit : 0 -> 8N1 (Default)
17:40:12.788 -> SpeedUARTDatte : 111 -> 115200bps
17:40:12.854 -> SpeedAirDataRate : 11 -> 4.8kbps
17:40:12.887 -> OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
17:40:12.985 -> OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
17:40:13.050 -> OptionWakeup : 100 -> 1250ms
17:40:13.083 -> OptionFEC : 0 -> Turn off Forward Error Correction Switch
17:40:13.181 -> OptionPower : 1 -> 17dBm
17:40:13.214 -> ----------------------------------------
17:40:13.247 ->
17:40:13.247 -> Start listening!```
Transmitter Code:
/*
* LoRa E32-TTL-100
* Send fixed transmission structured message to a specified point.
* https://www.mischianti.org/2019/12/03/lora-e32-device-for-arduino-esp32-or-esp8266-power-saving-and-sending-structured-data-part-5/
*
* E32-TTL-100----- Arduino UNO or esp8266
* M0 ----- 3.3v (To config) GND (To send) 7 (To dinamically manage)
* M1 ----- 3.3v (To config) GND (To send) 6 (To dinamically manage)
* TX ----- RX PIN 2 (PullUP)
* RX ----- TX PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected (5 if you connect)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6);
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6); // Config without connect AUX and M0 M1
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
LoRa_E32 e32ttl(6, 7);
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(2, 3, 5, 7, 6);
//LoRa_E32 e32ttl(2, 3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
//LoRa_E32 e32ttl(&mySerial, 5, 7, 6);
// -------------------------------------
// ---------------- STM32 --------------------
// HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
// LoRa_E32 e32ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
// -------------------------------------------------
// ---------- Raspberry PI Pico pins --------------
// LoRa_E32 e32ttl100(&Serial2, 2, 10, 11); // RX AUX M0 M1
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
delay(100);
e32ttl.begin();
// After set configuration comment set M0 and M1 to low
// and reboot if you directly set HIGH M0 and M1 to program
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0x01;
configuration.ADDH = 0x02;
configuration.CHAN = 0x17;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
c.close();
// ---------------------------
}
struct Message {
char type[5];
char message[8];
int temperature;
} message;
int i = 0;
// The loop function is called in an endless loop
void loop()
{
delay(2500);
i++;
struct Message {
char type[5] = "TEMP";
char message[8] = "Kitchen";
byte temperature[4];
} message;
*(float*)(message.temperature) = 19.2;
ResponseStatus rs = e32ttl.sendFixedMessage(0,3,17,&message, sizeof(Message));
Serial.println(rs.getResponseDescription());
}
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("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
Receiver Code:
/*
* LoRa E32-TTL-100
* Receive fixed transmission message on channel.
* https://www.mischianti.org/2019/12/03/lora-e32-device-for-arduino-esp32-or-esp8266-power-saving-and-sending-structured-data-part-5/
*
* E32-TTL-100----- Arduino UNO or esp8266
* M0 ----- 3.3v (To config) GND (To send) 7 (To dinamically manage)
* M1 ----- 3.3v (To config) GND (To send) 6 (To dinamically manage)
* TX ----- RX PIN 2 (PullUP)
* RX ----- TX PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected (5 if you connect)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6);
//LoRa_E32 e32ttl(D2, D3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(2, 3, 5, 7, 6);
SoftwareSerial mySerial(6, 7); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
LoRa_E32 e32ttl(6, 7);
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
//LoRa_E32 e32ttl(&mySerial, 5, 7, 6);
// -------------------------------------
// ---------------- STM32 --------------------
// HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
// LoRa_E32 e32ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
// -------------------------------------------------
// ---------- Raspberry PI Pico pins --------------
// LoRa_E32 e32ttl100(&Serial2, 2, 10, 11); // RX AUX M0 M1
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
delay(100);
e32ttl.begin();
// e32ttl.resetModule();
// After set configuration comment set M0 and M1 to low
// and reboot if you directly set HIGH M0 and M1 to program
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0x03;
configuration.ADDH = 0x00;
configuration.CHAN = 0x17;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
c.close();
// ---------------------------
Serial.println();
Serial.println("Start listening!");
e32ttl.setMode(MODE_0_NORMAL);
}
struct Message {
char type[5];
char message[8];
byte temperature[4];
};
// The loop function is called in an endless loop
void loop()
{
if (e32ttl.available() > 0){
ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Message));
struct Message message = *(Message*) rsc.data;
Serial.println(message.type);
Serial.println(*(float*)(message.temperature));
Serial.println(message.message);
// free(rsc.data);
rsc.close();
}
}
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, DEC);
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, DEC);
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("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
As you can see, receiver can't receive any data. Can anyone help me about it please? Thanks.