This is my page on home automation, nothing fancy, just my own creations to my life easier.
Home Automation
Parts that I used to make this happen.
I wrote my own arduino code, I am sure it can be done better and cleaner, but this works for me. I am still thinking about adding more Homekit compatibility, but I am not an programmer/coder. I would like to have some kind of status report back to Homekit/Homebridge so I can tell if the curtains are open or closed but that might never happen as longs as this code does what it needs to do.
The curtains close when it gets dark outside and they open again when it gets light outside, no manual actions required there. I added some kind of Homekit support by means of a webserver setup with two embedded links, one to open and one to close the curtains by manual override the light sensor.
#include Ethernet.h
#include AccelStepper.h
AccelStepper stepper(1, 5, 6);
boolean c_state = false;
boolean c_man = false;
const int driver_enable = 9;
int sensorPin = 3;
int light = 175; // Threshold when to open
int dark = 125; // Threshold when to close
unsigned long currentTime = 0;
unsigned int sensorValue = 0;
long previousMillis = 0;
long interval = 3000;
byte mac[] = { 0x72, 0x69, 0x67, 0x2E, 0x30, 0x33 }; // Your arduino mac-address
byte myip[] = { 192, 168, 1, 25 };
byte gwip[] = { 192, 168, 1, 1 };
byte dnsip[] = { 192, 168, 1, 1 };
EthernetServer server(80);
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, myip, gwip, dnsip);
server.begin();
stepper.setMaxSpeed(6000);
stepper.setAcceleration(2000);
}
void loop() {
read_ldr();
if (sensorValue > light && c_state == false) {
a_open();
}
if (sensorValue < dark && c_state == true) {
a_close();
}
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
boolean currentLineIsBlank = true;
String postText = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (postText.length() < 10) {
postText += c;
}
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
client.println("");
client.println("");
client.println("");
client.println(" ArduinoCurtains ");
client.println("");
client.println("