Only the list of sensors are supported.You need not write any code separately for sensors.Just connect the Sensor and configure on Dash board. Display or control it from DOMOTICZ over HTTP or MQTT protocols.
Download the MEGA version of ESP EASY.
Under dist folder Flasher application is provided.Double click on that.
Select the COM port where Nodemcu is connected.
Before selecting a .bin firmware file click on the update button.
Latest .bin files will be downloaded from Github repository.
Select the relevant .bin file for your hardware.Here I’m selecting ESP8266 4MB version, as my hardware is NODEMCU with 4096 flash memory.
Test beta version supports Nextion display hardware.
Setting of WIFI & fixed IP can be done later. For now Flash ESP EASY.
It takes approx 2 minutes to upload.
Once uploaded , close the flasher and reset Nodemcu.
It starts in AP mode and the WI FI access point name is ESP_EASY.
Connect your PC to this AP using password configesp
When a fresh ESP Easy module boots up, it has no Wifi config and it will start as an Access Point.
Use a Wifi enabled device (Laptop, Smartphone,..) to search for Wifi access and try to find an access point with the name ESP_Easy.
Connect to this access point with default password:
configesp
Once connected , open your browser and type in ip address 192.168.4.1
You should get a welcome screen:
Select your SSID and provide password.Click on CONNECT .
Now your NodeMcu connects with your SSID.
If the connection succeeded, you will see a screen, listing it’s new local IP address.
You can now reconnect your laptop or other device back to your private Wifi network.
Then click the “proceed” link to contact the ESP module on it’s private IP address:
ESP EASY Nodemcu is offered an IP ADDRESS by your Router.
Use this address on a browser to access the DASHBOARD of ESP EASY.
Under MAIN tab is the SYSTEM INFO.
Click on CONFIG tab.
Here you can change the AP password from configesp , if you need.
At the bottom is the IP Settings.
You can provide an IP address to make it STATIC.
The IP Address must be in the range of your Gateway IP.
Gateway IP is the IP of your ROUTER.When any client connects with the Router , it provides an IP address by its DHCP method.This IP will be in range of Gateway IP , only the last octet changes.
Finally click SUBMIT to effect changes.
Next tab is CONTROLLERS tab.
Under this you select a PROTOCOL .
HTTP,MQTT,UDP all are supported.
In this demo we control an LED from browser commands.So select STANDALONE.
Under HARDWARE tab you can set any GPIO pin to be High or Low on Boot up.
It is not needed in this demo , so we move on to next tab DEVICES.
Click on ADD from the list of devices.
Select SWITCH INPUT – SWITCH from the drop down.
Provide a name , like LED and then click the ENABLED .
Under GPIO , select GPIO 12 (D6) where we’ve connected an LED.
Click on SUBMIT.
Now from your browser use this command to control LED.
Instead of GPIO you can use PWM to control brightness of LED.
Previous post was on controlling home devices using BLYNK CLOUD.
Instead of controlling manually we can use voice commands to operate devices.For this we use the GOOGLE ASSISTANT on mobile phone.
Google assistant cannot directly communicate with BLYNK. For making a chain link between Google assistant and Blynk we use IFTTT.
If This Then That, also known as IFTTT, is a free web-based service to create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram,etc.
In this project we make use of WEBHOOKS on IFTTT to handle a web service , which is BLYNK.
The hardware setup is same as in previous post.
Create a new project on BLYNK.
Get the Authorized Token ID.
Create 2 button widgets , one for fan control and the other for light control.
Fan to be connected at digital pin D2 through relay board.
Light connected to digital pin D4 through relay board.
Once the settings on BLYNK application is completed we can close it.Need not be operated manually.
We shall use IFTTT to make a chain between Google assistant and Blynk.
Open IFTTT
Click on CREATE.
You see a + symbol before THIS.
Click on that.
Choose a service ,GOOGLE ASSISTANT
Choose a method to trigger , Say a simple phrase.
Next page is to complete trigger fields with options like what you want to say & what Google Assistant should reply.
Complete the fields for FAN ON control as shown below & click Create Trigger
Now you can see the GOOGLE ASSISTANT Logo at the THIS position.
Click on the + symbol before THAT
Search for WEBHOOKS and select it.
Then click on “ Make a WEB REQUEST”.
On next page you’ve to complete action fields.
Under URL, you need to provide the IP address of blynk-cloud.com
This can be achieved by opening Command prompt &
ping blynk-cloud.com
URL Format is
http://IP of blynk-cloud/auth id/update/digital pin
Authorized ID is the one you received in mail while creating your BLYNK project.
The digital pin to be controlled is that of Arduino. As we use NODEMCU hardware , check the pin out as below to select the correct digital pin.
For e,g we used D2 to connect Fan control.In NODEMCU pinout D2 is GPIO4 , so you need to input D4 .
Method to be selected is PUT
content type is : application/json
& the body is [“0”]
A 0 within double quotes & square brackets used to switch on the relay.As the 4 channel relay board we used is a LOW enabled ( LOW at input switches ON the relay) we need to feed 0 for ON.
Now the first APPLET is created and Connected.
Click on FINISH.
In the same way we need to create 3 more Applets for FAN OFF,LIGHT ON & LIGHT OFF.
Note that in Body you should send a 1 under double quotes & square brackets for switching OFF the relay.
Finally click on your account & MY APPLETS to see the applets you created.
Now open your Arduino IDE & under examples –> BLYNK –> BOARDS WIFI –> NODEMCU
Do the following modifications in code & upload to NODEMCU.
Finally install GOOGLE ASSISTANT from play store on your mobilr & open.
GOOGLE ASSISTANT will be running at the background.
You need to say OK GOOGLE or HEY GOOGLE to start the interaction.
Following is the screen shot on the commands given and the response from Google Assistant
In the previous post , we worked on a home automation project and Android mobile application & controlled devices locally .ie., over Local Area Network.
In this post we will see how to make the home automation project to control from anywhere in the world. IOT CLOUD Platform BLYNK is used for implementing this.BLYNK is the most popular IoT platform to connect your devices to the cloud,
BLYNK is a digital dashboard where you can build a graphic interface for your project by simply dragging and dropping widgets.It supports a wide range of Hardware including Arduino,Nodemcu,Raspberry PI & others.
First install BLYNK on your mobile phone by signing up with your EMAIL ID.
Open BLYNK application.Touch on NEW PROJECT.
Provide a name to the project & select hardware.Here Im using NODEMCU.
Connection type is WIFI .
Touch on CREATE button.
An authorized token ID will be sent to your registered EMAIL.
Now we shall see the WIDGET BOX to add some elements.Each element of WIDGET BOX has got an ENERGY LEVEL.
While starting up you will be provided a free energy level of 2000.According to the usage of widgets this energy level will be deducted.
For e.g , add a BUTTON to your project.
An energy level of 200 will be deducted.If you want you can BUY Energy level by touching on the ADD button.
Add 2 buttons as shown below.
To set the properties of first button , touch on that button.
Provide a name to the button 1.
Touch on PIN to select pin.As we control a dc fan through relay board which is connected to D2 of Nodemcu , select DIGITAL PIN D2.
There are also VIRTUAL PINS Upto 255 , which are specific to BLYNK firmware. These virtual pins are NOT Physical pins , but are handy to send data or message to them and then control physical pins from within code.
Slide the MODE setting to SWITCH which makes the button at as ON or OFF.
Similarly for the Button 2 set the PIN to digital D4 where we control an AC load through the relay board.
Now touch on the Back arrow to go to the start up page.
On touching the PLAY Icon , a message indication stating Not yet online is displayed.As we are yet to upload code on to Nodemcu , the setting is OFF line for now,
From your PC side , open the Arduino IDE.
For setting NODEMCU to Arduino core ,open File & under Preferences paste this json link
Then open Tools –> Boards Manager , search for ESP8266 & install.
Also from Sketch – > Manage Libraries –> Library
search fro BLYNK & install the library.
Once the library is installed you can see under Examples —> Blynk
Open the NodemCU Example code.
You need to replace with your Authorized token ID which you received in Email while creating the Blynk project.
Provide your WiFi credentials ,SSID & password of Router to which Nodemcu will be connected.
Also under setup() make the digital pins D2 & D4 HIGH.
This step is to make the loads connected to relays initially OFF.
As the relay board we are using is a LOW ENABLED , a LOW at input energizes the Relay and a HIGH makes it OFF.
We make use of MB102 PSU board on a MB102 bread board.This MB102 board has got jumper settings to make one rail as 5v & the other rail as 3.3v.
A jumper seen at he relay board can be removed.
Connect Vcc to 3.3v & JD-Vcc to 5v rail of bread board.
The loads can be connected as shown below.Always connect the power source on which the load operates to the POLE pin.Actual load is connected to Normally Open contact.
Connect NODEMCU to PC , from ARDUINO IDE select the board as NODEMCU & select the port allotted.For this you must have already installed driver for CP2102.
Upload the code & then disconnect USB cable.
Provide 12v 1amp or 9v 1amp adapter to MB102 PSU board.
Allow some time for NODEMCU to join the SSID mentioned in the code.
While using AC load ,take care not to touch the relay board and insulate properly the relay board inside a plastic box.
Now open the BLYNK Application and touch on the project you created.On top right corner touch on the PLAY Icon.
Once you see ONLINE indication , you can touch on the buttons created to control the loads.
upload the above code and open the serial monitor to note the IP address allotted to NodeMCU.
Note that all devices NODEMCU ,PC & mobile are connected to same Router.
The IP address allotted is DYNAMIC ,meaning , it may change on next power up.
To make it STATIC , you can set Address Reservation setting under Routers settings.
Once the IP is allotted , open up the WEB browser and type in IP/fanon
for e.g 192.168.1.107/fanon
Initially both the LEDs will be ON .As we will use a LOW enabled input Relay board, these LEDs are made ON indicating the devices are OFF initially.
On sending the string fanon from browser , the RED LED will go OFF.
On sending 192.168.1.107/lightoff , the Green LED will go off.
Similarly fanoff string will make Red LED ON , lightoff string will make Green LED ON.
Now the code is working perfectly, we shall replace the LEDs with actual devices to be controlled.
A 4 channel 5 volt Relay module is used to connect the actual devices .We use a DC FAN 5v at relay contact 1 and a CFL bulb AC at RELAY 4
For power source a MB102 PSU board is used on MB102 Bread board.This board can be easily plugged on to MB102 Breadboard and has jumpers.One jumper (top) is set to 5v and the bottom jumper set to 3.3v.
An external adapter of 9v 1amp is used .
Connect IN1 of relay board to D2 of NODEMCU
IN4 to D4, GND to GND.
While connecting Load to relay board, always connect the power to load at POLE.
Actual Load is connected to NO Normally Open pin of relay contact.
While handling AC loads, take precaution to insulate relay board within a plastic box and do not touch the relay board.
It is safer to connect Neutral to POLE and AC Phase to other end of Load.
Also remove the jumper on relay board.
Connect 3.3v to Vcc and 5v to JD-Vcc
This enables error free operation , as the NODEMCU is a 3.3v device.
Now let us develop our Android Mobile Application using on line MIT APP INVENTOR.
Click on Start a New project and provide a Project name. Space and Hyphen not alloed in name , but underscore allowed.
You will be presented with development screen which has 4 columns.
1st Column is Palette with all User Interfaces and components to build the App.
2nd Column is the actual Screen viewer.
3rd Column displays all the selected Components.
4th Column shows the Properties of the selected Components.
From LAYOUT drag and drop a HORIZONTAL ARRANGEMENT
Set the Height under properties to 10 percent , Width TO FILL PARENT
This is to provide space at top of screen.
Then drag and drop LABEL from User Interface
Set Width TO FILL PARENT , Text to Heading of App. , alignment center ,Fontsize to 25
and background color to yellow.
Next drag and drop TABLE ARRANGEMENT from LAYOUT.
Set properties , COLUMNS to 3 and ROWS to 2, Width to FILL PARENT, Height to Automatic.
2 Rows required for 2 device control.
3 columns for image , on button and off button.
Drag and drop an IMAGE component from User Interface.
Under Properties set the Height to 15 percent, Width to 30 percent.
Under Picture property click Upload File and select the image to upload.
Now drag and drop 2 buttons next to image 1.
Drag and drop another IMAGE component, below the first imge.
Set properties accordingly and upload the second image.
Drag and drop 2 more buttons as shown below.
Select the properties of Buttons
You need to change the Text and the background COLOR.
Next drag and drop a WEB component from CONNECTIVITY.
As this one is a Non Visible component , it will show up at the bottom of the screen.
Now click on the BLOCKS button at the right top corner.
Select Button1 from the left side Blocks.
You will see a list of options.
Select the When..Do ..Button..Click block.
Next click on WEB .
Select the set..web1..url..to block
Third block to select is under TEXT
Select an empty Text block for text.
Finally from WEB
select call..web..get block.
Following are the blocks we selected.
Assemble the blocks as shown.Just drag and fix at the connecting points.
IOT is Internet Of Things where devices are connected over internet and made SMART.
These devices can be controlled from any where in the World or collect data from devices to process.
In this 1st post of IOT series I will introduce the hardware required to start with and also the IOT platforms used.
Arduino boards are much popular among hobbyists and developers.But these Arduino boards (UNO,MEGA) lack Ethernet or WIFI capability which is essential for IOT.
For wired connection there is ETHERNET Shield which can be plugged on directly to UNO or Mega.
For internet access I’m using a Huawei make USB Dongle with a Data SIM inserted.This dongle
can be used in standalone mode , as it has got WIFI capability.But plugging this to a Router
like TP-LINK enhances its capability of WIFI Range, more Clients, Static IP setting,etc..
The Ethernet shield can be plugged on to Arduino and an Ethernet cable (straight type)
can be used to connect with the Router.
The Router will then allot an IP Address (local IP) to the ethernet shield which is now a client.
DHCP server of Router allots the IP on first come first basis.As this IP is DYNAMIC ,
the address may not be the same if powered off and connected again.’’
To make the IP address STATIC , the ROUTER has ADDRESS RESERVATION settings
under DHCP.
MAC address of the device is used to make the local IP STATIC.
Instead of wired Ethernet connection you can go for WIFI Devices. ESP8266 WIFI modules are
cheap and popular now.
ESP8266 WIFI modules , a wide range available.ESP8266-01 module is basic model .As it is not breadboard friendly , you can make use of a base board to plug on , as shown in picture below.
ESP8266-12E module has more GPIO pins and memory.
These modules can communicate with ARDUINO using AT COMMANDS for ESP.
To use ESP modules we need a controller like Arduino.
Easier option is to use NODEMCU Modules.These NODEMCU modules are built on ESP12E chip
and has USB to upload code.LUA is the official Firmware that comes with NODEMCU.
Using BOARDS MANAGER in Arduino IDE you can implement ARDUINO CORE on to NODEMCU
and start using NODEMCU individually.
You can check out my video on how to implement Arduino core on to NODEMCU.
Once Arduino core implemented , you can use Arduino IDE and libraries to develop code on NODEMCU.
Latest arrival is ESP32 which is much more powerful than NODEMCU with more Analog pins
and with BLUETOOTH,BLE and inbuilt sensors.
For IOT and HOME AUTOMATION projects RELAY BOARDS are helpful to connect wide
range of Loads or devices.
5V Relay boards are available with 1 channel , 2, 4,8 Upto 16 channels .
Each relay is driven by an opto coupler and a NPN transistor.The relay contacts are
provided as Terminal connectors.
Each Relay has a common POLE, a NC –Normally Connected contact and a
NO – Normally Open contact.
These 5V relay boards are LOW ENBLED, meaning , a LOW at input will energize the Relay.
A low at input will make the opto coupler conduct which drives the NPN Transistor.
This in turn will switch ON the relay.
Electronic solid state relay boards are also available which are called SSR.
12v Relay modules also are available.Here the relay is driven by a NPN transistor .12V Modules are HIGH ENABLED ,meaning, a HIGH at input drives the relay ON.
Any load ,DC or AC can be connected to the RELAY contacts, irrespective of the supply voltage to relay board.
The power supply to load is connected to POLE pin and the actual load is connected to the NO pin.
As the relay is energized the pole pin changes from NC to NO ,thus activating the Load.
While using AC load take precaution to insulate properly the wires as well as the Relay boar.Do not touch relay board with AC load.
You can control the devices over Local Area Network or through Cloud or internet.
While using LAN , make sure that the NODEMCU and your mobile , both are connected to the same Router SSID.
For control over internet you need to PORT FORWARD the local ip device port on the router settings.But nowadays a number of IOT PLATFORMS are available as CLOUD. Though you need a paid subscription , most of them offer free service for hobbyists with some limitations.
BLYNK, CAYENNE, THINGSBOARD are some popular IOT PLATFORMS.
Sign in to any of these platforms and start controlling the devices from anywhere in the world.