Updated to hiabuto.net Faction Timer PCB V1.0
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* LoRa E220
|
||||
* Get configuration.
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or 3.3v) ----- 19 (or 3.3v) ----- 4 (or 3.3v) ----- 2 (or 3.3v) ----- 10 (or 3.3v) ----- PB0 (or 3.3v) ----- 7 Volt div (or 3.3v)
|
||||
* M1 ----- D6 (or 3.3v) ----- 21 (or 3.3v) ----- 6 (or 3.3v) ----- 4 (or 3.3v) ----- 11 (or 3.3v) ----- PB10 (or 3.3v) ----- 6 Volt div (or 3.3v)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void printParameters(struct Configuration configuration);
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while(!Serial){};
|
||||
delay(500);
|
||||
|
||||
Serial.println();
|
||||
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.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);
|
||||
|
||||
ResponseStructContainer cMi;
|
||||
cMi = e220ttl.getModuleInformation();
|
||||
// It's important get information pointer before all other operation
|
||||
ModuleInformation mi = *(ModuleInformation*)cMi.data;
|
||||
|
||||
Serial.println(cMi.status.getResponseDescription());
|
||||
Serial.println(cMi.status.code);
|
||||
|
||||
printModuleInformation(mi);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
void printParameters(struct Configuration configuration) {
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
Serial.print(F("HEAD : ")); Serial.print(configuration.COMMAND, HEX);Serial.print(" ");Serial.print(configuration.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(configuration.LENGHT, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, HEX);
|
||||
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, HEX);
|
||||
Serial.println(F(" "));
|
||||
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.getUARTBaudRateDescription());
|
||||
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRateDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("OptionSubPacketSett: ")); Serial.print(configuration.OPTION.subPacketSetting, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getSubPacketSetting());
|
||||
Serial.print(F("OptionTranPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
|
||||
Serial.print(F("OptionRSSIAmbientNo: ")); Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("TransModeWORPeriod : ")); Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
Serial.print(F("TransModeEnableLBT : ")); Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
Serial.print(F("TransModeEnableRSSI: ")); Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
Serial.print(F("TransModeFixedTrans: ")); Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation) {
|
||||
Serial.println("----------------------------------------");
|
||||
Serial.print(F("HEAD: ")); Serial.print(moduleInformation.COMMAND, HEX);Serial.print(" ");Serial.print(moduleInformation.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(moduleInformation.LENGHT, DEC);
|
||||
|
||||
Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX);
|
||||
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
|
||||
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
||||
|
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* LoRa E220
|
||||
* Set configuration.
|
||||
*
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or 3.3v) ----- 19 (or 3.3v) ----- 4 (or 3.3v) ----- 2 (or 3.3v) ----- 10 (or 3.3v) ----- PB0 (or 3.3v) ----- 7 Volt div (or 3.3v)
|
||||
* M1 ----- D6 (or 3.3v) ----- 21 (or 3.3v) ----- 6 (or 3.3v) ----- 4 (or 3.3v) ----- 11 (or 3.3v) ----- PB10 (or 3.3v) ----- 6 Volt div (or 3.3v)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void printParameters(struct Configuration configuration);
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while(!Serial){};
|
||||
delay(500);
|
||||
|
||||
Serial.println();
|
||||
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.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);
|
||||
|
||||
// ----------------------- DEFAULT TRANSPARENT -----------------------
|
||||
configuration.ADDL = 0x03; // First part of address
|
||||
configuration.ADDH = 0x00; // Second part
|
||||
|
||||
configuration.CHAN = 23; // Communication channel
|
||||
|
||||
configuration.SPED.uartBaudRate = UART_BPS_9600; // Serial baud rate
|
||||
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; // Air baud rate
|
||||
configuration.SPED.uartParity = MODE_00_8N1; // Parity bit
|
||||
|
||||
configuration.OPTION.subPacketSetting = SPS_200_00; // Packet size
|
||||
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED; // Need to send special command
|
||||
configuration.OPTION.transmissionPower = POWER_22; // Device power
|
||||
|
||||
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED; // Enable RSSI info
|
||||
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; // Enable repeater mode
|
||||
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED; // Check interference
|
||||
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; // WOR timing
|
||||
// ----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- FIXED SENDER -----------------------
|
||||
// configuration.ADDL = 0x02;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- FIXED RECEIVER -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- FIXED SENDER RSSI -----------------------
|
||||
// configuration.ADDL = 0x02;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- FIXED RECEIVER RSSI -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- WOR SENDER -----------------------
|
||||
// configuration.ADDL = 0x02;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- WOR RECEIVER -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE 1 -----------------------
|
||||
// configuration.ADDL = 0x04;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE 2 -----------------------
|
||||
// configuration.ADDL = 0x05;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE 3 -----------------------
|
||||
// configuration.ADDL = 0x06;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE RSSI 1 -----------------------
|
||||
// configuration.ADDL = 0x04;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE RSSI 2 -----------------------
|
||||
// configuration.ADDL = 0x05;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE RSSI 3 -----------------------
|
||||
// configuration.ADDL = 0x06;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- MONITORING -----------------------
|
||||
// configuration.ADDL = BROADCAST_ADDRESS;
|
||||
// configuration.ADDH = BROADCAST_ADDRESS;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
|
||||
// Set configuration changed and set to not hold the configuration
|
||||
ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
|
||||
Serial.println(rs.getResponseDescription());
|
||||
Serial.println(rs.code);
|
||||
|
||||
c = e220ttl.getConfiguration();
|
||||
// It's important get configuration pointer before all other operation
|
||||
configuration = *(Configuration*) c.data;
|
||||
Serial.println(c.status.getResponseDescription());
|
||||
Serial.println(c.status.code);
|
||||
|
||||
printParameters(configuration);
|
||||
c.close();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
void printParameters(struct Configuration configuration) {
|
||||
DEBUG_PRINTLN("----------------------------------------");
|
||||
|
||||
DEBUG_PRINT(F("HEAD : ")); DEBUG_PRINT(configuration.COMMAND, HEX);DEBUG_PRINT(" ");DEBUG_PRINT(configuration.STARTING_ADDRESS, HEX);DEBUG_PRINT(" ");DEBUG_PRINTLN(configuration.LENGHT, HEX);
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("AddH : ")); DEBUG_PRINTLN(configuration.ADDH, HEX);
|
||||
DEBUG_PRINT(F("AddL : ")); DEBUG_PRINTLN(configuration.ADDL, HEX);
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("Chan : ")); DEBUG_PRINT(configuration.CHAN, DEC); DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.getChannelDescription());
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("SpeedParityBit : ")); DEBUG_PRINT(configuration.SPED.uartParity, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getUARTParityDescription());
|
||||
DEBUG_PRINT(F("SpeedUARTDatte : ")); DEBUG_PRINT(configuration.SPED.uartBaudRate, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getUARTBaudRateDescription());
|
||||
DEBUG_PRINT(F("SpeedAirDataRate : ")); DEBUG_PRINT(configuration.SPED.airDataRate, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getAirDataRateDescription());
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("OptionSubPacketSett: ")); DEBUG_PRINT(configuration.OPTION.subPacketSetting, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getSubPacketSetting());
|
||||
DEBUG_PRINT(F("OptionTranPower : ")); DEBUG_PRINT(configuration.OPTION.transmissionPower, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getTransmissionPowerDescription());
|
||||
DEBUG_PRINT(F("OptionRSSIAmbientNo: ")); DEBUG_PRINT(configuration.OPTION.RSSIAmbientNoise, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("TransModeWORPeriod : ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.WORPeriod, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
DEBUG_PRINT(F("TransModeEnableLBT : ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableLBT, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
DEBUG_PRINT(F("TransModeEnableRSSI: ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableRSSI, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
DEBUG_PRINT(F("TransModeFixedTrans: ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
|
||||
DEBUG_PRINTLN("----------------------------------------");
|
||||
}
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation) {
|
||||
Serial.println("----------------------------------------");
|
||||
DEBUG_PRINT(F("HEAD: ")); DEBUG_PRINT(moduleInformation.COMMAND, HEX);DEBUG_PRINT(" ");DEBUG_PRINT(moduleInformation.STARTING_ADDRESS, HEX);DEBUG_PRINT(" ");DEBUG_PRINTLN(moduleInformation.LENGHT, DEC);
|
||||
|
||||
Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX);
|
||||
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
|
||||
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* send a transparent message, you must check that the transmitter and receiver have the same
|
||||
* CHANNEL ADDL and ADDH
|
||||
*
|
||||
* Pay attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
// If you have ever change configuration you must restore It
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendMessage("Hello, world?");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
e220ttl.sendMessage(input);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* Send a string message to a fixed point ADDH ADDL CHAN
|
||||
*
|
||||
* You must configure 2 device: one as SENDER (with FIXED SENDER config) and uncomment the relative
|
||||
* define with the correct DESTINATION_ADDL, and one as RECEIVER (with FIXED RECEIVER config)
|
||||
* and uncomment the relative define with the correct DESTINATION_ADDL.
|
||||
*
|
||||
* Write a string on serial monitor or reset to resend default value.
|
||||
*
|
||||
* Pai attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
// #define DESTINATION_ADDL 3
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
#define DESTINATION_ADDL 2
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
//#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
void printParameters(struct Configuration configuration);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.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);
|
||||
c.close();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world?");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printParameters(struct Configuration configuration) {
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
Serial.print(F("HEAD : ")); Serial.print(configuration.COMMAND, HEX);Serial.print(" ");Serial.print(configuration.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(configuration.LENGHT, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, HEX);
|
||||
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, HEX);
|
||||
Serial.println(F(" "));
|
||||
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.getUARTBaudRateDescription());
|
||||
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRateDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("OptionSubPacketSett: ")); Serial.print(configuration.OPTION.subPacketSetting, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getSubPacketSetting());
|
||||
Serial.print(F("OptionTranPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
|
||||
Serial.print(F("OptionRSSIAmbientNo: ")); Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("TransModeWORPeriod : ")); Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
Serial.print(F("TransModeEnableLBT : ")); Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
Serial.print(F("TransModeEnableRSSI: ")); Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
Serial.print(F("TransModeFixedTrans: ")); Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* send a structured message to the device that have ADDH ADDL CHAN -> 0 DESTINATION_ADDL 23
|
||||
*
|
||||
* write the int humidity value on serial (or reset device that send default message)
|
||||
*
|
||||
* You must configure 2 device: one as SENDER (with FIXED SENDER config) and uncomment the relative
|
||||
* define with the correct DESTINATION_ADDL, and one as RECEIVER (with FIXED RECEIVER config)
|
||||
* and uncomment the relative define with the correct DESTINATION_ADDL.
|
||||
*
|
||||
* Write a string on serial monitor or reset to resend default value.
|
||||
*
|
||||
* Pay attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* You must uncommend the correct constructor and set the correct AUX_PIN define.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
#define DESTINATION_ADDL 3
|
||||
#define ROOM "Kitchen"
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
//#define DESTINATION_ADDL 2
|
||||
//#define ROOM "Bath"
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
// #define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
struct Message {
|
||||
char type[5];
|
||||
char message[8];
|
||||
float temperature;
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
struct Message message = {"TEMP", ROOM, 19.2};
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(Message));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessageRSSI(sizeof(Message));
|
||||
#else
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessage(sizeof(Message));
|
||||
#endif
|
||||
|
||||
// Is something goes wrong print error
|
||||
if (rsc.status.code!=1){
|
||||
Serial.println(rsc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rsc.status.getResponseDescription());
|
||||
struct Message message = *(Message*) rsc.data;
|
||||
Serial.println(message.type);
|
||||
Serial.println(message.message);
|
||||
Serial.println(message.temperature);
|
||||
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rsc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
struct Message message = { "TEMP", ROOM, 0 };
|
||||
message.temperature = Serial.parseFloat();
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(Message));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* send a structured message to the device that have ADDH ADDL CHAN -> 0 DESTINATION_ADDL 23
|
||||
*
|
||||
* The receiver read the first part of the packet and undestand the type.
|
||||
* If the type is HUMI read the message and the humidity as int
|
||||
* else read the temperature as float.
|
||||
* I use byte array because some microcontroller can have different size for float
|
||||
*
|
||||
* You must configure 2 device: one as SENDER (with FIXED SENDER config) and uncomment the relative
|
||||
* define with the correct DESTINATION_ADDL, and one as RECEIVER (with FIXED RECEIVER config)
|
||||
* and uncomment the relative define with the correct DESTINATION_ADDL.
|
||||
*
|
||||
* Write a string on serial monitor or reset to resend default value.
|
||||
*
|
||||
* You must uncommend the correct constructor and set the correct AUX_PIN define.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
#define MESSAGE_TYPE "HUMI"
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
//#define DESTINATION_ADDL 3
|
||||
//#define ROOM "Kitchen"
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
#define DESTINATION_ADDL 2
|
||||
#define ROOM "Bathroo"
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
// #define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
struct MessageTemperature {
|
||||
char type[5];
|
||||
char message[8];
|
||||
byte temperature[4];
|
||||
};
|
||||
|
||||
struct MessageHumidity {
|
||||
char type[5];
|
||||
char message[8];
|
||||
byte humidity;
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
struct MessageHumidity message = { "HUMI", ROOM, 80 };
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(MessageHumidity));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
|
||||
struct MessageTemperature messageT = { "TEMP", ROOM, 0 };
|
||||
*(float*)(messageT.temperature) = 19.2;
|
||||
|
||||
// Send message
|
||||
ResponseStatus rsT = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &messageT, sizeof(MessageTemperature));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rsT.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available() > 1) {
|
||||
// read the String message
|
||||
char type[5]; // first part of structure
|
||||
ResponseContainer rs = e220ttl.receiveInitialMessage(sizeof(type));
|
||||
String typeStr = rs.data;
|
||||
|
||||
// Is something goes wrong print error
|
||||
if (rs.status.code != 1) {
|
||||
Serial.println(rs.status.getResponseDescription());
|
||||
} else {
|
||||
Serial.println(typeStr);
|
||||
if (typeStr == "TEMP") {
|
||||
struct MessageTemperaturePartial {
|
||||
char message[8];
|
||||
byte temperature[4];
|
||||
};
|
||||
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessage( sizeof(MessageTemperaturePartial));
|
||||
struct MessageTemperaturePartial message = *(MessageTemperaturePartial*) rsc.data;
|
||||
|
||||
Serial.println(*(float*)(message.temperature));
|
||||
Serial.println(message.message);
|
||||
rsc.close();
|
||||
} else if (typeStr == "HUMI") {
|
||||
struct MessageHumidityPartial {
|
||||
char message[8];
|
||||
byte humidity;
|
||||
};
|
||||
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessage(sizeof(MessageHumidityPartial));
|
||||
struct MessageHumidityPartial message = *(MessageHumidityPartial*) rsc.data;
|
||||
|
||||
Serial.println(message.humidity);
|
||||
Serial.println(message.message);
|
||||
rsc.close();
|
||||
} else {
|
||||
Serial.println("Something goes wrong!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
if (MESSAGE_TYPE == "HUMI") {
|
||||
struct MessageHumidity message = { "HUMI", ROOM, 0 };
|
||||
message.humidity = Serial.parseInt();
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(MessageHumidity));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
} else {
|
||||
struct MessageTemperature message = { "TEMP", ROOM, 0 };
|
||||
*(float*)(message.temperature) = Serial.parseFloat();
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(MessageTemperature));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* Send wake up WOR message to a device in Sleep (WOR transmitter)
|
||||
*
|
||||
* You must configure the address with 0 3 23 (FIXED SENDER configuration)
|
||||
* and pay attention that WOR period must be the same of receiver
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or 3.3v) ----- 19 (or 3.3v) ----- 4 (or 3.3v) ----- 2 (or 3.3v) ----- 10 (or 3.3v) ----- PB0 (or 3.3v) ----- 7 Volt div (or 3.3v)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
#define DESTINATION_ADDL 3
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
|
||||
e220ttl.setMode(MODE_1_WOR_TRANSMITTER);
|
||||
|
||||
Serial.println("Hi, I'm going to send WOR message!");
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world? WOR!");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
|
||||
// e220ttl.setMode(MODE_0_NORMAL);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* Stay in sleep mode and wait a wake up WOR message
|
||||
*
|
||||
* You must configure the address with 0 2 23 (FIXED RECEIVER configuration)
|
||||
* and pay attention that WOR period must be the same of sender
|
||||
*
|
||||
* You must uncommend the correct constructor and set the correct AUX_PIN define.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or 3.3v) ----- 21 (or 3.3v) ----- 6 (or 3.3v) ----- 4 (or 3.3v) ----- PB10 (or 3.3v) ----- 6 Volt div (or 3.3v)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
#define DESTINATION_ADDL 2
|
||||
|
||||
#define AUX_PIN 15
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
bool interruptExecuted = false;
|
||||
#ifdef ESP32
|
||||
void IRAM_ATTR wakeUp() {
|
||||
// Do not use Serial on interrupt callback
|
||||
interruptExecuted = true;
|
||||
detachInterrupt(AUX_PIN);
|
||||
}
|
||||
#elif define(ESP8266)
|
||||
ICACHE_RAM_ATTR void wakeUp() {
|
||||
// Do not use Serial on interrupt callback
|
||||
interruptExecuted = true;
|
||||
detachInterrupt(AUX_PIN);
|
||||
}
|
||||
#else
|
||||
void wakeUp() {
|
||||
// Do not use Serial on interrupt callback
|
||||
interruptExecuted = true;
|
||||
detachInterrupt(AUX_PIN);
|
||||
}
|
||||
#endif
|
||||
|
||||
//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);
|
||||
|
||||
e220ttl.begin();
|
||||
|
||||
e220ttl.setMode(MODE_2_WOR_RECEIVER);
|
||||
|
||||
delay(1000);
|
||||
Serial.println();
|
||||
Serial.println("Start sleep!");
|
||||
delay(100);
|
||||
attachInterrupt(AUX_PIN, wakeUp, FALLING);
|
||||
}
|
||||
|
||||
// The loop function is called in an endless loop
|
||||
void loop() {
|
||||
if (e220ttl.available() > 1) {
|
||||
Serial.println("Message arrived!");
|
||||
ResponseContainer rs = e220ttl.receiveMessage();
|
||||
// First of all get the data
|
||||
String message = rs.data;
|
||||
|
||||
Serial.println(rs.status.getResponseDescription());
|
||||
Serial.println(message);
|
||||
|
||||
// Work only with full connection
|
||||
e220ttl.setMode(MODE_0_NORMAL);
|
||||
|
||||
delay(1000);
|
||||
|
||||
ResponseStatus rsSend = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "We have received the message!");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rsSend.getResponseDescription());
|
||||
}
|
||||
|
||||
if(interruptExecuted) {
|
||||
Serial.println("WakeUp Callback, AUX pin go LOW and start receive message!");
|
||||
Serial.flush();
|
||||
interruptExecuted = false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
*
|
||||
* Receive messages on CHANNEL 23
|
||||
* Uncomment #define ENABLE_RSSI true in this sketch
|
||||
* if the sender send RSSI also
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// If you want use RSSI uncomment
|
||||
//#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Start receiving!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
Serial.println("Message received!");
|
||||
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
*
|
||||
* Send a string message to all devices of the Channel CHAN 23
|
||||
*
|
||||
* Write a string on serial monitor or reset to send the string to all device on channel 23.
|
||||
*
|
||||
* Send a fixed message, you must check that the transmitter and receiver have different
|
||||
* ADDL or ADDH, check the configuration down
|
||||
*
|
||||
* For the test you can use
|
||||
* - BROADCAST MESSAGE 1
|
||||
* - BROADCAST MESSAGE 2
|
||||
* - BROADCAST MESSAGE 3
|
||||
*
|
||||
* Pai attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
//#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendBroadcastFixedMessage(23, "Hello, world?");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
ResponseStatus rs = e220ttl.sendBroadcastFixedMessage(23, input);
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user