Ebyte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and new WeMos D1 mini shield – Part 7

Spread the love

We have seen how this device (E32 UART LoRa based on popular SX1276/SX1278 Wireless Modules ) manages power saving, but If we use power saving only for the e32 the microcontroller continue to rest active, but we can use AUX pin to resolve this problem.

sx1278 sx1276 wireless lora uart module serial 3000m arduino 433 rf

You can find module here AliExpress (433MHz 5Km) - AliExpress (433MHz 8Km) - AliExpress (433MHz 16Km) - AliExpress (868MHz 915MHz 5.5Km) - AliExpress (868MHz 915MHz 8Km)

If you have trouble like freeze device, you must put a pull-up 4.7k resistor or better connect to the device AUX pin.

Instead the breadboard schema we used since now, but we are going to do some fix, instead of D2 and D3 we are going to use D3 and D4, so SDA and SCL (i2c protocol) remain free.

WeMos D1 mini esp8266 pinout mischianti low resolution
WeMos D1 mini esp8266 pinout mischianti low resolution

So the new connection schema become like so:

LoRa E32-TTL-100 and Wemos D1 mini fully connected
LoRa E32-TTL-100 and Wemos D1 mini fully connected

When you are in Sleep mode the e32 put on the buffer the data recived and go immediately LOW, when data is ready return HIGHT, LOW It’s perfect to wake the microcontroller.

LoRa e32 AUX pin on reception

WeMos D1 mini wake up

As the e32 device, WeMos have some sleep type, but for this test we are going to use Light sleep with GPIO wake up.

Refer to “WeMos D1 mini (esp8266), the three type of sleep mode to manage energy savings – Part 4” for a detailed description on sleep mode.

How to put in sleep WeMos D1 mini

The command to put on power down the microcontroller is this

      wifi_set_opmode(NULL_MODE);
      wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
      wifi_fpm_open();
      wifi_fpm_set_wakeup_cb(callback);
      wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);
      delay(1000);

But we must specify that the device must wake when AUX pin go LOW

    // Allow wake up pin to trigger interrupt on low.
    gpio_pin_wakeup_enable(GPIO_ID_PIN(AUX_PIN), GPIO_PIN_INTR_LOLEVEL);

    // Enter light sleep.
    wifi_set_opmode(NULL_MODE);
    wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
    wifi_fpm_open();
    wifi_fpm_set_wakeup_cb(callback);
    wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);
    delay(1000);

So the code to receive transmission become so:

/*
 * LoRa E32-TTL-100
 * Receive fixed transmission message on channel and wake up.
 * https://mischianti.org
 *
 * E32-TTL-100----- Arduino UNO or esp8266
 * M0         ----- LOW
 * M1         ----- HIGH
 * TX         ----- RX PIN D3 (PullUP)
 * RX         ----- TX PIN D4 (PullUP)
 * AUX        ----- PIN D5
 * VCC        ----- 5v
 * GND        ----- GND
 *
 */
#include "Arduino.h"
#include "LoRa_E32.h"
#include <ESP8266WiFi.h>

#define FPM_SLEEP_MAX_TIME           0xFFFFFFF
void callback() {
  Serial.println("Callback");
  Serial.flush();
}

// ---------- esp8266 pins --------------
LoRa_E32 e32ttl(D3, D4, D5);  // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
// -------------------------------------
void printParameters(struct Configuration configuration);
//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.setMode(MODE_2_POWER_SAVING);

//  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.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);
    // ---------------------------
    delay(1000);
    Serial.println();
    Serial.println("Start sleep!");

    //wifi_station_disconnect(); //not needed
    gpio_pin_wakeup_enable(GPIO_ID_PIN(D5), GPIO_PIN_INTR_LOLEVEL);
    wifi_set_opmode(NULL_MODE);
    wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
    wifi_fpm_open();
    wifi_fpm_set_wakeup_cb(callback);
    wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);
    delay(1000);

    Serial.println();
    Serial.println("Start 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.println(rs.status.getResponseDescription());
        Serial.println(message);
    }
}

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("----------------------------------------");

}

The result is that the Serial stop on line 91, when we receive the message the e32 wake itself and put AUX LOW, so Arduino wake with interrupt on AUX pin.

Here the sending sketch:

