Renzo Mischianti
Published © CC BY-NC-ND

LoRa E32 Device Arduino Shield (8Km Support)

E32 LoRa (long range) device very cheap and very long range (from 3Km to 8Km), here an Arduino shield for my library.

IntermediateFull instructions provided2 hours4,862
LoRa E32 Device Arduino Shield (8Km Support)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
E32-TTL-100 3Km LoRa
×1
E32-TTL-1W 8Km LoRa
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Web Editor
Arduino Web Editor

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Code snippet #2

Plain text
    // Allow wake up pin to trigger interrupt on low.
    attachInterrupt(0, AUX_PIN, LOW);

    // Enter power down state with ADC and BOD module disabled.
    // Wake up when wake up pin is low.
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

    // Disable external pin interrupt on wake up pin.
    detachInterrupt(0);

Code snippet #3

Plain text
/*
* LoRa E32-TTL-100
* Receive fixed transmission message on channel.
* https://www.mischianti.org
*
* 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)
* RX         ----- PIN 2 (PullUP & Voltage divider)
* TX         ----- PIN 3 (PullUP)
* AUX        ----- Not connected (5 if you connect)
* VCC        ----- 3.3v/5v
* GND        ----- GND
*
*/
#include "Arduino.h"
#include "LowPower.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); // RX, TX
//LoRa_E32 e32ttl(&amp;mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(4, 5, 3, 7, 6);
LoRa_E32 e32ttl(4, 5, 3); // Config without connect M0 M1
// Use pin 2 as wake up pin
const int wakeUpPin = 3;
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // RX, TX
//LoRa_E32 e32ttl(&amp;mySerial, 3, 7, 6);
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
void wakeUp()
{
Serial.println("WAKE!");
}
//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 = 3;
//	configuration.ADDH = 0;
//	configuration.CHAN = 0x04;
//	configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
//	configuration.OPTION.wirelessWakeupTime = WAKE_UP_250;
//
//    configuration.OPTION.fec = FEC_1_ON;
//    configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
//    configuration.OPTION.transmissionPower = POWER_20;
//
//    configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
//    configuration.SPED.uartBaudRate = UART_BPS_9600;
//    configuration.SPED.uartParity = MODE_00_8N1;
//
//	e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
//	printParameters(configuration);
// ---------------------------
Serial.println();
Serial.println("Start listening!");
e32ttl.setMode(MODE_2_POWER_SAVING);
// Allow wake up pin to trigger interrupt on low.
attachInterrupt(0, wakeUp, LOW);
// Enter power down state with ADC and BOD module disabled.
// Wake up when wake up pin is low.
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
// Disable external pin interrupt on wake up pin.
detachInterrupt(0);
Serial.println("OK listening!");
}
// The loop function is called in an endless loop
void loop()
{
if (e32ttl.available()  > 1){
ResponseContainer rs = e32ttl.receiveMessage();
// First of all get the data
String message = rs.data;
Serial.print("Received --> ");
Serial.print(rs.status.getResponseDescription());
Serial.print(" - ");
Serial.println(message);
}
delay(125);
}
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("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("----------------------------------------");
}

Code snippet #4

Plain text
/*
* LoRa E32-TTL-100
* Send fixed broadcast transmission message to a specified channel.
* https://www.mischianti.org
*
* 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)
* RX         ----- PIN 2 (PullUP &amp; Voltage divider)
* TX         ----- PIN 3 (PullUP)
* 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); //, D5); //, D7, D6); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // RX, TX
//LoRa_E32 e32ttl(&amp;mySerial, D5, D7, D6);
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // RX, TX
//LoRa_E32 e32ttl(&amp;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); // RX, TX
//LoRa_E32 e32ttl(&amp;mySerial, 5, 7, 6);
// -------------------------------------
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);
while (!e32ttl.begin()) {
delay(2000); // wait for serial port to connect. Needed for native USB
}
e32ttl.setMode(MODE_1_WAKE_UP);
//	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;
printParameters(configuration);
//	configuration.SPED.uartBaudRate = UART_BPS_9600;
//	configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.ADDL = 0x01;
configuration.ADDH = 0x00;
configuration.CHAN = 0x04;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
configuration.OPTION.wirelessWakeupTime = WAKE_UP_750;
configuration.OPTION.fec = FEC_1_ON;
configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.transmissionPower = POWER_20;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.uartParity = MODE_00_8N1;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
// ---------------------------
}
int i = 0;
// The loop function is called in an endless loop
void loop()
{
i++;
// ResponseStatus LoRa_E32::sendFixedMessage(byte ADDL, byte ADDH, byte CHAN, const String message)
String mess = "Message to 00 03 04 deviceMessage to  ";
String compMEss = mess+i;
Serial.print(compMEss);
Serial.print(" - ");
ResponseStatus rs = e32ttl.sendFixedMessage(0, 3, 0x04, compMEss);
Serial.println(rs.getResponseDescription());
delay(8000);
}
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("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("----------------------------------------");
}

Credits

Renzo Mischianti

Renzo Mischianti

35 projects • 45 followers
Software developer but I love electronics, wood, nature, and everything else as well. Now blogger? on www.mischianti.org

Comments