/********* 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: Irrigation_system
- Source Code compiled for: Arduino Uno
- Source Code created on: 2023-11-23 05:08:17
- Source Code generated by: Akhilesh
********* Pleasedontcode.com **********/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
#include
#include
/****** SYSTEM REQUIREMENT 1 *****/
/* Temperature monitoring */
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t Temp_DS18B20_DQ_PIN_D2 = 2;
/***** DEFINITION OF I2C PINS *****/
const uint8_t LCD_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
const uint8_t LCD_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
const uint8_t LCD_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
LiquidCrystal_I2C lcd(LCD_LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4);
DS18B20 ds(Temp_DS18B20_DQ_PIN_D2); // Initialize DS18B20 object with the DQ pin
void setup(void)
{
// put your setup code here, to run once:
pinMode(Temp_DS18B20_DQ_PIN_D2, INPUT);
lcd.init();
lcd.backlight();
// Add your initialization code here:
Serial.begin(9600); // Initialize the serial communication
}
void loop(void)
{
// put your main code here, to run repeatedly:
float temperature = ds.getTempC(); // Read temperature from DS18B20 sensor
lcd.clear(); // Clear the LCD screen
lcd.setCursor(0, 0); // Set the cursor to the first position of the first line
lcd.print("Temperature: "); // Print the text
lcd.print(temperature); // Print the temperature value
Serial.print("Temperature: "); // Print the text on the serial monitor
Serial.print(temperature); // Print the temperature value on the serial monitor
delay(1000); // Delay for 1 second
}