/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/2ce65d48-e84c-4cc8-a648-70a66da00ce3
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int random_value;
bool led_switch;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <Arduino.h>
#include <HTTPClient.h>
#include "DHT.h"
#include <ESP32Servo.h>
const int servoPin = 5;
Servo servo;
#define DHT22PIN 2
DHT dht(DHT22PIN, DHT22);
const char* ssid = "Wokwi-GUEST";
const char* password = "";
HTTPClient client;
int LED=13;
void setup() {
servo.attach(servoPin, 500, 2400);
dht.begin();
// 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);
pinMode(LED, OUTPUT);
//pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
// 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();
aTH = dht.readHumidity();
aTT = dht.readTemperature();
Serial.println(aTT);
Serial.println(aTH);
// Your code here
}
void onATXChange() {
digitalWrite(13,aTX);
// Add your code here to act upon ATX change
}
/*
Since ATY is READ_WRITE variable, onATYChange() is
executed every time a new value is received from IoT Cloud.
*/
void onATYChange() {
analogWrite(14,aTY);
// Add your code here to act upon ATY change
}
/*
Since ATZ is READ_WRITE variable, onATZChange() is
executed every time a new value is received from IoT Cloud.
*/
void onATZChange() {
servo.write(aTZ);
// Add your code here to act upon ATZ change
}
/*
Since ATX is READ_WRITE variable, onATXChange() is
executed every time a new value is received from IoT Cloud.
*/
/*
Since ATH is READ_WRITE variable, onATHChange() is
executed every time a new value is received from IoT Cloud.
*/
void onATHChange() {
// Add your code here to act upon ATH change
}
/*
Since ATT is READ_WRITE variable, onATTChange() is
executed every time a new value is received from IoT Cloud.
*/
void onATTChange() {
// Add your code here to act upon ATT change
}