I am trying to send data using Quectel and Arduino together. When trying the same commands just with the BC660 module and QCOM I get the OK responses and I can send the data. But when trying to use it with Arduino, the response is always empty and the data never sent.
The connections are:
- Arduino pin 7 to MCU_TX
- Arduino pin 8 to MCU_RX
- GNDs
And the code is:
`
#include <SoftwareSerial.h>
#define DEBUG true
// Define software serial pins
SoftwareSerial lteSerial(7, 8); // RX, TX
const int flowSensorPin = 5;
volatile int flowPulseCount;
unsigned long previousMillis = 0; // will store last time data was sent
const long interval = 5000; // interval at which to send data (milliseconds)
// ThingSpeak Settings
const String apiKey = “…”;
void setup() {
lteSerial.begin(9600);
Serial.begin(9600);
sendData(“AT\r\n”, 1000, DEBUG);
sendData(“AT+QCFG="logbaudrate",9600\r”, 1000, DEBUG);
sendData(“AT+CFUN=0\r”, 1000, DEBUG);
sendData(“AT+CEREG=2\r”, 1000, DEBUG);
sendData(“AT+QBAND=3,3,8,20\r”, 1000, DEBUG);
sendData(“AT+QCGDEFCONT=1,"IP","…"\r”, 1000, DEBUG);
sendData(“AT+CFUN=1\r”, 1000, DEBUG);
delay(5000);
sendData(“AT+QHTTPCFG="contextid",0\r”, 1000, DEBUG);
sendData(“AT+QHTTPURL=32,80\r”, 1000, DEBUG);
sendData(“http://api.thingspeak.com/update\r”, 1000, DEBUG);
sendData(“AT+QHTTPPOST=34,80,80\r”, 1000, DEBUG);
sendData(“api_key=…&field1=15\r”, 1000, DEBUG);
}
void loop() {
}
String sendData(String command, const int timeout, boolean debug) {
String response = “”;
if (debug) {
Serial.print("Start sending: ");
Serial.println(command);
}
// Clear any previous data in the buffer
while (lteSerial.available()) {
lteSerial.read();
}
lteSerial.print(command); // Send command to LTE module
unsigned long startMillis = millis(); // Record the start time
while (millis() - startMillis < timeout) { // Check if timeout has occurred
if (lteSerial.available()) { // Check if data is available to read
char c = lteSerial.read(); // Read a character from the serial
response += c; // Append the character to the response string
}
}
if (debug) {
Serial.print("Received: ");
if (response.length() > 0) {
Serial.println(response);
} else {
Serial.println("No response");
}
}
return response;
}
float calculateFlow() {
flowPulseCount = 5;
Serial.println(“flow measured”);
return flowPulseCount;
}
`
Just with the first AT command I already get an empty response, so I guess I need to set up the code in a different way. Anyone knows what can be happening?