Tag Archive: WIFI


 

Image 2

 

Image 1

 

Introducing a new ESP8266 Development Board with an ESP-12, a 3x AA battery holder, a voltage regulator, an RGB LED, several red LEDs, and a light sensor LDR on the ADC input all on one board.

The board can be controlled by an open source Android App which is available from the AI-THINKER Website.

GPIO pins are extended with berg pins for easy external connections. RXD,TXD & GND pins are provided for programming / firmware upgrading. A yellow jumper is provided to pull GPIO0 pin to GND during programming. During normal operation this jumper must be removed.

The board is powered by 3 nos AA batteries , for which a battery box is already wired. On board 3.3v regulator is provided for a stable power supply.

No power switch or Reset switch is provided. To switch off you need to pull out one of the batteries.

The board comes pre-loaded with a demo which does actually seem to work.  If you have an Android based phone or tablet you can download AI-Thinker’s app to control and mix the color balance on the RGB LED and to switch the other LEDs on and off.

The Android Application can be downloaded from :

https://play.google.com/store/apps/details?id=com.duvallsoftware.iotdemoapp

 

There are also 6 red LEDs fixed with the necessary resistors connected to GPIO16, GPIO14, GPIO5, GPIO4, GPIO0 and GPIO2. A BLUE LED is always ON if the board is powered.

The GPIO13, GPIO12 and GPIO15 are connected to a RGB LED which allows you color mixing using PWM.

ADC

The analog-digital converter is also available on a pin & connected to a light resistor. This lets you quickly test the ADC and you still can clip the resistor off if you want to measure another analog source.Remember the range of ADC is max 1v & not 0 to 3.3v

If you don’t want to use the light sensor or the LEDs you can simply clip them off. Then you’ll just have an  ESP8266 with 3xAA power supply, 9 available GPIO pins and one ADC.

On the playstore of your Android device search for  IOT DEMO App & install it.

Open the Settings & enable WIFI of the Android phone.Now power on the ESP board to see the AI-THINKER SSID on your mobile.

PAIR this with the ESP board using password ai-thinker

Now open the app & touch on LED 1 to 6 , to see the corresponding light glowing on the ESP board.On the top you can see 3 icons with sliders in the App. Use this to mix colors on the 3 color LED of ESP board.

Once the functioning of board is verified , you can proceed to connect the GPIO pins of ESP board with a 4 channel Relay board.

The 4 channel relay board used requires a separate power source of 5V, 1amp.For demo 2 of the GPIO pins are connected to relay 1 & relay 3.The GND pins of both ESP & the Relay. board to be made common.

You can watch this video to learn the home automation basics with ESP board :

 

 

 

cooltext753793315    cooltext753790696

After struggling for nearly a week with MTS dongle , finally I found an excellent solution to enable PORT FORWARDING.

HUAWEI POWER FI  E8221 model dongle  is the solution I found.This dongle accepts any data SIM for internet connectivity & we can create a WIFI HOTSPOT with this dongle to connect max. of 10 devices.

Further it has got a VIRTUAL SERVER setting tab in the configuration , thus enabling Port forwarding.

There is no need of an external Router like TP-LINK (which I used with MTS , as seen in my previous post).

1

I’ve inserted a BSNL DATA SIM into the HUAWEI dongle for Internet connection.

The DEFAULT GATEWAY IP address while using Huawei is 192.168.8.1

This can also be found by opening CMD in Windows search bar & then typing the command IPCONFIG /ALL

Typing this Gateway address in the browser , you get the HUAWEI CONFIGURATION window.Here the service provider (for me BSNL ) name is displayed with connection status.

Image 1

Click on CONNECTION SETTINGS seen below the “Connected” status.

On left pane , under SECURITY tab select the VIRTUAL SERVER.

Before clicking the ADD button under VIRTUAL SERVER LIST , we’ve to configure the ESP module & start a SERVER on port 333.

Image 2

The ESP 8266 module is connected to PC through USB-TTL board & the COM port allotted in my PC is COM 48 .

I’m using PUTTY terminal software to communicate with this COM port.

Following is the screen shot on which you can see the AT commands used to connect ESP with HUAWEI on WIFI , & starting a server on port 333.

The selection of port is random.You can select any port within 65536 , except the standard ports like 80 (HTTP) ,  21 (FTP), 23 (TELNET) ,etc..

AT+CWLAP   – to list the surrounding Access Points near ESP module

AT+CWJAP=”ssid”,”password”   – to join the AP using the SSID name & its password.

AT+CIPMUX=1   — to enable Multiple connections before starting server

AT+CIPSERVER=1,333   –  to start a server on port 333

AT+CIFSR  –  displays the IP address . STAIP is the IP address we need to port forward.

Image 3

After starting the server on ESP8266 , we need to port forward under the HUAWEI configuration.

Click on the ADD button , seen under VIRTUAL SERVER LIST.

Fill in details as below :

Name  : ESP

WAN Port : 333

