AWS IoT control disconnect and reconnect

Hi All,

I have a project whereby I send data from an ESP32 to AWS IoT via MQTT and then subscribe to the Topic using the node-red-contrib-aws-iot-hub palette and log the data.

It works fine, and I am able to disconnect the MQTT connection from the ESP32 until I need to send data again, but I would like to know if there is a way to disconnect my node-red connection and reconnect when needed.

The idea will be that the ESP32 will send it's update frequency as a value in the Topic, and the node-red program will then disconnect for just less than this time period, and reconnect in time to receive the next updated Topic, and reduce overall connectivity time. I may only be taking readings once an hour.

Any ideas?

Many Thanks

You don't say why you're using AWS IoT but if the ESP32 and the Pi are on the same network you could install a MQTT broker (look at mosquito) on the Pi and avoid the AWS connection together.

Hi zenofmud,

Thank you for responding.

Here's a little more clarity on what I've done so far and my thought process.

I have made a smart meter (of sorts), and am using the ESP32 to interface with my central heating system, and then started using the Pi to log the data, and will look to use this for weather predictions.

I have had mosquito working on the Pi and it worked great for devices on the same network, but I am now looking to have ESP32 devices at my friends houses, and would like to pull the data to one location in a cost effective way.

I was going to use other AWS services to log, control and display data, but figured it would be cheaper to just use my Pi to do that and minimise running costs.

When I created the flow in Node Red for the AWS connection, I then began to wonder if there was a way of disconnecting from AWS to minimise the overall connection time to their servers, which would reduce cost (although I'm sure it will very little anyway) .

Take a look at as a way to transmit the data. You can probable get away with the free account

Thanks very much for that.

I'm almost certain that the free package will fit my needs, and there doesn't look to be any restrictions/costs on connection time, just number of messages.

Thanks again, I will give this a go as soon as possible.