In the previous post part-1 I explained the initial setup of starting a Server on PC on a port , setting the Windows firewall to allow the port for external communication , PORT FORWARDING set up in the Router config, etc..
In this part 2 I’ll show a practical demo of sending Temperature data to the Server.
As given in part 1 , start a server on distant PC on port 350 & do the port forwarding settings in Router config as explained.
A LM35 sensor is connected to pin A0 of Arduino & a GSM SIM900A is connected to pins 7 , 8 , Gnd of Arduino. As Soft Serial library is used in the code , pins 7 & 8 are declared as soft Rx & Tx.
The Rx pin goes to Tx of GSM , Tx connected to Rx of GSM , GND is made common.An external power source of 12v 1A is used for the GSM.
Download the Arduino code HERE
int tempPin = 0;
myGsm.println(“AT+CSTT=\”bsnlnet\”,\”\”,\”\””);//setting the APN,username & password
myGsm.println(“AT+CIFSR”); //get IP address
temp = analogRead(tempPin);
temp = temp * 0.48828125;
Serial.print(“TEMPERATURE = “);
The Analog pin A0 is assigned as tempPin to read the LM 35 sensor data.
Initially any previous IP connection is SHUT using the command
This is essential to start a fresh TCP/IP comnnection.
Single IP connection mode is set by
GPRS is attached using
Task is started with the command
The Access Point Name of the mobile service provider can be known by placing the SIM on your Android mobile. It’s shown under
Settings –> More.. –> Cellular Networks –> Access Point Names
In my case the APN is bsnlnet , user name & password are empty
Then we bring up the Wireless connection with GPRS using
This takes a little moment , so a delay of 6 secs is a must in the code.
The IP address assigned by GPRS is obtained by
Now we start up TCP connection with Server IP address & Port number of distant server
Once the connection is established , we send data using
A CTRL+Z is required to send data which is executed using hex 1A
Upload the code to Arduino & open the Serial monitor to watch the AT commands executed
Following is the screen shot at the Server side.