/*
 * LoRa E32-TTL-100
 * Send fixed broadcast transmission message to a specified channel.
 * https://mischianti.org
 *
 * E32-TTL-100----- Arduino UNO or esp8266
 * M0         ----- HIGH
 * M1         ----- LOW
 * TX         ----- RX PIN D3 (PullUP)
 * RX         ----- TX PIN D4 (PullUP)
 * AUX        ----- PIN D5
 * VCC        ----- 5v
 * GND        ----- GND
 *
 */
#include "Arduino.h"
#include "LoRa_E32.h"

LoRa_E32 e32ttl(D3, D4, D5); 
// -------------------------------------

void printParameters(struct Configuration configuration);

//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++;
	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("----------------------------------------");

}

WeMos D1 mini shield

I create also a WeMos D1 mini shield very usefully to use.

LoRa E32-TTL-100 and Wemos D1 fully connected shield old version
LoRa E32-TTL-100 and Wemos D1 fully connected shield old version

The configuration is this:

LoRa_E32 e32ttl(D3, D4, D5, D7, D6); 

Than you can use all examples inside the library, you can use pin D6 and D7 to do a full connection or disable they and put M0 and M1 as you want with dipswitch.

Milled WeMos D1 Shield LoRa EBYTE E32
Milled WeMos D1 Shield LoRa EBYTE E32

Now we are going to soldering.

Ready to go

WeMos D1 mini LoRa E32 shield start soldering
WeMos D1 mini LoRa E32 shield start soldering

Milled WeMos D1 Shield LoRa EBYTE E32 bottom
Milled WeMos D1 Shield LoRa EBYTE E32 bottom
Milled WeMos D1 Shield LoRa EBYTE E32 up
Milled WeMos D1 Shield LoRa EBYTE E32 up

Here the result of milled PCB

Milled WeMos D1 Shield LoRa EBYTE E32 mounted
Milled WeMos D1 Shield LoRa EBYTE E32 mounted

Here the result with ordered PCB

WeMos D1 Shield LoRa EBYTE E32 mounted
WeMos D1 Shield LoRa EBYTE E32 mounted

The shield have some jumper and dip switch to configure M0 and M1.
If you want set M0 and M1 to a fixed value you must put jumper to F, if you want control via pin to P.
If you set to F you must put dip switch on property value Low or High.

WeMos D1 mini shield photo UP with description
WeMos D1 mini shield photo UP with description

Shopping List

You can find here AliExpress (433MHz 5Km) - AliExpress (433MHz 8Km) - AliExpress (433MHz 16Km) - AliExpress (868MHz 915MHz 5.5Km) - AliExpress (868MHz 915MHz 8Km)

AmountPart TypeProperties
1Lora E32-TTL-100variant 1; voltage 3-5V; type Basic
1DIP SWITCHchannels 1; package dipswitch-02
2Generic male header – 3 pinspins 3; pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm; form ♂ (male); package THT; row single
1WeMos D1 minitype esp8266
34.7kΩ Resistorbands 4; tolerance ±5%; pin spacing 400 mil; package THT; resistance 4.7kΩ
32kΩ Resistorbands 4; tolerance ±5%; pin spacing 400 mil; package THT; resistance 2kΩ
1 Generic female header – 7 pins Pin spacing 0.1in (2.54mm);
2 Generic male/female header – 8 pins Pin spacing 0.1in (2.54mm);

You can get pcb without additional costs here from PCBWay
PCB from PCBWay

Here my Crtistmas present

PCBWay Cristmas box
PCBWay Cristmas box

I chose this manufacturer because at the same cost it offers excellent quality, in the first screen it is possible to make countless options suitable for every need.

The board as you can see on various photo is very beautiful and simply to solder.

Assembly video

Here the soldering video.

Here the result

WeMos D1 Shield LoRa EBYTE E32 mounted
WeMos D1 Shield LoRa EBYTE E32 mounted

Thanks

  1. LoRa E32 device for Arduino, esp32 or esp8266: settings and basic usage
  2. LoRa E32 device for Arduino, esp32 or esp8266: library
  3. LoRa E32 device for Arduino, esp32 or esp8266: configuration
  4. LoRa E32 device for Arduino, esp32 or esp8266: fixed transmission
  5. LoRa E32 device for Arduino, esp32 or esp8266: power saving and sending structured data
  6. LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and Arduino shield
  7. LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and WeMos D1 shield
  8. EByte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) and new ESP32 shield
  9. Ebyte LoRa E32 with STM32: WOR (wake on radio) and new STM32 shield

