Share this post!
Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someone

In addition to previously built Smart A/C controller and IronMan remote control (links below), we wanted to build a system where all Poin2 members can easily access through the Web and control devices in the office. It is assumed in this post that below two are already implemented.

Smarter Office: Automatic control of A/C in a small officehttp://blog.poin2.com/2015/06/smarter-office-automatic-control-of-ac-in-a-small-office/
Iron Man Figure Remote Controllerhttp://blog.poin2.com/2015/06/iron-man-figure-remote-controller/

 

In this project, an additional Arduino Uno with Ethernet shield is used to make the Web server. There are many instructions on the internet on how to use Arduino Ethernet shield, so this post will focus more on building the web server UI and interfacing with various GPIOs of Arduino. The server has two main functions for now, one is “Weekend Mode” to enable/disable automatic control of A/C, and the other is pure remote controls to manually turn A/C on and off. After everything was figured out, Poin2’s Web server looked like this:
smartoffice
Since we cannot share the web address (we don’t want a random person fiddling with our A/C 😛 ), a non-functional example can be found here: http://poin2.com/example/


Things you need:

Arduino UNO x 1
Arduino Ethernet Shield x 1
IR transmitter LED x 1
Few wires ( + 1 x loooooong one)


Connection:
ethernetshield
20150622_1655132

Wiring components is rather simple in this one. Since the official Ethernet Shield uses digital pins 10, 11, 12, 13, you just need to avoid those pins when assigning GPIOs. For our configuration, digital pin 2 was used to indicate “Weekend Mode,” digital pin 3 to send “Weekend Mode” signal to another Arduino, and digital pin 4 to send IR signals. “Weekend Mode” signal is connected to other Arduino’s reset pin, so it will stop functioning when the pin status is LOW. For reset to work, it is important to tie two Arduino’s grounds together.


Programming Arduino:

Download Poin2’s code WebArduino.ino and follow the guideline below.

1. One thing to keep in mind when using Arduino Uno is that it has very limited memory space. In order to prevent memory being overloaded, I used print(F( )) command for html parts of the code so the data will be stored in flash memory instead.
2. Start by declaring MAC and IP address of Ethernet shield. Unless directly connected to ISP modem, network port through which Arduino shield is connected should be forwarded to be accessible via Internet.

3. Define variables like buffer and digital output pin numbers.
4. In setup(), make sure to pull up “Weekend Mode” pin, so the other Arduino in connection will be functional upon startup.

5. In the beginning of loop(), we will define button functions. The Textfinder library is used to simplify the process, and it will scan EthernetClient cl for certain text outputs. There are total of 4 buttons: Weekend Mode on/off & Manual A/C on/off. Each of the submit button in html will generate a value upon pressed. All the buttons will have the same name but different values. In the code below, you can see that Textfinder will find “pinD,” upon a button press and then recognize the value associated with the button. When the value received is 0 or 1, Weekend Mode will be switched on or off. Similarly, when the value received is 2 or 3, A/C will be turned on or off.

6. Functions for each of the 4 buttons is set now, then define HTML part of the web server. Notice that cl.println and cl.print have F() before declaring html codes.

7. Define HTML header and IR LED functions after closing loop(), and upload your code. We also imported some style and used jquery for loading screen in the header function. For Arduino UNO, it is important to keep html texts as small as possible for memory management, so we cut down some of the linked file names.
8. Connect to your web server on a web browser and your office is now even smarter!

 

20150622_1709112
Through CSS customization, it’s also responsive to mobile environments. Enjoy! 🙂

Controlling A/C over the internet via Arduino
Share this post!
Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someone
Tagged on:                             

Leave a Reply

Your email address will not be published. Required fields are marked *