IoT (Internet of Things) is a hot buzz around the world since last few years and lot of companies are entering this business. Although this concept has suddenly evolved in past few years, but this is not a new concept. Earlier this was limited to industries, now what is new is that we want to connect everything around us to internet, may it be your fridge, washing machine, microwave ovens, toaster, your car, bike or even each lighting bulb. CISCO calls this as “Internet of Everything (IoE)” and it is expected to have 50 billion devices will be connected to internet by 2020. Considering this, we can expect that in future almost everything may come with a unique IP address that can be connected to internet/your home wi-fi router and data can be pulled from each device thru connected sensors over internet at a remote location and remotely we can provide commands to actuators for performing some action at site.
With IPv4 there was limitation but with IPv6 in place we can have 2^128 different devices with unique IP. Today we have so many different service providers who are offering good bandwidth at lower prices. Smaller batteries can power devices for longer time and we have multiple sensors available to measure the physical parameters around us, hence above concept is easier to implement today. Here I have explained how to make a home automation system where we can measure temperature, relative humidity & light intensity and see it remotely on web, sitting anywhere in the world. At the same time, we can switch ON or switch OFF lights and fans or whatever devices connected to this device.
This article was also published in Electronics for You magazine in 2019 which is available here.
You can also download the “Cayenne” app from “Google Play Store”, login with same credentials and start controlling the things from anywhere over the internet.
Circuit Description:
It has two
input channels, one is analog input to measure light intensity thru LDR and
second one is digital input to read value of temperature and relative humidity
thru DHT11 sensor. For measuring wider range of temperature and humidity we can
replace it with DHT22 and in code also, we need to replace the word ‘DHT11’
with ‘DHT22’. Table below shows basic comparison of DHT11 and DHT22. Rest all
specs including pin configuration, is same.
Here we
have used NodeMCU V1.0/ESP8266 (ESP12) having 11 GPIO pins and 01 ADC input
with 10bit resolution. It has inbuilt 3.3V voltage regulator and CP2102 based
USB to serial converter which give easy interface with PC for loading the
Arduino code.
NodeMCU is
plugged into 30Pin (2X15) female header, and rest of the components around it
are wired on the general-purpose PCB.
LDR1 is
used to sense the intensity of light around it which is displayed as percentage
on Cayenne dashboard. This is connected to A0 pin of module to read analog
voltage being generated based on ambient light.
DHT11
sensor is used here to read the ambient temperature and relative humidity thru
digital I/O pin D5 (GPIO14). This sensor has capability to split the data for
temperature and relative humidity and send one by one thru same output pin.
Two 12V
relays are used here which are driven thru 2N2222 transistor and can drive any load thru terminal headers connected to
it as per relay rating.
Similar
relay switches can further be added to the module depending on available I/O
pins and your requirements.
Software Coding:
The
software is written in easy to use Arduino platform which allows us to write
the code in few lines and make the device communicate with Cayenne platform
when connected to internet thru any access point or wi-fi router.
To add
board manager for ESP8266 GotoÃ
File Ã
Preferences Ã
Paste below link in “Additional board Manager URL:”
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Open Boards
Manager from Tools > Board menu and install esp8266 platform (and
don't forget to select your ESP8266 board from Tools > Board menu after
installation).
For
programming the NodeMCU module, we need three unique identities from Cayenne
web site, i.e. “MQTT user name”, “MQTT password” & “Client ID”. Whenever
the device is connected on network, these IDs help Cayenne website to find the
device and start communicating with it.
Other IDs
required are your wi-fi “SSID” and “password” if any, to connect with local wi-fi
network. Before compiling and loading the code to NodeMCU module, two libraries
are supposed to be installed as described below.
Download required
libraries from below link:
https://github.com/myDevicesIoT/Cayenne-MQTT-ESP
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library
Arduino Code:
Building Dashboard on Cayenne Website:
Open the
website https://mydevices.com
and click on login on right top.
From the pop-up select “Cayenne” login. Create an account thru “Register” link below login button.
Click
“Bring Your Own Thing”, next page will give you three unique strings.
1- MQTT
Username
2- MQTT
Password
3- Client
ID
Page will
wait here to connect with the device on network.
Copy these
strings and paste at appropriate fields in arduino code. And load the code in
NodeMCU module thru USB cable.
Once the module is connected to Wi-fi, the web page will move to next screen. Here your device will be given a unique name, which can be changed thru “Settings” icon on right top.
Turn OFF the device, and
proceed for configuring buttons to control two relays.
Go to
“Settings” of Channel 3 & 4 and delete them, using “Remove” button.
Now Click
on “Add New” --> “Device/Widget”
Select
“Custom Widgets” --> Click on “Button”, fill the required data as below and Click on “Add Widget”.
Similarly repeat the steps for channel 4, as shown below.
Final dashboard will look as below. Now you are ready to control the two relays attached to channel 3 and 4. And collect Luminosity, temperature and humidity level of place where your device is located.
Enjoy your first IoT project. You can also download the "Cayenne" app from Google play store and login with same credentials. All your configured devices will display there. You can control from there also, rather than going to web page.
Return to List of content Return to DIY Project List
4 Comments
Keep It Up Sir & Contact Us For
ReplyDeleteAutomatic Voltage Stabilizer Manufacturers
Voltage Stabilizer Manufacturers
Servo Voltage Stabilizer Manufacturers
Servo Controlled Voltage Stabilizer
This comment has been removed by the author.
ReplyDeleteAwesome! Information. Great work thank you for sharing such useful information. keep it up all the best.
ReplyDeleteThanks for Sharing!!
ReplyDeleteGeorge Stevens Manufacturing has been a global leader in designing and building innovative winding machines since 1943. A range of coil and transformer winding machines is ideal for semiautomatic machines.