mailto: blog -at- heyrick -dot- eu

Storm Goretti

As I said in my previous post, the wind was really picking up around 6pm onwards as I was writing the content. It sounded pretty bad at 10pm which is when it hit the lowest air pressure (997.3mb, so not that low). I went to bed and, well, I expected to hear it whooshing around the chimney. But, as far as I was concerned it had more or less blown itself out by about midnight.

My friends in the village said midnight was when it started to get really bad, it was as if they could feel the house shaking from the wind. I can only guess that the wind changed direction to a way that didn't affect me that much.
Indeed, the real casualty here is my poor stressed letterbox microcontroller that recorded several dozen "open and close" events as the wind flipped the front flap open enough to activate the switch and be seen as something happening. ☺

Closed : 2026/01/08, 19:14:33
Open   : 2026/01/08, 19:14:32
Closed : 2026/01/08, 18:54:20
Open   : 2026/01/08, 18:54:19

 

And... not at work?

I went to work on Friday, and a number of people were surprised to see me.

I had told the girl in pick'n'pack that if her team wanted me to wash their coats, I could only do one and I had to have it by ten past one at the latest. This is because this week we worked shorter days, so I didn't have enough time to put two of them through the wash and dryer.

When I was doing my round, I noticed that a coat had been put there on Thursday. After a facepalm, I passed it through on the 25 minute rapid cycle, and tant pis, as I had to have it washed and dried for 3pm when I finished.

Well, it turns out that not only was the message mangled to the point where they put their coat to be washed on the wrong day, it was mangled to the point where lots of people thought I wasn't going to turn up on Friday.

Gee, if I'd known that, I'd have stayed in bed. 😂

 

Speaking of days not at work, my boss' underling caught up with me just as I was about to leave yesterday and asked me to sign a piece of paper. An authorisation to deduct the snow day from my hours in hand. I'm not sure how that works as I wasn't aware that I had any, but whatever, it is going to be counted as a justified absence. I had expected to not be paid, but I know this is likely happening because there's a contingent that would be all screamy-shouty about not being paid for a day when they weren't there. After seventeen years, I have lost all desire to even think about arguing that sort of logic. So I signed the paper.
Oh, and I just got a notification from the CPAM that I'm going to be paid something like €66 for the final day of when I was signed off work, so the three days unpaid is consecutive, not work days. I think that's something like 80%? I dunno, I am off work so rarely I didn't bother to read who pays what and how much. Again, I was expecting zero so...

 

On a slightly sadder note, one of the managers has now gone for her long awaited and deserved retirement. This is somebody that I really liked, and was one of the people who helped me with my barely-existent French when I started back in 2008. She also used to think and give me good answers when I asked questions about Frenchness or peculiarities of the French language (of which there are many), as well as explaining stuff happening at work because, well, because us plonge people often get forgotten so it's like we're the last to know anything. I'm going to miss her.

 

Linky TIC

I ordered an optocoupler from Amazon. It was something like €0,61 with €2,60 postage, and took a week to get here from Mulhouse.

The schematic for how to use this is very simple.

Linky TIC optocoupler schematic.
Linky TIC optocoupler schematic.

The TIC data interface (marked as I1 and I2 on the meter) outputs serial data overlaid onto a 50kHz carrier. This should be passed through an optoisolator in order to not have anything much connected to the port (in order to protect the Linky). It is also capable of providing power (between I1 and A), but it's something odd like 8~12VAC at 50kHz with a maximum capacity of about 130mA, so I won't pay much attention to that.

On the far side of the optoisolator, the output from the transistor is sent to the serial input line. It is pulled up by way of a 4K7 resistor, with the transistor pulling to ground when activated.

It was a doddle to build it on a piece of breadboard.

The interface built on breadboard.
The interface built on breadboard.

And here it is in use.

The interface in use.
The interface in use.

