Advertisement
zhexo

ENV_cloud_connect

Feb 6th, 2023 (edited)
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.86 KB | Source Code | 0 0
  1. #include "arduino_secrets.h"
  2. #include "thingProperties.h"
  3. #include <Arduino_MKRENV.h>
  4.  
  5. void setup() {
  6.   Serial.begin(9600);
  7.   delay(1500);
  8.   initProperties();
  9.   ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  10.   setDebugMessageLevel(2);
  11.   ArduinoCloud.printDebugInfo();
  12.  
  13.   if (!ENV.begin()) {
  14.     Serial.println("Failed to initialize MKR ENV shield!");
  15.     while(1);
  16.   }
  17. }
  18.  
  19. void loop() {
  20.   ArduinoCloud.update();
  21.   humidity = int(ENV.readHumidity());
  22.   illuminance = int(ENV.readIlluminance());
  23.   pressure = int(ENV.readPressure());
  24.   temperature = int(ENV.readTemperature());
  25.   delay(1000);
  26. }
  27.  
  28. void onHumidityChange() {
  29.   // Do something if necessary
  30. }
  31.  
  32. void onIlluminanceChange() {
  33.   // Do something if necessary
  34. }
  35.  
  36. void onPressureChange() {
  37.   // Do something if necessary
  38. }
  39.  
  40. void onTemperatureChange() {
  41.   // Do something if necessary
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement