The Mystery of Lego 7897 and 7898 IR
Recently I got myself two Lego Trains on Kleinanzeigen, similar to Craigslist.
- 7897 Passenger Train
- 7898 Cargo Train Deluxe (Whatever a deluxe train is...)
How it Started
As I did it for PowerFunctions I wanted to get these trains up and running with an Arduino to make it work with Track38. I grabbed a Vishay TSAL 6200 IR-Emitter 940 nm and tried this codebase. Nothing. Did not work.
Wait What! Why different parts? Different Firmware?
Then I started to do more research and found mattzobricks PowerFunctions. He writes that he has discovered two different versions of the IR Train Battery Receiver combination, which also have different firmware. He states that they cannot be visually distinguished without taking them apart. And the proposed modification will only work on newer ones. It turned out, my 7898 works with this method. But controlling channels independent does not work. All or none Then I discovered that my 7897 and my 7898 have different train bases:
Different Versions of 55455, see right cutouts
Lego even changed the Instructions (probably within their redesign of the set: New Motor version, Completely in plastic enclosed magnets, and a new 55455?). I assume that the non-symmetric version is the v1 because the set uses the old magnetic couplers they used before they had to comply with new dont eat magnets regulations. All just guesses.
Old Variant (v1)
New Variant (v2, Screenshot from Lego downloaded Instruction)
Bricklink 55455c01 Listing (2025-05-24)
Bricklink does only list the differences in the respective subpart. Its also only a note and not a different mold as seen within other bricks, which get their own listings if molds differ.
Bricklink 55455 Subpart (without battery carrier and cover) Listing (2025-05-24)
Then I got curios and wanted to know if I can see the differences on the PCBs as mattzobricks stated:
PCB v1
PCB v2
Remote different switch colors
For the sage of completeness here are the remotes. Nothing interesting here. Both work for both trains. I only opened them because they had different switch colors. There were no different PCB layouts, so I took a picture and closed them.
I assume the older one
I assume the newer one
Back to IR
Initially I just hoped that the trains will just work with the provided code. But sadly this is not the case. So I continued with my investigation by pulling out some Vishay TSOP4838 38 kHz Infrared Receiver I ordered for $2 on aliexpress some months ago. They are not ideal, Lego uses 76kHz and they are 38kHz, but JorgePe had success with a 56kHz receiver.
So I headed to his great blog article and plugged everything together. Recording a button up press with the remote and played it back. Yay works!! But only one power level... There is still work to do.
#include <IRLibSendBase.h>
#include <IRLib_HashRaw.h>
IRsendRaw mySender;
void setup() {
Serial.begin(9600);
delay(2000); while (!Serial)
Serial.println(F("Every time you press a key is a serial monitor we will send."));
}
#define RAW_DATA_LEN 36
uint16_t rawData[RAW_DATA_LEN]={
318, 1850, 266, 858, 230, 298, 262, 838,
234, 858, 238, 302, 266, 258, 262, 302,
238, 306, 266, 254, 262, 306, 218, 322,
234, 858, 234, 298, 238, 298, 238, 862,
238, 814, 238, 1000};
void loop() {
if (Serial.read() != -1) {
mySender.send(rawData,RAW_DATA_LEN,36);
Serial.println(F("Sent signal."));
}
}
Another finding I made was that I had to press stop twice to stop the train I started. This hints at the signal toggle JorgePe mentioned. Also the signal is longer than his recordings Array 12-16 vs 36. Fun Fact: Pressing the hooter button also emits a signal.
Did I say Lego uses 76kHz? I did not notice that I did not change mySender.send(rawData,RAW_DATA_LEN,36)
to use 76kHz, so I guess, trains use 38kHz.
JorgePe states:
USB version of the IR Tower can “speak” at 38 and 76 kHz I dont know where this information is coming from, but it validated my 38kHz theory So I have the right tools here, lets figure it out. JorgePe used IrScrutinizer with his Raspberry Pi. But I wanted to avoid the hustle of going through setting up Lirc and install a GUI on a Pi 4. I got luck: The developer provides Arduino firmware for a GIRS (General InfraRed Server Command Language) server. There is a Tutorial on how to wire everything but I decided to only use what I have and hooked up the IR led with a 220 Ohm resistor to Pin 3 of my Uno and the Receiver to Pin 8. Flashing was just running a bash script with the firmware hardcoded in there.
Connect to flashed Arduino Uno
Sniff first IR Signal
IrScrutinizer also says 38kHz signal.
To summarize:
- Signal Toggle
- 38kHz
- Like PowerFunctions 7 forward and backward PWM Channels
In lego_9v_ir.py I started to analyze timings. But decided to go with the hardcoded recording route, because its just faster. If you are interested, feel free to continue...
Whats left? Plug everything together and create a lib other people can use: https://github.com/fidoriel/Lego9vRC There is a platformIO package https://registry.platformio.org/libraries/fidoriel/Lego9vRC I hardcoded all commands, but used modified lengths for the timings, which worked best in my experience. All commands are sent twice with some time in between. Toggle is kept for every train.
Together with solutions for PoweredUp, PowerFunction and finally 9v RC, many to rule them all I guess ;) Happy train dispatching!