The main script

The main script can be used after some adjustments. The next data will be different for everybody:

  • The name and password of your WIFI network.
  • The (amount of) devices you want to control.
  • The grouping of the devices (on four tabs).
  • The way you want to control them (with relay of wireless).
  • The available radio codes to turn things on and off.

Besides those points, when you can work with HTML it is also possible to change the website, add or remove tabs, change the tab-icons or the turn on and off buttons. On the next page of this article you will find information about the website, as most is hidden in a JS file.

The devices

Make a list with all devices you want to control, and sort them as you want to see them on the website (first device is first item on first tab, second device is second item on first tab, and so on).

  • Enter the amount of devices in the program.  (const int devices)
  • Add the names (in the order meant above) between quotes and seperated by comma's to the const String deviceNames[].
  • For every device, add the tab number to const int deviceTabs[]
  • Add the destination. What needs to be used when the button of that device is pressed? Destination 1 - 8 are relays, 11 and higher are wireless codes to be broadcasted. (const int destinations[])

For all wireless devices, two codes are needed. One to turn off, and one to turn on. If you use devices which use only a single code like a pushbutton (door openers for example), add the code twice: once on the list of codes to turn on, and once on the list of codes to turn off.

The setup part of the RC Switch contains the pulseLength, which maybe can be different from mine. The pulselength of your wireless switches can be found with the test-program "ReceiveDemo_Advanced" mentioned on the page before.

The OLED screen is bus connected, and will only be able to work when the correct address had been entered in the program:

 

Arduino Code:
  1. display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //<-- The address(0x0C) can be different on other OLED screens.

 

Besides that, run the test-program at least once. It will also warn you when your library "Adafruit_SSD1306.h" needs an adjustment for your resolution. See the module-checking page..

 

Dwnldicon Download the Home Automation script

 

The script serves a website, which has dependencies to three other files:

  • http://2muchtime.org/projects/ha/ha.css
    This is the CSS file for the entire website.
  • https://ajax/googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
    This loads jQuery, which is used in the next file. It doesn’t need to be stores on an own server, as it is allowed to link directly to the Google Apis.
  • http://2muchtime.org/projects/ha/ha.js
    The JavaScript file does the big part: This file not only contains the functionality, it is also necessary for building up the HTML and building up the images (all SVG)

I can imagine you need to change ha.js, as it contains the images. And most people won’t use the same TV, light, bed and door icon I do. So you need to have access to a web server to store ha.css and ha.js. On the next page, you can find the zip files of these two files.

For testing purposes or “just wanting the same version I have”, you can use the ones stored on the 2muchtime server. (Link to the addresses above, not to their zip-file)

And off course: using your own files means you have to change the script on your Arduino: recplace the URLs in the string of the website with your own locations.

 

Index of this article

Add comment


Security code
Refresh

Powered by Amazing-Templates.com 2014 - All Rights Reserved.