Hi,
I’m new to ESP32 SIM800L board, just working on a project where I need to send and receive data from thingspeak.com, I’m getting this error while uploading the code.
In file included from C:\Users\win-10\OneDrive\Documents\Arduino\ESP32\ESP32.ino:3:0:
C:\Users\win-10\OneDrive\Documents\Arduino\libraries\TinyGSM\src/TinyGsmClient.h:117:4: error: #error “Please define GSM modem model”
#error “Please define GSM modem model”
^
exit status 1
Error compiling for board DOIT ESP32 DEVKIT V1.
Someone help me with this, I have tried many things but didn’t got any luck resolving it.
Here’s the code,
//#include <WiFi.h>
#include <Wire.h>
#include <TinyGsmClient.h>
//#include “secrets.h”
#include “ThingSpeak.h” // always include thingspeak header file after other header files and custom macros
#include “max6675.h”
int thermoDO = 4;
int thermoCS = 2;
int thermoCLK = 15;
int r = 5;
// Your GPRS credentials (leave empty, if not needed)
const char apn = “airtelgprs.com”; // APN (example: internet.vodafone.pt) use https://wiki.apnchanger.org
const char gprsUser = “”; // GPRS User
const char gprsPass = “”; // GPRS Password
// SIM card PIN (leave empty, if not defined)
const char simPIN = “”;
//char ssid = “SNGCONTROL”; // your network SSID (name)
//char pass = “Sngcontrol@123”; // your network password
//int keyIndex = 0; // your network key Index number (needed only for WEP)
WiFiClient client;
// TTGO T-Call pins
#define MODEM_RST 5
#define MODEM_PWKEY 4
#define MODEM_POWER_ON 23
#define MODEM_TX 27
#define MODEM_RX 26
#define I2C_SDA 21
#define I2C_SCL 22
// Weather station channel details
unsigned long weatherStationChannelNumber = 1476526;
unsigned long weatherStationChannelNumber1 = 1519040;
unsigned long myChannelNumber = 1519011;
const char* myWriteAPIKey = “5ZIPSAB1MJMMKZER”;
unsigned int targettemp = 2;
unsigned int manualcontrol = 1;
float val = 0.0;
// Counting channel details
unsigned long counterChannelNumber = 1476526;
const char * myCounterReadAPIKey = “PASLJUBX9AIFBOCA” ;
unsigned int counterFieldNumber = 1;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
// Set serial for debug console (to Serial Monitor, default speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to SIM800 module)
#define SerialAT Serial1
// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800 // Modem is SIM800
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
// I2C for SIM800 (to keep it running when powered from battery)
TwoWire I2CPower = TwoWire(0);
// TinyGSM Client for Internet connection
TinyGsmClient client(modem);
//#define uS_TO_S_FACTOR 1000000UL /* Conversion factor for micro seconds to seconds /
//#define TIME_TO_SLEEP 3600 / Time ESP32 will go to sleep (in seconds) 3600 seconds = 1 hour */
#define IP5306_ADDR 0x75
#define IP5306_REG_SYS_CTL0 0x00
bool setPowerBoostKeepOn(int en){
I2CPower.beginTransmission(IP5306_ADDR);
I2CPower.write(IP5306_REG_SYS_CTL0);
if (en) {
I2CPower.write(0x37); // Set bit1: 1 enable 0 disable boost keep on
} else {
I2CPower.write(0x35); // 0x37 is default reg value
}
return I2CPower.endTransmission() == 0;
}
void setup() {
SerialMon.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo native USB port only
}
// Start I2C communication
I2CPower.begin(I2C_SDA, I2C_SCL, 400000);
// Keep power when running from battery
bool isOk = setPowerBoostKeepOn(1);
SerialMon.println(String("IP5306 KeepOn ") + (isOk ? “OK” : “FAIL”));
// Set modem reset, enable, power pins
pinMode(MODEM_PWKEY, OUTPUT);
pinMode(MODEM_RST, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
digitalWrite(MODEM_RST, HIGH);
digitalWrite(MODEM_POWER_ON, HIGH);
// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(3000);
// Restart SIM800 module, it takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(“Initializing modem…”);
modem.init();
// use modem.init() if you don’t need the complete restart
// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 )
{
modem.simUnlock(simPIN);
}
digitalWrite(21,HIGH);
digitalWrite(22,LOW);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client); // Initialize ThingSpeak
// Configure the wake up source as timer wake up
//esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
}
void loop() {
val = thermocouple.readCelsius();
int statusCode = 0;
// Connect or reconnect to WiFi
if(WiFi.status() != WL_CONNECTED){
SerialMon.print(“Attempting to connect to SSID: “);
SerialMon.println(ssid);
while(WiFi.status() != WL_CONNECTED){
WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
SerialMon.print(”.”);
delay(5000);
}
SerialMon.println(“\nConnected”);
}
int x = ThingSpeak.writeField(myChannelNumber, 1,val, myWriteAPIKey);
if(x == 200){
SerialMon.println(“Channel update successful.”);
}
// Read in field 1 of the public channel recording the temperature
float target = ThingSpeak.readFloatField(weatherStationChannelNumber, targettemp);
// Check the status of the read operation to see if it was successful
statusCode = ThingSpeak.getLastReadStatus();
if(statusCode == 200){
SerialMon.println(“Target Temperature: " + String(target) + " deg C”);
}
else{
SerialMon.println("Problem reading channel. HTTP error code " + String(statusCode));
}
// Read in field 1 of the public channel recording the temperature
float mc = ThingSpeak.readFloatField(weatherStationChannelNumber1, manualcontrol);
// Check the status of the read operation to see if it was successful
statusCode = ThingSpeak.getLastReadStatus();
if(statusCode == 200){
SerialMon.println("Manual_control: " + String(mc));
}
else{
SerialMon.println("Problem reading channel. HTTP error code " + String(statusCode));
}
pinMode(r, OUTPUT);
if(mc == 0)
{
digitalWrite(r,LOW);
}
else if(val>= target)
{
digitalWrite(r,LOW);
}
else
{
digitalWrite(r,HIGH);
}
delay(2000); // No need to read the temperature too often.
SerialMon.println("Actual temperature: " + String(val));
delay(5000); // No need to read the counter too often.
// Put ESP32 into deep sleep mode (with timer wake up)
//esp_deep_sleep_start();
}