Hello
I am working on a project where I need to take temperature measurements on lake and if my sensor drifts I can locate it. I have really limited knowledge of coding. As I was working on a part where the temperature sensor shows numbers, I learned the difference of int and float numbers.
What I have is a arduino UNO, arduino GSM shield2 (quectel M10), adafruit ultimate gps logger, and a ds18b20 temperature sensor. Data is uploaded to Thingspeak.
I can get temperature data to thingspeak easily with the help of example codes like this:
// include the libraries
#include <GSM.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// PIN number if necessary
#define PINNUMBER ""
// APN information obrained from your network provider
#define GPRS_APN "julkinen.dna.fi" // replace with your GPRS APN
#define GPRS_LOGIN "" // replace with your GPRS login
#define GPRS_PASSWORD "" // replace with your GPRS password
// Data wire is plugged into pin 4 on the Arduino
#define ONE_WIRE_BUS 4
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = ""; //replace with your API Key
const int updateThingSpeakInterval = 30 * 1000; // Time interval in milliseconds to update ThingSpeak (number of seconds * 1000 = interval)
// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;
int failedCounter = 0;
String Incoming; // for incoming serial data
void setup() {
Serial.setTimeout(5);
Serial.begin(57600); // opens serial port, sets data rate to 57600 bps
StartGSM();
Serial.println("STARTUP ON OK");
// Start up the library
sensors.begin();
}
String readData() {
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
/********************************************************************/
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperature readings
Serial.println("DONE");
/********************************************************************/
Serial.print("Temperature is: ");
Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one DS18B20 on the same bus.
// 0 refers to the first IC on the wire
float temperature = sensors.getTempCByIndex(0);
int value1 = analogRead (A0);
int value2 = analogRead(A1);
String StringToThingSpeak = "field1=" + String(value1) + "&field2=" + String(value2) + "&field3=" + String(temperature);
return StringToThingSpeak;
}
void loop()
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
// Disconnect from ThingSpeak
if (!client.connected() && lastConnected)
{
Serial.println("...disconnected");
Serial.println();
client.stop();
}
// Update ThingSpeak
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
{
String ToThingSpeak = readData();
Serial.println (ToThingSpeak);
updateThingSpeak(ToThingSpeak);
}
// Check if Arduino Ethernet needs to be restarted
if (failedCounter > 3 ) {StartGSM();}
lastConnected = client.connected();
}
void updateThingSpeak(String tsData)
{
if (client.connect(thingSpeakAddress, 80))
{
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
lastConnectionTime = millis();
if (client.connected())
{
Serial.println("Connecting to ThingSpeak...");
Serial.println();
failedCounter = 0;
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
Serial.println();
}
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak Failed ("+String(failedCounter, DEC)+")");
Serial.println();
lastConnectionTime = millis();
}
}
void StartGSM()
{
char server[] = "api.thingspeak.com"; // the base URL
int port = 80; // the port, 80 for HTTP
Serial.println("Starting Arduino web client.");
// connection state
boolean notConnected = true;
// Start GSM shield
// pass the PIN of your SIM as a parameter of gsmAccess.begin()
while(notConnected)
{
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, port))
{
Serial.println("connected");
// Make a HTTP request:
// client.print("GET ");
// client.print(path);
// client.println(" HTTP/1.0");
// client.println();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
But as soon as I try to add gps with gsm it breaks. I have tried with libraries softwareserial, adafruitgps, adafruitAltgps, Tinygps++, altsoftserial. As I have looked up from internet I think the Tinygps++ and altsoftserial has been successfull for others for a similar projects. For me when using them I can see that the gps gives right coordinates but my uploading breaks.
This is the code where I join GSM, GPS and Temperature sensor:
// include the libraries
#include <GSM.h> //gsm lib
#include <OneWire.h> //for temperature sensor
#include <DallasTemperature.h> //for temperature sensor
#include <TinyGPS++.h> //gps lib
#include <AltSoftSerial.h> //gps connection lib
TinyGPSPlus gps;
AltSoftSerial ss;
unsigned char buffer[64]; // buffer array for data recieve over serial port
int fixed = 0;
// PIN number if necessary
#define PINNUMBER ""
// APN information obrained from your network provider
#define GPRS_APN "julkinen.dna.fi" // replace with your GPRS APN
#define GPRS_LOGIN "" // replace with your GPRS login
#define GPRS_PASSWORD "" // replace with your GPRS password
// Data temperaturesensor wire is plugged into pin 4 on the Arduino
#define ONE_WIRE_BUS 4
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = ""; //replace with your API Key
const int updateThingSpeakInterval = 5 * 1000; // Time interval in milliseconds to update ThingSpeak (number of seconds * 1000 = interval)
// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;
int failedCounter = 0;
String Incoming; // for incoming serial data
void setup() {
Serial.setTimeout(5);
Serial.begin(57600); // opens serial port, sets data rate to 57600 bps
StartGSM();
ss.begin(9600); // start gps
sensors.begin(); // start temperature things
}
String readData() {
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
/********************************************************************/
sensors.requestTemperatures(); // Send the command to get temperature readings
/********************************************************************/
// You can have more than one DS18B20 on the same bus.
// 0 refers to the first IC on the wire
float temperature = sensors.getTempCByIndex(0);
Serial.println(temperature); //Cheking if temperature is read correctly
GPSCord(); //Go read the coordinates
Serial.println(gps.location.lng()); //Checking if gps reads cordinates right
Serial.println(gps.location.lat()); //Checking if gps reads cordinates right
String StringToThingSpeak = "field1=" + String(gps.location.lat()) + "&field2=" + String(gps.location.lng()) + "&field3=" + String(temperature); //All the information for thingspeak
return StringToThingSpeak;
}
void loop()
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
// Disconnect from ThingSpeak
if (!client.connected() && lastConnected)
{
Serial.println("...disconnected");
Serial.println();
client.stop();
}
// Update ThingSpeak
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
{
String ToThingSpeak = readData();
Serial.println (ToThingSpeak);
updateThingSpeak(ToThingSpeak);
}
// Check if Arduino Ethernet needs to be restarted
if (failedCounter > 3 ) {StartGSM();}
lastConnected = client.connected();
}
void updateThingSpeak(String tsData)
{
if (client.connect("api.thingspeak.com", 80))
{
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");
client.print(tsData);
lastConnectionTime = millis();
if (client.connected())
{
Serial.println("Connecting to ThingSpeak...");
Serial.println();
failedCounter = 0;
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
Serial.println();
}
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak Failed ("+String(failedCounter, DEC)+")");
Serial.println();
lastConnectionTime = millis();
}
}
void GPSCord(){ //Tiny gps example
while (ss.available() > 0)
gps.encode(ss.read());
if (gps.location.isUpdated())
{
fixed = 1;
// Serial.print("LAT="); Serial.print(gps.location.lat(), 6);
// Serial.print(" LNG="); Serial.println(gps.location.lng(), 6);
}
if(fixed ==0)
{
// digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(300); // wait for a second
// digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
// delay(300);
// Serial.print("NO GPS Signal Detected");
}
}
void StartGSM()
{
char server[] = "api.thingspeak.com"; // the base URL
int port = 80; // the port, 80 for HTTP
Serial.println("Starting Arduino web client.");
// connection state
boolean notConnected = true;
// Start GSM shield
// pass the PIN of your SIM as a parameter of gsmAccess.begin()
while(notConnected)
{
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(100);
}
}
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, port))
{
Serial.println("connected");
// Make a HTTP request:
// client.print("GET ");
// client.print(path);
// client.println(" HTTP/1.0");
// client.println();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
Now at this point arduino IDE tells me that:
Low memory available, stability problems may occur.
And in serialmonitor gives me:
Starting Arduino web client.
connecting...
connected
...disconnected <- This happens when everything is ok also
-127.00 <-not currently temperature sensor connected
0.00 <-Fix not locked These show correctly now
0.00 ^^added those when posting to forum
Connecting to ThingSpeak...
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Status: 400 Bad Request
X-Frame-Options: SAMEORIGIN
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH
Access-Control-Allow-Headers: origin, content-type, X-Requested-With
Access-Control-Max-Age: 1800
Cache-Control: no-cache
Set-Cookie: request_method=POST; path=/
X-Request-Id: 1d1f35ad-bc6d-401a-b04b-e7f737e280f3
X-Runtime: 0.005472
X-Powered-By: Phusion Passenger 4.0.57
Date: Fri, 07 Dec 2018 11:27:13 GM...disconnected
What options do I have to get this working? Or was this total waste of time as someone said to other similar project that this cannot ever work with an UNO. Is it the memory limit or something in the code?
hammy:
Use and anchor , then you don’t need to worry about where it is .
You electronics needs tidying up - I would mount all the parts on a small board.
Going to use this on a big lake, so Im afraid that wind and small currents might blow it away. Or if somehow the anchor/anchor line fails I can still find it.
For mounting going to solder some wire directly to gps and connect it directly to arduino. (I have a bad breadboard where arduino pins dont fit nicely so I have done this on table like this)
PaulS:
String Incoming; // for incoming serial data
When you have memory problems, pissing away resources on the String class is the worst thing you can do.
I found people talking about strings and arrays, but I dont know if i get this.
Do I just replace the: String Incoming; to: char Incoming;?
My friend that has experience with C helped me this time.(No arduino experience.)
Now we hit a wall where we get error 400 when trying to upload data.
Same serial messages as other times:
Starting Arduino web client.
connecting...
connected
...disconnected
-127.00
Connecting to ThingSpeak...
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Status: 400 Bad Request
X-Frame-Options: SAMEORIGIN
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH
Access-Control-Allow-Headers: origin, content-type, X-Requested-With
Access-Control-Max-Age: 1800
Cache-Control: no-cache
Set-Cookie: request_method=POST; path=/
X-Request-Id: 3d6e4944-0cfa-4e2a-8631-2e4ed8558f84
X-Runtime: 0.005614
X-Powered-By: Phusion Passenger 4.0.57
Date: Mon, 17 Dec 2018 16:21:26 GM...disconnected
Here is the code that we lastly tried.
// include the libraries
#include <GSM.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TinyGPS++.h>
#include <AltSoftSerial.h>
TinyGPSPlus gps;
AltSoftSerial ss; //RX9 and TX8
unsigned char buffer[64]; // buffer array for data recieve over serial port
int fixed = 0;
// PIN number if necessary
#define PINNUMBER ""
// APN information obrained from your network provider
#define GPRS_APN "julkinen.dna.fi" // replace with your GPRS APN
#define GPRS_LOGIN "" // replace with your GPRS login
#define GPRS_PASSWORD "" // replace with your GPRS password
// Data temperaturesensor wire is plugged into pin 4 on the Arduino
#define ONE_WIRE_BUS 4
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
// initialize the library instances
GSMClient client;
GPRS gprs;
GSM gsmAccess;
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "X66AIY02M2TC7L8K"; //replace with your API Key
const long updateThingSpeakInterval = 5 * 1000; // Time interval in milliseconds to update ThingSpeak (number of seconds * 1000 = interval)
// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;
int failedCounter = 0;
//String Incoming; // for incoming serial data dont know if it works
void setup() {
Serial.setTimeout(5);
Serial.begin(57600); // opens serial port, sets data rate to 57600 bps
StartGSM(); //start gsm
ss.begin(9600); // start gps
sensors.begin(); // start temperature things
}
void loop()
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
// Disconnect from ThingSpeak
if (!client.connected() && lastConnected)
{
Serial.println("...disconnected");
Serial.println();
client.stop();
}
// Update ThingSpeak
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
{
sensors.requestTemperatures(); // Send the command to get temperature readings
float temperature = sensors.getTempCByIndex(0);
Serial.println(temperature);
GPSCord();
float lati = 1.1;
float longi = 2.2;
//String StringToThingSpeak = "field1=" + String(lati) + "&field2=" + String(longi) + "&field3=" + String(temperature); //THIS IS BROKEN SOMEHOW
String StringToThingSpeak = "field1=1.1&field2=2.2&field3=-127"; //Tried to make it like this to see if this would work
Serial.println(StringToThingSpeak); //doesnt print out
//updateThingSpeak(StringToThingSpeak);
if (client.connect("api.thingspeak.com", 80))
{
client.println("POST /update HTTP/1.1");
client.println("Host: api.thingspeak.com");
client.println("Connection: close");
client.println("X-THINGSPEAKAPIKEY: "+writeAPIKey);
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Content-Length: "+StringToThingSpeak.length() + 1);
client.println();
client.println(StringToThingSpeak);
lastConnectionTime = millis();
if (client.connected())
{
Serial.println("Connecting to ThingSpeak...");
Serial.println();
failedCounter = 0;
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
Serial.println();
}
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak Failed ("+String(failedCounter, DEC)+")");
Serial.println();
lastConnectionTime = millis();
}
}
// Check if Arduino Ethernet needs to be restarted
if (failedCounter > 3 ) {StartGSM();}
lastConnected = client.connected();
}
/*
void updateThingSpeak(String tsData)
{
if (client.connect("api.thingspeak.com", 80))
{
client.println("POST /update HTTP/1.1");
client.println("Host: api.thingspeak.com");
client.println("Connection: close");
client.println("X-THINGSPEAKAPIKEY: "+writeAPIKey);
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Content-Length: "+tsData.length() + 1);
client.println();
client.println(tsData);
lastConnectionTime = millis();
if (client.connected())
{
Serial.println("Connecting to ThingSpeak...");
Serial.println();
failedCounter = 0;
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
Serial.println();
}
}
else
{
failedCounter++;
Serial.println("Connection to ThingSpeak Failed ("+String(failedCounter, DEC)+")");
Serial.println();
lastConnectionTime = millis();
}
}
*/
void GPSCord(){ //GPS!
while (ss.available() > 0)
gps.encode(ss.read());
if (gps.location.isUpdated())
{
fixed = 1;
//Serial.print("LAT="); Serial.print(gps.location.lat(), 6); //Testing if this reads right
//Serial.print(" LNG="); Serial.println(gps.location.lng(), 6); //Testing if this reads right
}
if(fixed ==0)
{
// digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(300); // wait for a second
// digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
// delay(300);
//Serial.print("NO GPS Signal Detected");
}
}
void StartGSM()
{
int port = 80; // the port, 80 for HTTP
Serial.println("Starting Arduino web client.");
// connection state
boolean notConnected = true;
// Start GSM shield
// pass the PIN of your SIM as a parameter of gsmAccess.begin()
while(notConnected)
{
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(100);
}
}
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(thingSpeakAddress, port))
{
Serial.println("connected");
// Make a HTTP request:
// client.print("GET ");
// client.print(path);
// client.println(" HTTP/1.0");
// client.println();
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
Somehow our string that we want to send ends up breaking always. Are we doing something wrong that is arduino specific?
After trying different things with my friend this was a way to make this projects code.
/* GSM Shield Version 2 GPS Real time Tracking
* CAn display GPS location On Google Maps using the JavaScrpts
By: Ali Shwaiheen April 2018*/
/*
/********************************************************************
* AltSoftSerial always uses these pins for Serial communication: *
* *
* Board Transmit Receive PWM Unusable *
* ----- -------- ------- ------------ *
* Teensy 3.0 & 3.1 21 20 22 *
* Teensy 2.0 9 10 (none) *
* Teensy++ 2.0 25 4 26, 27 *
* Arduino Uno 9 8 10 *
* Arduino Leonardo 5 13 (none) *
* Arduino Mega 46 48 44, 45 *
* Wiring-S 5 6 4 *
* Sanguino 13 14 12 *
*********************************************************************/
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <AltSoftSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(6);
DallasTemperature DS18B20(&oneWire);
TinyGPSPlus gps;
AltSoftSerial ss;
SoftwareSerial GPRS(2, 3);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int fixed = 0;
int count = 0; // counter for buffer array
//int led = 13;
int setupStep = 0;
float longi;
float lati;
int temp;
void setup()
{
ss.begin(9600); //Start GPS
GPRS.begin(9600); // the GPRS baud rate
DS18B20.begin();
Serial.begin(19200); // the Serial port of Arduino baud rate.
Serial.print("hello");
delay(1000);
}
void loop() {
Serial.println("Lati ja longi jos asiat ok");
GPSCord();
longi = gps.location.lng();
lati = gps.location.lat();
DS18B20.requestTemperatures();
temp = DS18B20.getTempCByIndex(0);
Serial.println("temp:" + String(temp));
Send_pubnub();
Serial.println("Send pubnub ready");
delay(1);
setupStep = 0;
Serial.println("Loop Ready");
delay(10000); //Delay varmaan mistä voi lisätä
}
void clearBufferArray() // function to clear buffer array
{
for (int i = 0; i < count; i++)
{
buffer[i] = NULL; // clear all index of array with command NULL
}
}
void GPSCord(){
while (ss.available() > 0)
gps.encode(ss.read());
if (gps.location.isUpdated())
{
fixed = 1;
Serial.print("LAT="); Serial.print(gps.location.lat(), 6);
Serial.print(" LNG="); Serial.println(gps.location.lng(), 6);
}
if(fixed ==0)
{
// digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(300); // wait for a second
// digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
// delay(300);
// Serial.print("NO GPS Signal Detected");
}
if (gps.altitude.isUpdated())
{
//Serial.print("Altitude:");
//Serial.println(gps.altitude.meters());
}
}
void Send_pubnub() {
if (GPRS.available()) // if date is comming from softwareserial port ==> data is comming from gprs shield
{
while (GPRS.available()) // reading data into char array
{
buffer[count++] = GPRS.read(); // writing data into array
if (count == 64)break;
}
Serial.write(buffer, count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
}
if (setupStep < 15) {
ConnectToInternet(setupStep);
delay(1000);
return Send_pubnub();
}
}
void ConnectToInternet(int step) {
int delayT = 1000;
if (step == 0) {
GPRS.println("AT");
delay(delayT);
}
if (step == 1) {
GPRS.println("AT+CPIN?");
delay(delayT);
}
if (step == 2) {
GPRS.println("AT+CREG?");
delay(250);
}
if (step == 3) {
GPRS.println("AT+CGATT?");
delay(delayT);
}
if (step == 4) {
GPRS.println("AT+QIDEACT");
delay(delayT);
}
if (step == 5) {
GPRS.println("AT+QISTAT=?");
delay(250);
}
if (step == 6) {
GPRS.println("AT+QIMUX=0");
delay(250);
}
if (step == 7) {
GPRS.println("AT+QIREGAPP=\"zain\","",""");
delay(delayT);
}
if (step == 8) {
GPRS.println("AT+QIACT");
delay(delayT);
}
if (step == 9) {
GPRS.println("AT+QILOCIP");//get local IP adress
delay(250);
}
if (step == 10) {
GPRS.println("AT+QIPROMPT=0"); //No prompt ">" and show "SEND OK" when sending successes
delay(delayT);
delay(250);
}
if (step == 11) {
GPRS.println("AT+QIOPEN=\"TCP\",\"184.106.153.149\",\"80\"");
delay(delayT);
delay(2000);
}
if (step == 12) {
GPRS.println("AT+QISEND");
delay(delayT);
// delay(2000); //More delay time could be require depend on network
}
if (step == 13) {
String str="GET https://api.thingspeak.com/update?api_key=XXXXXXXX&field4=" + String(lati,6)+ "&field5=" + String(longi,6) + "&field6=" + String(temp); // after api_key= put your own apikey
GPRS.println(str);
delay(delayT);
//delay(2000);//More delay time could be require depend on network
}
if (step == 14) {
GPRS.println((char)26);// ASCII code of CTRL+Z
GPRS.println();
delay(delayT);
//delay(2000);//More delay time could be require depend on network
}
setupStep++;
}
Thank you Ali Shwaiheen for doing a good guide.
And in the picture there is a wiring setup that we did in testing.
Edit. something went wrong with posting the picture.