Linky

From Eric

Jump to: navigation, search

The documentation about the Linky TIC protocol can be found in the ENEDIS CPT manual.

The hardware

The TIC interface is composed of three lines (A, L1,L2).

The signals are at 50KHz.

The (A,L1) lines can be used to power a device. The voltage is 6Vrms (max 13V) with a maximum power of 130mW (!!).

I use (A,L1) to power the CubeCell that implements the TIC-to-LoRa gateway.

The setup (that can be found at many places over the Internet) simply uses a full bridge rectifier (using Schottky diodes) and a 7905 regulator. The 5V voltage is then used to charge a small LiPo battery which is finally used to power the CubeCell (the CubeCell has a battery interface). I use a solar charger to charge the battery:

Battery charger.jpg

I could have used a supercapacitor, but I only have a LiPo battery on hand at that time...

The TIC data are transmitted on (L1,L2) using a 1200bds serial protocol. Details about the frame format can be found in the Enedis documentation (see above).

Inorder to be used by the CubeCell, the (L1,L2) signal at 50Khz must be filtered and converted into a 3.3V signal.

This is done using a LTV814 optocoupler. The bandwidth of the optocoupler is sufficiently low to filter the 50Kz signal.


Here are pictures of the output of the optocoupler when the input is driven by a 10KHz signal and a 50Khz signal:

Linky opto10Khz.jpg
Linky opto50Khz.jpg

At 50Khz, there are no more ripples on the output.

The schematics of the interface is given below (copied from here).


Linky tic interface schema.jpg


The software

The software is very simple. Note that MiroQuettas has developed a library to capture the TIC frames, but I have found it a bit complicated (regarding the task to be done). See this thread. It is certainly optimized in space and time, but as I had no issue neither with memory space nor with throughput, I have simply written my own, straightforward, version.

The code can be found on github. It is pretty dirty... and it also contains a few lines of code to capture and send meteo data.

The TIC frames are captured (the frame that I am interested in...), and sent via LoRa as a JSON message. This message is received by my LoRa to MQTT gateway.

Note that to comply with the JSON format, integer values cannot start with a "0", so I remove them from the message...

The Lora to MQTT gateway simply publishes the JSON message which is then handled by HomeAssistant.

Here is an example of JSON frame published

 {
   "HCHC": 6225400,
   "HCHP": 8545655,
   "PTEC": 1,
   "IINST1": 1,
   "IINST2": 0,
   "IINST3": 1
 }


A few lines have to be added to the configuration.yaml file, "sensor" section, in order to receive the data:

 - platform: mqtt
   name: "Linky HC"
   state_topic: "linky"
   unique_id: 'linky_hc'
   value_template: 'Template:Value json.HCHC'
   unit_of_measurement: 'Wh'
   
 - platform: mqtt
   name: "Linky HP"
   state_topic: "linky"
   unique_id: 'linky_hp'
   value_template: 'Template:Value json.HCHP'
   unit_of_measurement: 'Wh'
   
 - platform: mqtt
   name: "Linky PTEC"
   state_topic: "linky"
   unique_id: 'linky_ptec'
   value_template: 'Template:Value json.PTEC'
   unit_of_measurement: '0/1' 
   
 - platform: mqtt
   name: "Linky IINST1"
   state_topic: "linky"
   unique_id: 'linky_iinst1'
   value_template: 'Template:Value json.IINST1'
   unit_of_measurement: 'A'
 
 - platform: mqtt
   name: "Linky IINST2"
   state_topic: "linky"
   unique_id: 'linky_iinst2'
   value_template: 'Template:Value json.IINST2'
   unit_of_measurement: 'A'
   
 - platform: mqtt
   name: "Linky IINST3"
   state_topic: "linky"
   unique_id: 'linky_iinst3'    
   value_template: 'Template:Value json.IINST3'
   unit_of_measurement: 'A'


In order to preserve the battery, and considering the very low power provided by the TIC interface (see above), I put the CubeCell in deep sleep between two messages, and I only capture the TIC data every 20s.

Personal tools