I’m using the Electron with a 3rd party SIM. In general, it works. I deep sleep 10 min, then wake and publish a battery voltage (about 41 bytes total application data if I calculated correctly). However I see two problems:
-
Overhead data usage is higher than with Particle SIM. Similar stuff found here (Electron Data Usage Overhead), but I’m using automatic mode which seems to help. Still not as good as with Particle SIM. Could it be a double ACK for 3rd party SIM or a ping plus an ACK? Any idea why data usage for 3rd party SIM is different (overhead ~148 bytes TX, 122 bytes RX) compared to Particle (65 bytes TX, 61 bytes RX)?
-
My larger problem is that I occasionally lose published data. I am not using NO_ACK, so I assume that Electron should get an ACK and retry if the publish fails. I don’t see that. The packet just doesn’t appear in the cloud. I modified my code to track data usage for each publish and found that I don’t get any RX data when a packet is dropped. Any suggestions on what I can do to ensure packets are received in the cloud?
Here’s a snippet of my Electron’s serial output (IP address masked). Notice that I normally TX 189 bytes and RX 122 bytes (see last two values deltaTX, deltaRX). When I see TX 189 and RX 0, I know I’ve lost a packet. It’s missing from the cloud (M2X in this case). [Note: I can confirm the data usage from the 3rd party SIM cloud provider. Because I deep sleep, each publish is listed as a separate session. Usually it shows 311 bytes (189 + 122), but on fail it shows 189 bytes.]
I get True for Cellular.ready(). Publish() returns True (success). RSSI (-75) and QUAL (43) don’t really change.
<,Timestamp,Init_CID,Tx,Rx,Tx,Rx,.ready,localIP,Reset_CID,Tx,Rx,Tx,Rx,batt_value,pubSuccess,RSSI,QUAL,Publish_CID,T,R,T,R,deltaTx,deltaRx,>
<,2016-10-30T17:26:25Z,31,74,0,74,0,true,10.52.xxx.xxx,31,0,0,0,0,3.9450,1,-75,43,31,189,122,189,122,189,122,>
<,2016-10-30T17:37:00Z,31,74,0,74,0,true,10.52.xxx.xxx,31,0,0,0,0,3.9450,1,-73,43,31,189,122,189,122,189,122,>
<,2016-10-30T17:47:35Z,31,74,0,74,0,true,10.52.xxx.xxx,31,0,0,0,0,3.9450,1,-75,43,31,189,0,189,0,189,0,>
<,2016-10-30T17:58:12Z,31,74,0,74,0,true,10.52.xxx.xxx,31,0,0,0,0,3.9450,1,-75,43,31,189,122,189,122,189,122,>
Code below. Running 0.6.0-rc.1.
//rev1 10/28/16: Adds .ready(), .publish return, localIP, RSSI, and QUAL
//rev2 10/29/16: Streamline output to use csv format (all data on single line)
// <,Timestamp,Init_CID,T,R,T,R,.ready,localIP,Reset_CID,T,R,T,R,batt_value,pubSuccess,RSSI,QUAL,Publish_CID,T,R,T,R,deltaT,deltaR,>
#include "cellular_hal.h"
STARTUP(cellular_credentials_set("apn.konekt.io", "", "", NULL));
// Connects to a cellular network by APN only
void setup()
{
bool readyOK;
Serial.begin(9600);
delay(5000); //delay 5 sec to allow user serial connection
//Serial.print("******** Init **********");
Serial.print("<,");
Serial.print(Time.format(Time.now(), TIME_FORMAT_ISO8601_FULL));
Serial.print(",");
PrintCellUsage(); //values on init
Serial.print(",");
Cellular.resetDataUsage();
if(Cellular.ready())
Serial.print("true");
else
Serial.print("false");
//Serial.print("localIP = ");
Serial.print(",");
Serial.print(Cellular.localIP());
}
void loop()
{
FuelGauge fuel;
float value;
bool success;
int tx1, rx1, tx2, rx2, deltatx, deltarx;
//Serial.print("Before Publish: ");
Serial.print(",");
CellularData data;
if (!Cellular.getDataUsage(data)) {
Serial.print("-1,-1,-1,-1,-1");
}
else {
Serial.print(data); // printed as CID,TX,RX,TX,RX
}
tx1 = data.tx_total;
rx1 = data.rx_total;
value = fuel.getVCell();
String output = "{\"batt-value\": \"" + String(value) + "\"}";
Serial.print(",");
Serial.print(value,4);
success = Particle.publish("fuel-level1", output);
//Serial.print("publish success = ");
Serial.print(",");
Serial.print(success);
CellularSignal sig = Cellular.RSSI();
// Serial.print("RSSI,QUAL = ");
Serial.print(",");
Serial.print(sig);
//delay(1);
delay(1000); //flush serial buffer
Serial.print(",");
if (!Cellular.getDataUsage(data)) {
Serial.print("-1,-1,-1,-1,-1");
}
else {
Serial.print(data); // data usage counter adter publish
}
tx2 = data.tx_total;
rx2 = data.rx_total;
deltatx = tx2 - tx1;
deltarx = rx2 - rx1;
Serial.print(",");
Serial.print(deltatx);
Serial.print(",");
Serial.print(deltarx);
Serial.println(",>"); //END OF CSV LINE
delay(1000); //allow serial flush before sleep
//NOTE: This currently bricks the device for OTA...
System.sleep(SLEEP_MODE_DEEP, 600); //1200 = 20 min
}
void PrintCellUsage() {
CellularData data;
if (!Cellular.getDataUsage(data)) {
Serial.print("-1,-1,-1,-1,-1");
}
else {
Serial.print(data); // printed as CID,TX,RX,TX,RX
}
}
Thanks all.