Have you ever forgotten to turn your home lights off when you got outside?
Sadly, it happens to me all the time. And this causes confusion once I get my bills!
Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed.
So, I got an idea. I am going to connect a lamp to the Internet and turn it on/off through an online MQTT “server” broker by using my smartphone. It’s an IoT-based Arduino Light Control. Therefore, it enables you to not only control light from inside home but also wherever you are and have an Internet access!
Internet of Things
IoT is the recent cutting-edge technology that allows devices around us to be connected together through the Internet. Simply, these devices are connected to a certain server called an MQTT broker. As a result, you can use your smartphone to connect it to that broker, so you can control all devices those are connected to the broker, too.
In this IoT Arduino Light Control tutorial, I am going to connect 2 devices to an online MQTT server “broker”, the lamp and the smartphone. The phone will publish a message “on” or “off” on a certain topic. The lamp will subscribe to the same topic. Hence, once it gets “on” message, it will turn on and the “off” message will turn it off, indeed.
Since the broker is online, then you need to connect the Arduino to the Internet, then connect it to the broker.
But Arduino alone can’t do that, so I will use the IoT Shield from 1Sheeld+ board that will be plugged into the Arduino and connect it to the online MQTT broker.
Also, you will need an iPhone “since IoT Shield works with iOS only” to be connected to the 1Sheeld via Bluetooth. And another one “iPhone or Android” that will act as the controller device where you will use it to publish “on” and “off” message through an IoT app.
You will find all the software and Apps required for this tutorial linked in the software components section.
If this is your first time to deal with 1Sheeld or you want to learn more about it, then I recommend checking this quick and easy getting started tutorial.
Furthermore, if this your first time reading about MQTT broker, then I recommend you go through this MQTT before going into this tutorial.
Now, after you’ve become a little bit familiar with 1Sheeld and MQTT broker, let’s start!
Step 1: Hardware components:
Arduino USB cable or 9-12v battery.
Relay 1 channel.
Male-to-Female jumper wires.
iOS phone with 1Sheeld App installed on it.
Android/iOS phone with the IoT MQTT Panel Pro installed on it.
Connect the lamp with the relay as illustrated below:
Switch the 1Sheeld power to operate on 5v (Not the 3.3v):
1Sheeld have 2 modes: Uploading mode and Operating mode. You can switch between them using the switch close to the Digital pins and is called “UART SWITCH” on 1Sheeld and “SERIAL SWITCH” on 1Sheeld+.
Firstly, you slide the switch towards the “SWITCH” notation which turns the 1Sheeld board into the Uploading mode to let you upload the Arduino code.
Then, after you finish uploading the code, slide the switch towards the “UART” notation (or “SERIAL” at 1Sheeld+ board) which turns the 1Sheeld board into the Operating mode to communicate with your smartphone 1Sheeld App.
Finally, connect the Arduino via your PC using Arduino USB cable.
I would recommend checking the Arduino IoT Shield documentation to know more about the Arduino IoT Shield functionalities and how to use them.
Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …
Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …
“Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …
Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …
MQTT is one of the most commonly used protocols in IoT projects. It stands for Message Queuing Telemetry Transport. In addition, it is designed as a lightweight messaging protocol that uses publish/subscribe operations to exchange data between clients and the server. Furthermore, its small size, low power usage, minimized data packets and ease of implementation …
Actually, that’s not a phrase from the Terminator movies, it’s just the reality of nowadays! Statistics show that the number of connected devices in 2018 are 23+ billion. This is almost 3 times the population density of the Earth, which is 7.6 billion at the time of writing this blog. Furthermore, this number is increasing …