Github library


Spread the love

9 Responses

  1. Craig says:

    Renzo,
    I’m using your sketch on page 7 as above, the only difference is that I need pin configeration LoRa_E32 e32ttl(D3, D4, D5, D7, D6); for the connection drawing you have.( if i use just d3,d4,d5 my sketch doesn’t work) The other difference is instead of receiving message in the void loop I’m sending a message.
    If I take out the wifi sleep lines and more importantly line gpio_pin_wakeup_enable(GPIO_ID_PIN(D5), GPIO_PIN_INTR_LOLEVEL); it works.
    If I only add line gpio_pin_wakeup_enable(GPIO_ID_PIN(D5), GPIO_PIN_INTR_LOLEVEL); it no longer works.
    It looks like the interrupt is causing an issue for transmitting a message how do I work around this ?

    • Hi Craig,
      I have a hard time helping you, or better, I understand that you have a trouble to send message on the device where you configure the interrupt.
      If you open a topic where you can put your code I try to help you.
      Bye Renzo

  2. craig stock says:

    Renzo,
    added info into forum
    Thanks

  3. kk says:

    Sir,may I ask you about the Modules?Could it possible connect with TTgo Meshtastic board? I mean soldering on board.I not sure modules can relay or transfer signals from Lilygo Meshtastic board.

  4. Srill says:

    Hello, can you help me? I am really confused about my LoRa E32 module.
    What does MIC —> -1 and TX MIC —> -1 mean when I run the getconfiguration program from library example. When I try to get GetParam information from the Ebyte RF setting program, I receive a ‘no response from device’ message. However, when I attempt it using the library, it appears as follows.But when I try to send data, there is no response at all. I am using an ESP32 and connecting it according to the scheme you provided, with a 5V VCC from the ESP32 board.

    X MIC —> -1
    TX MIC —> -1
    AUX —> 15
    M0 —> 21
    M1 —> 19
    Init AUX pin!
    Init M0 pin!
    Init M1 pin!
    Begin ex
    Begin Hardware Serial
    Begin
    MODE NORMAL!
    AUX HIGH!
    Complete!
    MODE PROGRAM/SLEEP!
    AUX HIGH!
    Complete!
    Available buffer: 6 structure size: 6
    AUX HIGH!
    Complete!
    —————————————-
    HEAD : 11000000 192 C0
    
    AddH : 0
    AddL : 1
    Chan : 2 -> 412MHz
    
    SpeedParityBit : 0 -> 8N1 (Default)
    SpeedUARTDatte : 11 -> 9600bps (default)
    SpeedAirDataRate : 10 -> 2.4kbps (default)
    OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
    OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
    OptionWakeup : 0 -> 250ms (default)
    OptionFEC : 1 -> Turn on Forward Error Correction Switch (Default)
    OptionPower : 0 -> 20dBm (Default)
    —————————————-
    —————————————-
    HEAD BIN INSIDE: 11000000 192 C0
    —————————————-
    MODE NORMAL!
    AUX HIGH!
    Complete!
    Success
    1
    —————————————-
    
    • Hi Srill,
      if you use Serial instead of pin, It’s normal to have -1 -1.

      For the communication problem, we must check what you are doing. To do this, open a topic forum and explain the code and steps.
      Bye Renzo

  5. Sidney Tupper says:

    The E22-900T30D manual shows a screenshot of an E22 configuration application for which I’ve searched the EBYTE website unsuccessfully and also asked their tech support where to get it, with no answer. It suggests to me that it could be used to configure the E22 device to go into repeater and WOR modes when powered up, without a microcontroller attached. This would reduce power consumption. Not having the application, I haven’t been able to confirm this. What do you think?

    • Hi Sid,
      you don’t need the application you must only set the configuration in repeater mode and wiring the M0 and M1 with the correct level.
      If you open a forum topic I attach the wiring schema and the configuration parameter.
      Bye Renzo

Leave a Reply

Your email address will not be published. Required fields are marked *