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.
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
On the next screen click PROPERTIES & then SHARING
Tick mark to ENABLE SHARING of Internet connection
Now plug in the USB cable to Arduino & then connect the RJ45 Straight cable from shield to the RJ45
Port of LAPTOP.
As soon as you connect the RJ45 cable you can see an UNIDENTIFIED NETWORK
Click on that new Network , select PROPERTIES.
On the next screen double click on Internet Protocol version 4 (TCP/IPV4)
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.
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 .
Let us try some built in example codes.
Under Examples –> Ethernet –> select DhcpAddressPrinter
This will print the IP allotted to the Shield.
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 .
Next example is WEBSERVER
Open the WEBSERVER code .
You need to change the IP Address as 192.168.137.xxx
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.
Upload the code & open the serial monitor to verify that SERVER is started.
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.
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.
Next example is the TELNETCLIENT
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
Scroll down further & note the PORT number on which the SERVER will LISTEN.
Here it is 10002.
Upload the code on to Arduino.
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
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.
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
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
Once code is uploaded open the Serial monitor.
On mobile you see the IP of CLIENT connected
Test 2 way communication by typing in characters.
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
Open the Serial Monitor to see the data being uploaded to THINGSPEAK.
WATCH THIS VIDEO :
wonderful work sir …
I am facing a problem that my new network is not showing. it appears for 2 sec and disappears again. Please tell me what possible error might be.
good effort. don’t stop sharing & keep updating.
Great help here! Thanks for the well laid out procedure.
Ethernet WebServer Example
Ethernet shield was not found. Sorry, can’t run without hardware. 😦
whats the problem?