Important notes:

  • My optocoupler has an integrated diode. If the one you choose does not, you'll need to add one. A generic diode, such as a 1N4004, will do - but it may be simpler to just get an SFH620A device?
  • There are all sorts of different resistor values in similar schematics that you may find online. These are the values that worked for me. Notably the input resistor being 1K (as is often shown) led to garbled data. I dropped it to 560 and the data looked good.
  • The data is amplitude modulated and inverted, that is to say "presence of carrier" means a 0 bit, absence means a 1 bit. This works for us as our optocoupler pulls the serial line to ground in the presence of a signal being input, and it floats high in the absence of a signal.
  • For a three-phase Linky, the TIC port on on the upper right, once you have removed the top cover. For a single-phase Linky, it's on the bottom right.
    This should be easily removable by turning the locking pin with a screwdriver and then pulling it gently. If it has a cable tie through it (like the EDF-sealed parts), do not remove the tie. Contact EDF to ask why it has been sealed first.

The Linky can work in two different modes. Historical (default) mode outputs some data repeatedly, every two seconds, at 1200 baud, with the protocol 7E1.
Standard mode outputs more detailed information at 9600 baud, 7E1.
The default mode is Historical. To find out which version your meter uses, press the + key to wake up the display, and then press it about sixteen more times until it reads "MODE TIC". It'll probably say "HISTORIQUE" on the top line, this means it is using historic mode at 1200 baud.
If you want to switch to standard mode, you need to make an application to EDF saying why you want to change to standard mode. This is a link I found online, but I've not tested it as it wants you to log in first.

More important notes:

  • The information provided may be different from that showing on the meter itself. The information provided is purely for information purposes and has no contractual value. Only that which is recorded and displayed by the meter itself counts.
  • If your supplier is not EDF, the available information and options may differ.

 

The information, which is all straight 7 bit ASCII, is sent as a series of frames in the following format:

STX (&02)[lines, see below]ETX (&03)

Each line has the following format:

LF (&0A)<label>SP (&20)<data>SP (&20)ChecksumCR (&0D)

Standard mode differs in that it uses tabs (&09) as a separator (so can support spaces in the data), and may have a timestamp in between the label and the data.

The fields with a green background are used in the calculation of the checksum. All of the characters present are added together. The result is ANDed with &3F to make a six bit vlaue. This then has &20 added to it in order to make the result be a printable character.

Let's take an example. A line is "ISOUSC 15 <". So...
I is 73, S is 83, then 79, 85, 83, 67, 32, 49, and finally 53.
This adds up to 604. The result is 28.
Adding 32 makes 60. And the ASCII character 60 is a left angle bracket, which is exactly what is shown.

Here is a dump of a frame received from my Linky. Each line begins with an LF and ends with a CR. These have been omitted for clarity.

<STX>
ADCO 012345678901 1
OPTARIF BASE 0
ISOUSC 15 <
BASE 012392108 %
PTEC TH.. $
IINST1 010 I
IINST2 011 K
IINST3 000 J
IMAX1 060 6
IMAX2 060 7
IMAX3 060 8
PMAX 03472 6
PAPP 04980 6
HHPHC A ,
MOTDETAT 000000 B
PPOT 00 #
<ETX>