LAN IP   : 192.168.8.100

LAN Port  ; 333

Protocol : TCP

Status  : ON

Finally click on APPLY.

Image 4

Needless to say , you’ve to apply an INBOUND RULE on Windows Firewall settings to allow this port 333 . (check the previous post on how to do this).

The external world can contact this ESP only through the EXTERNAL IP address.To know the IP , just type in WHAT IS MY IP on Google .In my case it is 117.252.205.55

To confirm that the PORT 33 is open & listening , visit the online tool www.yougetsignal.com

You need to test this on the PC where you’ve connected the ESP module.

The external IP will be automatically displayed.You just  type in the port no. to verify.

Following screen shot shows that my port 333 is open

Image 6

Now we’re all set to contact ESP from outside World.

From a distant PC with different Internet connection , open a PUTTY terminal.

Select RAW as Connection type & type in the IP 117.252.205.55  & port no. as 333.

Following screen shot shows the PUTTY terminal which I’ve opened on a different PC with a different IP.

Image 5

On clicking OPEN button , the ESP Terminal at the other end will respond with

0,CONNECT

This means a connection established on channel 0.

Image 8

Now type in some characters on the distant PC terminal.

newip2

The ESP terminal responds with

+IPD,0,21:characters received

which indicates , it has received 21 characters on channel 0.

The screen shots with HUAWEI symbol (IP 117.252.205.55 ) is that of TERMINAL where ESP module is connected & the screen shot of distant PC is shown with the IP address 180.215.121.135

Image 9

To send characters from ESP , use the AT command :

AT+CIPSEND=0,15

This indicates that you want to send 15 characters on channel 0.

The ESP will respond with a > symbol & waits till you type 15 characters.

Image 10

The distant PC now receives the 15 characters you typed inside ESP terminal.

newip3

Hence a two communication is established with ESP Terminal & a PC from anywhere in the world.This opens the door for INTERNET OF THINGS where you can control the devices connected to ESP from anywhere in the World.

WATCH THIS VIDEO :

cooltext753793315    cooltext753790696

In the previous post we’ve seen the ways to control the ESP8266 WIFI module from anywhere in the world.The key to success depends on the PORT FORWARDING , where we route the contact on particular port to the local IP address of the WIFI module.

Nowadays USB dongles are used widely for internet access .This post will help you troubleshoot PORT FORWARDING.

Following is the SETUP diagram .

TPLINK ROUTER is on the top of the NETWORK. An MTS USB dongle is plugged to TPLINK Router (model TL-MR 3420 with 3G/4G support).

A Laptop is connected to TPLINK Router on Ethernet using RJ45 cable.

A USB to TTL board is connected to PC on which the ESP 8266 module is wired.

The ESP module is linked to TPLINK Router on WIFI using the AT Command AT+CWJAP=”SSID”,”password”

 

ip8

On switching ON the ROUTER , it assigns LOCAL IP address to the modules connected to it either on RJ45 (wired) or on WIFI.

In our set up the LAPTOP which is connected by wire is assigned 192.168.0.100

& the ESP module which is connected on WIFI is assigned 192.168.0.101.

Note that the allotment of address is on first come basis.When you power off & on the Router again , this allotment may vary.

You can RESERVE the address by selecting the DHCP tab of TPLINK configuration.Here select

Address Reservation & then feed in the MAC address of the devices you’ve connected to the Router.

To know the MAC address you can use the ADVANCED IP SCANNER TOOL.

Download & install the tool. Start the scanner to know the IP address & MAC address of the devices connected .

ip12

STEP 1:

Confirm that you’ve Internet access after plugging  the USB dongle to the TPLINK Router .You need to login the TPLINK configuration with address 192.168.0.1 & enter the QUICK SETUP for this process.

STEP 2 :

Start the SERVER on ESP module

ip2

 

 

STEP 3 :OPEN PORT SCANNER

To confirm that the port we’ve started server ( here port no. 333) is OPEN , we use a  port scanner tool .

Advanced Port Scanner is a small, fast, robust and easy-to-use port scanner for Win32 platform. It uses a multithread technique, so on fast machines you can scan ports very fast.

Also, it contains descriptions for common ports, and can perform scans on predefined port ranges.

Download it & install.

http://download.cnet.com/Advanced-Port-Scanner/3001-18508_4-98269.html?hlndr=1&part=dl-73294

Open Port scanner & under Select port range enter 100 to 500 . As we’ve to check port 333 , we enter the range below 500 .Click on SCAN .

IP4

 

The PORT SCANNER displays the result regarding status of PORTs of your PC as well as the module connected to PC.

Here we can confirm that port 333 is OPEN on IP 192.168.0.101 (ESP module).

 ip5

 

STEP 4 : SET UP FORWARDING RULE on TPLINK CONFIGURATION

On TPLINK configuration window , under FORWARDING select the tab VIRTUAL SERVERS.

Click on ADD NEW.. & enter the Service & Internal port as 333 .

