Advertisement
pleasedontcode

Temperature Monitor rev_13

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