Answered step by step
Verified Expert Solution
Question
1 Approved Answer
help to fix the codes bellow to make them properly send a message and display characters correctly and not unreadable characters #include #include / /
help to fix the codes bellow to make them properly send a message and display characters correctly and not unreadable characters
#include
#include
Setup SoftwareSerial pins
SoftwareSerial mySerial; Change this to your correct TX and RX pins
Initialize LCD
LiquidCrystal lcd; RS EN D D D D
Moisture Sensor Pins
int areaonemoisturesensor A;
int areatwomoisturesensor A;
int areathreemoisturesensor A;
int areafourmoisturesensor A;
Relay Pins
int areaonerelay ;
int areatworelay ;
int areathreerelay ;
int areafourrelay ;
LED Pins
int LED; Indicate irrigation is on
int LED; Indicate irrigation is off
SMS configuration
const char recipientnumber ;
bool isareaoneirrigating false; Track irrigation status
bool isareatwoirrigating false; Track irrigation status
bool isareathreeirrigating false; Track irrigation status
bool isareafourirrigating false; Track irrigation status
void SendSMSconst char message
mySerial.printlnATCMGF; Set SMS mode to TEXT
delay; Increase delay for GSM stability
mySerial.printATCMGS;
mySerial.printrecipientnumber;
mySerial.println; Specify recipient
delay; Small delay
mySerial.printlnmessage; SMS content
mySerial.write; Send ASCII CtrlZ to end message
delay; Wait for GSM to process
void setup
Serial.begin; Initialize Serial monitor
mySerial.begin; Initialize GSM connection
Setup pin modes
pinModeareaonemoisturesensor INPUT;
pinModeareatwomoisturesensor INPUT;
pinModeareathreemoisturesensor INPUT;
pinModeareafourmoisturesensor INPUT;
pinModeareaonerelay, OUTPUT;
pinModeareatworelay, OUTPUT;
pinModeareathreerelay, OUTPUT;
pinModeareafourrelay, OUTPUT;
pinModeLED OUTPUT;
pinModeLED OUTPUT;
Initial LCD display
lcd.begin; Initialize LCD
lcd.printPrecision Irrigation";
lcd.setCursor;
lcd.printSystem;
delay; Display welcome message for seconds
void displayMoistureLevelsint m int m int m int m
lcd.clear;
lcd.printA:;
lcd.printm;
lcd.print A:;
lcd.printm;
lcd.setCursor;
lcd.printA:;
lcd.printm;
lcd.print A:;
lcd.printm;
void loop
Read moisture sensor values
int areaonemoisture analogReadareaonemoisturesensor;
int areatwomoisture analogReadareatwomoisturesensor;
int areathreemoisture analogReadareathreemoisturesensor;
int areafourmoisture analogReadareafourmoisturesensor;
Display moisture levels on LCD
displayMoistureLevelsareaonemoisture, areatwomoisture, areathreemoisture, areafourmoisture;
Relay and SMS logic for area one
if areaonemoisture High moisture, start irrigation
digitalWriteareaonerelay, LOW; Relay ON
digitalWriteLED HIGH; LED indicating irrigation is on
digitalWriteLED LOW; Off LED on
if isareaoneirrigating If not already irrigating
SendSMSArea One is being irrigated."; Send SMS
isareaoneirrigating true; Set flag
else Low moisture, stop irrigation
digitalWriteareaonerelay, HIGH; Relay OFF
digitalWriteLED LOW; Irrigation LED off
digitalWriteLED HIGH; Off LED on
if isareaoneirrigating If was irrigating, send SMS about stopping
SendSMSArea One has stopped irrigation."; SMS indicating irrigation stop
isareaoneirrigating false; Reset flag
delay; Delay before next loop iteration
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started