AssetTracker Shield - HTTP Post

Hello I am very new to programing and the arduino. I am working on a project using the AssetTracker Shield and having it post to a traccar server via http. I have modified the example code to add Speed,Heading,Altitude, Number of satellites. I am able print this data via serial just fine and also use the particle.publish funtion and have it working well. But I need to use the HTTPClient Library to send the data to a URL.

Here is my serial data code:

Serial.print("Location: ");
Serial.print("Lat: "); Serial.print(t.readLatDegree());
Serial.print(", ");
Serial.print("Lon: "); Serial.println(t.readLonDegree());
Serial.print("Speed (knots): "); Serial.println(t.readSpeed());
Serial.print("Angle: "); Serial.println(t.readAngle());
Serial.print("Altitude: "); Serial.println(t.readAltitude());
Serial.print("Satellites: "); Serial.println(t.readSatellites());
Serial.print("HDOP: "); Serial.println(t.readHDOP());
Serial.print("FIXQ: "); Serial.println(t.readFixquality());

Which I get the following via serial:

Location: Lat: 22.222222, Lon: -11.111111
Speed (knots): 0.050000
Angle: 100.580002
Altitude: 278.899994
Satellites: 8
HDOP: 0.990000
FIXQ: 1

So posting to serial has the right data... I need to construct the following URL from that data

http://server.host:port/?id=000001&lat=22.222222&lon=-11.111111&speed=0.050000&bearing=100.580002&altitude=278.899994

If i use curl 'http://server.host:port/?id=000001&lat=22.222222&lon=-11.111111&speed=0.050000&bearing=100.580002&altitude=278.899994 from my command line replacing proper server.host.port and device ID it posts properly. But now I need the electron to make that url and post. I do have the HTTPClient libary just not sure how to format the request.path properly so it makes the url above from the strings from the GPS.

Thanks,
Fred

Well walked away for a few and figured it out myself…

request.path = ("/?id=000001&lat="+(t.readLatDegree())
+"&lon="+(t.readLonDegree())
+"&speed="+(t.readSpeed())
+"&bearing="+(t.readAngle())
+"&altitude="+(t.readAltitude())
+"&batt="+String(fuel.getSoC())
);

Sometimes walking away for a few helps…

2 Likes

@netsound Hey mate, Did you ever get this working? Were you able to post straight from your device to traccar?