Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **Sensor Monitoring**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-12-31 11:59:14
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Arduino code generator for real time remote */
- /* monitoring and automation of distribution */
- /* transformer using Arduino uno, gsm, ac current */
- /* sensor, ac volage sensor, ultrasonic oil level */
- /* sensor, lm35, lcd 20*4 */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <GSM.h>
- #include <ACCurrentSensor.h>
- #include <ACVoltageSensor.h>
- #include <Ultrasonic.h>
- #include <LM35.h>
- #include <LiquidCrystal.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** GLOBAL VARIABLES *****/
- GSM gsm; // GSM module object
- ACCurrentSensor acCurrentSensor; // AC current sensor object
- ACVoltageSensor acVoltageSensor; // AC voltage sensor object
- Ultrasonic ultrasonicSensor(7, 8); // Ultrasonic sensor with trigPin 7 and echoPin 8
- LM35 lm35Sensor(A0); // LM35 temperature sensor on analog pin A0
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD object with appropriate pins
- void setup(void)
- {
- // Initialize the GSM module
- gsm.begin();
- // Initialize the LCD
- lcd.begin(20, 4); // Set up the LCD's number of columns and rows
- lcd.print("System Init"); // Print message on LCD
- // Initialize sensors
- acCurrentSensor.begin();
- acVoltageSensor.begin();
- ultrasonicSensor.setTimeout(20000UL); // Set timeout for ultrasonic sensor
- }
- void loop(void)
- {
- // Main code for monitoring and automation
- // Read values from sensors and display them
- double temperature = lm35Sensor.getTemp(); // Get temperature from LM35
- lcd.setCursor(0, 1);
- lcd.print("Temp: ");
- lcd.print(temperature);
- lcd.print(" C");
- // Read and display AC current and voltage
- double current = acCurrentSensor.readCurrent(); // Read current
- double voltage = acVoltageSensor.readVoltage(); // Read voltage
- lcd.setCursor(0, 2);
- lcd.print("Current: ");
- lcd.print(current);
- lcd.print(" A");
- lcd.setCursor(0, 3);
- lcd.print("Voltage: ");
- lcd.print(voltage);
- lcd.print(" V");
- // Read distance from ultrasonic sensor
- unsigned int distance = ultrasonicSensor.read(); // Read distance
- lcd.setCursor(0, 0);
- lcd.print("Distance: ");
- lcd.print(distance);
- lcd.print(" cm");
- delay(1000); // Delay for readability
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement