More messages than expected on application server.
-
@Crowdsourcer Power usage on the arduino do not seem to be high on the design list with the mkr devices it seems
-
sadly starting 0:00 this morning I started receiving the long messages again (I changed nothing) so still not working as expected for me.
-
Hi @Martijn-Kooijman , I think that the extra messages that you receive might be related to the lifecycle events that our platform sends. Sometimes when your device sends a message an re-registration event occurs this generates an lifecycle message. Have a look at this text: https://docs.iot.t-mobile.nl/docs/device-data-reporting we create both a lifecycle and a resource subscription when you register a device.
-
@Eric-Barten Hi, I think the question is how do we turn this off? I don’t want my device to send data without my explicit request
-
@Eric-Barten @Stefan-de-Lange Yes, It would be nice to know how how to manage the subscriptions, see https://forum.iot.t-mobile.nl/topic/556/delete-subscriptions-via-api
The file supplied on the website for posstman di-oes not include the correct json syntax to use it.Also I am not sure the extra events are lifecycle events. I get to types of messages:
1:{"reports":[{"serialNumber":"IMEI:352753096136229","timestamp":1589356837854,"subscriptionId":"80ec5c8b-209a-47d8-8e8c-ef0dba0343b1","resourcePath":"uplinkMsg/0/data","value":"5a204fb8e506ffc304f73000"}],"registrations":[],"deregistrations":[],"updates":[],"expirations":[],"responses":[]}
and
2:{"reports":[],"registrations":[{"deviceType":"device","serialNumber":"IMEI:352753096136229","timestamp":1589358107277,"make":"Generic","model":"Sensor","groupName":"TMNL.STARTERKIT.CON_0000001542","imsi":"N/A","protocol":"N/A","tags":"N/A","subscriptionId":"bf3aedf1-26bc-4e28-b739-7debac04b68e","deviceProps":{"device/0/imsi":"IMSI:901405700007913","device/0/model":"Sensor","uplinkMsg/0/data":"000000000000000000006040","device/0/manufacturer":"Generic","connectivity/0/port":"2390","connectivity/0/mncmcc":"","location/0/longitude":"","device/0/endPointClientName":"IMEI:352753096136229","connectivity/0/cellid":"","connectivity/0/ip":"10.128.0.90","location/0/radius":"","connectivity/0/rat":"","location/0/latitude":"","connectivity/0/apn":""}}],"deregistrations":[],"updates":[],"expirations":[],"responses":[]}
The second type is always the same, the first type sometimesgives a very large payload:
{"reports":[{"serialNumber":"IMEI:352753096136229","timestamp":1589355068395,"subscriptionId":"80ec5c8b-209a-47d8-8e8c-ef0dba0343b1","resourcePath":"uplinkMsg/0/data","value":"428ae3f0080234000ecc30a80d006f0d0001eeeaf00a18150af996fd3f410e00002b0e28100e87bb01001d2a8f18080a0204000029ac0418150a0100fd3f410e2001210a2c100e100ec007dfbc0f18080a0504000021510718110a0100fd3f410a2001210a02100e510e0018080a02000000293a0418170a0495fd3f41100000210a64100e104a00002ae02ec20c18080a05040000219d0818120a0100fd3f410b2001210a0c100e4d0e6f0118120a0100fd3f410b2001210a0c100e4b0e590018080a0200000029250b180a0a11fc0020231d00000018080a11fc450029bdff18080a0100300121f60d"}],"registrations":[],"deregistrations":[],"updates":[],"expirations":[],"responses":[]}
-
@Crowdsourcer I did not have the opportunity to measure the sleep current myself but was wondering if you tried to comment out the following lines in wiring.c in the arduino core samd folder?
#ifndef VERY_LOW_POWER // Setup all pins (digital and analog) in INPUT mode (default is nothing) for (uint32_t ul = 0 ; ul < NUM_DIGITAL_PINS ; ul++ ) { pinMode( ul, INPUT ) ; } #endif
-
@Crowdsourcer I measured the deep sleep current on the mkrnb1500 without changes to wiring.c I got around 400 uA, with changes 194uA, later it dropped to 35uA but I am not 100% the 35uA is correct
-
No, I did not change wiring.c. Your current is really low but can you please check if the Arduino is also really working? I could also get these low currents but it appeared that the internal resistance of my multimeter was too high to let the Arduino start!
-
I was working, It send a message +/-55mA then went to deep sleep for 3 minutes and repeat
-
If you dont want to change wiringe.c you can also add -DVERY_LOW_POWER in boards.txt (thats what I did)
-
@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 }