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("----------------------------------------");
}
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.
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("----------------------------------------");
}
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
Below 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 server
Available 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!
Success
below 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!
Success
below 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!
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 ?
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!
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_LH
Below 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)
// 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;
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;
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
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
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: share_your_ideas@mischianti.org
The content displayed on this website is protected under a CC BY-NC-ND license. Visitors are prohibited from using, redistributing, or altering any content from this website for commercial purposes, including generating revenue through advertising. Any unauthorized use is a violation of the license terms and legal action may be taken against individuals or entities found to be in violation.
You must also provide the link to the source.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.