Advertisement
pleasedontcode

Temperature Monitoring rev_01

Jun 28th, 2024
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Temperature Monitoring
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-06-28 19:31:50
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Read sensor and print on serial monitor */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <DS18B20.h>  //https://github.com/matmunk/DS18B20
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  31. const uint8_t Sensor_DS18B20_DQ_PIN_D4 = 4;
  32.  
  33. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  34. DS18B20 ds(Sensor_DS18B20_DQ_PIN_D4);  // Initialize DS18B20 object with the pin number
  35.  
  36. /****** GLOBAL VARIABLES *****/
  37. #define LOW_ALARM 20
  38. #define HIGH_ALARM 25
  39. uint8_t address[] = {40, 250, 31, 218, 4, 0, 0, 52};  // Example address
  40.  
  41. void setup(void) {
  42.   // put your setup code here, to run once:
  43.   Serial.begin(9600);
  44.   pinMode(Sensor_DS18B20_DQ_PIN_D4, INPUT);
  45.  
  46.   if (ds.select(address)) {
  47.     ds.setAlarms(LOW_ALARM, HIGH_ALARM);
  48.   } else {
  49.     Serial.println("Device not found!");
  50.   }
  51. }
  52.  
  53. void loop(void) {
  54.   // put your main code here, to run repeatedly:
  55.   if (ds.select(address)) {
  56.     if (ds.hasAlarm()) {
  57.       Serial.print("Warning! Temperature is ");
  58.       Serial.print(ds.getTempC());
  59.       Serial.println(" C");
  60.     } else {
  61.       Serial.print("Temperature is ");
  62.       Serial.print(ds.getTempC());
  63.       Serial.println(" C");
  64.     }
  65.   } else {
  66.     Serial.println("Device not found!");
  67.   }
  68.  
  69.   delay(10000);
  70. }
  71.  
  72. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement