Hello I'm having this issue while compling the code but the code was working few weeks ago
Here is the massage.
no matching function for call to 'HardwareSerial::HardwareSerial(int)'
the code is
#define TINY_GSM_MODEM_SIM7600
#define SerialMon Serial
//HardwareSerial SerialAT(1);
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 650
#endif
#define TINY_GSM_YIELD() { delay(2); }
const char apn[] = "ucnet"; // Change this to your Provider details
const char gprsUser[] = "";
const char gprsPass[] = "";
const char server[] = ""; // Change this to your selection
const char resource[] = "/";
const int port = 80;
unsigned long timeout;
const char* device_token = "";
#include <TinyGsmClient.h>
#include "Adafruit_FONA.h"
TinyGsm modem(SerialAT);
TinyGsmClient client(modem);
const int FONA_RST = 4;
char replybuffer[255];
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
String smsString = "";
char fonaNotificationBuffer[64]; //for notifications from the FONA
char smsBuffer[250];
HardwareSerial *fonaSerial = &SerialAT;
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);
boolean buttonEnable = false;
String SMSSendString = "";
char SMSSendBuffer[100];
float Lat = 0;
float Log = 0;
String latitude;
String longitude;
void setup() {
Serial.println(F("Initializing....(May take 3 seconds)"));
fonaSerial->begin(115200, SERIAL_8N1, 16, 17, false);
if (! fona.begin(*fonaSerial))
{
Serial.println(F("Couldn't find FONA"));
while (1);
}
Serial.println(F("FONA is OK"));
fonaSerial->print("AT+CNMI=2,1\r\n"); //set up the FONA to send a +CMTI notification when an SMS is received
Serial.println("FONA Ready");
SerialMon.begin(115200);
delay(10);
SerialMon.println("Wait...");
SerialAT.begin(115200, SERIAL_8N1, 16, 17, false);
delay(600);
SerialMon.println("Initializing modem...");
//gps();
connectToModem();
}
void loop() {
//modem.restart();
gps();
donnees();
}
void donnees() {
if (!client.connect(server, port)) {
SerialMon.println(" fail");
}
SerialMon.println("Performing GET POST request...");
String httpRequestData = ("&latitude=") + latitude +
("&longitude=") + longitude +
("&device_token=") + device_token +
" HTTP/1.1\r\n" +
"Host: " + server + "\r\n" +
"Connection: \r\n\r\n" + "";
client.print(String("GET http:") + httpRequestData);
//client.print(String("GET http://")+httpRequestData);
Serial.println(latitude);
Serial.println(longitude);
Serial.print("httpRequestData: ");
Serial.println(httpRequestData);
timeout = millis();
while (client.connected() && millis() - timeout < 10000L) {
while (client.available()) {
char c = client.read();
SerialMon.print(c);
timeout = millis();
}
}
/*SerialMon.println();
client.stop();
SerialMon.println(F("Server disconnected"));
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
*/
}
void connectToModem() {
SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) {
SerialMon.println(" fail");
delay(1000);
return;
}
SerialMon.println(" success");
if (modem.isNetworkConnected()) {
SerialMon.println("Network connected");
}
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
delay(1000);
return;
}
SerialMon.println(" success");
if (modem.isGprsConnected()) {
SerialMon.println("GPRS connected");
}
}
void gps() {
GPSPositioning();
SMSSendString = "Google Maps:\nhttp://www.google.com/maps/place/" + String(-Lat, 6) + "," + String(Log, 6);
Serial.println(SMSSendString);
char* bufPtr = fonaNotificationBuffer; //handy buffer pointer
if (fona.available()) //any data available from the FONA?
{
int slot = 0; //this will be the slot number of the SMS
int charCount = 0;
//Read the notification into fonaInBuffer
do
{
*bufPtr = fona.read();
Serial.write(*bufPtr);
delay(1);
} while ((*bufPtr++ != '\n') && (fona.available()) && (++charCount < (sizeof(fonaNotificationBuffer) - 1)));
//Add a terminal NULL to the notification string
*bufPtr = 0;
//Scan the notification string for an SMS received notification.
// If it's an SMS message, we'll get the slot number in 'slot'
if (1 == sscanf(fonaNotificationBuffer, "+CMTI: " FONA_PREF_SMS_STORAGE ",%d", &slot))
{
Serial.print("slot: "); Serial.println(slot);
char callerIDbuffer[32]; //we'll store the SMS sender number in here
// Retrieve SMS sender address/phone number.
if (! fona.getSMSSender(slot, callerIDbuffer, 31))
{
Serial.println("Didn't find SMS message in slot!");
}
Serial.print(F("FROM: ")); Serial.println(callerIDbuffer);
// Retrieve SMS value.
uint16_t smslen;
if (fona.readSMS(slot, smsBuffer, 250, &smslen)) // pass in buffer and max len!
{
smsString = String(smsBuffer);
Serial.println(smsString);
}
if (smsString == "LOCATION") {
buttonEnable = true;
Serial.print("Requesting device location...");
GPSPositioning();
delay(100);
SMSSendString = "Google Maps:\nhttp://www.google.com/maps/place/" + String(Lat, 6) + "," + String(Log, 6);
Serial.println(SMSSendString);
SMSSendString.toCharArray(SMSSendBuffer, 100);
// Send SMS for status
if (!fona.sendSMS(callerIDbuffer, SMSSendBuffer)) {
Serial.println("Failed");
}
else {
Serial.println(F("Sent!"));
SMSSendString = "";
}
}
else {
Serial.print("Invalid command.");
// playErrorMelody();
}
if (fona.deleteSMS(slot)) {
Serial.println(F("OK!"));
} else {
Serial.print(F("Couldn't delete SMS in slot "));
Serial.println(slot);
fona.print(F("AT+CMGD=?\r\n"));
}
}
}
}
uint8_t sendATcommand(const char* ATcommand, const char* expected_answer, unsigned int timeout)
{
uint8_t x = 0, answer = 0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while (fona.available() > 0) { // Clean the input buffer
fona.read();
}
fona.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// This loop waits for the answer
do {
if (fona.available() != 0) {
// if there are data in the UART input buffer, reads it and checks for the answer
response[x] = fona.read();
Serial.print(response[x]);
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL) {
answer = 1;
}
}
// Waits for the asnwer with time out
} while ((answer == 0) && ((millis() - previous) < timeout));
// SIM7600Serial->print("\n");
return answer;
}
bool GPSPositioning()
{
uint8_t answer = 0;
bool RecNull = true;
int i = 0;
char RecMessage[200];
char LatDD[3], LatMM[10], LogDD[4], LogMM[10], DdMmYy[7] , UTCTime[7];
int DayMonthYear;
Lat = 0;
Log = 0;
memset(RecMessage, '\0', 200); // Initialize the string
memset(LatDD, '\0', 3); // Initialize the string
memset(LatMM, '\0', 10); // Initialize the string
memset(LogDD, '\0', 4); // Initialize the string
memset(LogMM, '\0', 10); // Initialize the string
memset(DdMmYy, '\0', 7); // Initialize the string
memset(UTCTime, '\0', 7); // Initialize the string
Serial.print("Start GPS session...\n");
sendATcommand("AT+CGPS=1,1", "OK", 1000); // start GPS session, standalone mode
delay(2000);
while (RecNull) {
answer = sendATcommand("AT+CGPSINFO", "+CGPSINFO: ", 1000); // start GPS session, standalone mode
if (answer == 1) {
answer = 0;
while (fona.available() == 0);
// this loop reads the data of the GPS
do {
// if there are data in the UART input buffer, reads it and checks for the asnwer
if (fona.available() > 0) {
RecMessage[i] = fona.read();
i++;
// check if the desired answer (OK) is in the response of the module
if (strstr(RecMessage, "OK") != NULL) {
answer = 1;
}
}
} while (answer == 0); // Waits for the asnwer with time out
RecMessage[i] = '\0';
// Serial.print(RecMessage);
// Serial.print("\n");
if (strstr(RecMessage, ",,,,,,,,") != NULL) {
memset(RecMessage, '\0', 200); // Initialize the string
i = 0;
answer = 0;
delay(1000);
}
else {
RecNull = false;
sendATcommand("AT+CGPS=0", "OK:", 1000);
}
}
else {
Serial.print("error \n");
return false;
}
delay(2000);
}
strncpy(LatDD, RecMessage, 2);
LatDD[2] = '\0';
strncpy(LatMM, RecMessage + 2, 9);
LatMM[9] = '\0';
Lat = atoi(LatDD) + (atof(LatMM) / 60);
if (RecMessage[12] == 'N') {
Serial.print("Latitude is ");
Serial.print(String(-Lat, 6));
Serial.print(" N\n");
}
else if (RecMessage[12] == 'S') {
Serial.print("Latitude is ");
Serial.print(String(-Lat, 6));
Serial.print(" S\n");
}
else {
return false;
}
strncpy(LogDD, RecMessage + 14, 3);
LogDD[3] = '\0';
strncpy(LogMM, RecMessage + 17, 9);
LogMM[9] = '\0';
Log = atoi(LogDD) + (atof(LogMM) / 60);
if (RecMessage[27] == 'E') {
Serial.print("Longitude is ");
Serial.print(String(Log, 6));
Serial.print(" E\n");
}
else if (RecMessage[27] == 'W') {
Serial.print("Latitude is ");
Serial.print(String(-Lat, 6));
Serial.print(" W\n");
}
else {
return false;
}
latitude = String(-Lat, 6);
longitude = String(Log, 6);
strncpy(DdMmYy, RecMessage + 29, 6);
DdMmYy[6] = '\0';
Serial.print("Day Month Year is ");
Serial.print(DdMmYy);
Serial.print("\n");
strncpy(UTCTime, RecMessage + 36, 6);
UTCTime[6] = '\0';
Serial.print("UTC time is ");
Serial.print(UTCTime);
Serial.print("\n");
return true;
}
// End of Arduino file