Advertisement
pleasedontcode

Temperature Monitor rev_01

Mar 6th, 2024
71
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 Monitor
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-06 11:15:35
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* note: Ensure  to save sanitizer from running out */
  21.     /* fastly  ensuring that the pump operates for only 4 */
  22.     /* seconds after starting, even if the hand remains */
  23.     /* under the sensor. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Wire.h>
  28. #include <Adafruit_MLX90614.h>
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF I2C PINS *****/
  35. const uint8_t irsensor_GY_906_I2C_PIN_SDA_A4    = A4;
  36. const uint8_t irsensor_GY_906_I2C_PIN_SCL_A5    = A5;
  37. const uint8_t irsensor_GY_906_I2C_SLAVE_ADDRESS = 90;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. Adafruit_MLX90614 mlx = Adafruit_MLX90614();
  41.  
  42. // Variable to track the pump activation time
  43. unsigned long pumpActivationTime = 0;
  44. const unsigned long pumpActivationInterval = 4000; // 4 seconds
  45.  
  46. void setup(void)
  47. {
  48.   // put your setup code here, to run once:
  49.   Serial.begin(9600);
  50.   while (!Serial);
  51.  
  52.   Serial.println("Adafruit MLX90614 test");
  53.  
  54.   Wire.begin();
  55.  
  56.   if (!mlx.begin(irsensor_GY_906_I2C_SLAVE_ADDRESS)) {
  57.     Serial.println("Error connecting to MLX sensor. Check wiring.");
  58.     while (1);
  59.   }
  60.  
  61.   Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
  62.   Serial.println("================================================");
  63. }
  64.  
  65. void loop(void)
  66. {
  67.   // put your main code here, to run repeatedly:
  68.   unsigned long currentMillis = millis();
  69.  
  70.   // Check if the pump activation interval has passed
  71.   if (currentMillis - pumpActivationTime >= pumpActivationInterval)
  72.   {
  73.     pumpActivationTime = currentMillis;
  74.  
  75.     Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
  76.     Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  77.     Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
  78.     Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
  79.  
  80.     Serial.println();
  81.   }
  82.  
  83.   delay(500);
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement