Introduction: Wireless MOOD Light With Arduino & BLYNK App
BLYNK APP tutorial Series, No coding, Shield free
In this tutorial we will be creating a MOOD (you can create any color you can imagine to fit your mood) light, that can be controlled from your smartphone, we will be creating the APP too (NO ANDROID APP CODING required)
It can be operated from your local network (NO INTERNET needed) well you can basically extend it to make it controllable from the web but I will be teaching you how to install a local SERVER to handle everything, and the most interesting part of this project is , even if you are very new to ARDUINO and only have the ARDUINO board , and don’t have any BLUETOOTH module or WIFI shield , It really doesn’t matter …we will help you extend your LAPTOPS WIFI card to talk SERIALLY to the ARDUINO ,yes guys …we are making it as SIMPLE and SILLY as possible , well it isn’t SILLY ,as it give a SMART HOME feeling :)
Step 1: Gathering the Stuffs ( REQUIREMENTS)
3 LEDs (RED, GREEN, BLUE)
3 RESISTORS (100 Ohms)
JUMPER WIRES
BREADBOARD
ARDUINO (UNO will do) and obviously that creepy Arduino cable
SMARTPHONE (Android)
ROUTER (optional)
A LAPTOP with WIRELESS CAPABILITY (except a laptop or mainframe from the 80’s)
Step 2: Assembling the ELECTRONICS:-
Back to the basics:
Well, I think it would be really silly to tell people what a breadboard does and how to select the resistor values. Still repeating, breadboard makes us hassle free from an interesting stuff which we call SOLDERING (involves SMOKES, METALS n WIRES oh yeah!!!) And to select the RESISTOR values we have to use simple maths:
OUTPUT voltage from ARDUINO pin: 5V
OUTPUT current from ARDUINO pin: 40mA = (.04 Amperes)
But typical LEDs generally require less current and voltage which is (1.7 to 2 volts and 35 mA)
R = (V/I) ; Resistance = (Voltage/Current)
We need to drop 5V to 2V and want to make the current 35mA so,
R = ((V1-V2)/ I) ; R=((5-2)/.035))
So R becomes 85.7 OHMS
You won’t find a RESISTOR with 85.7 Ohms so the nearest standard value is 100 Ohms. But from a little electronics experience I say we may use any RESISTOR between 100-500 Ohms.
We start by connecting the resistance, the LED and then the jumper wires to the ARDUINO, first for the red LED, and then for the green and blue LED. We have to connect the wires to Digital pin 9, 10, 11 in Arduino, and why we should do so, I will explain in a while.
Color Mania:
So why choose RED GREEN and BLUE, Why not Yellow, white or
whatever (umm ORANGE, oh it’s a fruit too). The RGB is a color mode. Which uses the Red, Green, Blue variations to create colors.Our TV and the screen in which you are reading this uses RGB to color up the pixels.
Adjusting Brightness with ARDUINO:
We will use PULSE WIDTH MODULATION ( PWM )to control the LED
brightness , so we have to choose the ARDUINO pins carefully , The Arduino pins with the ~ ( tilde ) symbol supports PWM ,that’s the main reason we have to choose digital pins 9,10,11. Now let us wire up with the ARDUINO.
Now the brightness can be adjusted using PWM duty cycles. So
a 100% duty cycle parameter value is stored in a byte which equals 8 bits so we can fit in 0 or 1 , so the 2 values in 8 boxes makes up 2^8 = 256 or [0 – 255] combinations , the RGB , LED can thus produce 256 x 256 x 256 = 16,777,216 colors to be exact . So PWM with 100% duty cycle makes the LED brightest and the 50% duty cycle makes the LED 50% of its total brightness. Enough of the boring theory.
Step 3: Installing the BLYNK Local Server
Now that we have ended up creating our lamp we need to make it talk over the WI-Fi and create an APP to control it .We start by hosting the BLYNK local server, now BLYNK is an awesome piece of project recently featured in KICKSTARTER it helps creating apps for development board like ARDUINO a breeze, which can be controlled over Ethernet, Wi-Fi or the BLE (Bluetooth low energy) enabled devices.
So I started to tinker a bit and found out we can also use the ARDUINO USB cable to talk SERIALLY with the BLYNK server, so that we don’t have to connect any shields.
Now, I will be using a laptop with Windows to configure the BLYNK server locally in my network, So from this point we can either use a ROUTER if we want to make this prominent and want to attach more devices to the network later, else we can use the Android smartphone’s MOBILE HOTSPOT capability to create the SMART_HOME network.
I will be using a Router for this tutorial, Configure your router and connect it with both your smartphone & laptop
Or else
You can use MOBILE HOTSPOT: (no ROUTER needed)
The main plan is to keep the laptop and smartphone in same network. Whether it’s mobile HOTSPOT based or a WIFI network.
After connecting our laptop and smartphone (in my case a router and a smartphone) to the local network. Let’s find out the IP address of our laptop in which we will be hosting our BLYNK LOCAL SERVER.
Open cmd
And TYPE: ipconfig
(in my case 192.168.0.100)
So , in this example my laptop runs Windows , (you can find installation guide of Blynk server for other OS and even Raspberry PIhere )now make sure your Laptop has JAVA 8 installed else google it and install it .You can verify the version from CMD. (hit Windows + R button and type cmd to run it )
Type in :
TYPE : java –version
OUTPUT: java version “1.8.0_60”
I have provided all the screenshots for a better illustration.
Downloading the Blynk SERVER:
After you have installed and verified JAVA version. Next you have to download the BLYNK server .You can either download it from GitHub but, since you makers, hackers and tinkerers are the best I have made it super easy by adding some more files to make it more efficient.
You can find the file bundle HERE.
Now extract it (BLYNKserver folder) and keep it in DESKTOP or anywhere you like, navigate to the directory using cd (CHANGE DIRECTORY command)
And type in: java -jar server-0.16.2.jar
If you have done everything nicely you should be able to see a screen like picture 6 in screenshot
(You can also start the BLYNK server by opening the start-bynk.bat file which I have provided for a one click start)
Now, don’t close the command Prompt instance else it will shut the SERVER down.Open up any modern WEB BROWSER and
Type in:
You will get a warning (depending on your browser) in my case FIREFOX I get a warning, but skip this by adding an exception, you should now be inside the ADMIN panel of the BLYNK server feel free to explore it, and in the meantime let’s flash our ARDUINO and create the APP.
Step 4: Configuring the App
Download the BLYNK app from Google Play store.
The link is HERE
Well, first you need to create an ACCOUNT and then register it to your local server. You need an Internet connection to create the account and verify it to your local SERVER after that you don’t need any Internet to LOG IN to your server
STEP 1: Open the BLYNK app with Smartphone having Internet, log in with a valid Email ID to register the account, and then LOG OUT
STEP 2:Now , comes the tricky part in order to register that valid email
in your local BLYNK server you need to be in the SMART_HOME network , now recall the Laptop’s IP address and tap the ICON near the login where it says (Problem signing in?) with a Traffic light type of icon
Enter the IP where your server is running, keep the Port to 8443.Now that your local server has registered your ACCOUNT from the Internet , you will be able to sign in easily.Give it a try disconnect the Internet and try to sign in from your local network and you will be able to do so .After signing in to your LOCAL server ,Tap on Create new project
STEP 3: Now, most important you need to note down the AUTH TOKEN, and hit create.
STEP 4.Swipe, from the left to bring up the Widget Box, add the Slider L (which will be used to adjust LED brightness).
STEP 5:Adjust the slider setting ,give it a NAME , change the slider COLOR ,most important the PIN to D9 (digital 9 ) and to get a better effect toggle the SEND ON RELEASE to OFF, repeat this for Green and blue and don’t forget to change the pins to D10 and D11.We are now completed with the APP.
Step 5: Light E'm UP
For the final setup we will be configuring the Arduino and downloading the Blynk library for Arduino
Open up the ARDUINO IDE (code editor), If you don’t have the Blynk library I will give you a quick trip, to install the library , the most easy way is to download the library is from the Library manager provided by the Arduino IDE. Open up the Arduino IDE, click on the Sketch menu > Include Library > Manage Libraries. Type “Blynk” in search box and install it.(You need INTERNET to download the library )
After installing the library you should now be able to open up this sketch
Files > Examples > Blynk > Board_USB_Serial > Arduino_serial_USB
Now , paste the Authentication token (AUTH TOKEN) which was noted down while creating the app , in case you have lost it you can view it from the app like this (By taping the Hex like icon )
After updating the AUTH TOKEN In the sketch, wait a while and connect the circuit with your Arduino, Check the connections, verify the sketch and upload it. We now have to tell our Arduino to talk with the laptop and what is the Server IP to do this navigate to your users folder where the Blynk library has been installed , if you can’t figure it out there’s a little trick.
Open the TAB with the Arduino_serial_USB sketch. Sketch > Show sketch Folder. After you have found the library location .
In my case :
C:\Users\Zymon\Documents\Arduino\libraries\Blynk\examples\Boards_USB_Serial\Arduino_Serial_USB
Open the Blynk library folder, and navigate to scripts:
C:\Users\Zymon\Documents\Arduino\libraries\Blynk\scripts
Note this location, and now open up the BLYNKserver folder which I created , and had the Blynk server .jar file (in case you haven’t downloaded it find It HERE)
Make the Arduino listen:
Edit the server_connect_SERIAL.bat file It should have 2 lines of code:
cd C:\Users\Zymon\Documents\Arduino\libraries\Blynk\scripts
blynk-ser.bat -c COM8 -s 192.168.0.100
Edit the location of your Blynk script folder, edit the –c parameter for the COM port where your Arduino is connected, to find it out you may see the Arduino IDE or open up device manager from control panel
Ex: edit it like COM4 or COM6 not like COM 6 (with a space in between)
-s parameter is the IP of your Local Blynk server (Laptops IP) in my case 192.168.0.100 edit this to your IP.After editing this file save it. With the SERVER running Arduino connected and code uploaded, run the server_connect_SERIAL.bat file. If you have done everything right you should see a screen like the screenshot shown above.
Step 6: Testing the App in Action:
Now open up Blynk app in your smartphone while connected to the SMART_HOME network .Now LOG IN (no Internet needed). You should be able to see your saved MOOD LAMP project.
Tap on the PLAY (small triangular) icon on the top right corner of your phone to test the APP ,adjust the sliders to see the LEDs in action, if it’s not glowing Check the AUTH TOKEN ,and backtrack any mistake in COM ports or IP etc.
Well we have finally made an APP which let the LEDs glow using Wi-Fi requires no Internet and no special circuitry and shields but , why isn’t the RGB theory of making and mixing colors working well , why can’t we create YELLOW by adjusting our sliders to 255 on RED and GREEN , because we need to MIX those lights well, to tackle this we need a diffused white plastic material , papers work too , it may be a White ping pong ball or White old camera film container or a paper cube . Gladly I found an unemployed white PLASTIC cone for this job.
Now by diffusing the Lights and keeping Red and Green to 255 we get a pure Yellow like this the one shown in the 2nd picture.By adjusting the sliders a little bit I got some more vibrant colors.
.
.Congratulation guys, hope you liked it. This is my first POST in Instructables, I had been a maker for 5 years and a daily visitor of instructables but couldn’t find time to write one and share with you.
Thanks for reading till the end, the idea was originally developed by my younger brother, plz plz plz write a comment and some feedback which would help me to write more tutorials in the future and encourage me.
Where’s next, Taking it further:
I had some plans to extend this project but didn’t have plenty of time, some of the ideas are
1. Make this accessible from web using PORT FORWARDING or the Blynk CLOUD
2. Using more LEDs, or some concave reflectors to make a color changing ROOF.
3. Adding more widgets in the App
Plz post your ideas, I would be very happy to listen from you and up to where you can extend this idea, See you next time.