Smart Lighting Solution With Fedora 22 And Arduino

Internet of Things is a very new thing to us but when we think of it, we had access to the internet for a long amount of time and we come across these "things" inour  day to day life, and they have been making our lives easier each day.

Let's say for example a light bulb, it consumes energy and produces light which helps us everyday. Technology and improvements have stripped down the consumption of resource to a bare minimum and optimized the output. Now we have a era where the mobile industry and teleco industry are booming and the speed of the internet is unimaginable. Hence, we have  the idea of making things smarter by connecting them to the internet and analyzing petabytes of historical and real-time data and automating their operation.This will result in a smarter way of living. IoT affects almost all the major areas of the industry: Agriculture, Healthcare, Home Automation and many more.

This post is POC of how easy it is to smartly control light on an Arduino without Ethernet shield but over HTTP. The idea is to let you control a bulb or series of lights in your house with the tap from an application with a proper internet connection of course.

Things you will need:

  1. Arduino UNO with its USB.
  2. Arduino IDE (get it here).
  3. Smooth internet connection to the system.
  4. Root or su access to the dev machine.
  5. node.js
  6. jonnyfive and narf

Arduino UNO which I am going to use is a micro controller much like the name says, I will use it to control a light. To keep this very simple and keeping the entry barrier low, I will be using the Pin13 of my arduino itself which has a LED and won't be using any ethernet of wifi shield.

Setting up the system:

Arduino IDE : $ sudo dnf install arduino

Once installed, make sure that you plug in your arduino and check out that your system is detecting it.

cmd

Just after inserting in USB to the system , type in " $ dmesg | tail " in your terminal. It will return you with where your Arduino is hooked up. Once you have it here, we should move ahead and set up to communication protocol.

Setting up jonny-five

  • Plug in your Arduino or Arduino compatible microcontroller via USB

  • Open the Arduino IDE, select: File > Examples > Firmata > StandardFirmata

    a. StandardFirmata is available in Firmata v2.5.0 or greater

  • Click the "Upload" button.

If the upload was successful, the board is now prepared and you can close the Arduino IDE.

board

Setting up project folderCreate any folder and copy paste the two files in the folder.

  1. index.html[1]
  2. LED_Server.js[2]

Setting up node.js

You need to go inside your project folder and making sure that you are in su, type in $ dnf install npm nodejs.

Once you are done, you can go ahead and set up the jonnyfive and narf.

$ npm install narf jonny-five

If you get it done with out any error, you can find your server successfully running at

http://127.0.0.1:8079/index.html

After you execute $ node LED_Server.js

If, you are getting an serial port not found error execute

$ npm install serialport

cmd

When done you can find the following screen after execution of, 

$node LED_Server.js

js

The Webpage

page

Now, you can turn on and turn off Pin 13 from this webpage. Best possible use case can be, you forgetting to turn off the lights of your room and you are out on a vacation. This smart solution will let you control your lights from any part of the world!

Since this is a proof of concept, here is how it looks in action: 

This youtube video proves the functionality.

Up Next
    Ebook Download
    View all
    Learn
    View all