While I was planning to recap and improve some of my older projects, there was the opportunity (or rather necessity) for me to jump into a new project instead: The home automation system I was planning to do since I moved to France. There was three factors supporting it:
- An electric counter with a serial interface
- Electrical heating
The serial interface alone is already pretty awesome. It lets you retrieve your present and total consumption and tells you whether you are in the high price or low price period. The zeros and ones are modulated on a 50Hz signal, carrying 7 bit of data, one parity bit and a stop bit at 1200 baud. They are following a simple protocol around a set of data that is being repeated over and over again. While all the details can be found in the 105 pages manual provided by the energy company, there is already quite a few projects dealing with the demodulation and usage of the signal.
The electrical heating should also be quite easy to control. After worrying quite a bit about amperage and duty cycles almost made me go for solid state relays. Then I found that the heaters were equipped with some sort of a control line (“fil pilote”). You can influence the behavior of the heater by putting a 220V 50Hz signal on it (run, stop, setting – 1°C, setting – 2°C, reduced heating, anti-icing), instead of turning the main power to the radiator on / off (at full load).
And then there is free.fr, one of the big three internet providers in France. If there is anything awesome about French internet and phone companies (at least compared to Germany), then it is the package they give you along with the service. Not only did they send me a router with a 500GB HDD, an additional TV-Box with a blue ray player, an USB game controller and a remote that has almost the same features as the Wii-Mote (hmm… I did some projects with that, too…), but there is also a free DNS address you can assign to your router, so you can reach it from the outside. All in all a quite nice package at a more than reasonable price.
The first tests were made with an Atmega minimal circuit (the Arduino Uno was being used for another project… A MP3 player for my son… but that’s another story to be told).
Most of the projects I found used a SFH620 optocoupler to connect the counter to the MCU, which I didn’t have. I decided to rebuild what I found in the datasheet with two LEDs and a phototransistor, put them inside the tube of an old pen and sealed it with hot glue – and it worked like a charme.
Well, at least the LEDs started blinking when I attached my DIY optocoupler to the two wires coming from the counter. I was a little hesitant, though, since they were quite big, hinting some heavy duty on the line. But measuring several times and checking the wires revealed that the signal was as harmless as described in the manual and not lethal at all, neither to human beings nor to the MCU.
(more details on the circuit and power supply will be in the second part of this story)
After fiddling around a little (took a while to figure out that the 7bit chars only show correctly when marrying the incoming chars to 0x7F) and adding a heart-beat LED, I was confident enough that I had the thing going. The main task by the way was to turn on / off the water heater depending on low / high cost time. This was accomplished by re-using the relay that was in the old control unit that went u/s a few weeks before. The system was supposed to replace my manual input (switching on / off the power) during the winter holidays.
Unfortunately, after testing it for one night, I found the MCU to be hung. Following the main stream of what I found on the web, I was using the SoftwareSerial Library and as it seemed, the library was somewhat unstable and caused the program to hang after a while. I didn’t have time to debug the Library, as I was supposed to catch a flight only a few hours later, so I switched over to the hardware serial pins (which I wanted to keep for debugging first) and added a LCD screen on which I could toggle through the received values instead of reading them via serial connection (since the installation would only need the RX pin to connect to the counter, I still could use the TX… uhm… no. LCD it is).
The software can be found in my github repository.
Pre-Final Thoughts (since this is going to be continued in a second part)
When I was looking around for some ideas on the EDF Téléinfo, I found quite a few very active and well documented French projects on the web. I was always wondering why there is so much IT stuff on the web in English, German, Chinese or Russian and rarely any French projects. It is definitely not that they wouldn’t be interested in hacking or lacking the skills. It’s rather that they are using a total different vocabulary than the rest of the world. E.g. they call a computer “ordinateur” and a byte is an “octet” (which kinda makes sense but also looks weired on the boxes, where a thumbdrive is said to have 32Go instead of GB) and a mouse is a “souris” for them.
What I want to say: I have the impression, that the hacking community of a whole nation is being seperated from the rest of the world due to the usage of a different vocabulary, making a lot of brilliant minds and projects invisible. And that’s quite a pitty.