/*
-- New project --
This source code of graphical user interface
has been generated automatically by RemoteXY editor.
To compile this code using RemoteXY library 3.1.13 or later version
download by link http://remotexy.com/en/library/
To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- for ANDROID 4.13.13 or later version;
- for iOS 1.10.3 or later version;
This source code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
*/
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__WIFI_CLOUD
#include <DHT.h>
#include <WiFi.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "Wokwi-GUEST"
#define REMOTEXY_WIFI_PASSWORD ""
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "ab7051da53bda6f4b2ebd7da272cbfd6"
#include <RemoteXY.h>
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 98 bytes
{ 255,0,0,15,0,91,0,17,0,0,0,24,1,106,200,1,1,4,0,67,
18,55,73,20,4,133,26,11,129,8,32,90,14,119,84,101,109,112,32,82,
101,97,100,105,110,103,0,71,21,121,61,61,60,0,8,12,189,75,0,0,
0,0,0,0,200,66,0,0,160,65,0,0,32,65,0,0,0,64,133,0,
129,12,99,80,13,133,72,85,77,32,82,101,97,100,105,110,103,0 };
// this structure defines all the variables and events of your control interface
struct {
// output variables
char temp_reading[11]; // string UTF8 end zero
float humidity; // from 0 to 100
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
// Define DHT sensor type and pin
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
#define DHTPIN 4 // Digital pin connected to the DHT sensor
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
RemoteXY_Init ();
Serial.begin(115200); // Initialize Serial for debug output
dht.begin(); // Initialize the DHT sensor
}
void loop()
{
RemoteXY_Handler ();
// Read temperature and humidity from the DHT sensor
float temperature = dht.readTemperature(); // Read temperature in Celsius
float humidity = dht.readHumidity(); // Read humidity
// Check if any reads failed and print an error message
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Update the RemoteXY interface with the sensor values
snprintf(RemoteXY.temp_reading, sizeof(RemoteXY.temp_reading), "%.1f°C", temperature);
RemoteXY.humidity = humidity;
// Print the values to the Serial Monitor for debugging
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C, Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}