More messages than expected on application server.
-
@Martijn-Kooijman Thanks for the advice! Good to know that current can be lower. I will check mine again. Other issues I had was missing messages, up to 20%! I seem to have solved it by adding a 4 s delay after opening a port (between opening port and sending message). I did that about 12 h ago and still not a single message lost!
-
Would like to know your results! Do you use the mkrnb library or do you send the at commands yourself?
-
@Martijn-Kooijman
I do not use the library, I send the commands to the serial ports using the following script below. Crucial for me is to add a 35 s delay after a reset (otherwise I get double messages, or mising messages, or wrong data), additionally I need the 4 s delay after opening port (before sending the message itself). I haven’t checked current again, will arrange a different meter for that./**
- Send AT command to u-blox module
*/
String cmd(String cmd) {
l("cmd: " + cmd);
SerialSARA.println(cmd);
int timeout = TIMEOUT;
while (!SerialSARA.available() & timeout > 0) {
timeout–;
delay(1);
}if (timeout == 0 || timeout < 0) {
l(“Timed out”);
return “”;
}String result = “”;
do {
result += char(SerialSARA.read());
delay(5);
} while(SerialSARA.available());l("rsp: " + result);
return result;
} - Send AT command to u-blox module
-
@Martijn-Kooijman Some updates, I tried your suggestion to add -DVERY_LOW_POWER to boards.txt but the result was that the Arduino IDE did not compile anymore. So I re-installed the IDE and it works again.
I again measured power consumption but now with another meter and in sleep mode it still consumes 1.2 mA. Will try your other suggestions later. First I need to solve something else:
I added a few more sensors and I could not send more than 6 bytes using my script. So tried your messages writing using Udp.write((uint8_t*)&msg, 16); This worked fine, I did receive 16 bytes. However, I never managed to receive the HEX values. For example sending a 16 bit value of 43869 should be sent as AB5D, however it arrives as 4154. Help much appreciated! -
@Crowdsourcer said in More messages than expected on application server.:
VERY_LOW_POWER
Strange did you add the option in the same way as you can see for the mkrfox1200? Can you post (part of) the code where you fill the msg variable? also could you give a complete example of a msg that you send and what you receive? for example with webhook.info?
-
@Martijn-Kooijman Thanks for the quick response. I have found the sending data error (cmd: see a previous post)!
My correct code now is:
sendcommand=“AT+USOST=0,“172.27.131.100”,15683,”+String(payload_size);
cmd(sendcommand); //
cmd(payload);
I had a Serial.println(“…”); statement before cmd(payload), this was not a problem with payload size 6 but did not work with a larger payload! It seems that the Ublox module wants the data immidiately after initiating the AT+USOST… command.I will look into power savings later this week. A 2Ah battery now lasts about a month and includes some solar charging days. I have a solar panel facing west and capable of charging a powerbank at >200 mA, but it only manages to charge at around 100 mA at the MKR1500. Note that the Arduino stops sending data at around 3.4 V of the LiPo, so one cannot use the full capacity!
Settings (every 15 minutes): 16 s at about 65 mA (switching on modem after sleep and a 4 s wait after opening a channel) , then about 880 s sleeping at 1.1 mA. I don’t think I can make the 16 s shorter or the 4 s delay shorter, because in the past this has lead to loss of data or double messages. But I will check again with the improved data sending with the 16 bytes. -
@Crowdsourcer said in More messages than expected on application server.:
@Martijn-Kooijman Thanks for the quick response. I have found the sending data error (cmd: see a previous post)!
My correct code now is:
sendcommand=“AT+USOST=0,“172.27.131.100”,15683,”+String(payload_size);
cmd(sendcommand); //
cmd(payload);That doesn’t look good. You must wait for the ‘@’ before sending the payload:
I had a Serial.println(“…”); statement before cmd(payload), this was not a problem with payload size 6 but did not work with a larger payload! It seems that the Ublox module wants the data immidiately after initiating the AT+USOST… command.
Are you sure Serial.println() doesn’t reuse the serial port for the u-blox module? That would explain why it works up to certain sizes.
I will look into power savings later this week. A 2Ah battery now lasts about a month and includes some solar charging days. I have a solar panel facing west and capable of charging a powerbank at >200 mA, but it only manages to charge at around 100 mA at the MKR1500. Note that the Arduino stops sending data at around 3.4 V of the LiPo, so one cannot use the full capacity!
You can include a buck/boost converter depending on the battery voltage. That will make sure the u-blox still works if the battery voltage drops below it’s minimum rated voltage. Be aware that a 3.4V battery may drop below 3V during module transmission.
Settings (every 15 minutes): 16 s at about 65 mA (switching on modem after sleep and a 4 s wait after opening a channel) ,
You don’t have to wait. If you set a greeting message via AT+CSGT you can listen for this message instead of waiting a fixed time.
then about 880 s sleeping at 1.1 mA. I don’t think I can make the 16 s shorter or the 4 s delay shorter, because in the past this has lead to loss of data or double messages. But I will check again with the improved data sending with the 16 bytes.
The 1.1mA at sleep is very high, it should be 7-8uA’s. So it looks like you have some issue with the power saving.
-
@Martijn-Kooijman I tried AT+CSGT but only ERROR as a return value (also with the serialpassthrough script). I can’t set it either: AT+CSGT=1,“test” for example.
So I have no clue how I should be able to test when it is fine to start.
I include the relevant code here, that my help understanding my power and “delay time” problems. I have no clue how I should do this modem greetings test to get rid of these excessive delays which consume power.#include <MKRNB.h>
#include <ArduinoLowPower.h>
#define LOG true
#define l(x) if (LOG) Serial.println(x);
#define DELAY (15 * 1000) //default 15 s
#define TIMEOUT (5 * 1000) //default 5 s
unsigned long baud = 115200;
String response;
// connection state
boolean notConnected = true;void setup() {
// enable the POW_ON pin SARA module
pinMode(SARA_PWR_ON, OUTPUT);
digitalWrite(SARA_PWR_ON, HIGH);// reset the ublox module
pinMode(SARA_RESETN, OUTPUT);
digitalWrite(SARA_RESETN, HIGH);
delay(100);
digitalWrite(SARA_RESETN, LOW);
Serial.begin(baud);
SerialSARA.begin(baud);
}
Loop{
delay(16000); //wait for SARA module to get ready (>65mA)
//do some measurements
cmd(“AT+USOCR=17,7000”); //opens a port
delay(4000); //need to wait here also
cmd(“AT+USOST=0,“172.27.131.100”,15683,16” //it returns “@”
cmd(payload);
digitalWrite(SARA_PWR_ON, LOW);
LowPower.sleep(900000); //(10 mA with modem on, 1.2 mA with modem off)
digitalWrite(SARA_PWR_ON, HIGH);
}
/**- Send AT command to u-blox module
*/
String cmd(String cmd) {
l("cmd: " + cmd);
SerialSARA.println(cmd);
int timeout = TIMEOUT;
while (!SerialSARA.available() & timeout > 0) {
timeout–;
delay(1);
}if (timeout == 0 || timeout < 0) {
l(“Timed out”);
return “”;
}String result = “”;
do {
result += char(SerialSARA.read());
delay(5);
} while(SerialSARA.available());l("rsp: " + result);
return result;
} - Send AT command to u-blox module
-
@Martijn-Kooijman I tried AT+CSGT but only ERROR as a return value (also with the serialpassthrough script). I can’t set it either: AT+CSGT=1,“test” for example.
So I have no clue how I should be able to test when it is fine to start.AT+CSGT=1 works fine on my u-blox R4, I guess it’s not supported on your older firmware. You can try monitoring the V_INT signal, that will tell you if the module is in low power mode or not and may also tell you if the module is ready to receive commands
-
@Martijn-Kooijman I solved it by checking the return message after sending “AT+USOCR=17,7000”. Once it is contains “+USOCR: 0” in the returning string I know it is ok:
(it takes about 5 s after a reset)
added code:String check_sara=cmd("AT+USOCR=17,7000"); while ((check_sara.indexOf("+USOCR: 0",1)<0)) { delay(500); check_sara=cmd("AT+USOCR=17,7000"); Serial.println(check_sara);//just for checking }