IP Address as 192.168.0.101 , which is the local IP allotted by Router to ESP module.

Select Protocol as TCP & then SAVE the settings.

 

IP9

 

IP 10

 

STEP 5 : WINDOWS FIREWALL SETTINGS

Open Windows Firewall Advanced settings & click on INBOUND RULES.

SET the rule to allow communication on port 333.

IP11

 

Now you are set to check the condition of PORT 333 externally.

For this we make use of an online tool www.canyouseeme.org

On opening the site your external IP will be automatically displayed.Enter the port number to check.

Click on CHECK PORT.

ip 13

Unless you see SUCCESS on this test , you can’t contact your ESP module from external world.

If you get ERROR , open the TPLINK configuration & click on STATUS.

Note IP Address displayed under 3G/4G.

From another computer with a different internet connection try to PING this IP address.

Open CMD & type in PING x.x.x.x

ip1

 

If the PING result is OK , you can be sure that the ESP module can be contacted from outside world.

If the PING result is TIMED OUT , you can’t communicate with ESP.

The   STATUS tab in my case , as shown in above screen shot , indicates an IP address starting 100.86.x.x

Generally following IP address ranges are PRIVATE IP ADDRESS RANGES :

10.x.x.x

172.16.x.x

192.168.x.x

These are reserved by IANA for private Intranets & NOT ROUTABLE TO INTERNET.

Private addresses are not reachable on the Internet. Therefore, Internet traffic from a host that has a private address must either send its requests to an Application layer gateway (such as a proxy server), which has a valid public address, or have its private address translated into a valid public address by a network address translator (NAT) before it is sent on the Internet.

In my case , the MTS ISP provider hide the PUBLIC IP address.

The MTS dongle does not support VIRTUAL SERVER settings , which means PORT FORWARDING IS NOT POSSIBLE with MTS.

What I couldn’t understand was , while writing my previous blog ,it worked sometimes.While MTS customer support was contacted repeatedly , they finally accepted that port forwarding is blocked by them.

After sleepless nights I’ve found a solution….. Read on my next post ….

 

cooltext753793315    cooltext753790696

In the previous post we’ve seen how to initiate ESP module & use AT commands.In this post TCP CLIENT mode operation is explained.

ESP8266 WIFI module has 3 modes of operation.

ST  – Station mode in which ESP acts as a device & connects to an existing Access point.

AP – Access Point mode where the ESP itself acts as AP & other devices like Mobile can connect to it.

Both – ST & AP both mode is allowed in ESP.The mode of operation is set by the AT command

AT+CWMODE = 1 for ST mode , 2 for AP mode & 3 for both.

As we’re testing ESP on STation mode , issue the command

AT+CWMODE=1

Image 7

To communicate with a webpage , we need to start a server with ESP module.You need to set multiple connections using command

AT+CIPMUX=1

This initiates the server for a Webserver.

Next we start the server at HTTP port 80 using command ,

AT+CIPSERVER=1,80

Image 8

To close the server the command is AT+CIPSERVER=0 followed by a Reset AT+RST

To get the STATION IP address ,

AT+CIFSR

The module returns the Station IP address , 192.168.1.3 .

If the CWMODE is set to 3 , you’ll get 2 IP address , one for AP & another for Station mode.We need the station IP address for Client mode operation.

Open your web browser & type in the address 192.168.1.3

The browser sends a HTTP GET request which is displayed on the putty window where ESP module is connected.The host IP address & the user agent (your web browser name) are displayed.

After you get OK  type in the command

AT+CIPSEND=0,30

This command is to send 30 characters through channel 0 .Use the channel number which is displayed as CONNECT while a request is received from the browser.

Image10

Now you get a  >  symbol , after which you’ve to type in 30 characters.

The module will wait till you type in 30 characters & finally displays SEND OK.

You’ve to type characters within the Timeout limit.Otherwise the link will be closed.

Image11

Now the characters are sent to the Web browser.

But the browser is still waiting for the channel to be closed.

Type in AT+CIPCLOSE=0

Here use the channel number ( 0) where the connection was established .

Image12

Once the channel is closed , you get the characters displayed on the browser.

HTML tags can be used to send characters

AT+CIPSEND=0,30

>

HELLO WORLD !!!!!

The above one displays characters using HTML tag type Heading 1.

Image 121

To close the server the command is AT+CIPSERVER=0 followed by a Reset AT+RST

For testing 2 way communication , open another instance of PUTTY .

Select connection type as TELNET & Port 80.

Type in the host address , which you get by AT+CIFSR command in ESP window.

Click on open.

Image 122

Type some characters inside TELNET window .You get these inside ESP window

+IPD,0,17:HELLO….

0 is the channel of communication & 17 is the number of characters received.

Image123

From within ESP window type AT+CIPSEND=0,20

ESP will wait till you type 20 characters.

On TELNET window the characters are received.

Image124

Watch this support video :

ESP WIFI Modules available at :

cooltext753793315  cooltext753790696