EDF Téléinfo – Heating water only when it’s cheap (Part 2)

This is the second part of my little home automation project. In the first part I was laying out the basic idea and first trials. This part is covering the test setup with an arduino and has a few words on the data structure sent by the electric counter and the software used to interpret it.

The drawing of the breadboard and the schematics below were both done with Fritzing. It’s my first time to use the tool and I think I have to practice a bit more. The autorouting did not work that well, so I had to redraw all the connections manually. Also the wiring on the breadboard could be a bit nicer… There was no I2C LCD hardware interface in the libraries, so I just drew two wires from the SDA and SCL ports to the display. Anyhow, here it is:


EDF Téléinfo circuit on the breadboard

For the optocoupler it doesn’t matter which wire goes to which connector of the counter, either way works. The signal is being rectified by the white LED. The output of the photoresistor is analog and does not comply with the zeros and ones that are required by serial communication. That’s where the PNP transistor comes in. The photoresistor triggers the transistor, which then drains the RX pin of its high signal resulting in the bitstream we are interested in.

The data groups can be displayed on the LCD screen and scrolled through via the toggle button.

Depending on the high / low cost period, pin 8 toggles the signal for the NPN transistor, which then enables / disables the relay. I chose a fail safe setup, where the water heater would be connected to the NC part of the relay. This means a high signal on pin 8 actually turns the heater off. That way the heater would still be working even when the circuit gets disconnected. The relay itself is fed by an external 12VDC power supply. Please note that the GND of that supply needs to be connected to the GND of the circuit for the current to flow!

A word of WARNING: Whatever you want to control with the circuit (e.g. a relay with a water heater connected), it will most probably run on a much higher current than the 5VDC the Arduino is using. If you are not familiar with or feel uncomfortable working with high voltage, don’t do it on your own. Ask a professional electrician / experienced person to support you and above all: Make sure the power is turned off (CBs out, lines tested with a current tester) before you start connecting anything. There is the definite potential of severe injury or death if anything goes wrong, not only for yourself, but also for your loved ones when you leave wires unsecured or currents running wild!


EDF Téléinfo circuit schematics


V2 of the installation, with Arduino and 16×2 LCD

Visualizing the signals on an oscilloscope looked like this:

Screen Capture

The raw signal on the connectors of the EDF counter

Screen Capture

The signal at the RX Pin of the Arduino


The software can be found in my github repository.

The code is rather straight forward: After setting up the pins for input / output and putting them in an initial state, the LCD would show “OK.”. Then the main loop would wait for a new frame transmission to start. At each start of a frame, the status LED (pin 13 for the Arduino Uno) is being toggeled to have some kind of heart beat indication. Then the frame is being read. As per specification a frame would look like this:

<STX (0x02)>

<LF (0x0a)>

<Label (String with up to 8 characters)>
<SP (0x20) or HT (0x09)>
<Value (String with up to 12 characters)>
<SP (0x20) or HT (0x09)>
<Checksum (single character)>

<CR (0x0D)>

<ETX (0x03)>


Each frame (starting with STX and ending with ETX) contains multiple groups and each group consists of a label, a value and a checksum.

After reading a group, the status of the water heater is being checked and changed depending on the high / low cost period. Then the button is being checked and when pressed, the group to be displayed on the LCD gets toggled.

Finally, the LCD gets updated.

This is far from perfect. First of all, the checksum is not being used. Then the water heater status could only be checked when the specific group is being processed (in order to save some cycles). At the end, the LCD should only be updated if the toggle button has been pressed or the present value has changed. But this was only a proof of concept and used as the baseline for the python code that is now running on the Raspberry Pi.

Future Steps

The next step was to move the logic from the Arduino to a more sophisticated platform, connect it to the LAN and Internet, have it log the consumption and control the radiators and water heater. But this is another story to be told…


Posted in Home Automation, Projects | Tagged , , , , , | Leave a comment

EDF Téléinfo – Heating water only when it’s cheap (Part 1)

Basic Idea

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:

  1. An electric counter with a serial interface
  2. Electrical heating
  3. free.fr

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).

