I am developing a thin gateway for mesh networks with cellular capability. Maximizing data usage will be an important factor to consider due to a considerable amount of data created in the network.
I am testing Electron as the possible modem for each network. With that in mind, I ran some tests to measure resources consumption (Data usage and Battery). My code follows (firmware version 0.6.0-rc.1):
//#include "cellular_hal.h"
#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
//STARTUP(cellular_credentials_set("apn.konekt.io", "", "", NULL));
void sendStream();
void readBattery();
// called once on startup
void setup() {
Cellular.on();
Cellular.connect();
Particle.connect();
waitUntil(Particle.connected);
}
void loop() {
sendStream();
readBattery();
// sleeps for 5 min
System.sleep(SLEEP_MODE_DEEP, 300, SLEEP_NETWORK_STANDBY);
}
void sendStream() {
String data = "{\"key\":\"bb16471e088b989350aa79a\",\"body\":\"40c06b72&102&M0:4.096:4.3&M1:0:0:0:358:359&M2:34.89:0.00&M3:63.0:75&M4:0.347:0.347&M5:7.8:20.7\"}";
Particle.publish("streams", data, PRIVATE, NO_ACK);
}
void readBattery() {
FuelGauge fuel;
String value = String(fuel.getVCell());
Particle.publish("librato", value, PRIVATE, NO_ACK);
}
Basically the code publishes a stream and the battery level to webhooks every 5 minutes. The tests were run with a third party SIM card and then with a Particle one (because at first I though it was a issue using a third party one).
Each call is publishing 156 Bytes of data (stream string, event names and float value).
These are my results (battery results are not include - they were pretty satisfactory):
Third party SIM card:
Total time: 7 hr 26 min
Total data consumption: 112,575 Bytes
89 calls * 156 Bytes each = 13,884 Bytes of application data
Particle SIM card
Total time: 7 hr 32 min
Total data consumption: 0.14 MB
90 calls * 156 Bytes each = 14,040 Bytes of application data
We see there is a pattern here. We have an overhead in an order of 10. This is too much to consider using Electron in my application.
I am using the Deep Sleep with SLEEP_NETWORK_STANDBY, which is supposed to give me lower data usage for Particle cloud re-connection and NO_ACK for my publish events.
Am I missing something here? Is there any other snippet of code I could incorporate in mine?