I've been at it desperately for days now but I can't seem to figure out what I'm doing wrong. I searched online but the little information I can find is for outgoing data from the modem. I want to listen for incoming data from a webhook. Please help if you can.
I have a Botletics SIM7000 shield connected to the Hologram network. I have confirmed network access and can POST their prepackaged messages to dweet.io (in LTE_Demo.ino)
I am a novice in C++ programming and I think that is tripping me up. My experience lies in HTML/CSS/PHP. Here is my stripped back code that defines the pins, turns on the modem, configures it, and enables data. I don't know if I enabled CIPSERVER correctly or if I'm processing incoming data. I get:
"
server set
Data received:
Data received:
E
Data received:
RRO
Data received:"
which is deffo not the right result. When I send data via the Hologram Dashboard it never appears.
#include "BotleticsSIM7000.h" // https://github.com/botletics/Botletics-SIM7000/tree/main/src
#define SIMCOM_7000
// For botletics SIM7000/7070 shield
#define BOTLETICS_PWRKEY 6
#define RST 7 // No RST pin for SIM7070
#define TX 10 // Microcontroller RX
#define RX 11 // Microcontroller TX
#include <SoftwareSerial.h>
SoftwareSerial modemSS = SoftwareSerial(TX, RX);
SoftwareSerial *modemSerial = &modemSS;
Botletics_modem_LTE modem = Botletics_modem_LTE();
char incomingDataBuffer[256];
void setup() {
pinMode(RST, OUTPUT);
digitalWrite(RST, HIGH); // Default state
modem.powerOn(BOTLETICS_PWRKEY);
Serial.begin(9600);
Serial.println(F("please merciful electricity let my data pass"));
modemSS.begin(115200); // Default SIM7000 shield baud rate
Serial.println(F("Configuring to 9600 baud"));
modemSS.println("AT+IPR=9600"); // Set baud rate
delay(100); // Short pause to let the command run
modemSS.begin(9600);
if (! modem.begin(modemSS)) {
Serial.println(F("Couldn't find modem"));
while (1); // Don't proceed if it couldn't find the device
}
// Set modem to full functionality
modem.setFunctionality(1); // AT+CFUN=1
modem.setNetworkSettings(F("hologram")); // For Hologram SIM card
if (!modem.enableGPRS(true)) {
Serial.println(F("Failed to turn on"));
}
Serial.println("Before pause");
delay(5000);
Serial.println("After pause"); // let the device register and get settled(???)
modemSS.println("AT+CIPSERVER=1,80");
Serial.println("server set");
}
void readModemData() {
int index = 0;
while (modemSerial->available() > 0) {
char incomingByte = modemSerial->read();
incomingDataBuffer[index++] = incomingByte;
// Check if buffer size is exceeded
if (index >= sizeof(incomingDataBuffer)) {
index = 0;
break;
}
}
// Null-terminate the string
if (index > 0) {
incomingDataBuffer[index] = '\0';
Serial.println("Data received:");
Serial.println(incomingDataBuffer);
}
}
void loop() {
if (modemSerial->available()) {
readModemData();
}
}
Its clear that AT+CIPSERVER in setup failed.
To troubleshot the problem, first of all make following modifications in your code to be able to enter AT commands and see results of execution.
Sequence of commands you should enter in console described SIM7000_Series_TCPIP_Application_Note_V1.01.pdf
After all will work as expented with manual AT commands entering, you should wrap all the commands into C functions (i believe not all them are implemented in Botletics-SIM7000 library).
Be carefull in code after sending AT commands to SIM7000 you should read and parse all responses from it, and only after this to send next AT command.
For the AT commands expected mutiline response you may use:
Take a look into sources of another library handling SIM7000 TinyGSM