"ADCO" is the meter identity.
"OPTARIF" is what tariff I have subscribed to. I have the standard basic tariff.
"ISOUSC" is the "subscribed intensity". My amount is 9kW three phase, so why does it say 15? Well, because it isn't as easy as that. Oh, no, of course it isn't. 15 × 200 × 3 is 9,000 which is the 9kW. 200 for... I have no idea, and 3 for three phase. If I had a single-phase meter, I think that would say 45 instead.
"BASE" is the base meter reading in watt hours. Drop the last three digits for what the meter shows.
You may see lines beginning "HC", "EJ", or "BB" if you have multiple tariffs, such as Heures Creuses (night rate).
"PTEC" is the tariff in course. It always says "TH.." for me as I don't have differing tariffs.
"IINST1" to "IINST3" is the instantaneous current on each phase. Multiply by 230 to get an idea of the watts being drawn on each phase. As you can see, I'm drawing ~2,300W on phase 1 (my car) and ~2,530W on phase 2 (my kettle). This adds up to 4830 and the meter shows 4961 so it's close enough - likely the meter can record, but doesn't transmit, if it's like 11½A, which is more like what the kettle is likely to be drawing.
"IMAX1" to "IMAX3" is the maximum permitted current. That's nearly 14kW per phase. That's more than my subscribed allocation (9kW) and it's more than the wiring could cope with, so I'll just ignore this. "PMAX" is the maximum draw (in VA) yesterday.
"PAPP" is the apparent draw (in VA), rounded to the nearest 10. The meter will have said something akin to 4984, say, and this was sent as 4980. Not that I said 4961 above. This is because the current draw is not always exactly steady. It can bounce around slightly. I think this is one of the reasons why bills went up slightly with the introduction of smart meters. Power draw is not constant. I have an electric blanket on my lap, for instance, and it is running at about half power so is switching the heater on and off rapidly to run it "for half the time". With spinning disc meters, these sorts of changes would be damped out because of the inertia of the disc, while a smart meter can track it more accurately.
"HHPHC" is for whether you're at full or night tariff. I'm neither, so it says 'A'.
"MOTDETAT" is the meter state. I think it's an error code, so should say all zeroes unless there's a problem.
"PPOT" means presence of potentials. The first digit is always '0'. The second can be a bitmap of which phases are missing (phase n missing = bit n set).
For painfully obvious reasons, this will not report when all three phases are missing.

Standard mode adds a lot of additional data such as time, date, voltage (per phase), etc etc. It won't be considered here, you can read the datasheet if you like (in French).

 

If your data looks like this and you are sure that you are running at 1200 baud 7E1...

