One maker is taking a love of LEGO to a whole new level with Raspberry Pi. Take a tour of this incredible internet-connected cityscape being built brick by brick
We love LEGO and the internet, so what could be finer than this ‘Internet of LEGO’ project? Well, discovering the Raspberry Pi serving as its brain, and catching up with its maker to learn all about this amazing connected city.
“The Internet of LEGO is a living project where I set out to learn everything about the Internet of Things,” says Cory Guynn. Packed with sensors, the city reports to a Raspberry Pi that acts as its brain. Cory has used this to create the Internet of LEGO blog.
The full article can be found in The MagPi 48 and was written by Lucy Hattersley
“I grew up playing with LEGO bricks and model trains, which taught me about construction and electronics, and allowed me to be creative. The use of LEGO also allows me to represent a city or build prototype systems easily. Plus, it gives me an excuse to buy a bunch of LEGO bricks in my thirties,” laughs Cory.
“A Raspberry Pi Model B+ is the heart of my city,” he reveals, “and that was the starting point of the project.” The Raspberry Pi is attached to Arduino boards that control most of the GPIO operations. Cory also uses Cactus Micro Rev2, BlueDuino, WeMos and NodeMCU boards, along with a Wio Link and BeagleBone Green.
The city itself is complex, with many structures and buildings hooked up to a huge range of sensors: RFID, ultrasonic proximity, infrared, and magnetic reed switches are used to keep track of the city environment.
The train system is Cory’s favourite part of the city. “I love seeing things in motion,” he reveals. “There are several things that I’ve been able to do that make for a dynamic environment.” Cory has built a train scheduling system using the Transport for London API. This system displays the schedule on an OLED screen and switches to the train track to match the destination.
The trains are controlled by WiFi and an infrared transmitter attached to a tower. Infrared sensors are used to detect incoming trains and trigger a crossing signal (with a servo controlling the arm, and LEDs for lights).
“Everything is connected to an Arduino Mega, which is then USB‑tethered to the Raspberry Pi,” explains Cory.
He has developed a huge amount of software to control all the structures in the Internet of LEGO. “The Johnny-five.io robotics framework made programming sensors and servos easy. I wrote a few projects, including a train crossing, train track switch, elevator, motion detector, and city lights.”
Most of the orchestration of the city and its many sensors is handled by Node-RED. “This system allows me to add inputs and outputs from any of my projects that can interact with one another,” says Cory. “For example, when somebody visits my blog, a REST call to Node-RED triggers an MQTT message to my disco lights, which turns on strobing LEDs in a LEGO club and also triggers the Palace Cinema marquee lights for five seconds.”
Cory tells us he is indebted to the open-source community, which has allowed him to learn so much about programming and hardware. “I hope to give back to the community through my projects and experience along the way.”
Internet of LEGO is one of the amazing projects you can vote for in our top 20 projects poll – we want your input for our 50th issue spectacular!