IoT without Internet… Yes it's possible :)

I hope you guys liked my last article. The intent was to show how easy was it to get started. I am not going to talk about real sensors or actuators until we have built our base understanding strong.

“The secret of getting ahead is getting started. The secret of getting started is breaking your complex, overwhelming tasks into smaller manageable tasks, and then starting on the first one.” — Mark Twain

I always like to break big problem statements into a chunk of smaller ones, which help me focus and then knock them down one at a time. It's just a matter of time, we could stitch these different solutions together and achieve our ultimate goal.

So, in this article, I shall demonstrate how we could build an IoT application without Internet. Basically, set up the control center locally in this case would be a MQTT broker. In the course of my further articles, I will cover how can we secure the local MQTT broker which would demonstrate the IoT security aspect which is a major design consideration when we build an IoT application be it on the edge or the cloud.

We shall install the MQTT broker on our Raspberry Pi IoT gateway which we got ready here. Our client would be a laptop that will have a MQTT client. I recommend MQTT.Fx, since it's a free and offers cross-platform support. Overall, what we are trying to achieve is depicted in the below image.

Image for post
Image for post

Let us begin…!

Login to the Raspberry Pi IoT gateway and install the broker and the clients if not installed using the below commands. This will install the Mosquitto MQTT broker on the gateway. After the installation mosquitto starts as background service automatically. This is also true after the reboot of the gateway.

Install MQTT.Fx on your laptop and start the application. This would be our MQTT client which would connect to our IoT gateway, and then we could send and receive messages locally without being connected to the Internet.

Image for post
Image for post
MQTT.fx Application

Create a connection profile from the menu options. It should look something like this.

Image for post
Image for post
Set up a connection profile

Use your Raspberry Pi IoT gateway’s IP address in the broker address field. Leave the default values for the rest of the parameters. Click apply and save the configuration.

Select the profile you created and click connect.

Image for post
Image for post
Before connection with the Broker

If everything was okay, you should see the connection status as Green in the top right corner which was earlier Red. In case of error, it will still be Red.

Image for post
Image for post
After connection with the Broker

Congratulations…! You are in the game now :)

Go to the "subscribe tab" and subscribe to a Topic e.g /IoTSensor/ID/01

Image for post
Image for post

After you subscribe to the topic, go to the publisher tab, set the topic to the same Topic /IoTSensor/ID/01, enter a message in the below text area and press publish.

Image for post
Image for post

If everything went well, you should see your published message in the subscriber tab where you subscribed to the Topic.

Image for post
Image for post

Simple isn’t it… 😊

Good news, we could also do this programmatically. I have put a simple sample code here. The reason I showcased MQTT.fx application is that its very handy when we want to do quick debugging.

Just run the subscriber and the publisher like we did in our previous article. It does exactly the same thing we did above with MQTT.fx.

Image for post
Image for post

Now that we have successfully setup a local MQTT broker, the possibilities are endless. You could try all the MQTT features like message retention, last-will and testament, QOS, etc and see how they could be used in the IoT app.I found it very interesting when I did that. What I would cover in my next tutorial is, how can we secure our MQTT broker using various method like credentials and with self-signed TLS certificates. It would be an advanced tutorial. I personally love it as it gives one a great insight not only when working with IoT cloud platforms like AWS or Microsoft Azure but also when you develop Edge or Fog computing centric IoT application.

Stay tuned… 😊

Linux Enthusiast, Embedded systems, Quick Learner, IoT Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store