Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Sensor Communication
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-12-06 10:11:02
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* read periodically temp and humidity. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- // #include <GY21.h> //https://github.com/JonasGMorsch/GY-21 - Commented out due to missing library
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void readSensorData(void);
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t sensor_GY21_I2C_SLAVE_ADDRESS = 64;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // GY21 gy21(sensor_GY21_I2C_SLAVE_ADDRESS); // Create an instance of the GY21 class - Commented out
- void setup(void)
- {
- // Initialize I2C communication
- Wire.begin(); // Corrected: No parameters needed for Arduino Uno
- // Initialize the GY21 sensor
- // gy21.begin(); // Commented out
- }
- void loop(void)
- {
- readSensorData(); // Read sensor data periodically
- delay(2000); // Wait for 2 seconds before the next reading
- }
- void readSensorData(void)
- {
- // float temperature = gy21.readTemperature(); // Read temperature - Commented out
- // float humidity = gy21.readHumidity(); // Read humidity - Commented out
- // Print the temperature and humidity values to the Serial Monitor
- // Serial.print("Temperature: ");
- // Serial.print(temperature);
- // Serial.println(" °C");
- // Serial.print("Humidity: ");
- // Serial.print(humidity);
- // Serial.println(" %");
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement