I had a project idea and purchased all of what I think I need for it. I am going to control my air conditioner over wifi with an arduino and a relay. However, I would like to sync the air conditioner to my google calendar, so that when I am not home, it isn't running, then 5 minutes after I get out of whatever is scheduled it turns on. This will force me to start planning my life out more (because I need my AC), and save electricity on the side.
I purchased an Arduino Uno R3, a pair of ESP8266 wifi modules, and a relay capable of handling the power of a 5,000 BTU air conditioner.
My code question is, how do I structure this? What should I code in what language? I need to use the Google Calendar API, which they have in multiple languages, and then the arduino needs to be running its own code to communicate with my home network. I have the most experience with Java and Visual C#. I have enough C experience to get me through the coding of the arduino, but I am most definitely not advanced. For example: I have never touched a pointer, although I know what they are.
I do have one question you might be able to answer. How do you think the hardware inside the air conditioner will fare being turned on and off at the outlet 3 or 4 times a day? Its a basic unit, with no temperature sensing or anything, just a rotary switch to select compressor/fan speed. I am hoping it will be able to last a while operating like that.
This sounds like an old window unit which does not have a temperature controller, in which case @ProCompGaming cycling it on and off via the power is fine. You will want to use a contractor which is a higher amp rated relay.
There are a bunch of smart home plugin switched receptacles that may work for your application usually in zigbee, x10 or zwave... Otherwise any relay that handles 20A@115vac will do. Or what ever your mains voltage is.
Here is how I think you could structure your code.
CalendarApi: this module is what will communicate with google calendar. I'm not sure if google calendar got an api, you might need some research on how you can use it, maybe there is some library for that, if you cant find anything, envisage to change to another webhosted calendar. (maybe something open). It should provide methods to retrieve the Calendar.
Calendar: represent the calendar within your program. Implementation is up to you. with a calendar that has been retrieved using CalendarApi you can check if your ac should be running or not.
ACControl: provide methods to control the ac unit. It could have methods like start(), stop() and status() which activate, stop or give the current status of the ac unit.
Core, contains the loop of your program. In this loop, retrieve the calendar using CalendarApi, check if the ac should be running if yes and the ac isn't running, activate it, if the ac should not be running and it's running, desactivate it.
Note: I used oriented object because that's how I program. but it can easly be adapted to C.
I think I am going to use Java for the majority of this, although I might make it some Windows only language later on so it can run in the background instead of as a java app. I guess the part I'm super confused about is the communication between the arduino (specifically the ESP8266) and my computer. I have never done any network programming, and I hope to learn a lot from this. I need to be able to retrieve the status of the Air Conditioner, and then set the status. It would be awesome if I could do this from anywhere, but if it is simpler to restrict it to a local network, then I will go that route.
I just got home from school and was playing around with my relay and I encountered a problem. I'm pretty sure this problem is because there is a DC load on it. The relay turns on when I set it to 5V, but when I set it back to ground, the relay turns off, but the LED I have as the load stays on. I just did some reading on the internet, and I believe it is because this relay is only rated for an AC load. I thought it would work either way, as I thought it was just a switch, but I must be wrong.