SHOW:
|
|
- or go back to the newest paste.
1 | - | /********* Pleasedontcode.com ********** |
1 | + | /********* Pleasedontcode.com ********** |
2 | - | |
2 | + | |
3 | - | Pleasedontcode thanks you for automatic code generation! Enjoy your code! |
3 | + | Pleasedontcode thanks you for automatic code generation! Enjoy your code! |
4 | - | |
4 | + | |
5 | - | - Terms and Conditions: |
5 | + | - Terms and Conditions: |
6 | - | You have a non-exclusive, revocable, worldwide, royalty-free license |
6 | + | You have a non-exclusive, revocable, worldwide, royalty-free license |
7 | - | for personal and commercial use. Attribution is optional; modifications |
7 | + | for personal and commercial use. Attribution is optional; modifications |
8 | - | are allowed, but you're responsible for code maintenance. We're not |
8 | + | are allowed, but you're responsible for code maintenance. We're not |
9 | - | liable for any loss or damage. For full terms, |
9 | + | liable for any loss or damage. For full terms, |
10 | - | please visit pleasedontcode.com/termsandconditions. |
10 | + | please visit pleasedontcode.com/termsandconditions. |
11 | - | |
11 | + | |
12 | - | - Project: **Sensor Monitoring** |
12 | + | - Project: **Sensor Monitoring** |
13 | - | - Source Code NOT compiled for: Arduino Uno |
13 | + | - Source Code NOT compiled for: Arduino Uno |
14 | - | - Source Code created on: 2024-12-31 11:59:14 |
14 | + | - Source Code created on: 2024-12-31 11:59:14 |
15 | - | |
15 | + | |
16 | - | ********* Pleasedontcode.com **********/ |
16 | + | ********* Pleasedontcode.com **********/ |
17 | - | |
17 | + | |
18 | - | /****** SYSTEM REQUIREMENTS *****/ |
18 | + | /****** SYSTEM REQUIREMENTS *****/ |
19 | - | /****** SYSTEM REQUIREMENT 1 *****/ |
19 | + | /****** SYSTEM REQUIREMENT 1 *****/ |
20 | - | /* Arduino code generator for real time remote */ |
20 | + | /* Arduino code generator for real time remote */ |
21 | - | /* monitoring and automation of distribution */ |
21 | + | /* monitoring and automation of distribution */ |
22 | - | /* transformer using Arduino uno, gsm, ac current */ |
22 | + | /* transformer using Arduino uno, gsm, ac current */ |
23 | - | /* sensor, ac volage sensor, ultrasonic oil level */ |
23 | + | /* sensor, ac volage sensor, ultrasonic oil level */ |
24 | - | /* sensor, lm35, lcd 20*4 */ |
24 | + | /* sensor, lm35, lcd 20*4 */ |
25 | - | /****** END SYSTEM REQUIREMENTS *****/ |
25 | + | /****** END SYSTEM REQUIREMENTS *****/ |
26 | - | |
26 | + | |
27 | - | /* START CODE */ |
27 | + | /* START CODE */ |
28 | - | |
28 | + | |
29 | - | /****** DEFINITION OF LIBRARIES *****/ |
29 | + | /****** DEFINITION OF LIBRARIES *****/ |
30 | - | #include <GSM.h> |
30 | + | #include <GSM.h> |
31 | - | #include <ACCurrentSensor.h> |
31 | + | #include <ACCurrentSensor.h> |
32 | - | #include <ACVoltageSensor.h> |
32 | + | #include <ACVoltageSensor.h> |
33 | - | #include <Ultrasonic.h> |
33 | + | #include <Ultrasonic.h> |
34 | - | #include <LM35.h> |
34 | + | #include <LM35.h> |
35 | - | #include <LiquidCrystal.h> |
35 | + | #include <LiquidCrystal.h> |
36 | - | |
36 | + | |
37 | - | /****** FUNCTION PROTOTYPES *****/ |
37 | + | /****** FUNCTION PROTOTYPES *****/ |
38 | - | void setup(void); |
38 | + | void setup(void); |
39 | - | void loop(void); |
39 | + | void loop(void); |
40 | - | |
40 | + | |
41 | - | /****** GLOBAL VARIABLES *****/ |
41 | + | /****** GLOBAL VARIABLES *****/ |
42 | - | GSM gsm; // GSM module object |
42 | + | GSM gsm; // GSM module object |
43 | - | ACCurrentSensor acCurrentSensor; // AC current sensor object |
43 | + | ACCurrentSensor acCurrentSensor; // AC current sensor object |
44 | - | ACVoltageSensor acVoltageSensor; // AC voltage sensor object |
44 | + | ACVoltageSensor acVoltageSensor; // AC voltage sensor object |
45 | - | Ultrasonic ultrasonicSensor(7, 8); // Ultrasonic sensor with trigPin 7 and echoPin 8 |
45 | + | Ultrasonic ultrasonicSensor(7, 8); // Ultrasonic sensor with trigPin 7 and echoPin 8 |
46 | - | LM35 lm35Sensor(A0); // LM35 temperature sensor on analog pin A0 |
46 | + | LM35 lm35Sensor(A0); // LM35 temperature sensor on analog pin A0 |
47 | - | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD object with appropriate pins |
47 | + | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD object with appropriate pins |
48 | - | |
48 | + | |
49 | - | void setup(void) |
49 | + | void setup(void) |
50 | - | { |
50 | + | { |
51 | - | // Initialize the GSM module |
51 | + | // Initialize the GSM module |
52 | - | gsm.begin(); |
52 | + | gsm.begin(); |
53 | - | |
53 | + | |
54 | - | // Initialize the LCD |
54 | + | // Initialize the LCD |
55 | - | lcd.begin(20, 4); // Set up the LCD's number of columns and rows |
55 | + | lcd.begin(20, 4); // Set up the LCD's number of columns and rows |
56 | - | lcd.print("System Init"); // Print message on LCD |
56 | + | lcd.print("System Init"); // Print message on LCD |
57 | - | |
57 | + | |
58 | - | // Initialize sensors |
58 | + | // Initialize sensors |
59 | - | acCurrentSensor.begin(); |
59 | + | acCurrentSensor.begin(); |
60 | - | acVoltageSensor.begin(); |
60 | + | acVoltageSensor.begin(); |
61 | - | ultrasonicSensor.setTimeout(20000UL); // Set timeout for ultrasonic sensor |
61 | + | ultrasonicSensor.setTimeout(20000UL); // Set timeout for ultrasonic sensor |
62 | - | } |
62 | + | } |
63 | - | |
63 | + | |
64 | - | void loop(void) |
64 | + | void loop(void) |
65 | - | { |
65 | + | { |
66 | - | // Main code for monitoring and automation |
66 | + | // Main code for monitoring and automation |
67 | - | // Read values from sensors and display them |
67 | + | // Read values from sensors and display them |
68 | - | double temperature = lm35Sensor.getTemp(); // Get temperature from LM35 |
68 | + | double temperature = lm35Sensor.getTemp(); // Get temperature from LM35 |
69 | - | lcd.setCursor(0, 1); |
69 | + | lcd.setCursor(0, 1); |
70 | - | lcd.print("Temp: "); |
70 | + | lcd.print("Temp: "); |
71 | - | lcd.print(temperature); |
71 | + | lcd.print(temperature); |
72 | - | lcd.print(" C"); |
72 | + | lcd.print(" C"); |
73 | - | |
73 | + | |
74 | - | // Read and display AC current and voltage |
74 | + | // Read and display AC current and voltage |
75 | - | double current = acCurrentSensor.readCurrent(); // Read current |
75 | + | double current = acCurrentSensor.readCurrent(); // Read current |
76 | - | double voltage = acVoltageSensor.readVoltage(); // Read voltage |
76 | + | double voltage = acVoltageSensor.readVoltage(); // Read voltage |
77 | - | lcd.setCursor(0, 2); |
77 | + | lcd.setCursor(0, 2); |
78 | - | lcd.print("Current: "); |
78 | + | lcd.print("Current: "); |
79 | - | lcd.print(current); |
79 | + | lcd.print(current); |
80 | - | lcd.print(" A"); |
80 | + | lcd.print(" A"); |
81 | - | lcd.setCursor(0, 3); |
81 | + | lcd.setCursor(0, 3); |
82 | - | lcd.print("Voltage: "); |
82 | + | lcd.print("Voltage: "); |
83 | - | lcd.print(voltage); |
83 | + | lcd.print(voltage); |
84 | - | lcd.print(" V"); |
84 | + | lcd.print(" V"); |
85 | - | |
85 | + | |
86 | - | // Read distance from ultrasonic sensor |
86 | + | // Read distance from ultrasonic sensor |
87 | - | unsigned int distance = ultrasonicSensor.read(); // Read distance |
87 | + | unsigned int distance = ultrasonicSensor.read(); // Read distance |
88 | - | lcd.setCursor(0, 0); |
88 | + | lcd.setCursor(0, 0); |
89 | - | lcd.print("Distance: "); |
89 | + | lcd.print("Distance: "); |
90 | - | lcd.print(distance); |
90 | + | lcd.print(distance); |
91 | - | lcd.print(" cm"); |
91 | + | lcd.print(" cm"); |
92 | - | |
92 | + | |
93 | - | delay(1000); // Delay for readability |
93 | + | delay(1000); // Delay for readability |
94 | - | } |
94 | + | } |
95 | - | |
95 | + | |
96 | /* END CODE */ |