How to know my data traffic

I would like to know what is data trafic for my imps per day. How do I find out?

This is not currently exposed (it used to be but then we removed it). You can generally tell based on what you’re sending in your code?

If I send small sentence to server like “temperature of room is 24 celsius” every second, 24 hours a day, it will be probably more then 1MB of data traffic, isnt it?

That would be 28.5 Mb. You could just send “24”, which would come down to 1.8 Mb.

This topic made me interested in how much data the imp in my weather station is transmitting, so I went to have a look.

The weather station is sending a table with readings of temperature, wind speed, wind direction and the amount of pulses it got from the rain gauge. To that is also the voltage, light reading from the build in sensor in the imp, ssid and rssi.

It is all send once every second, and my AP shows that it is laying just under 1kb/s. It does not really matter to me how much it is sending, even if it was 1MB/s, but it is interesting to see how things add up. :slight_smile:

How can I make data (traffic) smaller?
Some kind of converting? What is the size of char, integer or float in squirell?
Coud converting integers to char help?

Do you really need to know the temperature every second? If you set it to every 2 seconds you already cut the traffic in half.

Yes, I know but I need to go bellow 1MB a day. And I would like to to connect several sensors simultaneously…

What kind of temperature sensor are you using?

This is more general question. I would like to use humidity, temperature, acceleration sensors and maybe some others, but question is: Is there a way how to keep the amount of informations (5 sensors updated every second) and make data traffic smaller?

I read the squirrel documentation and maybe the blobs could be the solutions, because blobs support a greater range of data types and I could use just 8-bit integers for some sensor values.

For example: If I make a blob with size one byte, assign value like 100, send it to server (agent), would that make my data traffic lower then sending integer (32 bites) variable?

Is there a function similar to sizeof in c/c++ in Squirrel?

I would suggest you compress your traffic by sending a one character message to say nothing changed, which would be the case most of the time as temperature, pressure etc generally change very slowly. If some reading does change then send just that one, plus a general update every ten minutes perhaps.

This is very good point and I will definitely use it. Very clever. Thanks!

And what about the blobs? Could that help too?

Instead of telling nothing has changed, why not just send every time something has changed enough, depending on some hysteresis?

I thought RFranta might be more comfortable with the positive confirmation that nothing had changed. Of course it is redundant really, as is the occasional full update. One should be fine with an initial set of readings and updates whenever a value goes outside hysteresis limits.

It’s up to Electric Imp to determine how the data is metered.

At some stage in the past, the IDE did display the amount of data transferred between the agent and device after each restart. The values seems to indicate that not just the payload was counted. Sending a single value still equated to around 100 bytes. There is definite value in keeping data exchanges brief, but more value in reducing the number of messages exchanged.

When it comes to meeting the 1MB limit, sending a message every second simply won’t fly. The beauty of the imp model is that you have a versatile controller at the device end. It should determine whether it is worthwhile sending new data. ie only send new data when it changes or varies outside specified bounds.

Hi Coverdriven,

do you know how is exactly data traffic measured? ? Is data traffic calculated from data sent between imp and agent or it is about http requests from websites and apps?

It’s a question best answered by Electric Imp.

It’s solely based on data between agent and device, not between agent and the Internet. External data requests of the agent do appear to be rate limited, however.

We only count bytes you send; TCP overhead, link maintenance and TLS encryption is not counted.

However, an agent.send(“test”, “foo”) has to encode both the “test” and the “foo” parts, plus there’s overhead for the message itself and the BSON encoding.

We will be bringing back visibility for data used in the future.

That would be really useful!