In the previous post we’ve seen how to connect the Arduino ETHERNET SHIELD to a Router directly  & upload LM35 data to Thingspeak.

What if  you do not have physical access to your Router & your Laptop is connected over WIFI to the Router. Or you cannot run a RJ45 cable from Router to Ethernet shield.

The procedure we follow is similar to the one we did for connecting Raspberry PI to Laptop.

Link here

First step is to enable SHARING of your existing internet.In my case , Laptop is connected to Router

over WIFI.

Open Control Panel –> Network & Internet –> Network & Sharing Center

Click on the existing internet connection

Image 1

On the next screen click PROPERTIES &  then SHARING

Image 2

Tick mark to ENABLE SHARING of Internet connection

Image 3

 

Now plug in the USB cable to Arduino & then connect the RJ45 Straight cable from shield to the RJ45

Port of LAPTOP.

ETH_SETUP

As soon as you connect the RJ45 cable you can see an UNIDENTIFIED NETWORK

 

Image 4

 

Click on that new Network , select PROPERTIES.

On the next screen double click on Internet Protocol version 4 (TCP/IPV4)

Image 5

You can see an IP address like 192.168.137.1.

Note that this is the new Gateway IP of the new network formed by Ethernet shield.If you do not see any IP , just select the “ Use the following IP “ &  feed in manually the IP.

 

Image 6

Now RUN  –> CMD  > IPCONFIG /ALL

to verify the IP.

Under Ethernet adapter the Gateway IP of new network is displayed.

Note that this is the GATEWAY IP & Ethernet shield will be allotted IP in this range  .

 

Image 7

Let us try some built in example codes.

Under Examples  –> Ethernet –> select  DhcpAddressPrinter

This will print the IP allotted to the Shield.

Image8

Upload the code & open up the Serial monitor.

The IP allotted to the shield here is 192.168.137.30  which is in range of new Gateway .

Image 9

 

Next example is WEBSERVER

Image 10

 

Open the WEBSERVER code .

You need to change the IP Address as 192.168.137.xxx

 

Image11

 

Here change it to 192.168.137.177 where the SERVER will be started. Note the usage of comma instead of dot between each byte.

Image 12

 

Upload the code & open the serial monitor to verify that SERVER is started.

Image 13

You can use your Browser as CLIENT.

Type in the IP 192.168.137.177 to access the server.

On the Serial monitor “Client connected “ information will apper.

Image 14

On the browser you can see the values of ANALOG Pins of Arduino.

As nothing is connected to the Analog pins , you get random values.

Image 17

 

Next example is the TELNETCLIENT

Image 2

 

Open the code.

Here Ethernet shield is used  as CLIENT & you need to change the IP of client in range with the new Gateway  192.168.137.177

Next is the IP of the SERVER . This may be another PC or Android phone connected to the same Network .

Here the SERVER is started on PC with IP 192.168.0.103

Note that this IP is in the range of Gateway of Router 192.168.0.xxx

Image 3

Scroll down further & note the PORT number on which the SERVER will LISTEN.

Here it is 10002.

Upload the code on to Arduino.

Image 4

To test the setup , you need to start a SERVER on another PC on the same network with IP 192.168.0.103

For this we use HERCULES software. DOWNLOAD HERE

Click on TCP Server tab on Hercules , feed in the port number 10002 & click LISTEN.

The server is started on PC with IP 192.168.0.103 , so , no need to enter the IP

Image 5

Now open the Serial Monitor of Arduino where SHIELD is declared as CLIENT.

You can see the “Connected..”  feed back from the Server.

Type in some characters on Arduino side , as well as Hercules side to verify 2 way communication.

Image 6

Instead of PC & HERCULES you can use your Android mobile ( to be connected over WIFI to the same Network).

On your mobile install TCP TOOLS

mobile1

Open TCP SERVER

The IP of Android device is shown with default port 8080.Click on LISTEN

In the TELNET CLIENT code you need to change the SERVER IP t from 1,1,1,1

to  192.168.0.102 & then change the port of server to 8080 & then upload to Arduino

 

mobile 2

Once code is uploaded open the Serial monitor.

On mobile you see the IP of CLIENT connected

mobile3

Test 2 way communication by typing in characters.

mobile4

 

mobile5

 

Next we shall test the code which sends LM35 Data to THINGSPEAK SERVER.

You can check my previous post for details

Upload the same code without any change in IP.

IT WORKS FOR BOTH RANGE OF ipS 192.168.0.xxx    &   192.168.137.xxx

Image 7

Open the Serial Monitor to see the data being uploaded to THINGSPEAK.

Image 8

WATCH THIS VIDEO  :

cooltext753793315   cooltext753790696

Advertisements