Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Optimal Protocol on Mongoose OS for Battery Powered Devices (MQTT vs HTTPS vs HTTP )

I am working on a device that requires to be turned on, on a trigger with the ESP8266. I have a way to send the information out via HTTP or MQTT, but I need to choose one.

Whenever I use HTTP, it takes about 15-20 seconds before I can send out a message.

Whenever I enable MQTT, I get the following below which I believe is the device brokering with AWS MQTT server(s). This takes about 35 seconds from boot before I can send successful messages.

SW ECDSA verify curve 3 hash_len 32 sig_len 70
SW ECDSA verify curve 3 hash_len 32 sig_len 71
SW ECDH

I haven't tested HTTPS yet, but it should be longer than 15-20 seconds because of encryption.

I may test battery consumption for each, but if the developers know one that should work better, please discuss this here.
Also, is there an optimal way of configuring Mongoose OS for devices that need to turn on for a short time and then turn off?
I know there is deep sleep mode, but will this cause the connection times to be about the same?

Any feedback would be great. Thanks as always!

Comments

  • SergeySergey Dublin, Ireland

    If you want it to be secure and fast, use ECC508A https://mongoose-os.com/docs/core_components/security.html#atecc508a-crypto-chip
    It can keep AWS credentials secure and bring TLS connection time down to < 1s.

  • Or you could use ESP32 with flash encryption and faster boot time ~10 secs (including AWS credentialing). Unfortunately, deep sleep isn't implemented yet on Mongoose for ESP32 (but available via native SDK). @sergey has mentioned the team is working on "mqtt connected successfully" js api which should be useful to your project.

    As far as turning on and off, you could look at ATtiny (low voltage) as an option.

  • SergeySergey Dublin, Ireland

    We do not yet plan to move a deep sleep API into Mongoose OS API.
    Rationale: apparently it is very hardware specific, and thus might not make sense to generalise.
    Therefore, for deep sleep please use native SDK API.

    Thanked by 1bravokeyl
  • @jocode, I'm probably going to be working on a lib to do something like this, for the esp8266.

    My plan is to do this in the lib:
    * add support for deep-sleep, with a callback to return "savedData"
    * make it so one can control if the network is on/off during wake-up (so no every wake will require wifi/reporting)
    * provide a report-time interval (like every x minutes) in which the network will be enabled and data can be reported -- probably requiring the library user to implement a special function which gets the collected data so it can "do" something on the network with it.

    This will allow one to collect data periodically, without reporting it be on the network, and allow the user to specify how frequently data is sent. It effectively means that data can be cached during readings/wakss and reported periodically.

    If the report-time is not-set/less than the sleep-period then the library would just be a simple framework to pass information across the deep-sleep wake, like via the RTC memory in the esp8266 (this is a pre-req and limit for this system, but the fall-back could be to do a non-deep-sleep, or persist the data to the fs, but I'm not sure that would be good for power-usage or memory longevity).

    Thanked by 2jocode bravokeyl
  • SergeySergey Dublin, Ireland

    sounds like an awesome library, Scott !

  • edited June 2017

    Is there a way to trigger code when HTTP is booted successfully and it's ready to send out information? That way it's not a guessing game with telling the device to execute code before connecting to WIFI.

  • SergeySergey Dublin, Ireland
    edited June 2017

    Setup wifi event handler with mgos_wifi_on_change_cb() and catch MGOS_WIFI_IP_ACQUIRED event.
    We're going to integrate ethernet support soon and that API will probably generalise a bit - it does not really matter, wifi or ethernet, main thing in that the device is online.

  • I appreciate this, but how would I go about doing this with mjs? Would I need to ffi the method and then the constant? If so, how is that done for this particular instance? Or is this not developed yet?

  • SergeySergey Dublin, Ireland

    OK, we've got enough demand for this to just do it in JS too,
    let me handle this, I'll follow up on this thread soon.

  • @Sergey can we get mqtt connect in JS also? I know it's on your list. Thanks!

  • SergeySergey Dublin, Ireland
    load('api_net.js');
    
    Net.setStatusEventHandler(function(ev) {
      print('wifi status change:', ev);
    }, null);
    

    Will add MQTT event too.

    Thanked by 2bravokeyl jocode
  • Thank you!

Sign In or Register to comment.