Electron per message overhead?

I just put the finishing touches on a weather station built using the Electron and the Sparkfun Weather shield and Weather station sensors.

My question is that after 10 hours of sending reports to Weather Underground for web posting of the data, Particle Dashboard reports that I used 180KB of data. for 60 messages (one update report every 10 minutes) during that 10 hours that’s 3KB per message with less than 300bytes of ASCII data per message. Is this level of overhead to be expected?
No OTA uploads where made for about 10 hours prior to the measurement period.
A months total is about 14MB, way more than I expected. (my fault of course as I am hopelessly optimistic)

BTW I do not use sleep, as power is an not an issue, This is for installation at my Radio Control Model Aircraft Club’s flying field. We do not have internet access (hence the Electron), but do have a good size solar system, with backup storage batteries available.

David Garrison

How are you sending the messages?

with client,print statements;

example

" client.print("&tempf=");
  client.print(tempF);
  client.print("&dewptf=");
  client.print(dewptF);
  client.print("&humidity=");
  client.print(humidity);

Etc…

D.G.

Is this over TCP? Please also provide an example of one message.

Each call to client.print() will send a separate TCP packet, so there will be considerable overhead there.

You should instead print your message to a buffer and then send that as one message.

here is complete function that sends the message ( I don’t know how to put this in a code window!)

void sendToWU()
{
  Serial.println("connecting...");

  if (client.connect(SERVER, 80)) {
  Serial.println("Connected");
  client.print(WEBPAGE);
  client.print("ID=");
  client.print(ID);
  client.print("&PASSWORD=");
  client.print(PASSWORD);
  client.print("&dateutc=now");      
  client.print("&tempf=");
  client.print(tempF);
  client.print("&dewptf=");
  client.print(dewptF);
  client.print("&humidity=");
  client.print(humidity);
  client.print("&baromin=");
  client.print(inches);
  
  client.print("&winddir=");
  client.print(winddir);
  
  client.print("&winddir_avg2m=");
  client.print(winddir_avg2m);
  
  client.print("&windgustmph=");
  client.print(windgustmph_10m);      
  //client.print("&windgustmph_10m="); 
//  client.print(windgustmph_10m);
  
  client.print("&windgustdir=");
  client.print(windgustdir);
  
  client.print("&windgustdir_10m=");
  client.print(windgustdir_10m);
  
  client.print("&windspeedmph=");
  client.print(windspeedmph);
  
  client.print("&windspeedmph_avg2m=");
  client.print(windspeedmph_avg2m);
  
  //client.print("&rainin=");
 // client.print(rainin);
  
 // client.print("&dailyrainin=");
 // client.print(dailyrainin);
  
  
  client.print("&action=updateraw");    //Standard update rate - for sending once a minute or less
  //client.print("&softwaretype=Particle-Photon&action=updateraw&realtime=1&rtfreq=30");  //Rapid Fire update rate - for sending multiple times per minute, specify frequency in seconds
  client.println();
  Serial.println("Upload complete");
  delay(300);                        
  }else{
    Serial.println(F("Connection failed"));
  return;
  }
}

How does one do that?

D.G.

There are some ways but I’d do it like that with snprintf()


char buf[1024]; // if your message is longer split it into smaller chunks
                // if it's shorter you can reduce the buffer

snprintf(buf, sizeof(buf), "%sID=%s&PASSWORD=%s&dateutc=now&tempf=%.2f&dewptf=%.2f&humidity=%d&...", 
     WEBPAGE, ID, PASSWORD, tempF, dewptF, humidity, ...);
client.println(buf);

You can also look at strncat() and the docs for the printf() formatting for it.

How often do you call that function and what do you do in between (e.g. deep sleep)?

4 Likes

It is called every 10 minute, in between calls it reads the various sensors (some are interrupt driven--wind speed and wind dir) does some peak determination and averaging but mostly it sucks its thumb, idling away in non blocking delays. I do not use deep sleep
.

Thanks for the info on snprint() . I will give it a try!

David Garrison

I played with this today and now have it working , but it did take awhile as sizeof [buf] should be sizeof (buf). sizeof[buf] produces a large number of (to me at least )of indecipherable complier errors. It does identify the line, of course, but there is a lot on that line. sizeof[buf] sure looks right..hey buf is an array and they use don't they, or at least that's what the code trouble shooting part of me was leading me to believe for a long time, until ah ha!.

But the up side is I am now comfortable with snprintf() and the others of its ilk.

Thanks again for your help and support

David Garrison

1 Like

Sorry for the typo :blush:
I’ll correct the post.

Following the advice of several responders, I managed to get to get a monthly usage down to 5 MB of data. A really big decrease. But, the hourly usage seems to depend on when I ask Dashboard for a report (steadily sending a fixed size report every 10 minutes) :
time last night at 11:03PM --0.18 MB (just rolled over from last month)
today 11:10AM --0.22 MB --12hours , used 40 KB or 3KB/ hr
today 5:40PM --0.31 MB --18.7 hours ,used 130KB or 6.95KB/ hr ??

David G.