Components and supplies
Arduino Nano 33 IoT
GPS Module (Generic)
Project description
Code
Emitter Software
arduino
1#include <ArduinoJson.h> 2#include<ArduinoHttpClient.h> 3#include <SPI.h> 4#include <WiFiNINA.h> 5#include <Bridge.h> 6#include <BridgeHttpClient.h> 7#include "TinyGPS++.h" 8 9 10TinyGPSPlus gps; 11 12WiFiClient client; 13 14 15 16char server [] = "YOUR_API_HERE"; 17 18 19StaticJsonDocument<200> doc; 20char ssid[] = "YOUR_SSID"; 21char pass[] = "YOUR_PASS"; 22int status = WL_IDLE_STATUS ; 23 24void setup() { 25 26 Serial.begin(9600); 27 Serial1.begin(9600); 28 while (status != WL_CONNECTED) { 29 status = WiFi.begin(ssid , pass); 30 if (status == WL_CONNECTED) { 31 Serial.print("You are connected to "); 32 Serial.print(ssid); 33 Serial.println(" "); 34 35 } 36 delay(10000); 37 } 38 39 40 41} 42 43void loop() { 44if(Serial1.available()){ 45 gps.encode(Serial1.read()); 46} 47if(gps.location.isUpdated()){ 48Serial.println(gps.location.lat()); 49double lat = gps.location.lat(); 50double lng = gps.location.lng(); 51doc["latitude"] = lat; 52doc["longitude"] = lng; 53 String JSON; 54 serializeJson(doc , JSON); 55 Serial.println(JSON); 56 char JSON_ARRAY [JSON.length() + 1]; 57 strcpy(JSON_ARRAY , JSON.c_str()); 58 HttpClient HTTP = HttpClient(client, server , 80); 59 Serial.println("Sending request"); 60 HTTP.post("/api" , "application/json" , JSON_ARRAY ); 61 Serial.println(HTTP.responseStatusCode()); 62 Serial.println(HTTP.responseBody()); 63 Serial.println("==============================================="); 64 65 66 67 68 delay(180000); 69} 70 71} 72 73
Emitter Software
arduino
1#include <ArduinoJson.h> 2#include<ArduinoHttpClient.h> 3#include 4 <SPI.h> 5#include <WiFiNINA.h> 6#include <Bridge.h> 7#include <BridgeHttpClient.h> 8#include 9 "TinyGPS++.h" 10 11 12TinyGPSPlus gps; 13 14WiFiClient client; 15 16 17 18char 19 server [] = "YOUR_API_HERE"; 20 21 22StaticJsonDocument<200> doc; 23char ssid[] 24 = "YOUR_SSID"; 25char pass[] = "YOUR_PASS"; 26int status = WL_IDLE_STATUS 27 ; 28 29void setup() { 30 31 Serial.begin(9600); 32 Serial1.begin(9600); 33 34 while (status != WL_CONNECTED) { 35 status = WiFi.begin(ssid , pass); 36 37 if (status == WL_CONNECTED) { 38 Serial.print("You are connected to "); 39 40 Serial.print(ssid); 41 Serial.println(" "); 42 43 } 44 45 delay(10000); 46 } 47 48 49 50} 51 52void loop() { 53if(Serial1.available()){ 54 55 gps.encode(Serial1.read()); 56} 57if(gps.location.isUpdated()){ 58Serial.println(gps.location.lat()); 59double 60 lat = gps.location.lat(); 61double lng = gps.location.lng(); 62doc["latitude"] 63 = lat; 64doc["longitude"] = lng; 65 String JSON; 66 serializeJson(doc , JSON); 67 68 Serial.println(JSON); 69 char JSON_ARRAY [JSON.length() + 1]; 70 strcpy(JSON_ARRAY 71 , JSON.c_str()); 72 HttpClient HTTP = HttpClient(client, server , 80); 73 Serial.println("Sending 74 request"); 75 HTTP.post("/api" , "application/json" , JSON_ARRAY ); 76 Serial.println(HTTP.responseStatusCode()); 77 78 Serial.println(HTTP.responseBody()); 79 Serial.println("==============================================="); 80 81 82 83 84 85 delay(180000); 86} 87 88} 89 90
Downloadable files
Schematics
Schematics
Comments
Only logged in users can leave comments
clairiereriom
2 years ago
Yes of course! Just send me an email at jdain@outlook.fr!
clairiereriom
0 Followers
•1 Projects
2
mdfazril
4 years ago
Hi bro, Great work! I'm working on a similar project using Arduino NANO 33 IOT and Ublox NEO-6M GPS Module. If you don't mind, is it possible could I contact you to discuss on how you did your project turtle?