first shot.jpg

First Try with a minimalistic Atmega circuit

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.

diy opto coupler.jpg

DIY optocoupler with two LEDs and a photo transistor in a pen tube

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.

Posted in Home Automation, Projects | Tagged , , , , | 1 Comment

Harley Davidson Radio Muter (Part 2)

“Ordinal 459”

459When trying to take some screenshots of the tools I mentioned in my last post, I got a few “urlmon.dll ordinal 459s” error messages and empty windows instead of a running application. Apparently they are using the activex controls of MS IE. Since I prefer Firefox, I uninstalled the IE right after setting up my system. I also realized that the extended pane of the “services.msc” was not displaying anything, which seemed to refer to the same issue. I tried quite a few things I found on some forums when looking for a solution (like registering the urlmon.dll and a few others, no need to go into more details, though), but it did not help, so I kinda gave in and installed IE back again. That apparently was not enough and I had to upgrade to version 11, but then all was good.

Long story short, I should’ve gone for Avrdude for uploading the binaries in the first place, but I found the point and click tools much handier as a start and they came with a nice fuse calculator. Frustrated about the above error and how it made me re-install IE, I rembered that there was a command line tool for uploading the binaries to the MCU. Then I checked out the AVR tutorial by Lady Ada (gotta love her for the tools and tutorials she and her team come up with!) and decided (once more) not to re-invent the wheel and just refer to it. She has everything you need in there, starting from setting up the environment on different OSes, how to use the programmer and applications and she even got a few lines on the fuses. A one stop shop for newbies and those who want to refresh their memory.

I have to say that I did not try the box myself, but my friend told me it was working fine. Only his customer decided to go for the much more expensive OEM solution in the end. For me it was worth trying and I still have the board, which I am going to use on my brand new Android car radio or rather the CanBus Decoder BOX, which is mediating between the radio and the car and definitely has some space for improvement (e.g. keeping the radio on when starting the engine). But this will be the topic of another post…

Posted in Projects | Tagged , , , | Leave a comment

Harley Davidson Radio Muter (Part 1)

Basic Idea

A friend of mine, who is doing customizations for motorcycles, asked me if I would be able to do some CAN Bus programming. He was looking for a device that could mute the radio on a Harley Davidson when the intercom is being used. The activation of the intercom would be indicated via a pin high / pin low signal.

As it so happened, I started digging into CAN Bus with one of those ELM327 dongles and my Android phone just a few weeks before he asked me (this will be the topic of another post, promised). So I was quite excited to do something useful with the knowledge I just recently gained, getting to solve a real world problem challenge ;o)


Olimex Header Board with circuit board below

Olimex AVR-H128-CAN header board with circuit board below

