IoT Arduino Light Control using 1Sheeld and Smartphone

Arduino Light Control

Arduino Light Control

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.


Getting started:

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 Uno.
  • 1Sheeld+ board.
  • Arduino USB cable or 9-12v battery.
  • Relay 1 channel.
  • AC lamp.
  • 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.

Step 2: Software components:

Step 3: Connection and Schematic:

  • Plug the 1Sheeld board into your Arduino as this:


  • 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.

Also, you can check this IoT Shield Functions Explainer blog to know about the usage of all the Arduino functions related to the IoT shield.


Now, switch the 1Sheeld board to the Uploading mode, upload this code:

Note: change this code:

to your own broker instance credentials you got after you have created it on CloudMQTT website.

If you don’t know how to get your own CloudMQTT broker instance, please check this MQTT blog.


Then, Switch the 1Sheeld board to the Operating mode then open the 1Sheeld app and connect it to the 1Sheeld board via Bluetooth.


Step 5: Configure it:

Firstly, let’s configure the phone and connect it to the broker.

Open the IoT MQTT Panel App and create a connection to the CloudMQTT broker. Again, all these MQTT broker stuff are explained in the MQTT blog.

After that, you will add a panel with a type “switch”. So, select the switch type.

Then write any name for the panel, like “Light”. Then make its topic as “home/light/operate”. That’s the topic which this switch will publish on.

Hence, we need to publish only 2 messages, “on” and “off”. So, write them on the Payload on and Payload off sections. A payload is just another name for the message.

The Final step in the App is to mark on the “Use icon switch” option and choose whatever switch shape and color you prefer for both the on and off icons.

When finished, press “CREATE”.

Step 6: Run the IoT Arduino Light Control

First of all, you will open the CloudMQTT website from here and navigate to the Websocket UI to monitor what’s going on on the broker.

Then on the App, press on the upper right cloud-shaped button to connect the phone to the broker.

Once connected, the cloud-shaped button will change its color to be orange.

Finally, press on the RESET button on the Arduino and monitor the CloudMqtt WebSocket UI panel.

You saw something on the WebSocket UI, right? Cooool!

That’s because once the Arduino connects to the broker, it publishes on the topic “home/light/state” a message “ready”. Just an indication that the Arduino has connected to the broker.

And once you press on the switch on the App, the lamp will respond by turning on and off. Just this easy!



You can easily monitor all the publishing and subscribing operations on the broker from the Websocket UI console. It will be something like that:

And here is the project working 🙂


That’s it for the IoT Arduino Light Control, guys.

If you are interested in this IoT Blog Series, stay tuned for the next IoT tutorial which will demonstrate how to control a fan using IoT via your smartphone as well.


Furthermore, check my previous 2 IoT blogs:

I hope you enjoyed this IoT Arduino Light Control. And for any questions or even opinions about it please don’t hesitate to leave your comments down below 🙂

Related Blogs

Arduino Robotics

Arduino Robotics Series, from a car to a robot arm

Arduino keeps standing out from the crowd of all-around development boards due too its ease of use and budget price. As a result, this has enabled almost anyone to get his own idea into life no matter how crazy or even useless to the whole world it was, except for its maker! Also, it has …

Arduino Robot Arm

How to build an Arduino Robot Arm placed on RC Car

Arduino robots are always funny and definitely more enjoyable when combined with robotic arm! And today, I will walk you through the making of a simple Arduino Robot Arm that’s made of cardboard and how you can attach it over your Arduino Bluetooth RC Car / Robot that you have made so far through this series. …

Arduino Line Following Robot

How to build an Arduino Line Following Robot using Cardboard

Arduino Line Following Robot is one of the easiest and most well-known projects that anyone can make to learn the basics of programming, electronics, and mechanics all in one project. It’s known that this project is common for most of the makers and tech students and today I am going to give it a revisit …

Arduino Obstacle Avoiding Robot

How to build an Arduino Obstacle Avoiding Robot using Cardboard

Back again with another Arduino Bluetooth RC Car tutorial but with an advanced feature that makes your car autonomous by adding ultrasonic sensors to the RC Car you have made before!. Yeah, I know that you may have seen other tutorials using ultrasonic to make the car/robot avoid obstacles ahead, but I am going to …

Arduino Bluetooth RC car

How to make an Arduino Bluetooth RC Car using Cardboard

  Cardboard crafts are one of the most popular and easy to make DIY stuff. Mixing this with the unmatchable enjoyment of RC Cars and the ease of using Arduino, I am going to show you how to make a Cardboard Arduino Bluetooth RC car that you can control via Bluetooth from your smartphone.  …

Arduino Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …