Two-way communication via Nuelectronics ethernet shield…
…is possible, and does work – but only sometimes.
I struggled last night for several hours trying to get reliable two way communications. The idea is that every time the arduino receives a home easy command from a remote or motion detector, it sends a message to the MPC-L. Then, with some funky programming, the server will decide what events to fire off.
Unfortunately while I can reliably receive messages, and reliably send messages, I can’t do both – it just hangs. I’m thinking it’s the nuelectronics ethernet shield, the software certainly isn’t very nice, so as I’ve only been playing with this for a few days, I’m splashing out on an official shield. As a by-product of this, it is supported by Nicholas O’Leary’s MQTT code. So, moving away from last night’s PHP start, I’ll write a small java program to receive these, process them, and fire off any events if need be.
The logic for the event firing will end up being more complicated, but initially, I want a bunch of events/desired actions, and each event has a sequence of signals required, each of which have to happen within a changable amount of time. Only if a path through the sequence is achieved in the right time will the action be fired.
For example, a motion detector in the hall, and a door open/shut detector on my front door. An event (i.e. turn off all lights) with a sequence of 1. Motion detector fired, 2. Door opened will detect when someone has just left the house, but obviously you only want it to happen if the time between 1 and 2 isn’t too much, otherwise the person could have walked upstairs and someone else came in through the front door!
I got this working in PHP, so will Java-it-up tonight. Then will code the more complicated (and more useful) central heating logic (i.e. I want the house at 18 degrees at 7PM, it’s now 16 degrees, and takes 45mins to warm up to 18degrees, so turn on centreal heating at 6.15PM).