Advertisement
pleasedontcode

"Temperature Tracker" rev_01

Mar 6th, 2024
75
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: 2024-03-06 07:06:39
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on the led when it work */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Wire.h>
  25. #include <Adafruit_MLX90614.h>    //https://github.com/adafruit/Adafruit-MLX90614-Library
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF I2C PINS *****/
  32. const uint8_t but_GY_906_I2C_PIN_SDA_A4 = A4;
  33. const uint8_t but_GY_906_I2C_PIN_SCL_A5 = A5;
  34. const uint8_t but_GY_906_I2C_SLAVE_ADDRESS = 90;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  37. Adafruit_MLX90614 mlx = Adafruit_MLX90614();
  38.  
  39. /****** SYSTEM REQUIREMENTS *****/
  40. /****** SYSTEM REQUIREMENT 1 *****/
  41. const uint8_t ledPin = 13;
  42.  
  43. void setup(void)
  44. {
  45.     // put your setup code here, to run once:
  46.     pinMode(ledPin, OUTPUT);  // Set the LED pin as output
  47.  
  48.     Serial.begin(9600);
  49.     while (!Serial);
  50.  
  51.     Serial.println("Adafruit MLX90614 test");
  52.  
  53.     Wire.begin();
  54.  
  55.     if (!mlx.begin(but_GY_906_I2C_SLAVE_ADDRESS)) {
  56.         Serial.println("Error connecting to MLX sensor. Check wiring.");
  57.         while (1);
  58.     }
  59.  
  60.     Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
  61.     Serial.println("================================================");
  62. }
  63.  
  64. void loop(void)
  65. {
  66.     // put your main code here, to run repeatedly:
  67.     digitalWrite(ledPin, HIGH);   // Turn on the LED
  68.  
  69.     Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
  70.     Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  71.     Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
  72.     Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
  73.  
  74.     digitalWrite(ledPin, LOW);   // Turn off the LED
  75.  
  76.     Serial.println();
  77.     delay(500);
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement