Category: IOT


For HOME AUTOMATION project we use a 4 channel Relay board of 5v Relays.

This is LOW enabled , a LOW at input makes the RELAY ON.

So on start up these input pins must be pulled HIGH.

NodeMCU is loaded with ESPEASY FIRMWARE . You can check this post on how to load.

The Relay board requires a separate power source of 5 volt.

The GND of 5v supply to be made common with the GND of Nodemcu.

RELAY BOARD   NODEMCU

IN1     ——- GPIO 16

IN2     ——- GPIO 14

IN3    ——- GPIO 12

IN4    ——- GPIO 13

 

 

hat

 

DOMOTICZ Service is running on Raspberry PI which is on the same LAN as my PC.

The Domoticz server is accessed by typing in the RPI’s IP address followed by port no. 8080

192.168.0.150:8080

Click on Setup – > Hardware and create Type DUMMY for Relay 1 , name it as RL1.Click ADD

Same way create 3 more Type Dummy for other 3 Relays RL2, RL3 & RL4.

Image 10

 

 

Image 12

On top a list of Types created is displayed.

 

Image 8

Click on Create Virtual Sensor for RL1.

Image 15

Select Sensor type as SWITCH and name it as RL1.

Image 13

Similarly create Sensor type Switches for other 3 ,  RL2,RL3 & RL4

Image 14

Under setup –> Devices all the 4 switches are listed out with INDEX (IDX) numbers.

Note these IDX numbers , as we have to set the same IDX number in ESPEASY Setup.

Image 9

Under SWITCHES tab you can see the VIRTUAL SWITCHES created.

Image 3

Click on EDIT button on RL1

Switch ICON is a bulb by default.You can select any one from the drop down list.

Under ON Action feed in the IP address of ESPEASY with HTTP command

http//192.168.0.110/control?cmd=gpio,16,0

Note the usage of 0 for ON , as the relay board is LOW enabled.

Against OFF action

http://192.168.0.110/command?cmd=gpio,16,1

Click SAVE

Image 4

Same way click on other Relay switches EDIT button and feed in the HTTP command including the correct GPIO number.

 

Image 5

 

Image 6

 

 

Image 7

Once the HTTP commands are saved , you can go to ESPEASY Dashboard by typing in the IP address on browser.

Here mine is 192.168.0.110

 

Under CONTROLLERS select the protocol as DOMOTICZ HTTP

Provide the IP address of DOMOTICZ and its port no. 8080

Click ENABLED.

Image 7

 

Under HARDWARE make the GPIO pins used to OUTPUT HIGH on Boot.

As the RELAY Board is LOW enabled , this is necessary.

GPIO16 by default is HIGH on Boot , so there is no settings for GPIO 16.

Image 8

 

Under DEVICES select the DEVICE as SWITCH INPUT – SWITCH

Provide a name RL1

Click ENABLED.

RL1 is connected to GPIO 16 , select it.

Provide the IDX number as 1.

Internal pull up is similar to OUTPUT HIGH , not needed for GPIO 16.

Image 2

 

As done for RL1 repeat for other relays

RL2 –GPIO14 , iNTERNAL PULL UP –Yes, IDX 2

Image 3

 

Image 4

RL3 –GPIO12 , iNTERNAL PULL UP –Yes, IDX 3

Image 5

RL2 –GPIO13 , iNTERNAL PULL UP –Yes, IDX 4

Image 6

 

Now all the settings are done.

Image 1

Go to DOMOTICZ Dashboard and click on SWITCHES tab.

From here you can Switch ON OFF the relays and the load connected to it.

 

Image 11

VIDEO :

 

blog_image

DHT11 module can sense both Temperature and Humidity data.

As a module it has 3 pins .Vcc can be connected to 3.3v , as it can work with 3.3v.

Gnd to Gnd.

Data pin is connected to GPIO 13.

DHT_ESP

DOMOTICZ service is running on Raspberry PI which is on the same WIFI network as my PC.

 

rpi8

 

Domoticz Dashboard can be accessed from a browser by typing in the address followed by port number

192.168.0.150:8080

 

Image 3

Click on Setup –> Hardware

Select Type as DUMMY and provide a name

Image 4

 

Image 5

When you click ADD it appears on the list.

Image 6

Click on Create Virtual Sensors

Select Sensor Type as Temp+Hum

ans provide a name.

Image 7

 

Image 8

 

Click on OK .

The Virtual Sensor is visible under TEMPERATURE tab.

 

Image 11

If you want a description to be added , click on Edit and add description.

 

Image 12

 

Now go to ESP EASY by typing in the IP address 192.168.0.110

Under Controllers select protocol DOMOTICZ HTTP.

Image 13

Provide the IP address of DOMOTICZ Service and the port number.

Click Enabled.

Image 15

 

Under Devies click ADD.

Image 16

Select a device Environment DHT11

Image 17

 

Click Enabled and select the GPIO pin as GPIO 13.

 

Image 18

Interval is the REFRESH rate of DHT11.

DHT11 has a refresh rate of 1 sec , meaning every second it can send out data.

On DOMOTICZ Virtual Sensor you can see the display of Temperature and Humidity.

Image 20

video :

 

blog_image

In the previous post we installed ESPEASY over NODEMCU.

This post is on controlling an LED connected to GPIO 12 of NODEMCU from DOMOTICZ Service.

 

LED_NODE

 

My Raspberry PI and PC both are on same Local Area Network , i.e connected to same WIFI Router .

Domoticz is installed on RPI

 

rpi1

 

 

Image 21

The IP address of RPI connected to the Router over WIfI is 192.168.0.150 & the DOMOTICZ dashboard is accessed by URL

192.168.0.150:8080

 

rpi7

 

On Domoticz dashboard click on Setup –> Hardware

 

Image 28

 

Create a Type  “Dummy “ (select from the drop down list) and provide a name as LED.

Image 29

 

Click on ADD

 

Image 30

Now click on  “ Create Virtual Sensors “

Image 31

Select a Sensor type as SWITCH and provide a name.

 

Image 32

 

The Virtual Switch is visible under SWITCHES tab.

Image 33

Click on EDIT

Against On Action , type in this HTTP command

http ://192.168.0.110/control?cmd=gpio,12,1

192.168.0.110  is the IP address of ESPEASY NODEMCU.

LED is at gpio12 & 1 for switching ON , 0  for Switching Off.

Image 34

Now go to the dashboard of ESPEASY by typing in 192.168.0.110 in the browser.

Under Controllers select a Protocol Domoticz HTTP

Provide the IP address of DOMOTICZ and the port no. as 8080

Click on Enabled & Submit.

Image 35

Under Devices select from the drop down Switch Input –Switch

Provide a Name and click Enabled.

Select the GPIO as GPIO 12.

Image 36

Click on SUBMIT.

Now you can switch On / Off the LED by clicking bulb icon on Domoticz.

 

Image 3

VIDEO:

 

blog_image

ESP EASY IOT OS ON NODEMCU

Video :

 

ESP module can be turned into an IOT MULTIFUNCTION Sensor device by  installing  ESP EASY Firmware on to the module.

For HOME AUTOMATION projects it suits well and can be easily controlled from application servers like DOMOTICZ.

Configuration of the ESP EASY is entirely web based , so once the firmware is loaded , you just need a common web browser to work with.

Older version of ESP EASY is R120. Mega is the newer version.

https://github.com/letscontrolit/ESPEasy/releases

documentation :

https://espeasy.readthedocs.io/en/latest/

 

supported Hardware ESP modules :

https://www.letscontrolit.com/wiki/index.php?title=ESP_Hardware

The NodeMCU or WeMOS D1 mini are recommended , as they have inbuilt USB.

Sensors supported :

https://www.letscontrolit.com/wiki/index.php?title=Devices

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.

Image 1

 

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.

 

Image 2

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.

Image 3

Setting of WIFI & fixed IP can be done later. For now Flash ESP EASY.

It takes approx 2 minutes to upload.

 

Image 5

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

 

Image 6

 

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:

Image 7

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.

Image 8

 

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.

Image 9

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.

 

Image 10

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.

Image 11

Now from your browser use this command to control LED.

Image 12

 

Image 13

Instead of GPIO you can use PWM to control brightness of LED.

gpio, pwm can be in small or capital letters.

Image 14

 

blog_image

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.

 

title

 

Create a new project on BLYNK.

 

2020_01_03_15.08.34

Get the Authorized Token ID.

2020_01_03_15.08.39

Create 2 button widgets , one for fan control and the other for light control.

 

2020_01_03_15.06.29

Fan to be connected at digital pin D2 through relay board.

2020_01_03_15.06.38

Light connected to digital pin D4 through relay board.

2020_01_03_15.06.43

 

2020_01_03_15.06.52

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

 

 

Image 4

 

Click on CREATE.

 

Image 7

You see a + symbol before THIS.

Click on that.

Image 8

Choose a service ,GOOGLE ASSISTANT

Image 9

Choose a method to trigger , Say a simple phrase.

Image 10

Next page is to complete trigger fields with options like what you want to say & what Google Assistant should reply.

Image 11

 

Complete the fields for FAN ON control as shown below & click Create Trigger

 

Image 13

 

Now you can see the GOOGLE ASSISTANT Logo at the THIS position.

Click on the + symbol before THAT

 

 

Image 15

Search for WEBHOOKS and select it.

Image 16

Then click on “ Make a WEB REQUEST”.

Image 17

On next page you’ve to complete action fields.

Image 18

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

 

Image 2

 

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 .

Image 12

 

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.

Image 19

 

Now the first APPLET is created and Connected.

 

Image 20

Click on FINISH.

Image 21

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.

Image 22

 

Image 23

 

Image 24

 

 

Image 26

 

Finally click on your account & MY APPLETS to see the applets you created.

Image 29

Image 28

 

Now open your Arduino IDE & under examples –> BLYNK –>  BOARDS WIFI –> NODEMCU

Do the following modifications in code & upload to NODEMCU.

 

Image 14

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

Accordingly the devices will be made ON or OFF.

2020_01_03_16.25.10

 

 

IMG_20200103_145849

VIDEO

 

blog_image

 

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.

2020_01_03_15.07.55

Provide a name to the project & select hardware.Here Im using NODEMCU.

 

2020_01_03_18.39.47

 

Connection type is WIFI .

Touch on CREATE button.

 

2020_01_03_18.39.56

An authorized token ID will be sent to your registered EMAIL.

 

2020_01_03_18.40.02

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.

 

2020_01_03_18.41.52

For e.g , add a BUTTON to your project.

2020_01_03_18.41.59

An energy level of 200 will be deducted.If you want you can BUY Energy level by touching on the ADD button.

 

2020_01_03_18.42.04

 

2020_01_03_18.42.41

Add 2 buttons as shown below.

 

2020_01_03_18.43.16

To set the properties of first button , touch on that button.

 

2020_01_03_18.43.22

 

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.

2020_01_03_18.43.48

Slide the MODE setting to SWITCH which makes the button at as ON or OFF.

2020_01_03_18.44.29

 

Similarly for the Button 2 set the PIN to digital D4 where we control an AC load through the relay board.

 

2020_01_03_18.44.49

 

2020_01_03_18.45.11

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

https://arduino.esp8266.com/stable/package_esp8266com_index.json

 

Image 5

Then open Tools –> Boards Manager , search for ESP8266 & install.

Image 29

Also from Sketch – > Manage Libraries –> Library

search fro BLYNK & install the library.

Image 31

Once the library is installed you can see under Examples —> Blynk

Open the NodemCU Example code.

Image40

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.

Image41

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.

Image 32

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.

Image 37

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.

Image 38

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.

video tutorial :

 

 

blog_image

 

 

 

title_iot2

This post is on Home Automation project where we control 2 devices from a mobile App. over Local Area Network.

NodeMCU with Arduino core installed is used with relay board.

You can watch this video on how to install Arduino core on NodeMCU.

https://www.youtube.com/watch?v=BbiLBiFvlsI

Android Mobile Application is developed using MIT APP INVENTOR , a WEB Application IDE.

https://appinventor.mit.edu/

For Arduino code we will use the one from my previous post

https://alselectro.wordpress.com/2017/11/08/nodemcu-arduino-core-2-led-on-off-from-webbrowser/

Download code for web browser LED On/Off HERE

This code is to control an LED from a Web browser on LAN.

We shall modify the code to work for Home Automation.

Arduino Code , Android App. (both .aia , .apk) files can be downloaded HERE

To start with connect a Red LED at D2 (which will be replaced with a DC Fan load)

A green LED at D4  ( will be replaced with CFL lamp AC Load)

 

I41

——————————————

#include <ESP8266WiFi.h>
#define FAN D2
#define LIGHT D4
const char* ssid = “Saravana”;
const char* password = “######”;

WiFiServer server(80);

