Hello
I am Noé and I am making a arduino project to feed the chickens automaticaly when it is time. I already have the material:
esp8266 (it is not exactly that one)
I have this code:
#include <RtcDS1302.h>
#include <ThreeWire.h>
const int buzzPin = 12;
const int relPin = 8;
const int clk = 10;
const int dat = 11;
const int rst = 9;
int Hour = 13;
int Minute = 58;
int Second = 10;
ThreeWire myWire(dat, clk, rst);
RtcDS1302<ThreeWire> Rtc(myWire);
void setup() {
Serial.begin(9600); // Start serial communication for debugging
pinMode(buzzPin, OUTPUT);
pinMode(relPin, OUTPUT);
Rtc.Begin();
RtcDateTime currentTime = RtcDateTime(__DATE__, __TIME__);
Rtc.SetDateTime(currentTime);
if (!Rtc.IsDateTimeValid()) {
Serial.println("RTC lost confidence in the DateTime!");
RtcDateTime currentTime = RtcDateTime(__DATE__, __TIME__);
Rtc.SetDateTime(currentTime);
}
if (!Rtc.GetIsRunning()) {
Serial.println("RTC was not actively running, starting now");
Rtc.SetIsRunning(true);
}
}
void loop() {
RtcDateTime now = Rtc.GetDateTime();
// Print current time for debugging
Serial.print(now.Hour());
Serial.print(":");
Serial.print(now.Minute());
Serial.print(":");
Serial.println(now.Second());
if (now.Hour() == Hour && now.Minute() == Minute && now.Second() == Second) {
digitalWrite(relPin, HIGH); // Note: fixed typo in relPin
// Play melody
tone(buzzPin, 130.81); delay(600);
tone(buzzPin, 146.83); delay(600);
tone(buzzPin, 164.81); delay(600);
tone(buzzPin, 174.61); delay(600);
tone(buzzPin, 196); delay(600);
tone(buzzPin, 220); delay(600);
tone(buzzPin, 246.94); delay(600);
noTone(buzzPin); // Stop the buzzer
digitalWrite(relPin, LOW);
}
delay(1000); // Add a small delay to prevent excessive checking
}
Now I can change the time of feeding in the code. But I want to change it via a site or app. I thought blynk IOT is a good site. I also want the posibility to feed the chickens with a button.
Do anyone know how to do this?
thank you in advance
PS: I also posted this in other topics