#include <SoftwareSerial.h>
#include <RemoteXY.h>
// Thermistor connections
const int thermistorPin = A0;
const int referenceResistor = 10000; // Value of the fixed resistor in the voltage divider circuit
// Buzzer and LED connections
const int buzzerPin = 7;
const int ledPin = 8;
// Photoresistor (LDR) connection
const int ldrPin = A1;
// Temperature and quality thresholds
const int minTemperature = 20; // Minimum temperature threshold
const int maxTemperature = 30; // Maximum temperature threshold
const int minQuality = 30; // Minimum quality threshold
// RemoteXY configuration
#define REMOTEXY_MODE__SOFTWARESERIAL
#define REMOTEXY_SERIAL_RX 10
#define REMOTEXY_SERIAL_TX 11
#define REMOTEXY_SERIAL_SPEED 9600
// Define RemoteXY interface
char remoteXY_CONF[] = {
0, 2, 0, 6, 0, 20, 0, 8, 11, 0,
1, 'T', 'e', 'm', 'p', 'e', 'r', 'a', 't', 'u', 'r', 'e', 1, 10, 0, 4, 16, 2, 'L', 'D', 'R', 0, 100, 0, 3, 15, 10, 'B', 'u', 'z', 'z', 'e', 'r', 1, 2, 0, 3, 7, 2, 'L', 'E', 'D', 1, 0, 1, 7, 7, 79, 78, 0
};
struct {
int8_t temperature;
int16_t ldr;
} remoteXY;
SoftwareSerial bluetooth(10, 11); // RX, TX pins for Bluetooth module
void setup() {
// Initialize RemoteXY
RemoteXY.begin();
// Start serial communication with Bluetooth module
bluetooth.begin(9600);
// Set pin modes for buzzer and LED
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
RemoteXY_Handler();
// Read temperature from thermistor
int rawADC = analogRead(thermistorPin);
double voltage = (5.0 / 1023.0) * rawADC;
double resistance = ((5.0 - voltage) / voltage) * referenceResistor;
double temperature = -0.06844 * resistance + 85.115;
// Read LDR sensor value
int ldrValue = analogRead(ldrPin);
// Update RemoteXY variables
remoteXY.temperature = (int8_t)temperature;
remoteXY.ldr = map(ldrValue, 0, 1023, 0, 100);
// Send data to the RemoteXY app
RemoteXY_Send();
// Check temperature range
if (temperature < minTemperature || temperature > maxTemperature) {
digitalWrite(buzzerPin, HIGH);
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
}
// Check water quality
if (remoteXY.ldr < minQuality) {
digitalWrite(buzzerPin, HIGH);
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
}
// Check if Bluetooth data is available
if (bluetooth.available()) {
char data = bluetooth.read();
// Check if received data is '1' to turn on the buzzer and LED
if (data == '1') {
digitalWrite(buzzerPin, HIGH);
digitalWrite(ledPin, HIGH);
}
// Check if received data is '0' to turn off the buzzer and LED
if (data == '0') {
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
}
}
}
Welcome to the forum
Do the examples from the RemoteXY library work ?
This sketch on the RemoteXY web site looks different (RemoteXY.init()
v RemoteXY.begin()
).
Yup. It's work well.
Please post an example sketch that works
Does it use the RemoteXY.begin() function ?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.