I am using a LCD with a temperature sensor and wanting to send a text whenever the temperature reaches a certain degree Celsius. The GSM module SIM 800L is currently blinking every once every 3 seconds so it seems to work. Other scripts used seem to be sending a text. With my code, nothing showing in the software serial monitor and the text is not sending. Please help. Code is below:
#include<LiquidCrystal.h>
#include <SoftwareSerial.h>
#include "Adafruit_FONA.h"
//This* part declares that the RX, TX and RST pins of the SIM800L must be connected
//to pin 2, 3 and 4 of the Arduino.
#define FONA_RX 3
#define FONA_TX 2
#define FONA_RST 4
SoftwareSerial fonaSS = SoftwareSerial(FONA_RX, FONA_TX);
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
LiquidCrystal lcd(12, 11, 5, 9, 7, 8);
const int sensor=A1; // Assigning Analog Pin A 1to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float tempf; //variable to store temperature in Fahrenheit
float vout; //temporary variable to hold sensor reading
void setup()
{
pinMode(sensor,INPUT); // Configuring pin A1 as INPUT Pin
Serial.begin(9600);
lcd.begin(16,2);
delay(100);
}
void loop()
{
vout=analogRead(sensor);
vout=(vout*500)/1023;
tempc=vout; // Storing value in degrees Celsius
tempf=(vout*1.8)+32; // Converting Temperature value from degrees Celsius to Fahrenheit
lcd.setCursor(0,0);
lcd.print("DegreeC= ");
lcd.print(tempc);
lcd.setCursor(0,1);
lcd.print("Fahrenheit=");
lcd.print(tempf);
delay(1000); //Delay of 1 second for ease of viewing in serial monitor
if (tempc > 20.0) {
SendSms();
}
}
void SendSms() {
char sendto[] = "+447874072326"; //put the desired destination phone number for sms here
char message[141];
sprintf(message, "Alert TEMP is %.2f", tempc);// limit to 140
//sends the message via SMS
if (!fona.sendSMS(sendto, message)) {
Serial.println(F("error"));
} else {
Serial.println(F("sent!"));
}
}
I would like help to try and solve the problem of nothing showing in the software serial monitor. Thanks for any help.