Site icon Renzo Mischianti

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

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

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

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

So the new connection schema become like so:

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

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

Now we are going to soldering.

Ready to go

WeMos D1 mini LoRa E32 shield start soldering

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

Here the result of milled PCB

Milled WeMos D1 Shield LoRa EBYTE E32 mounted

Here the result with ordered PCB

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

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

Here my Crtistmas present

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

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
Exit mobile version