ZTETT  
mTP #
`^BtO #1993^F1 
XTRIF E 
Ig5C 1 
E 12^VX^V^V 
^ETeC T^Z^Y 
IIT1  
IIT3  I
And it keeps repeating like it's so close to being correct, try changing the resistor between the Linky and the optocoupler. The gibberish shown here is what I got with a 1K resistor. Dropping to 560 ohm fixed this.

 

Out of the available information, the important things are going to be "BASE" for tracking consumption, "PAPP" for the overall meter reading, and "IINSTx" for breaking that down per phase. The rest can be ignored.

As it is a pretty simple circuit, I ought to be able to add it to my letterbox ESP32 and have that also read the meter data from the serial port. There isn't really enough memory on-board to create bitmaps, but it shouldn't be hard to maintain a buffer of values that can be fetched like JSON format or something and have some JavaScript running on the browser to turn them into a chart. This will shift complexity to the browser rather than expecting a microcontroller to cope with it.

It will remain to be seen if/how the data is best read. I don't need 2s accuracy. Maybe every 20s to have three points per minute? If I only track the main reading and not the per-phase, that will be eight bytes per data point (four bytes for the reading, and four for some sort of timestamp). A 32,768 byte buffer would hold 4,096 readings, or 1,365 minutes if I take three points per minute, which is 22¾ hours. If I was going to do this, I'd make the buffer slightly larger to hold twenty four hours, as twenty two and three quarters is just annoying.
This, of course, depends upon how much memory actually exists, if I am even able to malloc() a buffer of that size. I don't recall how the letterbox firmware is built.
As for the per-phase and kWh readings, I think it would suffice to just read and remember the most recent.
But if I ever did want to track by phase, using a word per value would be too much. I could reduce the overall consumption to a fourteen bit value, as it won't be over 16,383 when my meter cuts off at 9,000. Then each phase could be held in five bits as it is measured in amps and won't pass 31A. This would require 29 bits so will fit without problem into a 32 bit word. Building and extracting would be a simple matter of shifting and masking. Hmmm, that might be a way to hold all of the information without consuming too much memory.

Still, this is all a discussion for the future. I have read information from the meter into my phone. At some point I'll need to get around to writing some code to write to the ESP32 to support this. But that's not today.

 

Bloody bots

I have a program running on my older Pi2 that takes periodic recordings of the current weather and makes a webpage that I can read to know it's 4.1°C outside so I'd better close the shutters...

Only, it was failing. And failing quite frequently.

It turns out that WebJames, the server, can hold the index.html file open across polls when serving it. This means if my program tries to open it, it'll fail with an error about the file being open when trying to OPENOUT (write access, create new) it.
This was possible but not so likely when it was just me and a search engine or two accessing it, as it would have to be serving the page at the exact same time as it was to be updated.

Now, in common with the rest of the internet, it is being hammered by bots. I can't give you any stats as I turned off all logging ages ago in order not to burn through my SD card writing all of that rubbish. But I can see the network lights flickering often, which ought to give me an idea of what's going on.

Oh, and my BBS server on the telnet port is getting hit frequently. I have blocked places like Russia, China, and Pakistan - connections that appear to be from IP blocks associated with those countries get instantly hard dropped. Wanna know which country is hitting my server now? The two-letter code that turns up the most now is "US". Need I say more?

Anyway, the chance of a clash-leading-to-crash is much greater, to the point of happening several times per day, rather than a couple of times a week. This is a new development (and WebJames doesn't IP block or log so I don't know who to blame for this) which has annoyed me to the point of doing something about it.

Here's what I did.

Some BASIC code.
Writing some better code, via ShareFS.

The simple approach would have been to include a LOCAL ERROR handler to give up if the file was open, something I probably should have coded in a decade ago when I first wrote that crap. But, alas, I wanted it to try just a little bit harder.

So what it does is use the underlying SWI to open the file so that I can spot if the V flag was set (bit 1 of the returned flags), and if so then wait for a second before trying again. This will repeat six times and if the file still cannot be opened it'll safely (not crashily) give up at that point.

It's been going all afternoon, so either it works or the bots have left me alone. I know which option I think is the most likely.

 

 

Your comments:

Please note that while I check this page every so often, I am not able to control what users write; therefore I disclaim all liability for unpleasant and/or infringing and/or defamatory material. Undesired content will be removed as soon as it is noticed. By leaving a comment, you agree not to post material that is illegal or in bad taste, and you should be aware that the time and your IP address are both recorded, should it be necessary to find out who you are. Oh, and don't bother trying to inline HTML. I'm not that stupid! ☺
As of February 2025, commenting is no longer available to UK residents, following the implementation of the vague and overly broad Online Safety Act. You must tick the box below to verify that you are not a UK resident, and you expressly agree if you are in fact a UK resident that you will indemnify me (Richard Murray), as well as the person maintaining my site (Rob O'Donnell), the hosting providers, and so on. It's a shitty law, complain to your MP.
It's not that I don't want to hear from my British friends, it's because your country makes stupid laws.

 
You can now follow comment additions with the comment RSS feed. This is distinct from the b.log RSS feed, so you can subscribe to one or both as you wish.

No comments yet...

Add a comment (v0.12) [help?] . . . try the comment feed!
Your name
Your email (optional)
Validation Are you real? Please type 99240 backwards.
UK resident
Your comment
French flagSpanish flagJapanese flag
Calendar
«   January 2026   »
MonTueWedThuFriSatSun
   23
79
13141517
19202223
282930 

(Felicity? Marte? Find out!)

Last 5 entries

List all b.log entries

Return to the site index

Geekery
 
Alphabetical:

Search

Search Rick's b.log!

PS: Don't try to be clever.
It's a simple substring match.

Etc...

Last read at 22:05 on 2026/02/09.

QR code


Valid HTML 4.01 Transitional
Valid CSS
Valid RSS 2.0

 

© 2026 Rick Murray
This web page is licenced for your personal, private, non-commercial use only. No automated processing by advertising systems is permitted.
RIPA notice: No consent is given for interception of page transmission.

 

Have you noticed the watermarks on pictures?
Next entry - 2026/01/11
Return to top of page