I decided to go for the AVR-H128-CAN header board by Olimex, which is not too expensive and comes in a nice format (even though it is missing some holes to install the board with spacers instead of having it “floating” around). The board is based on the Atmel AT90CAN128 and one of the things I like the most about Atmel is that they are not only providing the hardware but also tons of documentation and even a software library to start with. (I might as well have gone with any other MCU (German, translated), like the Atmega328P, which is being used in the Arduino Uno, but the AT90CAN128 (as the name is already suggesting) comes with a built-in CAN controller. With the Atmega328P you would need to add a CAN controller (e.g. Microchip MCP2515) to the circuit. All you have to add to it is a CAN transceiver (e.g. Microchip MCP 2551) and you are good to go.

radio muter

Schematic of the Radio Muter


I’m not going into detail about CAN bus communication, since there is already A LOT of documentation around. But this much shall be said: If you want to talk to a CAN bus, appart from the hardware you also need message IDs and message data. This was something Harald already got from Harley Davidson, so sniffing the CAN bus was not necessary anymore. The ID for the radio commands is 0x383 and the data for muting / unmuting the radio is just two bytes, either 0x08 0x1E or 0x08 0x1C.

The software can be found in my github repository.

MCU Programming

From there it was pretty straight forward… or was it? Well, since I chose a non-Arduino approach I also wanted to avoid the Arduino overhead that comes with the IDE and toolchain. With notepad++ as my favorite text source code editor I decided to use WinAVR to compile the source code.

The biggest challenge was to create a makefile, which is one of the many things Arduino is hiding from keeping transparent to you (there was a quite nice article about this on hackaday). The next challenge was uploading the binary to the board. Using the mySmartUsb light dongle and the on board ICSP was quite easy, but then you also have to deal with fuses. Setting them wrong could either damage the MCU or lock it up. But again, there is so much information around, I won’t waste your time elaborating about this.

myAVR is offering two tools to be used with the dongle: myAVR_ProgTool and myavr_support_box. (to be continued)

Posted in Projects | Tagged , , | 3 Comments

Cockpit Panel (Part 1)

After reconsidering carefully (or just following the example of oh so many wonderful blogs out there), I decided to move the page to the blog. This way I also get to tag it, which makes searching and categorizing much easier once I have created a few more entries. So here it goes:

Basic Idea

I had this half round table top from Ikea (they seem to have changed the size, though), which I used with three kitchen legs (also from Ikea) as a cheap monitor stand. The stand got replaced by a more fancy arm that I got from Konrad and so I wanted to put the table top to a new use. As a father, computer scientist and aviation enthusiast, the first thing I saw in it was a cockpit panel to play with for myself kids.


Sketchup Model of a basic cockpit model based on the half round table top

The panel I had in mind was supposed to have a standard T arrangement (air speed indicator, altimeter, attitude indicator, compass, turn/slip indicator and variometer,) along with a landing gear lever and a few switches for batteries, lights and such.

Attitude Indicator (AI)


Due to the (assumed) complexity of it, I started with the AI. It later turned out to be much easier to build than expected, but isn’t that the case with most challenges?

ArtHor 1

The first idea for the artificial horizon was to use a shpere

The first idea was to have a sphere rotate along the longitudinal and lateral axis to have the highest freedom of movement possible. But when reading through a few pages about the technical details and design of the instrument, I found that most of standard (non fighter jet) aircraft using a classic AI would have a limitation of +/- 27° pitch and +/- 60° bank and thus a sphere would be a little bit of an overkill. I also wanted to work with the material I had at hand and for driving the AI it was two Hitec hs-55 servo motors.

ArtHor 2

Second design, a toilet paper roll in a chips can

In the second attempt I started from the casing of the instrument. I had this old Altimeter lying around and derived the dimensions of my instruments from it. The frame should be a 83mm square, and the tube… Well, I found the perfect match for the tube in an old potatoe chips can, which has the exact same diameter as the tube the altimeter was installed in: 75mm. Based on that, I chose the frame rotating around the longitudinal axis to be limited to 74mm, giving 1mm of space. A cover ring around the outer rim to hide the edges also left enough space for another very simple solution: a toilet paper roll with each the diameter and length of 45mm to rotate around the lateral axis. To save some space, I decided to install the servo inside the roll, attaching it to one of the lids of it.

Another part I wanted to use for the instrument was an Arduino Pro Mini clone. With its small footprint and easy way to program (the Arduino IDE comes with a servo library), the hardware part of the AI was finished in half a day only.

Hooking up the servos is pretty straight forward, you can find plenty of exaples all over the web, so I won’t re-invent the wheel there. The example coming closest to my setup might be this.


The software can be found in my github repository.


Posted in Projects | Tagged , , | Leave a comment

First (half of a) Project Page online

Only four days later, I finally managed to create a project page for my simulator cockpit panel. While there is still space for improvement (for both, the panel and the page), I think it is mature enough to be kicked out into the open…

Simulator Cockpit Panel

Posted in Uncategorized | Leave a comment

Happy New Year

…and of course 2016 comes with new resolutions. One one them is to get hold of all the loose ends I created in the past few years, by starting to document the projects I have been working on. And where better to do it than in public space. Primarily to contribute to the open source community from which I have learned so much and second, to receive some thoughts and second opinions in order to improve things.

Have fun.

Posted in Uncategorized | Leave a comment