I am not good at English
after releaseing the disconnection of device gps
'yunclient' worls well
but when I connect the gps to Arduino
'yunclient does not work at all... ㅠㅠㅠㅠㅠㅠ
what would be the reason?
Please help me
I would like to combined the two sources.
arduino yun board ...AdafruitGPS.....
Adafruit_GPS
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
Adafruit_GPS GPS(&Serial1);
//The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX)
HardwareSerial mySerial = Serial1;
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO true
void setup() {
Serial.begin(115200);
//Serial.begin(9600);
delay(5000);
Serial.println("Adafruit GPS library basic test!");
GPS.begin(9600);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
GPS.sendCommand(PGCMD_ANTENNA);
delay(1000);
mySerial.println(PMTK_Q_RELEASE);
}
uint32_t timer = millis();
void loop() {
char c = GPS.read();
if ((c) && (GPSECHO)) {
// Serial.write(c);
}
if (GPS.newNMEAreceived()) {
if (!GPS.parse(GPS.lastNMEA()))
return;
}
if (timer > millis()) timer = millis();
if (millis() - timer > 2000) {
timer = millis();
// Serial.print("Fix: "); Serial.print((int)GPS.fix);
if (GPS.fix) {
Serial.print("Location: ");
Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
Serial.print(", ");
Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
Serial.print("convertDegMinToDecDeg / Location: ");
Serial.print(convertDegMinToDecDeg(GPS.latitude), 7);
Serial.print(", ");
Serial.println(convertDegMinToDecDeg(GPS.longitude), 7);
Serial.print("conv_coords / Location: ");
Serial.print(conv_coords(GPS.latitude), 8);
Serial.print(", ");
Serial.println(conv_coords(GPS.longitude), 8);
}
}
}
double convertDegMinToDecDeg (float degMin) {
double min = 0.0;
double decDeg = 0.0;
//get the minutes, fmod() requires double
min = fmod((double)degMin, 100.0);
//rebuild coordinates in decimal degrees
degMin = (int) ( degMin / 100 );
decDeg = degMin + ( min / 60 );
return decDeg;
}
float conv_coords(float in_coords) {
float f = in_coords;
int firsttwodigits = ((int)f) / 100;
float nexttwodigits = f - ((float)firsttwodigits * 100.0);
float theFinalAnswer = (float)(firsttwodigits + nexttwodigits / 60.0);
return theFinalAnswer;
}
YunClient
#include <Bridge.h>
#include <HttpClient.h>
#include <YunClient.h>
#include <SPI.h>
YunClient client;
IPAddress server(~~~~~~~); //my ip Address<<
//74,125,227,16 google
int port = 8080;
int temp = 64;
String parametri = "";
void setup() {
Bridge.begin();
Serial.begin(9600);
delay(5000);
Serial.println("setup");
}
void loop() {
Serial.println("loop");
parametri = "";
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
connect();
}
void connect() {
Serial.println("connect");
parametri = "";
if (client.connect(server, port)) {
Serial.println("connected");
delay(3000);
parametri = "rem_temp=" + String(temp);
client.println("POST /test?gpsid=bus1111 HTTP/1.1");
client.print("Content-length:");
client.println(parametri.length());
Serial.println(parametri.length());
Serial.println(parametri);
client.println("Connection: Close");
client.println("Host:19~~~~~);
client.println("Content-Type: application/x-www-form-urlencoded");
client.println();
client.println(parametri);
}
else {
Serial.println("connection failed");
}
}