IoT loco demo

Written on December 2, 2022; 4 minutes to read
iot locomotive

Pablo is a middle-aged train driver, with a round face, brown like the dirt of the freight car eyes, and an evergreen smile. Pablo lives in Spiez, Switzerland.

When Pablo was in sixth grade, the train driver who worked for the local rail company organised the lecture for the kids.

The train driver walked into the class, dressed in his clean blue uniform. He sat at the teacher’s desk and told them how beautiful it is to drive a train. Pablo looked at him with fascination, the way that only a twelve-year-old can look at someone. The voice of the train driver sounded like a low mumble of diesel exhaust as he spoke of train tracks and engines.

An image formed in Pablo’s mind of a man standing at the controls of a huge black machine, its metal glinting in the sun. It seemed to him that if life were simply a matter of keeping such a machine running smoothly, it would be an excellent life!

In ten years Pablo graduated from the Railroad School of Engineering in Luzern.

Now Pablo drives trains everyday. In rain and sun, he loves trains! HWdriving in the rain

Problem

But there is one thing Pablo hates about his job.

So many kilometers, so many kilometers of peaceful, solitary driving are spoiled by reports.

Pablo’s boss, Mr. Schmetterlink, is a short man with jet-black hair streaked gray. His tiny body always alarmed Pablo with nervous energy. Mr. Schmetterlink demands to fill hundreds of reports.

Brake test reports, Engine reports, Safety reports. Reports, reports, and more reports for Pablo.

Mr. Schmetterlink calls Pablo each couple of hours to ask where the train is and how much precious fuel he is burning. Pablo wants to drive the train, not to fill excel tables with the test data or answer calls about temperature inside the engine manifold.

The Rail industry is still using paper processes. Even though all the data about the train’s performance is available in the onboard centralized management system.

How can we help Publo to move from Excel tables to the modern Internet of Things (IoT) solution?

What train operators want

My last job as an IoT engineer is to get engine and other important data out of the train (using MVB, CAN, Voith and other protocols) to the cloud in order to help people like Pablo and Mr. Schmetterlink.

There are three main things that fleet operators want to know:

  1. Where is the loco.
  2. How much energy it is using.
  3. What mailfunctions and errors are there.

IoT Demo

I have built a small demonstration project that shows how mentioned loco data can be transferred and processed on the cloud.

3D model

The 3d model of EMD GP38 is from the excellent OS Railway train project.

You can check all the designs at Thingiverse

Hardware

The hardware is of the system is based on ESP32, to measure the current INA218 sensor is used. Skylab SKM53 module is gathering GPS coordinates and time. IoT Loco is powered by LiPo batteries with voltage up to 12v (maximum voltage for the HalfBridge DC motor driver I am using).

HW

Firmware

Embedded Software is written in C++ and using arduino framework. FW There are three software states:

  1. Init - Initialisation of all sensors and hardwere.
  2. Main - MQTT data publishing and subsctibing, measuring power, GPS, motor contron and WiFi.
  3. Error - Routine to handle errors, such as no WiFi connection or absent GPS data. The full architeture of the system is fully descriped in the docs forder of the repo.

Connectivity

Server Side data processing is implemeted by utilizing Mosquitto MQTT Broker. The data is transmitted using wifi connection to my personal server. Connectivity

Dashboard

Server-side dashboard, which can display data and conntrol the loco, is built using Python Paho and Dash libraries Python IoT Dashboard

Conclusion

With the IoT Loco Dashboard Pablo can drive his train and do forget about all the Excel processes and calls from Mr. Schmetterlink. The energy dashboard clearly shows how much energy the train is using, along with the GPS location.

Code

Documentation and code are available on github and distributed under MIT license. The code is in development and can change with the project. At least some refactoring is planned along with tests.