#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
#include <DFRobot_SIM7000.h>
#include <SoftwareSerial.h>
#include <ATcommands.h>
#define PIN_TX 7
#define PIN_RX 8
SoftwareSerial mySerial(PIN_RX,PIN_TX);
DFRobot_SIM7000 sim7000(&mySerial);
#define MESSAGE_LENGTH 60 //test code
char message[MESSAGE_LENGTH]; //test code
int messageIndex = 0; //test code
char phone[14];
char datetime[12];
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
mySerial.begin(19200);
Serial.println("Turn ON SIM7000......");
if(sim7000.turnON()){ //Turn ON SIM7000
Serial.println("Turn ON !");
}
Serial.println("Set baud rate......");
while(1){
if(sim7000.setBaudRate(19200)){ //Set SIM7000 baud rate from 115200 to 19200 reduce the baud rate to avoid distortion
Serial.println("Set baud rate:19200");
break;
}else{
Serial.println("Faile to set baud rate");
delay(1000);
}
}
mySerial.begin(19200);
Serial.println("For example, if you type AT\\r\\n, OK\\r\\n will be responsed!");
Serial.println("Enter your AT command :");
sendATcommand("AT+COPS=1,2,20205,0", 2000);
delay(1500);
sendATcommand("AT+CGACT=1", 2000);
sendATcommand("AT+CREG=1", 2000);
sendATcommand("AT+CGATT=1", 2000);
sendATcommand("AT+CNACT=1,em", 2000);
delay(1000);
sendATcommand("AT+CIPSTART= TCP , 184.106.153.149 , 80", 2000);
delay(4000);
sendATcommand("AT+CIPSEND=4",2000);
delay(2000);
sendATcommand("GET /update?key=S0UA5DHOWEH6J4I1&field1=",2000);
//sendATcommand("GET /update key=S0UA5DHOWEH6J4I1&field1=10", 2000);
delay(2000);
sendATcommand("GET /update key=S0UA5DHOWEH6J4I1&field1=20", 2000);
void loop() {
//code
}
String sendATcommand(const char *toSend, unsigned long milliseconds)
{
String result;
Serial.print("Sending: ");
Serial.println(toSend);
mySerial.println(toSend);
unsigned long startTime = millis();
Serial.print("Received: ");
while (millis() - startTime < milliseconds) {
if (mySerial.available()) {
char c = mySerial.read();
Serial.write(c);
result += c; // append to the result string
}
}
Serial.println(); // new line after timeout.
return result;
}
}
> Blockquote
I cant send to SIM7000 the comands
- sendATcommand("AT+CIPSEND=4",2000);
- sendATcommand("GET /update?key=S0UA5DHOWEH6J4I1&field1=",2000);
reply from module : `
Sending: AT+CIPSTART= TCP , 184.106.153.149 , 80
Received: AT+CIPSTART= TCP , 184.106.153.149 , 80
OK
Sending: AT+CIPSEND=4
Received: AT+CIPSEND=4
ERROR
Sending: GET /update?key=S0UA5DHOWEH6J4I1&field1=
Received: ate?key=S0UA5DHOWEH6J4I1&field1=
ERROR`