I am working on GPS, temperature sensor and GSM module and I want to get temperature, position from GPS and send to this data to my web site. I can get position but couldnt send. I will wirte my code blog below. Thank you
#include "TinyGPS.h"
TinyGPS gps;
int year;
byte month, day, hour, minute, second, hundredths;
unsigned long chars;
unsigned short sentences, failed_checksum;
static void print_date(TinyGPS &gps);
int lm35Pin=0;
float temperature;
char bilgi;
float latitude,longitude;
void setup()
{
Serial2.begin(19200);
Serial.begin(19200);
Serial1.begin(9600);
Serial.println("Config SIM900...");
delay(2000);
Serial.println("Done!...");
Serial2.flush();
Serial.flush();
// attach or detach from GPRS service
Serial2.println("AT+CGATT?");
delay(100);
toSerial();
// bearer settings
Serial2.println("AT+SAPBR=2,1,"CONTYPE","GPRS"");
delay(2000);
toSerial();
// bearer settings
Serial2.println("AT+SAPBR=2,1,"internet",""");
delay(2000);
toSerial();
// bearer settings
Serial2.println("AT+SAPBR=2,1");
delay(2000);
toSerial();
}
void loop()
{
while(Serial1 .available())
{
int c = Serial1 .read();
if(gps.encode(c))
gps.f_get_position(&latitude, &longitude);
temperature=analogRead(lm35Pin);
temperature=((((5000*temperature)/1023)/10));
}
Serial.print(latitude);
// initialize http service
Serial2.println("AT+HTTPINIT");
delay(2000);
toSerial();
// set http param value
Serial2.println("AT+HTTPPARA="URL","fircasiz.com - This website is for sale! - fircasiz Resources and Information."");
delay(2000);
toSerial();
// set http action type 0 = GET, 1 = POST, 2 = HEAD
Serial2.println("AT+HTTPACTION=0");
delay(6000);
toSerial();
// read server response
Serial2.println("AT+HTTPREAD");
delay(1000);
toSerial();
Serial2.println("");
Serial2.println("AT+HTTPTERM");
toSerial();
delay(300);
Serial2.println("");
delay(10000);
}
void toSerial()
{
while(Serial2.available()!=0)
{
Serial.write(Serial2.read());
}
}
You can focus on this section ..
while(Serial1 .available())
{
int c = Serial1 .read();
if(gps.encode(c))
gps.f_get_position(&latitude, &longitude);
temperature=analogRead(lm35Pin);
temperature=((((5000*temperature)/1023)/10));
}
Serial.print(latitude);
// initialize http service
Serial2.println("AT+HTTPINIT");
delay(2000);
toSerial();
// set http param value
Serial2.println("AT+HTTPPARA="URL","fircasiz.com - This website is for sale! - fircasiz Resources and Information."");