Advertisement
pleasedontcode

**Sensor Readings** rev_01

Nov 20th, 2024
489
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: **Sensor Readings**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-11-21 00:14:06
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* crear un portafolio de diseño visual con doce */
  21.     /* fotos y texto describiéndome, que utilice colores */
  22.     /* #4C000D #72071E #160002 y textos blancos */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /* START CODE */
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <forcedBMX280.h>   //https://github.com/soylentOrange/Forced-BMX280
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. // Instantiate the ForcedBMX280 object
  36. ForcedBMX280 sensor; // Default I2C address will be used
  37.  
  38. void setup(void)
  39. {
  40.     // Initialize the sensor
  41.     if (sensor.begin() != ERROR_OK) {
  42.         Serial.println("Sensor initialization failed!");
  43.         while (1); // Stop the program
  44.     }
  45.  
  46.     // Set up serial communication for debugging
  47.     Serial.begin(9600);
  48. }
  49.  
  50. void loop(void)
  51. {
  52.     // Read temperature and humidity
  53.     int32_t temperature = sensor.getTemperatureCelsius(true);
  54.     uint32_t humidity = sensor.getRelativeHumidity(true);
  55.  
  56.     // Display the readings
  57.     Serial.print("Temperature: ");
  58.     Serial.print(temperature);
  59.     Serial.println(" °C");
  60.    
  61.     Serial.print("Humidity: ");
  62.     Serial.print(humidity);
  63.     Serial.println(" %");
  64.  
  65.     // Add a delay for readability
  66.     delay(2000);
  67. }
  68.  
  69. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement