Components and supplies
Antenna, GPS
Resistor 220 ohm
SIM900 development board
Arduino Leonardo
NEO-6M GPS module
LED (generic)
12V to 5V step down module
Adafruit SD card reader
Solder board 7 x 5cm
Flash Memory Card, MicroSD Card
Tools and machines
Soldering iron (generic)
Apps and platforms
Thinger.io Platform
Project description
Code
GPS_tracker_Leonardo_v2.ino
arduino
GPS_tracker_Leonardo_v2.ino
arduino
Downloadable files
track_me_project_bb_uejafKcZyT.png
track_me_project_bb_uejafKcZyT.png
track_me_project_bb_uejafKcZyT.png
track_me_project_bb_uejafKcZyT.png
Documentation
Casing top (compact)
A compact version of the top casing (less space inside enclosure)
Casing top (compact)
settings_iMpR6v81OB.txt
rename to "settings.txt" and place on SD card
settings_iMpR6v81OB.txt
lock2_ZR5SAmG6IJ.stl
Locks SIM900 board in place (no mounting holes on SIM900 board)
lock2_ZR5SAmG6IJ.stl
Casing top (large)
Top of casing for more space (taller). The mounting holes are closed and must be drilled after print (to make for easier printing)
Casing top (large)
casing_bottom_0Cy4SBAx3t.stl
Bottom part of casing - for SIM900 and Arduino board with cutouts for connectors
casing_bottom_0Cy4SBAx3t.stl
dist_1qOG9VMO2D.txt
rename to "dist.txt" and place on SD card
dist_1qOG9VMO2D.txt
Casing top (large)
Top of casing for more space (taller). The mounting holes are closed and must be drilled after print (to make for easier printing)
Casing top (large)
settings_iMpR6v81OB.txt
rename to "settings.txt" and place on SD card
settings_iMpR6v81OB.txt
lock2_ZR5SAmG6IJ.stl
Locks SIM900 board in place (no mounting holes on SIM900 board)
lock2_ZR5SAmG6IJ.stl
casing_bottom_0Cy4SBAx3t.stl
Bottom part of casing - for SIM900 and Arduino board with cutouts for connectors
casing_bottom_0Cy4SBAx3t.stl
lock1_C45eXQfR5p.stl
Locks SIM900 board in place
lock1_C45eXQfR5p.stl
dist_1qOG9VMO2D.txt
rename to "dist.txt" and place on SD card
dist_1qOG9VMO2D.txt
Casing top (compact)
A compact version of the top casing (less space inside enclosure)
Casing top (compact)
Comments
Only logged in users can leave comments
Anonymous user
2 years ago
Hi, i wanna say thank you for your hard work. i was searching the net for months something like this. im struggling around three days to get it done. im using sim800c. i always getting +HTTPACTION: 1,400,51 i dont use https Evan if i run it manually or using the sketch. do you have any idea what could be the problem. thanks again.
Anonymous user
2 years ago
It works. ! Specifying the data length is also crucial as you said.
tormods
2 years ago
Its a little late update on the issue, but I found that the SIM900 chip needed a firmware upgrade to enable the "CONTENT" option for the AT+HTTPPARA command. Without this command the HTTP header will not include "content-type: application/json" which it needs. If it does not, it returns a 400 "bad request". This worked previously, but in May thinger.io changed the API somehow and it stopped working. So I had to update the firmware to make it work again, I have updated this guide with this information too. However, you have a different chip, so this might not be the issue, but can't hurt to check. An easy way to test this is by using https://requestcatcher.com and not the thinger URL in the code. The HTTP POST request will then be shown in plain text at this site, and what you are looking for is the "content-type" section. If its not there, you have a problem.. maybe look into the firmware issue as mentioned.
tormods
2 years ago
Hi Samantha! Glad you found it useful! I try my best :) I'm not familiar with the sim800 models although I've seen that it is what I should have used as its replacing the older sim900. Are you also posting to thinger.io or just a HTTP post request in general? The 400 return code just means "bad HTTP request", so the request is rejected. The message basically says that "something is wrong with your request". This can come down to anything really, what you are essentially doing is building the HTTP POST request with all attention commands (AT commands) before sending it with"HTTPACTION=1". So any of the previous AT commands can be wrong in one way or another. The things I struggled with that you can check: - Wrong/bad URL, e.g. using https and not http, wrong address, syntax error. - Missing quoation mark around text, small things like this. - I struggled for a long time with the byte count in "AT+HTTPDATA=<byte count>,<input delay>". This byte count has to be *exact* for *your* string which you send, otherwise it won't work. Took me quite som time to figure that one out. - If using thinger.io, make sure the authorisation key is correct. - the data fields in the "content" section needs to be in *exact order and syntax* otherwise you will get problems, e.g. { field1 : field1_value , field2 : field2_value } etc. - Thinger.io bucket must also be set to "From Write Call" to enable HTTP write requests If any one of these things are wrong, you might get that return code (or similar). If none of that works, I think you are better off posting your code and serial output in the forum section, that way it's easier to see the code and what might be wrong.. it always helps to have some context
tormods
2 years ago
Hey, glad it worked :)
Anonymous user
2 years ago
Hi, I really like what you did here and I want to try to do this project myself, but it looks like the SD card Arduino library has been deleted. Can you provide a new link or a new library? Ty in advance and well done again for this amazing project
tormods
2 years ago
Hi! And thanks for your interest in the project :) It seems that I messed up the link and included the "dot" at the and as part of the address, lol. Try this link instead, the library seems to be online and well at GitHub: https://github.com/greiman/PetitFS You can also try finding it directly in the Arduino IDE (library manager). It should be there.
Anonymous user
3 years ago
Hi, I really like what you did here and I want to try to do this project myself, but it looks like the SD card Arduino library has been deleted. Can you provide a new link or a new library? Ty in advance and well done again for this amazing project
tormods
2 years ago
Hi! And thanks for your interest in the project :) It seems that I messed up the link and included the "dot" at the and as part of the address, lol. Try this link instead, the library seems to be online and well at GitHub: https://github.com/greiman/PetitFS You can also try finding it directly in the Arduino IDE (library manager). It should be there.
Anonymous user
4 years ago
Good day, many thanks for sharing a very well detailed project! Being new in the world of Arduino coding, please advise whether this project's source code could be tailored to work on an Arduino Uno? Thank you
tormods
2 years ago
Hi Js, and thanks for your interest in my project. While it's possible (in theory) to make it work for an Uno board, it's not advisable. The reason for this is that Uno only have one hardware serial line, whereas this project requires two. In theory, you could use the "USB" line (and disconnect the GPS while downloading), but then you will loose all debugging, testing and monitoring capabilities. I don't think I've ever made a project work on first try without any adjustments and testing, so it would make things a lot harder. And you would then need to adjust the code without any means to monitor and test it properly. So I'd say you are better off getting the right board to make this work :) Having said that, you don't need the Leonardo board though. The code could be adjusted to work with other boards as long as there are two hardware serial lines, like the Mega or others.
Anonymous user
5 years ago
Hi, i wanna say thank you for your hard work. i was searching the net for months something like this. im struggling around three days to get it done. im using sim800c. i always getting +HTTPACTION: 1,400,51 i dont use https Evan if i run it manually or using the sketch. do you have any idea what could be the problem. thanks again.
tormods
2 years ago
Hey, glad it worked :)
tormods
2 years ago
Hi Samantha! Glad you found it useful! I try my best :) I'm not familiar with the sim800 models although I've seen that it is what I should have used as its replacing the older sim900. Are you also posting to thinger.io or just a HTTP post request in general? The 400 return code just means "bad HTTP request", so the request is rejected. The message basically says that "something is wrong with your request". This can come down to anything really, what you are essentially doing is building the HTTP POST request with all attention commands (AT commands) before sending it with"HTTPACTION=1". So any of the previous AT commands can be wrong in one way or another. The things I struggled with that you can check: - Wrong/bad URL, e.g. using https and not http, wrong address, syntax error. - Missing quoation mark around text, small things like this. - I struggled for a long time with the byte count in "AT+HTTPDATA=<byte count>,<input delay>". This byte count has to be *exact* for *your* string which you send, otherwise it won't work. Took me quite som time to figure that one out. - If using thinger.io, make sure the authorisation key is correct. - the data fields in the "content" section needs to be in *exact order and syntax* otherwise you will get problems, e.g. { field1 : field1_value , field2 : field2_value } etc. - Thinger.io bucket must also be set to "From Write Call" to enable HTTP write requests If any one of these things are wrong, you might get that return code (or similar). If none of that works, I think you are better off posting your code and serial output in the forum section, that way it's easier to see the code and what might be wrong.. it always helps to have some context
tormods
2 years ago
Its a little late update on the issue, but I found that the SIM900 chip needed a firmware upgrade to enable the "CONTENT" option for the AT+HTTPPARA command. Without this command the HTTP header will not include "content-type: application/json" which it needs. If it does not, it returns a 400 "bad request". This worked previously, but in May thinger.io changed the API somehow and it stopped working. So I had to update the firmware to make it work again, I have updated this guide with this information too. However, you have a different chip, so this might not be the issue, but can't hurt to check. An easy way to test this is by using https://requestcatcher.com and not the thinger URL in the code. The HTTP POST request will then be shown in plain text at this site, and what you are looking for is the "content-type" section. If its not there, you have a problem.. maybe look into the firmware issue as mentioned.
Anonymous user
2 years ago
It works. ! Specifying the data length is also crucial as you said.
Car GPS tracker with thinger.io map integration | Arduino Project Hub
shaargerber
a year ago
The Code that is provided , is not working.I evidentially gave up on the Code as there no mention of any headers in the post method , you cant use the Auth section in the url parameters.Also you cant use "\\ in n string , also there is no need to define the actual data length in the post request. This section is wrong , "AT+HTTPPARA="URL","http://backend.thinger.io/v3/users/abc/devices/1/callback/data?authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" You have to define a payload section as well as a header section. Like this , sim800l->doPost(URL, HEADERS, CONTENT_TYPE, PAYLOAD, 20000, 20000); Just use the sim800l.h as a added libary. Here is diff coded if you are interested. This Code only applies to GSM , I tested and working. #include <SoftwareSerial.h> #include "SIM800L.h" #define TXPin 2 // SIM800 Tx pin 2 #define RXPin 3 // SIM800 Rx pin 3 #define RSTPin 6 SoftwareSerial SIM800( RXPin, TXPin ); const char APN[] = "internet"; const char URL[] = "https://backend.thinger.io/v3/users/abc/devices/1/callback/data"; user abc is n not valid change with your own user const char CONTENT_TYPE[] = "application/json"; const char HEADERS[] = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"; //Use your own auth keys const char PAYLOAD[] = "{\"lat\": \"-26.24913\", \"lng\": \"28.121685\"}"; SIM800L* sim800l; void setup() { Serial.begin(9600); while(!Serial); SoftwareSerial* serial = new SoftwareSerial(RXPin, TXPin); serial->begin(9600); delay(1000); //sim800l = new SIM800L((Stream *)serial, RSTPin, 200, 512); sim800l = new SIM800L((Stream *)serial, RSTPin, 256, 512, (Stream *)&Serial); setupModule(); } void loop() { bool connected = false; for(uint8_t i = 0; i < 5 && !connected; i++) { delay(1000); connected = sim800l->connectGPRS(); } if(connected) { Serial.print(F("GPRS connected with IP ")); Serial.println(sim800l->getIP()); } else { Serial.println(F("GPRS not connected !")); Serial.println(F("Reset the module.")); setupModule(); return; } Serial.println(F("Start HTTP POST...")); uint16_t rc = sim800l->doPost(URL, HEADERS, CONTENT_TYPE, PAYLOAD, 20000, 20000); if(rc == 200) { // Success, output the data received on the serial Serial.print(F("HTTP POST successful (")); Serial.print(sim800l->getDataSizeReceived()); Serial.println(F(" bytes)")); Serial.print(F("Received : ")); Serial.println(sim800l->getDataReceived()); } else { // Failed... Serial.print(F("HTTP POST error ")); Serial.println(rc); } delay(1000); // Close GPRS connectivity (5 trials) bool disconnected = sim800l->disconnectGPRS(); for(uint8_t i = 0; i < 5 && !connected; i++) { delay(1000); disconnected = sim800l->disconnectGPRS(); } if(disconnected) { Serial.println(F("GPRS disconnected !")); sim800l->reset(); } else { Serial.println(F("GPRS still connected !")); } // Go into low power mode bool lowPowerMode = sim800l->setPowerMode(MINIMUM); if(lowPowerMode) { Serial.println(F("Module in low power mode")); } else { Serial.println(F("Failed to switch module to low power mode")); } while(1); } void setupModule() { // Wait until the module is ready to accept AT commands while(!sim800l->isReady()) { Serial.println(F("Problem to initialize AT command, retry in 1 sec")); delay(1000); } Serial.println(F("Setup Complete!")); // Wait for the GSM signal uint8_t signal = sim800l->getSignal(); while(signal <= 0) { delay(1000); signal = sim800l->getSignal(); } Serial.print(F("Signal OK (strenght: ")); Serial.print(signal); Serial.println(F(")")); delay(1000); // Wait for operator network registration (national or roaming network) NetworkRegistration network = sim800l->getRegistrationStatus(); while(network != REGISTERED_HOME && network != REGISTERED_ROAMING) { delay(1000); network = sim800l->getRegistrationStatus(); } Serial.println(F("Network registration OK")); delay(1000); // Setup APN for GPRS configuration bool success = sim800l->setupGPRS(APN); while(!success) { success = sim800l->setupGPRS(APN); delay(5000); } Serial.println(F("GPRS config OK")); }