The project was started thanks to the previous work of AJB2K3 with his Control the Lego Interface B with Python project. His python program made it possible to communicate with a LEGO interface B via python.
It inspired me to try my luck with my interface B's, as I previously had no luck setting one up with the original software on era appropriate hardware and OS's.
Let's get started!I started the project by getting the required hardware, doing research in the interface B and python (as I don't have a lot of experience coding). After modifying the code (so python can see the serial port on my linux PC) I started collecting data... Bingo!
All of this was Chinese to me, I didnt understand any of it. After mounting various pushbuttons, temperature sensors and other stuff to the inputs I completely got lost. The data completely changes with the smallest change!
So I started collecting various inputs in a text file, first one without any sensors, then with 1 button on 1 input...etc... After collecting a handful of samples I manually removed the "\x" characters I ended up with this list:
This helped a lot but some things were still unclear to me. I had to do more research. this is where the article of lgauge.com on the interface B became extremely important. This article explained in great detail how the communication of the interface B worked. thanks to this information I better understood the protocol and could rectify some mistakes:
I cannot understate enough how important the article on Lgauge.com is!
My findings agree with the results of lgauge.com. the only difference is a typo in there's table.
update (4-aug-2025):just recently i have found out that when the stop button is pressed the first "00" is turned into a "10", this could mean that the first 2 zero bytes are probably feedback of the current state of the interface B.
interB, no sensors: b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xb7'
interB, no sensors, stop button pressed: b'\x10\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xa7'
notice the change in the first byte and the last (checksum) byte.
Summing up how the interface B sends data:So, the interface B sends 19 bits of data at roughly 50-60Hz to the computer. This data can be separated into 10 parts: 1 part of only zeros, 8 parts of input data (1 per port) and finally 1 checksum byte.
The data always start with the zeros, at least the first of the 2 pairs of zeros tell the computer if the interface B is in stop or not. It is currently not known what the second pair of zeros mean (if anything at all).
The following 8 pairs of bytes are all port data, as you can see in the table above the ports are in alternating order, counting backwards.
and finally in the end there is 1 checksum byte. if you count all of the 19 bytes you should become "FF" or 11111111. this can be used to verify if the data you received is corrupt or not.
Conclusion and what is next:So far everything went reasonably smoothly. I was able to modify and code my own program in python (thanks to AJB2K3 and the countless examples on the internet),
Currently I am working on a "decrypter" a program that orders all the data per port and allows the port data to be changed between ASCII and binary, as different sensors have different means of working.
Comments