#include "thingProperties.h"
#include "LiquidCrystal_I2C.h"
#include "DHT.h"
// #define DHTPIN 14
// #define DHTTYPE DHT22
// LiquidCrystal_I2C lcd(0x27,16,2);
// DHT dht (DHTPIN,DHTTYPE);
// const int potPin = 34;
// const int pinled = 12;
// int potValue = 0;
void setup() {
// 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);
// dht.begin();
// pinMode(pinled,OUTPUT);
// lcd.init();
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
// onHumadityChange();
// onVoltageChange();
// onMyLedChange();
onPlantNameChange();
// Serial.print(F("Kelembaban: "));
// Serial.print(humadity);
// Serial.print(F("% Suhu: "));
// Serial.print(temperature);
// Serial.print(F(" Celcius"));
// Serial.print(" Tegangan = ");
// Serial.print(voltage);
// Serial.print(" V ");
// Serial.print(" Potensio(ADC)= ");
// Serial.print(potValue);
// Serial.print(" LED= ");
// Serial.println(my_led);
// lcd.clear();
// lcd.setCursor(0,0);
// lcd.print("H: ");
// lcd.print(humadity);
// lcd.print("%");
// lcd.setCursor(9,0);
// lcd.print("T: ");
// lcd.print(temperature);
// lcd.print("C");
// lcd.setCursor(0,1);
// lcd.print("V: ");
// lcd.print(voltage);
// lcd.print("V");
// lcd.setCursor(8,1);
// if(my_led == HIGH)
// lcd.print("Led On");
// else
// lcd.print("Led Off");
}
// void onHumadityChange() {
// // Add your code here to act upon Humadity change
// float t = dht.readTemperature();
// float h = dht.readHumidity();
// if(isnan(h) || isnan(t)){
// Serial.println(F("Gagal membaca data sensor"));
// return;
// }
// temperature = t;
// humadity = h;
// delay(500);
// }
// void onVoltageChange(){
// potValue = analogRead(potPin);
// float v = potValue * (5.0/4096.0);
// voltage = v;
// delay(500);
// }
/*
Since MyLed is READ_WRITE variable, onMyLedChange() is
executed every time a new value is received from IoT Cloud.
*/
// void onMyLedChange() {
// // Add your code here to act upon MyLed change
// if(my_led == HIGH)
// digitalWrite(pinled, HIGH);
// else
// digitalWrite(pinled,LOW);
// }
/*
Since PlantName is READ_WRITE variable, onPlantNameChange() is
executed every time a new value is received from IoT Cloud.
*/
void onPlantNameChange() {
// Add your code here to act upon PlantName change
Serial.println(plantName);
}