Last active
September 4, 2022 10:32
-
-
Save ariesmcrae/95aba3bfc2ed0265703545a56e7efec0 to your computer and use it in GitHub Desktop.
Arduino Cloud: M5Stack Core 2 with ENV III temperature/humidity sensor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "thingProperties.h" | |
// M5Unit-ENV - Version: 0.0.6 | |
#include <M5_ENV.h> | |
SHT3X sht30; | |
void setup() { | |
Wire.begin(); // Wire init, adding the I2C bus. | |
// Initialize serial and wait for port to open: | |
Serial.begin(9600); | |
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found | |
delay(1500); | |
// Defined in thingProperties.h | |
initProperties(); | |
// Connect to Arduino IoT Cloud | |
ArduinoCloud.begin(ArduinoIoTPreferredConnection); | |
} | |
void loop() { | |
if (sht30.get() == 0) { // Obtain the data of shT30 | |
temperature = sht30.cTemp; // Store the temperature obtained from shT30. | |
humidity = sht30.humidity; // Store the humidity obtained from the SHT30. | |
} else { | |
temperature = 0; | |
humidity = 0; | |
} | |
delay(2000); | |
ArduinoCloud.update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment