Визуализация в thingspeak.com координат GPS
- Войдите на сайт для отправки комментариев
Добрый вечер, продолжаю ковырять (atmega 32u4 with ai thinker A7 GPRS/GSM/gps с загрузчиком arduino).
Сегодня получилось "поробыты" скетч, при помощи которого удалось отправить на thingspeak.com координаты GPS.
В свою очередь thingspeak дал понять, что координаты пришли в предполагаемом виде: ({"created_at":"2017-08-06T19:08:07Z","entry_id":34,"field1":"E:*****.*****-N:****.*****"}]})
Как известно thingspeak способен визуализировать полученные координаты на карте. Однако, я не могу нигде найти, а также понять в каком именно формате thingspeak должен получить координаты, что бы их отобразить на карте и вообще как в этом сервисе это настроить? На данный момент получилось только разобраться с диаграммами в thingspeak.
Вынужден снова взывать о помощи, так как информации о вышеизложенном в интернете найти не могу, а читая всё с нуля про программирование ардуино до меня ничего не доходит, как как учиться могу лишь путём ошибок и метода тыка, увы такова моя сущность(((
Скетч отправляющий полученные координаты на thingspeak.com:
#define DEBUG true char byteGPS=-1; char linea[300] = ""; char comandoGPR[7] = "$GPRMC"; int cont=0; int bien=0; int conta=0; int indices[13]; int GPS_time=30; // When the board gets the 30 times location information successfully and the location information will be send by sms. String target_phone = "+38063*******"; // Your phone number,be careful need to add a country code before the cellphone number String GPS_position=""; int GPS_position_count=0; const char resource[] = "http://api.thingspeak.com/update?key=CE4ZIMSDTBOFTYNX&field1="; const char coord[] = "12"; void setup() { Serial.begin(115200); Serial1.begin(115200); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(8,OUTPUT); digitalWrite(5, HIGH); digitalWrite(4, LOW); digitalWrite(8, LOW); delay(2000); digitalWrite(8, HIGH); delay(3000); digitalWrite(8, LOW); Serial.println("A7 Power ON!"); sendData("AT+GPS=0",3000,DEBUG); //Close GPS for(int i=0;i<2;i++){ //Make sure the GPS has been turned on sendData("AT+GPSRD=1",1000,DEBUG); Serial1.println("AT+GPS=1"); } Serial.println("*********************************************************"); Serial.println("**If don`t display 'GPS positioning....',please reboot.**"); Serial.println("*********************************************************"); } void loop() { testgps(); } void testgps(){ while(Serial1.available()){ byteGPS=Serial1.read(); // Read a byte of the serial port if (byteGPS == -1) { // See if the port is empty yet } else { // note: there is a potential buffer overflow here! linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer conta++; //Serial.print(byteGPS); //If you delete '//', you will get the all GPS information if (byteGPS==13){ // If the received byte is = to 13, end of transmission // note: the actual end of transmission is <CR><LF> (i.e. 0x13 0x10) cont=0; bien=0; // The following for loop starts at 1, because this code is clowny and the first byte is the <LF> (0x10) from the previous transmission. for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR if (linea[i]==comandoGPR[i-1]){ bien++; } } if(bien==6){ // If yes, continue and process the data //Data Partitioning for (int i=0;i<300;i++){ if (linea[i]==','){ // check for the position of the "," separator // note: again, there is a potential buffer overflow here! indices[cont]=i; cont++; } if (linea[i]=='*'){ // ... and the "*" indices[12]=i; cont++; } } //panel data, for example:Direction (E/W):Longitude-Direction(N/S):Latitude<--->E:11350.51872-N:2236.40687 for(int i=5;i>1;i--){ for (int j=indices[i];j<(indices[i+1]-1);j++){ GPS_position+=linea[j+1]; } if((i==5)||(i==3)){ GPS_position+=":"; }else if(i==4){ GPS_position+="-"; } } //If the return ":-:", it means empty data, continue positioning if(GPS_position==":-:"){ Serial.println("GPS positioning...."); }else{ Serial.println(GPS_position); GPS_position_count++; //When GPS_position_count is equivalent to GPS_time, stop positioning and start to send sms messages if(GPS_position_count==GPS_time){ GPS_position_count=0; //Reset count sendData("AT+GPS=0",1000,DEBUG); delay(1000); //SendTextMessage(GPS_position); //SMS TcpGprsMessage(GPS_position); //Internet sendData("AT+GPS=1",1000,DEBUG); } } } GPS_position=""; conta=0; // Reset the buffer for (int i=0;i<300;i++){ // linea[i]=' '; } } } } } void TcpGprsMessage(String message){ sendData("AT+CREG?",3000,DEBUG); sendData("AT+CGATT=1",1000,DEBUG); sendData("AT+CGDCONT=1,\"IP\",\"www.ab.kyivstar.net\"",1000,DEBUG); sendData("AT+CGACT=1,1",1000,DEBUG); sendData("AT+CIPSTART=\"TCP\",\"184.106.153.149\",80",3000,DEBUG); sendData("AT+CIPSEND=80",1000,DEBUG); sendData(String("GET ") + resource + message,2000,DEBUG); delay(1000); //sendData(String("GET ") + resource + + coord + " HTTP/1.0\r\n",100,DEBUG); } void SendTextMessage(String message) { sendData("AT+CMGF=1",5000,DEBUG); //Set the SMS in text mode delay(100); sendData("AT+CMGS="+target_phone,2000,DEBUG);//send sms message to the cellphone , be careful need to add a country code before the cellphone number delay(100); sendData(message,2000,DEBUG); //the content of the message delay(100); Serial1.println((char)26); //the ASCII code of the ctrl+z is 26 delay(100); sendData("",1000,DEBUG); //Clear serial data delay(100); } void sendData(String command, const int timeout, boolean debug) { String response = ""; Serial1.println(command); long int time = millis(); while( (time+timeout) > millis()){ while(Serial1.available()){ response += (char)Serial1.read(); } } if(debug){ Serial.print(response); } }
Elmirus, Вы "засветили" своё местоположение и номер мобильного телефона в этой теме, я зазвездил.
Если Вы понимаете, о чём это я, то будьте пожалуйста впредь осторожнее, если нет - извините за беспокойство.
У радиолюбителей для этой цели есть APRS, посмотреть местоположение можно по карте на aprs.fi, через шлюз видны и посудины в чёрном и азовском морях, в других не смотрел )))
Спасибо, я понял, но хотел узнать в каком формате сервер принимает координаты, как их формировать? шиота долгота или долгота , а потом широта нужно ли время вставлять и какие разделители присутствуют? Может загоняется весь пакет NMEA?
У меня эта строка отправляет коодинаты: sendData(String("GET ") + resource + message,2000,DEBUG);