void setup() {
Serial.begin(115200);
pinMode(FAN, OUTPUT);
pinMode(LIGHT, OUTPUT);
digitalWrite(FAN,HIGH);
digitalWrite(LIGHT,HIGH);

Serial.println();
Serial.println();
Serial.print(“Connecting to “);
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.println(“WiFi connected”);
server.begin();
Serial.println(“Server started”);
Serial.println(WiFi.localIP());
}

void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}

Serial.println(“new client”);
while(!client.available())
{
delay(1);
}
String req = client.readStringUntil(‘\r’);
Serial.println(req);
client.flush();

if (req.indexOf(“/fanon”) != -1)
{

digitalWrite(FAN,LOW);
Serial.println(“FAN ON”);
}
else if(req.indexOf(“/fanoff”) != -1)
{
digitalWrite(FAN,HIGH);
Serial.println(“FAN OFF”);
}

if (req.indexOf(“/lighton”) != -1)
{
digitalWrite(LIGHT,LOW);
Serial.println(“LIGHT ON”);
}
else if(req.indexOf(“/lightoff”) != -1)
{
digitalWrite(LIGHT,HIGH);
Serial.println(“LIGHT OFF”);
}
String web = “HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n”;

client.print(web);
}

————————————————-

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.

l3

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

 

I42

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 .

I43

Connect IN1 of relay board to D2 of NODEMCU

IN4 to D4,  GND to GND.

I40

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.

I45

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.

jdvcc

 

Now let us develop our Android Mobile Application using on line MIT APP INVENTOR.

 

Image 3

Click on Start a New project and provide a Project name. Space and Hyphen not alloed in name , but underscore allowed.

 

Image 5

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.

Image 6

From LAYOUT drag and drop a HORIZONTAL ARRANGEMENT

Image 7

Set the Height under properties to 10 percent , Width TO FILL PARENT

This is to provide space at top of screen.

Image 8

Then drag and drop LABEL from User Interface

Image 9

Set Width TO FILL PARENT , Text to Heading of App. , alignment center ,Fontsize to 25

and background color to yellow.

Image 10

Next drag and drop  TABLE ARRANGEMENT from LAYOUT.

Image 11

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.

 

Image 12

Drag and drop an IMAGE component from User Interface.

Image 13

Under Properties set the Height to 15 percent, Width to 30 percent.

Under Picture property click Upload File and select the image to upload.

Image 14

 

Image 15

Now drag and drop 2 buttons next to image 1.

Image 16

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.

 

Image 18

Select the properties of Buttons

You need to change the Text and the background COLOR.

Image 19

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.

Image 22

Now click on the BLOCKS button at the right top corner.

Image 23

Select Button1 from the left side Blocks.

You will see a list of options.

Select the When..Do ..Button..Click block.

Image 24

Next click on WEB .

Select the set..web1..url..to block

Image 25

Third block to select is under TEXT

Select an empty Text block for text.

Image 26

Finally from WEB

select  call..web..get   block.

Image 27

Following are the blocks we selected.

Image 28

Assemble the blocks as shown.Just drag and fix at the connecting points.

Image 29

Click on Text block and type in

http://192.168.1.5/fanon

Your IP may be different.Change the IP according to the one shown at serial monitor of

Arduino, after uploading code.

Image 30

The first block is ready.

Right click and select DUPLICATE.

 

Image 31

Change the Text for other blocks as shown.

Image 32

Now click on BUILD App TO SAVE .apk file to computer.

You can transfer this .apk file to mobile using SHAREIT or any application.

Image 34

Also you can export the .aia file.

.apk file is for Android mobile.

.aia file is the one you can import on your MIT APP and do the necessary modifications

and then finally generate your own .apk file.

Also you can install MIT AI2 Companion on mobile to view Real Time development.

By this application you can view the real time changes on mobile , as you develop

appplication on MIT APP Inventor.

Image 36

Now open the Application on mobile.

Touch on the buttons to see the project working.

IMG_20191219_132341

VIDEO TUTORIAL

 

 

blog_image

title_iot1

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.

l1

 

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

i3

 

i1

 

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.

l3

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.

 

I6

 

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.

https://www.youtube.com/watch?v=BbiLBiFvlsI

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.

I8

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.

 

I10

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.

jdvcc

Electronic solid state relay boards are also available which are called SSR.

 

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.

 

I11

 

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.

I12

 

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.

iot2

VIDEO support :

 

blog_image