Using 3g dongle for remote logging


I'm testing use of a 3g dongle which is pay as go (in the UK). I'm sending messages to Thingspeak (via Python on Pi) but the credit allowance decrease indicates several megabytes have been used. Even if one message is 1,000 bytes then after 1,000 messages like this I'd expect to lose 1 megabyte of credit but instead it's 10 MB (I'm sending https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxx&field3=12345 ) Has anyone experience of data logging over a mobile data dongle and how much it should cost ?

Vinod
Vinod le 15 Avr 2021

The Pi may be doing lots of other network stuff you're not aware of. A better test might be an ESP32 or ESP8266 hooked up via the dongle. That way you know exactly the data going over the network.

BTW, if you are concerned about data usage, I'd strongly suggest looking at the MQTT API. That is far more efficient and designed for machine-to-machine communication.

Colin kerr
Colin kerr le 16 Avr 2021

Thanks. There's no data use except when I'm sending requests to Thingspeak.I left it on for hours without requests and there was no data used. Can you plug a dongle into an ESP32 ? I thought the USB on it was just for power and coding ? MQTT API, thanks I didn't know that was efficient. Will learn about it now. It can't be worse than the 720 bytes used to send my API string and 5 digit number to Thingspeak !

Vinod
Vinod le 16 Avr 2021
Colin kerr
Colin kerr le 23 Avr 2021 (modifié(e) le 23 Avr 2021)

Update: Success - using MQTT and shutting off the dongle except for 1 second prior to transmission I'm sending 500 pairs of sensor values for 5p (PAYG of 5p/MB) which is a good result. I toggle the dongle using

  • sudo ifconfig eth1 up
  • sudo ifconfig eth1 down

Thank you.

Colin kerr
Colin kerr le 17 Avr 2021 (modifié(e) le 17 Avr 2021)

So, seems MQTT keeps the connection open avoiding the overhead every time an HTPP request is sent. There’s a Keep Alive limit to spot AWOL connections. If this limit is lower than frequency of my updates it may not be an improvement. Not yet found the Thingspeak maximum stay alive time. I have now: 1 hour which is ample for my 10 minute sampling. Looks promising, thanks.