#include <ESP32Servo.h>
// const int dht22_pin = 0;
// const int sr04_water_pin = 0;
// const int sr04_lid_pin = 0;
Servo lock;
Servo food;
Servo water;
const int lock_pin = 27;
const int water_pin = 32;
const int food_pin = 33;
int last_time = 0;
// Read temperature and humidity
// 21127601
double * getTempAndHumid() {
}
// Measure water level
// 21127601
double getWaterLevel() {
}
// Check if the Lid is open (> 10 cm)
// 21127601
bool isLidOpen(){
}
//21127643
// Lock the cage
// 21127643
void lockCage(){
lock.write(0);
delay(1000);
}
// Lock the cage
// 21127643
void openCage(){
lock.write(90);
delay(1000);
}
// Release water
// 21127643
void releaseWater() {
water.write(0);
delay(200);
water.write(90);
delay(200);
}
// Maintain humidity
// 21127643
void maintainHygro(double cur_Hygro, double cur_WaterLevel, bool manual){
double max_Hygro;
double min_Hygro;
double min_Water;
if(manual && cur_Hygro < max_Hygro){
releaseWater();
return;
}
if(cur_Hygro < min_Hygro && cur_WaterLevel > min_Water){
releaseWater();
return;
}
}
//Maintan food
//21127643
void maintainFood(bool manual, int schedule_interval){
schedule_interval *= 3600000; // Get value from thingspeak
int cur_time = millis()
if(manual){
releaseFood();
last_time = millis();
}
if(cur_time - last_time == schedule_interval){
releaseFood();
last_time = millis();
}
}
// Release food
// 21127643
void releaseFood() {
food.write(0);
delay(1000);
food.write(90);
delay(1000);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
lock.attach(lock_pin);
food.attach(food_pin);
water.attach(water_pin);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
// lockCage();
// openCage();
// releaseFood();
releaseWater();
delay(1000);
}