So I am sending sensor data. The sensor is reading the data and putting it into the serial monitor. It then displays the string built with a GET statement:
(Yes I do have the api key in the x’s field) I can take that line put it into a browser with random numbers and it will update the thingspeak page.
I can send SMS to and from the Sim7000 modem.
Here is the sketch:
#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(2,3);
#include <String.h>
#include <DHT.h>
#define DHTPIN A0
DHT dht(DHTPIN, DHT11);
void setup()
{
gprsSerial.begin(9600); // the GPRS baud rate
Serial.begin(9600); // the GPRS baud rate
dht.begin();
delay(1000);
}
void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
delay(100);
Serial.print("Temperature = ");
Serial.print(t);
Serial.println(" °C");
Serial.print("Humidity = ");
Serial.print(h);
Serial.println(" %");
if (gprsSerial.available())
Serial.write(gprsSerial.read());
gprsSerial.println(“AT”);
delay(1000);
gprsSerial.println(“AT+CPIN?”);
delay(1000);
gprsSerial.println(“AT+CREG?”);
delay(1000);
gprsSerial.println(“AT+CGATT?”);
delay(1000);
gprsSerial.println(“AT+CIPSHUT”);
delay(1000);
gprsSerial.println(“AT+CIPSTATUS”);
delay(2000);
gprsSerial.println(“AT+CIPMUX=0”);
delay(2000);
ShowSerialData();
gprsSerial.println(“AT+CSTT="hologram"”);//start task and setting the APN,
delay(1000);
ShowSerialData();
gprsSerial.println(“AT+CIICR”);//bring up wireless connection
delay(3000);
ShowSerialData();
gprsSerial.println(“AT+CIFSR”);//get local IP adress
delay(2000);
ShowSerialData();
gprsSerial.println(“AT+CIPSPRT=0”);
delay(3000);
ShowSerialData();
gprsSerial.println(“AT+CIPSTART="TCP","api.thingspeak.com","80"”);//start up the connection
delay(6000);
ShowSerialData();
gprsSerial.println(“AT+CIPSEND”);//begin send data to remote server
delay(4000);
ShowSerialData();
Blockquote
String str=
Serial.println(str);
gprsSerial.println(str);//begin send data to remote server
delay(4000);
ShowSerialData();
gprsSerial.println((char)26);//sending
delay(5000);//waitting for reply, important! the time is base on the condition of internet
gprsSerial.println();
ShowSerialData();
gprsSerial.println(“AT+CIPSHUT”);//close the connection
delay(100);
ShowSerialData();
}
void ShowSerialData()
{
while(gprsSerial.available()!=0)
Serial.write(gprsSerial.read());
delay(5000);
}
I can get the sensor data → to the Uno → I can build the string data that works in a browswer page → I am losing it somewhere maybe in the config prior to the GET or maybe not closing it properly, but -X it isnt getting to where I need it.
I have an ESP8266 reading sensor data and sending over wifi and it works no problems, just got to be in the AT commands.
Any help or ideas from something jumping out ?
Thanks for any help
Steve