Refining and expanding home auto project

I'll start by saying, i'm a PHP guy first and foremost. I've dabbled with C++ etc. over the years but never really coded something properly from scratch. This project is essentially, my first attempt.

As it currently stands, it's a basic proof-of-concept that fades up our main bedroom light via RF at a set time (to act as a S.A.D. light) but the plan was always to expand this to control more devices, of various manufacturers, both scheduled and on-demand. Project has been on the back burner for a while but I'm looking to get going with it again so...

Borrowing from the way Harmony remotes work, I intend to create a database and have tables for rooms, devices, functions, tasks and events. Database will probably be file based (SD) and a httpd will be used for monitoring/managing events/devices/etc.

In the main loop, the code will first check for any serial or web requests and act on them if necessary. Then it will check the DB for any scheduled events due to run and loop back with maybe a 10ms delay.

If a task requires a lot of functions and, more specifically, delays, instead of having the delay in the task, it should exit back out to the main loop and do nothing until it's time to run the next part of the task - to allow other requests or scheduled events to run (primitive multitasking?). I'd imagine setting a status flag and a timeout in the DB would accomplish this best? If there were any event collisions, there would be some kind of priority system in place.

The rest would just be input/output functions, DB management, RF protocol defs etc.

What I want to avoid, as much as I can, is unresponsiveness due to an already running task. That and bloating the program out so much that I run out of EPROM space! I have an extra 32k of SPI memory so should be ok there so long as i'm careful with leaks.

Does this sound like i'm on the right track?

TIA

I'd be inclined to offload the database and web site to a platform that can handle them well. You can do it on an arduino, but it makes a pretty feeble web server. Given your expertise, you could make yourself a nicer web interface on something with a bit more power and just have the arduino manage the hardware. If you don't already have a web server you can use, take a look at the Pi.

I've been putting together a system to interface a chicken coop to a web interface. (yes I know overkill but it's more about the journey than getting there :slight_smile:

I don't have an ethernet sheild for the arduino but I have an old netbook just kicking around so the aproach I have adopted will likely solve a lot of the problems that you may encounter.

The arduino is plugged into the netbook.
The netbook uses wamp server to serve up a user interface.
The userinterface (accessed through a browser from anywhere on the internett) provides the following
video feeds from two cameras
control to pan and tilt
real time temperature and humidity readings
open and close control for the coop door.

The chicken coop door is also closed automatically at dusk but uses pir to ensure all the chickens have gone home first.

I haven't pulled it all together yet but I've overcome most of the hurdles. I've built a "schedule" library to take care of running processes as they become due. I've managed to get PHP communicating with the arduino through the com port fairly reliably.

All I need to do now is build a chicken coop :slight_smile:

wildbill:
I'd be inclined to offload the database and web site to a platform that can handle them well. You can do it on an arduino, but it makes a pretty feeble web server. Given your expertise, you could make yourself a nicer web interface on something with a bit more power and just have the arduino manage the hardware. If you don't already have a web server you can use, take a look at the Pi.

You're right, of course but the whole point of this from the beginning was to a)teach me how to code properly/efficiently and b)have a nice "simple" all-in-one solution - that's why I went with a NanodeRF and had the supplier fit an RTC, backup battery and extra mem :slight_smile:

The web UI will really be nothing fancy, just a simple responsive layout with some AJAX-type behaviour for keeping load times down.

KenF:
I've been putting together a system to interface a chicken coop to a web interface. (yes I know overkill but it's more about the journey than getting there :slight_smile:

Know exactly what you mean :wink: