Send GPS data to Thing Speak channel & SD card

Dependencies:   GPS SDFileSystem mbed

Fork of Send_GPS_data by Lucas Prido

NUCLEO F303K8 pins:

/media/uploads/LucasPrido/pins.png

Picture:

/media/uploads/LucasPrido/20180207_102642.jpg

Files at this revision

API Documentation at this revision

Comitter:
LucasPrido
Date:
Thu Feb 08 09:32:28 2018 +0000
Parent:
1:1e635bc84266
Commit message:
small update

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 1e635bc84266 -r c189e0c04d99 main.cpp
--- a/main.cpp	Thu Feb 08 09:09:32 2018 +0000
+++ b/main.cpp	Thu Feb 08 09:32:28 2018 +0000
@@ -7,10 +7,11 @@
 DigitalOut myled(LED1);
 
 Serial sim800(PA_2,PA_3, 9600);//Arduino pins A7, A2
-//Serial sim800(PB_6,PB_7, 9600);
 SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd");//Arduino pins D11, D12, D13, D10
 //                PB_5      PB_4     PB_3    PA_11
 
+char* wapi_key = "4PI3GKVCH4OW96LX";
+
 void init_sim(){
     sim800.printf("AT+CPIN?\r\n");
     wait(0.2);
@@ -28,7 +29,7 @@
     wait(0.2);
 }
 
-int new_file(char* adr_file)
+int new_file(char* adr_file)//fonction to write on new file
 {
     FILE *fp = fopen(adr_file, "w");
     if(fp == NULL) {
@@ -42,7 +43,7 @@
     }
 }
 
-int read_file(char* adr_file)
+int read_file(char* adr_file)//fct to read a file
 {
     char c;
     FILE *file;
@@ -59,7 +60,7 @@
     return -1;
 }
 
-int add_data(char* adr_flie, char* msg)
+int add_data(char* adr_flie, char* msg)//fct to update a file
 {
     FILE *fp = fopen(adr_flie, "a");
     if(fp == NULL) {
@@ -73,7 +74,7 @@
     }
 }
 
-void send_ts(char* url_para)
+void send_ts(char* url_para)//Get url using sim800
 {
     sim800.printf("AT+HTTPINIT\r\n");   //enable the HTTP mode.
     wait(0.2);
@@ -108,7 +109,7 @@
             myled=1;
             
             //put data in string to send
-            sprintf(url_sim,"AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update?api_key=4PI3GKVCH4OW96LX&field1=%f&field2=%f&field3=%f\"\r\n", my_gps.latitude, my_gps.longitude, my_gps.utc);
+            sprintf(url_sim,"AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update?api_key=%s&field1=%f&field2=%f&field3=%f\"\r\n", wapi_key, my_gps.latitude, my_gps.longitude, my_gps.utc);
             sprintf(msg_gps,"GPS Coordinate: Latitude: %0.4f, Longitude: %f0.4, UTC: %f0.4\r\n", my_gps.latitude, my_gps.longitude, my_gps.utc);
             
             //send data to ThingSpeak channel & SD card
@@ -120,7 +121,7 @@
             pc.printf("Msg: %s\r\n", my_gps.msg);
             
             myled=0;
-            wait(60);//wait 10 sec for the test
+            wait(60);//wait 60 sec for the test
         }
     }
 }
\ No newline at end of file