Advertisement
pleasedontcode

Temperature Tracker rev_12

Dec 19th, 2023
62
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 Tracker
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-19 10:34:32
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* read temperature and show on serial. */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <Wire.h>
  26. #include <Adafruit_MLX90614.h>
  27.  
  28. /****** SYSTEM REQUIREMENTS *****/
  29. /****** SYSTEM REQUIREMENT 1 *****/
  30. /* read temperature and show on serial. */
  31. /****** END SYSTEM REQUIREMENTS *****/
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF I2C PINS *****/
  38. const uint8_t I2C_PIN_SDA = A4;
  39. const uint8_t I2C_PIN_SCL = A5;
  40. const uint8_t I2C_SLAVE_ADDRESS = 0x5A;
  41.  
  42. /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
  43. Adafruit_MLX90614 mlx = Adafruit_MLX90614();
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.   Serial.begin(9600);
  49.   while (!Serial);
  50.  
  51.   Serial.println("Adafruit MLX90614 test");
  52.  
  53.   Wire.begin(); // Remove the arguments from the Wire.begin() function call
  54.  
  55.   if (!mlx.begin(I2C_SLAVE_ADDRESS)) {
  56.     Serial.println("Error connecting to MLX sensor. Check wiring.");
  57.     while (1);
  58.   }
  59.  
  60.   Serial.print("Emissivity = ");
  61.   Serial.println(mlx.readEmissivity());
  62.   Serial.println("================================================");
  63. }
  64.  
  65. void loop(void)
  66. {
  67.   // put your main code here, to run repeatedly:
  68.   Serial.print("Ambient = ");
  69.   Serial.print(mlx.readAmbientTempC());
  70.   Serial.print("*C\tObject = ");
  71.   Serial.print(mlx.readObjectTempC());
  72.   Serial.println("*C");
  73.   Serial.print("Ambient = ");
  74.   Serial.print(mlx.readAmbientTempF());
  75.   Serial.print("*F\tObject = ");
  76.   Serial.print(mlx.readObjectTempF());
  77.   Serial.println("*F");
  78.  
  79.   Serial.println();
  80.   delay(500);
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement