With the Internet of Things it is possible to create all kinds of cool projects. Many projects are based on the Raspberry Pi. I always wanted to do a project that’s interesting for both adults and children. So I combined the best of both worlds and added a Raspberry Pi to a Lego train. Thus the Internet of (Lego) trains was born!
The first step was to get a Raspberry Pi working with a WIFI usb dongle, Raspberry Pi camera and infrared transmitter. That setup enabled me to control the Raspberry on the train through Wifi. The Raspberry Pi than sends the infrared command to the Lego train infrared receiver. All of this is powered by a USB battery pack.
This setup offers quite some advantages:
– Live camera feed from the train
– Less dependent on infrared signal. The normal Lego remote is hard to operate at a distance or when there are objects blocking the signal
– If you already have a Lego train and a Raspberry than it’s quite cheap to create this setup
– There are countless extra options such as automating track switches, adding RFID to figure out where the train is located, collision detection etcetera
– You can play with cool stuff (together with your children)
– It can help children to get more involved in electronics and programming
– You get time to play with Lego again! 🙂
Some pictures of the first setup:
For the first POC I created a simple web application to send the different commands to the Lego train. The application also shows the feed from the Raspberry Pi cam on top of the train.
The web application can not only show the live webcam feed but it can also record videos. An example video can be seen here First video low quality. Due to resource limitations I had to convert the original video to a lower quality video.
This was the first step towards the Internet of Trains. I already have quite a wishlist of things to do next such as:
– Using RFID for instance to slowdown or even stop at certain points such as the trainstation
– Figure out a way to have collision detection
– Automating switches
– Using Docker on the Raspberry’s
– Adding multiple trains with the smaller Raspberry Pi A+
– Live cam feed of the complete track
– Figure out a way to hide (parts of) the electronics
– Create a better application (probably a combination of Java and Angular) to control the trains and to create auto-pilot functionality
If you have any cool ideas or tips, please let me know!