Untitled
unknown
plain_text
2 years ago
2.8 kB
16
Indexable
#include <SoftwareSerial.h>
#include "Wire.h"
const int pressureInput = A0;
const int pressureZero = 98.58;
const int pressureMax = 921.6;
const int pressuretransducermaxPSI = 30;
const int baudRate = 9600;
const int sensorreadDelay = 1000;
const float psiToCmWater = 70.307;
const float alpha = 0.95; // Increased alpha for stronger smoothing
float pressureValue = 0;
float depthCm = 0;
int TX=15;
int RX=14;
const String MaximumCapacity = "20";
SoftwareSerial gsm(TX,RX);
void SendMessage(){
if(gsm.available()){
Serial.write(gsm.read());
}
Serial.println("Sending Message...");
gsm.print("AT+CMGF=1\r");
delay(100);
gsm.print("AT+CMGS=\"+639927584492\"\r");
gsm.print("ALERT From Load Detection System of Passenger Boat!");
gsm.println();
gsm.println();
gsm.print("WARNING!! WARNING!! WARNING!!.");
gsm.println();
gsm.print("Boat is OVERLOADING.");
gsm.println();
gsm.println();
gsm.print("Information:");
gsm.println();
gsm.println();
gsm.print("Status: DOCK");
gsm.println();
gsm.print("Number of People:");
gsm.println();
gsm.print("Maximum Capacity:");
gsm.println();
gsm.print("Total Weight of Load: ");
gsm.println();
gsm.print("Maximum Capacity Level:");
gsm.print(" %");
gsm.println();
gsm.print("\r");
delay(200);
gsm.print(char(26));
delay(100);
gsm.println();
Serial.println("Sent Message");
}
void SendMessage1(){
if(gsm.available()){
Serial.write(gsm.read());
}
Serial.println("Sending Message...");
gsm.print("AT+CMGF=1\r");
delay(100);
gsm.print("AT+CMGS=\"+639927584492\"\r");
gsm.print("Notification From Load Detection System of Passenger Boat!");
gsm.println();
gsm.println();
gsm.print("Boat is operating in STANDARD CAPACITY.");
gsm.println();
gsm.println();
gsm.print("Information:");
gsm.println();
gsm.println();
gsm.print("Status: DEPARTED");
gsm.println();
gsm.print("Number of People:");
gsm.println();
gsm.print("Maximum Capacity:");
gsm.println();
gsm.print("Total Weight of Load: ");
gsm.println();
gsm.print("Maximum Capacity Level:");
gsm.print(" %");
gsm.println();
gsm.print("\r");
delay(200);
gsm.print(char(26));
delay(100);
gsm.println();
Serial.println("Sent Message");
}
void setup() {
Serial.begin(9600);
gsm.begin(9600);
SendMessage1();
SendMessage();
}
void loop() {
float rawPressure = analogRead(pressureInput);
pressureValue = ((rawPressure - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero);
// Convert PSI to initial depth estimate:
float newDepthCm = pressureValue * psiToCmWater;
// Low-pass filter:
depthCm = alpha * depthCm + (1 - alpha) * newDepthCm;
Serial.print("Depth: ");
Serial.print(depthCm, 1);
Serial.println(" cm");
delay(sensorreadDelay);
}
Editor is loading...
Leave a Comment