Home › Forums › The libraries hosted on the site › EByte LoRa e32 UART devices sx1262/sx1268 › WOR wemos server cannot send message after wake
- This topic has 19 replies, 1 voice, and was last updated 3 years, 9 months ago by
Renzo Mischianti.
-
AuthorPosts
-
-
20 July 2021 at 11:32 #13731
craig stock
Renzo,
I’ve used your Wemos D1 WOR example on page 7 as my base for my sketch.
The main change is that after it wakes I intend to send a value taken from a flow meter back to my sever. I’m storing these values in Modbus register’s.
If I delete the wifi sleep section my sketch works, if i add in only the GPIO interrupt it no longer works.
For my test setup I’m using a fixed value for my flow reading and therefore have commented out the flow sampling section
I’ve wired the E32 Lora as your diagram and works with the following connections :LoRa_E32 e32ttl(D3, D4, D5, D7, D6);
My code for the node is below, let me know if something is clearly wrong
#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 LoRa_E32 e32ttl(D3, D4, D5, D7, D6); // ------------------------------------- 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 = 1; // moded for my testing back to mega server 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!"); delay(500); //wifi_station_disconnect(); //not needed // gpio_pin_wakeup_enable(GPIO_ID_PIN(D5), GPIO_PIN_INTR_LOLEVEL); // this line added only causes sketch to stop working // 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!"); e32ttl.begin(); e32ttl.setMode(MODE_1_WAKE_UP); } int i = 0; // The loop function is called in an endless loop void loop() { delay(2500); i++; struct Message { char type[6] = "LOT19"; char message[8] = "Flow_LH"; word flow; } message; message.flow = 65519; Serial.println("sending message to 0,3,4"); ResponseStatus rs = e32ttl.sendFixedMessage(0, 3, 4, &message, sizeof(Message)); Serial.println(rs.getResponseDescription()); } unsigned long currentMillis = millis(); // grab current time // Every 10 seconds, calculate and print litres/hour // if(currentMillis >= (cloopTime + 1000)) // { // Serial.println(flow_frequency+2); //debug calculation going negative since changing to 10 seconds added +2 to see what is happening as 0 are confusing // cloopTime = currentMillis; // Updates cloopTime // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. (Results in +/- 3% range) // l_hour = (flow_frequency * 6 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flow rate in L/hour changed 60 to 6 in formula // flow_frequency = 0; // Reset Counter // } // previousMillis = millis(); // delay(2500); // i++; 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("----------------------------------------"); }
-
20 July 2021 at 11:39 #13732
craig stock
Renzo,
Just to clarify what I mean by sketch not working, in the serial monitor it appears to be working with the following info being displayed : “sending message to 0,3,4” and also another response line saying “success” but my receiving server no longer receives the message.
-
20 July 2021 at 11:59 #13734
Hi Craig,
for now the only problem I see is that you do begin 2 times, removee32ttl.setMode(MODE_2_POWER_SAVING);
and the second
e32ttl.begin();
and to have more information uncomment this line on LoRa_E32.h
// #define LoRa_E32_DEBUG
and put the client code also.
Bye Renzo
-
20 July 2021 at 12:40 #13735
craig stock
This is my receiver server that also initiates the wake of the node by setting modbus address 40014 to value of 1.
The mega is wired as per page 4 fixed transmission.
Code below:
// modbus slave address 20 #include "Arduino.h" #include "LoRa_E32.h" #include <modbus.h> #include <modbusDevice.h> #include <modbusRegBank.h> #include <modbusSlave.h> //LoRa_E32 e32ttl(3, 4, 2); // Config without connect M0 M1 //LoRa_E32 e32ttl(3, 4, 5, 7, 6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 //LoRa_E32 e32ttl(4, 5, 3, 7, 6); this one for wake up arrangement with hardware/software control over working modes of e32 LoRa_E32 e32ttl(10, 11); // e32 TX e32 RX // THIS IS FOR MY BASIC SETUP ON UNO, swapped from 2,3 as not working on my mega as faulty, had to use pins 10 & 11 //LoRa_E32 e32ttl(4, 5, 3); //All of the data accumulated will be stored here modbusDevice regBank; //Create the modbus slave protocol handler modbusSlave slave; void printParameters(struct Configuration configuration); void printModuleInformation(struct ModuleInformation moduleInformation); //The setup function is called once at startup of the sketch void setup() { //Assign the modbus device ID. modbus 20 used for my project regBank.setId(20); /* modbus registers follow the following format 00001-09999 Digital Outputs, A master device can read and write to these registers 10001-19999 Digital Inputs, A master device can only read the values from these registers 30001-39999 Analog Inputs, A master device can only read the values from these registers 40001-49999 Analog Outputs, A master device can read and write to these registers Analog values are 16 bit unsigned words stored with a range of 0-32767 Digital values are stored as bytes, a zero value is OFF and any nonzer value is ON It is best to configure registers of like type into contiguous blocks. this allows for more efficient register lookup and and reduces the number of messages required by the master to retrieve the data */ //Add Digital Output registers 00001-00016 to the register bank regBank.add(1); regBank.add(2); regBank.add(3); regBank.add(4); regBank.add(5); regBank.add(6); regBank.add(7); regBank.add(8); regBank.add(9); regBank.add(10); regBank.add(11); regBank.add(12); regBank.add(13); regBank.add(14); regBank.add(15); regBank.add(16); //Add Digital Input registers 10001-10008 to the register bank regBank.add(10001); regBank.add(10002); regBank.add(10003); regBank.add(10004); regBank.add(10005); regBank.add(10006); regBank.add(10007); regBank.add(10008); //Add Analog Input registers 30001-10010 to the register bank regBank.add(30001); regBank.add(30002); regBank.add(30003); regBank.add(30004); regBank.add(30005); regBank.add(30006); regBank.add(30007); regBank.add(30008); regBank.add(30009); regBank.add(30010); //Add Analog Output registers 40001-40020 to the register bank regBank.add(40001); regBank.add(40002); regBank.add(40003); regBank.add(40004); regBank.add(40005); regBank.add(40006); regBank.add(40007); regBank.add(40008); regBank.add(40009); regBank.add(40010); regBank.add(40011); regBank.add(40012); regBank.add(40013); regBank.add(40014); // use this for write to to initiate a wake on radio outut from server regBank.add(40015); regBank.add(40016); regBank.add(40017); regBank.add(40018); regBank.add(40019); regBank.add(40020); /* Assign the modbus device object to the protocol handler This is where the protocol handler will look to read and write register data. Currently, a modbus slave protocol handler may only have one device assigned to it. */ slave._device = & regBank; { // Initialize the serial port for coms at 9600 baud slave.setBaud(9600); 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; configuration.ADDL = 0x03; // CHANGED THIS FOR TESTING WITH WEMOS SERVER OF SAME ADDRESS NEED TO CHANGE BACK WHEN TESTING WITH NODES WAS 3 configuration.ADDH = 0x00; configuration.CHAN = 0x04; configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION; configuration.OPTION.wirelessWakeupTime = WAKE_UP_250; //WAKE_UP_250;, also tried 750, also tried 2000 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!"); } struct MessageLot18 { //Message { char message[8]; word flow; //[5];// was byte }; struct MessageLot19 { //MessageHumidity char message[8]; word flow2; // if using word causes reboot // byte flow[5];// took out [5] to test as modbus register doesn't like it }; struct MessageLot09 { //MessageHumidity char message[8]; word flow3; // if using word causes reboot // byte flow[5];// took out [5] to test as modbus register doesn't like it }; struct MessageLot10 { //MessageHumidity char message[8]; word flow4; // if using word causes reboot // byte flow[5];// took out [5] to test as modbus register doesn't like it }; struct MessageLot11 { //MessageHumidity char message[8]; word flow5; // if using word causes reboot // byte flow[5];// took out [5] to test as modbus register doesn't like it }; struct MessageLot12 { //MessageHumidity char message[8]; word flow6; // if using word causes reboot // byte flow[5];// took out [5] to test as modbus register doesn't like it }; // int i = 0; // DELETED OUT TO TRY AND GET SERVER WORKING AGAIN 170721 17:57 // The loop function is called in an endless loop void loop() { if (regBank.get(40014) == 1) { e32ttl.begin(); e32ttl.setMode(MODE_1_WAKE_UP); delay(500); // half a second delay Serial.println("wake up world!"); // display wake function to test modbus write to register worked ResponseStatus rs = e32ttl.sendBroadcastFixedMessage(4, "Send message to channel 4 and all of my nodes that exist"); Serial.println(rs.getResponseDescription()); } slave.run(); { if (e32ttl.available() > 1) { char type[6]; // first part of structure ResponseContainer rs = e32ttl.receiveInitialMessage(sizeof(type)); // Put string in a char array (not needed) // memcpy ( type, rs.data.c_str(), sizeof(type) ); String typeStr = rs.data; Serial.println(typeStr); if (typeStr == "LOT18") { ResponseStructContainer rsc = e32ttl.receiveMessage( sizeof(MessageLot18)); struct MessageLot18 message = *(MessageLot18*) rsc.data; Serial.println(message.flow); // copied from regBank.set(40001, (word) (message.flow)); // flow reading into modbus registry for site 1 Serial.println(message.message); free(rsc.data); } else if (typeStr == "LOT19") { ResponseStructContainer rsc = e32ttl.receiveMessage( sizeof(MessageLot19)); struct MessageLot19 message = *(MessageLot19*) rsc.data; Serial.println(message.flow2); regBank.set(40003, (word) (message.flow2)); // site 2 flow flow reading into modbus registry, doesn't accept having[5] in the struct message, this appears to be working not tested on 232 Serial.println(message.message); free(rsc.data); } else if (typeStr == "LOT09") { ResponseStructContainer rsc = e32ttl.receiveMessage( sizeof(MessageLot09)); struct MessageLot09 message = *(MessageLot09*) rsc.data; Serial.println(message.flow3); regBank.set(40005, (word) (message.flow3)); // site 3 flow flow reading into modbus registry, doesn't accept having[5] in the struct message, this appears to be working not tested on 232 Serial.println(message.message); free(rsc.data); } else if (typeStr == "LOT10") { ResponseStructContainer rsc = e32ttl.receiveMessage( sizeof(MessageLot10)); struct MessageLot10 message = *(MessageLot10*) rsc.data; Serial.println(message.flow4); regBank.set(40007, (word) (message.flow4)); // site 4 flow flow reading into modbus registry, doesn't accept having[5] in the struct message, this appears to be working not tested on 232 Serial.println(message.message); free(rsc.data); } else if (typeStr == "LOT11") { ResponseStructContainer rsc = e32ttl.receiveMessage( sizeof(MessageLot11)); struct MessageLot11 message = *(MessageLot11*) rsc.data; Serial.println(message.flow5); regBank.set(40009, (word) (message.flow5)); // site 5 flow flow reading into modbus registry, doesn't accept having[5] in the struct message, this appears to be working not tested on 232 Serial.println(message.message); free(rsc.data); } else if (typeStr == "LOT12") { ResponseStructContainer rsc = e32ttl.receiveMessage( sizeof(MessageLot12)); struct MessageLot12 message = *(MessageLot12*) rsc.data; Serial.println(message.flow6); regBank.set(400011, (word) (message.flow6)); // site 6 flow flow reading into modbus registry, doesn't accept having[5] in the struct message, this appears to be working not tested on 232 Serial.println(message.message); free(rsc.data); } else { Serial.println("Something goes wrong!!"); } } } } void printParameters(struct Configuration configuration) { Serial.println("----------------------------------------"); Serial.print(F("HEAD : ")); Serial.print(configuration.HEAD, BIN); Serial.print(" "); Serial.print(configuration.HEAD, DEC); Serial.print(" "); Serial.println(configuration.HEAD, HEX); Serial.println(F(" ")); Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, DEC); Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, DEC); Serial.print(F("Chan : ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription()); Serial.println(F(" ")); Serial.print(F("SpeedParityBit : ")); Serial.print(configuration.SPED.uartParity, BIN); Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription()); Serial.print(F("SpeedUARTDatte : ")); Serial.print(configuration.SPED.uartBaudRate, BIN); Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRate()); Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN); Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate()); Serial.print(F("OptionTrans : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN); Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription()); Serial.print(F("OptionPullup : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN); Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription()); Serial.print(F("OptionWakeup : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN); Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription()); Serial.print(F("OptionFEC : ")); Serial.print(configuration.OPTION.fec, BIN); Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription()); Serial.print(F("OptionPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN); Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription()); Serial.println("----------------------------------------"); } void printModuleInformation(struct ModuleInformation moduleInformation) { Serial.println("----------------------------------------"); Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN); Serial.print(" "); Serial.print(moduleInformation.HEAD, DEC); Serial.print(" "); Serial.println(moduleInformation.HEAD, HEX); Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX); Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX); Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX); Serial.println("----------------------------------------"); }
-
20 July 2021 at 14:35 #13737
Hi Craig,
also in this sketch you must calle32ttl.begin();
only one time, remove the others, you can’t change mode without connect M0 and M1, that these are needed to set LOW or HIGH to change the mode.
do these changes and retry.
Bye Renzo
-
21 July 2021 at 11:04 #13791
craig stock
Renzo,
Thanks for your help, I’ve tried what you have suggested with removing the duplication and tried connecting my arduino server responsible for waking node and then receiving messages with fully connected scenario as in tutorial six. I’m still getting similar results see screen prints below
below is serial info from wemos node is woken by broadcast
16:48:33.715 -> Start sleep!
16:48:45.249 -> Callback
16:48:45.249 ->
16:48:45.249 -> Start listening!
16:48:57.727 -> sending message to 0,3,4
16:48:57.772 -> AUX HIGH!
16:48:57.772 -> Complete!
16:48:57.869 -> Clear buffer…ok!
16:48:57.869 -> Success
16:49:10.296 -> sending message to 0,3,4
16:49:10.296 -> AUX HIGH!
16:49:10.342 -> Complete!
16:49:10.342 -> Clear buffer…ok!
16:49:10.342 -> SuccessBelow is serial print from receiving arduino, First 2 messages are with node sketch wifi sleep and interrupt removed from sketch.
After the first 2 messages the serial prints are after sketch reloaded into node with sleep section active.
you can see the braodcast which wakes the node but after that it never recieves anymore messages from the node.
You can see in the node serial print that it is sending messages after being woken.
this is with connections as tutorial 4 fixed transmission on arduino serverAvailable buffer: 10 structure size: 10
Wait no AUX pin!
Complete!
65518
Flow_LH
LOT18
Available buffer: 10 structure size: 10
Wait no AUX pin!
Complete!
65518
Flow_LH
wake up world!
Wait no AUX pin!
Complete!
Clear buffer…ok!
Success
wake up world!
Wait no AUX pin!
Complete!
Clear buffer…ok!
Success
wake up world!
Wait no AUX pin!
Complete!
Clear buffer…ok!
Success
wake up world!
Wait no AUX pin!
Complete!
Clear buffer…ok!
Success
wake up world!
Wait no AUX pin!
Complete!
Clear buffer…ok!
Success
wake up world!
Wait no AUX pin!
Complete!
Clear buffer…ok!
Successbelow is with arduino fully connected as per tutorial page 7, node did wake up but still did not receive a message.
Clear buffer…ok!
Success
Init AUX pin!
Init M0 pin!
Init M1 pin!
Begin ex
Begin Software Serial
Begin
MODE NORMAL!
AUX HIGH!
Complete!
MODE WAKE UP!
AUX HIGH!
Complete!
wake up world!
AUX HIGH!
Complete!
Clear buffer…ok!
Successbelow is print screen from node after wake up
8:57:34.664 -> AUX HIGH!
18:57:34.664 -> Complete!
18:57:34.709 -> Clear buffer…ok!
18:57:34.709 -> Success
18:57:40.272 -> AUX HIGH!
18:57:40.272 -> Complete!
18:57:40.272 -> Clear buffer…ok!
18:57:40.318 -> Success
18:57:45.842 -> AUX HIGH!
18:57:45.842 -> Complete!
18:57:45.888 -> Clear buffer…ok!
18:57:45.888 -> Success
18:57:51.447 -> AUX HIGH!
18:57:51.447 -> Complete!
18:57:51.447 -> Clear buffer…ok!
18:57:51.491 -> Success
18:57:57.047 -> AUX HIGH! -
21 July 2021 at 12:59 #13805
Hi Craig,
the log sayWait no AUX pin!
there is a configuration problem, and you can’t change mode without fully connection.
Bye Renzo -
21 July 2021 at 13:31 #13806
craig stock
Renzo,
I tried also fully connected , you can see it further down in the above log, I made a comment in the log to note the difference.
-
21 July 2021 at 15:57 #13814
In the log I can’t see the mode change after Wake up, It’s possible that there isn’t??
Bye Renzo
-
-
22 July 2021 at 10:25 #13821
craig stock
Renzo,
I have M0 connected to D7 and M1 connnected to D6 on my wemos node, Does the debug show the working status of the M0 and M1 pins when changing between modes ?
If this is the case that means my wemos node is not changing M0/M1 states when going from power saving (sleep) to wake mode , would that be correct ?
-
22 July 2021 at 10:55 #13822
Sorry Craig,
I explain better.
In this list there isn’t the change mode log that allow send messagebelow is print screen from node after wake up 8:57:34.664 -> AUX HIGH! 18:57:34.664 -> Complete! 18:57:34.709 -> Clear buffer…ok! 18:57:34.709 -> Success 18:57:40.272 -> AUX HIGH! 18:57:40.272 -> Complete! 18:57:40.272 -> Clear buffer…ok! 18:57:40.318 -> Success 18:57:45.842 -> AUX HIGH! 18:57:45.842 -> Complete! 18:57:45.888 -> Clear buffer…ok! 18:57:45.888 -> Success 18:57:51.447 -> AUX HIGH! 18:57:51.447 -> Complete! 18:57:51.447 -> Clear buffer…ok! 18:57:51.491 -> Success 18:57:57.047 -> AUX HIGH!
It seems that not switch to Wake up mode
Bye Renzo
-
-
22 July 2021 at 13:03 #13823
craig stock
Renzo,
Debug log from my node test’s , my original log didn’t have everything.
Below i can see it change modes but after the 3rd test with sleep enabled it no longer receives messages.
Debug logs from node testing
copy of debug log with sleep section deleted from node (test 1)
Arduino server receives messages
20:50:07.209 -> Start sleep!
20:50:07.710 ->
20:50:07.710 -> Start listening!
20:50:07.710 -> Init AUX pin!
20:50:07.710 -> Init M0 pin!
20:50:07.756 -> Init M1 pin!
20:50:07.756 -> Begin ex
20:50:07.756 -> Begin Software Serial
20:50:07.800 -> Begin
20:50:07.800 -> MODE NORMAL!
20:50:07.800 -> AUX HIGH!
20:50:07.846 -> Complete!
20:50:07.846 -> MODE WAKE UP!
20:50:07.890 -> AUX HIGH!
20:50:07.890 -> Complete!
20:50:10.402 -> sending message to 0,3,4
20:50:10.402 -> AUX HIGH!
20:50:10.448 -> Complete!
20:50:10.448 -> Clear buffer…ok!
20:50:10.448 -> Success
20:50:12.956 -> sending message to 0,3,4
20:50:12.956 -> AUX HIGH!
20:50:13.002 -> Complete!
20:50:13.002 -> Clear buffer…ok!below is with power saving deleted and 2nd serial begin deleted and sleep disabled as you pointed out (test 2)
arduino recives messages that are sent below
20:53:21.098 -> Start sleep!
20:53:21.597 ->
20:53:21.597 -> Start listening!
20:53:21.642 -> MODE WAKE UP!
20:53:21.688 -> AUX HIGH!
20:53:21.688 -> Complete!
20:53:24.198 -> sending message to 0,3,4
20:53:24.243 -> AUX HIGH!
20:53:24.243 -> Complete!
20:53:24.288 -> Clear buffer…ok!
20:53:24.288 -> Success
20:53:26.738 -> sending message to 0,3,4
20:53:26.783 -> AUX HIGH!below is debug with sleep mode enabled and a boradcast sent to wake node. (test 3)
arduino server does not receive messages
20:55:14.272 -> Start sleep!
20:55:28.400 -> Callback
20:55:28.400 ->
20:55:28.400 -> Start listening!
20:55:28.445 -> MODE WAKE UP!
20:55:28.492 -> AUX HIGH!
20:55:28.492 -> Complete!
20:55:30.997 -> sending message to 0,3,4
20:55:31.088 -> AUX HIGH!
20:55:31.088 -> Complete!
20:55:31.088 -> Clear buffer…ok! -
22 July 2021 at 14:21 #13824
From the log seems that you send only wake up message, but the receiver was already waked up.
If I understand the behavior you must do:
Master
– Wake up mode
– You must send wake up message to the slave with broadcast
– go in normal mode and wait response messagesSlave
– Sleep mode
– wake up via message
– after wake up set normal mode
– send data to the MasterBye Renzo
-
23 July 2021 at 10:06 #13825
craig stock
Renzo,
thankyou for all your help.
I’ve updated my code with your suggestions but still cannot receive a message from my wemos D1 node once woken, I now have 2 nodes talking back to Arduino server for comparison test’s
Below is the serial debug logs from all 3 units.
I have now setup 2 nodes with same sketch, the only difference is one has the sleep code removed
and a different value used to identify where the data is coming from. (value 62229 is from the node without wake code)I have corrected the modes to normal, then wake when broadcasting and then back to normal.
I still have the same problem that I’m not receiving messages from the node that is woken, I
continue receiving messages from the node without the wake code.below log is from my arduino server that wakes the node and then recieves the message.
Init M0 pin!
Init M1 pin!
Begin ex
Begin Software Serial
Begin
MODE NORMAL!
AUX HIGH!
Complete!
MODE WAKE UP!
AUX HIGH!
Complete!
wake up world!
AUX HIGH!
Complete!
Clear buffer…ok!
Success
Init AUX pin!
Init M0 pin!
Init M1 pin!
Begin ex
Begin Software Serial
Begin
MODE NORMAL!
AUX HIGH!
Complete!
MODE WAKE UP!
AUX HIGH!
Complete!
wake up world!
AUX HIGH!
Complete!
Clear buffer…ok!
Success
MODE NORMAL!
AUX HIGH!
Complete!
LOT19
Available buffer: 10 structure size: 10
AUX HIGH!
Complete!
62229
Flow_LHBelow log is from the node with the wake code, you can see the switch from wake to normal mode before transmitting messages. Not receiving these messages from this node.(has identical code to below node except for sleep code and value of message)
6:13.173 -> Start sleep!
17:56:23.782 -> Callback
17:56:23.782 ->
17:56:23.782 -> Start listening!
17:56:23.827 -> MODE WAKE UP!
17:56:23.873 -> AUX HIGH!
17:56:23.919 -> Complete!
17:56:34.952 -> MODE NORMAL!
17:56:34.997 -> AUX HIGH!
17:56:34.997 -> Complete!
17:56:45.018 -> sending message to 0,3,4
17:56:45.062 -> AUX HIGH!
17:56:45.109 -> Complete!
17:56:45.109 -> Clear buffer…ok!
17:56:45.109 -> Success
17:56:45.154 -> MODE NORMAL!
17:56:45.154 -> AUX HIGH!
17:56:45.200 -> Complete!
17:56:55.209 -> sending message to 0,3,4
17:56:55.256 -> AUX HIGH!
17:56:55.301 -> Complete!
17:56:55.301 -> Clear buffer…ok!
17:56:55.301 -> Success
17:56:55.347 -> MODE NORMAL!
17:56:55.347 -> AUX HIGH!
17:56:55.392 -> Complete!Below log is from the node without the wake code, I’m receiving messages from this node.
7:59:43.419 -> Start sleep!
17:59:44.912 ->
17:59:44.912 -> Start listening!
17:59:44.957 -> MODE WAKE UP!
17:59:45.001 -> AUX HIGH!
17:59:45.001 -> Complete!
17:59:56.051 -> MODE NORMAL!
17:59:56.097 -> AUX HIGH!
17:59:56.097 -> Complete!
18:00:06.098 -> sending message to 0,3,4
18:00:06.142 -> AUX HIGH!
18:00:06.142 -> Complete!
18:00:06.142 -> Clear buffer…ok!
18:00:06.188 -> Success
18:00:06.188 -> MODE NORMAL!
18:00:06.233 -> AUX HIGH!
18:00:06.233 -> Complete!
18:00:16.231 -> sending message to 0,3,4
18:00:16.276 -> AUX HIGH!
18:00:16.276 -> Complete!
18:00:16.321 -> Clear buffer…ok!
18:00:16.321 -> Success
18:00:16.321 -> MODE NORMAL!
18:00:16.366 -> AUX HIGH!
18:00:16.410 -> Complete!Any suggestions ?
-
23 July 2021 at 11:08 #13826
craig stock
Renzo,
I’ve also taken voltage readings on M0 and M1 and can see it change states as the changes occur in the debug log
-
23 July 2021 at 11:31 #13827
craig stock
Renzo,
This is my wemos node code that i’ve used in regards to the above 2 post’s
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
LoRa_E32 e32ttl(D3, D4, D5, D7, D6);
// ————————————-
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 = 1; // moded for my testing back to mega server
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!”);
delay(500);
//wifi_station_disconnect(); //not needed
gpio_pin_wakeup_enable(GPIO_ID_PIN(D5), GPIO_PIN_INTR_LOLEVEL); // this line added only causes sketch to stop working
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!”);
// e32ttl.begin();
e32ttl.setMode(MODE_1_WAKE_UP);
delay(10000);
// e32ttl.setMode(MODE_0_NORMAL);
delay(1000);}
int i = 0;
// The loop function is called in an endless loop
void loop()
{
if (e32ttl.available() > 1){
Serial.println(“Message arrived!”);
ResponseContainer rs = e32ttl.receiveMessage();
// First of all get the data
String message = rs.data;Serial.println(rs.status.getResponseDescription());
Serial.println(message);
e32ttl.setMode(MODE_0_NORMAL);
}
e32ttl.setMode(MODE_0_NORMAL);
delay(10000);
i++;
struct Message {
char type[6] = “LOT19”;
char message[8] = “Flow_LH”;
word flow;
} message;message.flow = 61119;
Serial.println(“sending message to 0,3,4”);
ResponseStatus rs = e32ttl.sendFixedMessage(0, 3, 4, &message,
sizeof(Message));
Serial.println(rs.getResponseDescription());
}
unsigned long currentMillis = millis(); // grab current time// Every 10 seconds, calculate and print litres/hour
// if(currentMillis >= (cloopTime + 1000))
// {
// Serial.println(flow_frequency+2); //debug calculation going negative since changing to 10 seconds added +2 to see what is happening as 0 are confusing
// cloopTime = currentMillis; // Updates cloopTime
// Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. (Results in +/- 3% range)
// l_hour = (flow_frequency * 6 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flow rate in L/hour changed 60 to 6 in formula
// flow_frequency = 0; // Reset Counter// }
// previousMillis = millis();// delay(2500);
// i++;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(“—————————————-“);
-
24 July 2021 at 06:29 #13828
craig stock
Renzo,
I tried my experiment today using a arduino mega as my wake node , changed the code to suite arduino and it worked ok.
Seems the problem is with the wemos setup and sleep, just not sure what is the problem
-
24 July 2021 at 10:54 #13829
Hi craig,
check better if M0 and M1 changing correctly. With that 3.3v device sometime can be problem when one of that are LOW and HIGH at the sametime.
Bye Renzo -
28 July 2021 at 04:16 #13855
craig stock
Renzo,
Problem solved I had to detach interrupt used to wake node once it wakes.
I noticed you have the detach interrupt in your arduino example WOR tutorial.
The line I added is “detachInterrupt (GPIO_ID_PIN(14));”(wemos pin D5)
Thanks for your help and excellent library
regards
Craig
-
28 July 2021 at 07:42 #13857
Hi Craig,
Well, I’m glad you solved the problem. I hope the topic will be of help to others as well.
Bye Renzo
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.