Hans Tanner's "Internet of Toy Trains" youtube channel is fascinating. See www.myiott.org as a starting point. He has taken modern concepts for message exchange and applied them to existing railway control systems, resulting in much greater flexibility.
The core concept for his ideas is: the information to operate the railway can be exchanged using an MQTT ("Mosquito") message broker. He has created several versions of a gateway from LocoNet to an MQTT broker; from there it can be accessed via many other kinds of device. He has demonstrated a smartphone as a message viewer and throttle, and several additional electronic modules. It means that a CTC type panel needn't have a LocoNet cable; instead it can have a WiFi connection to an MQTT broker. Processing logic and some forms of display can be implemented using NodeRed.
How will I use this? No idea yet, but it will fit in somewhere!
Github: https://github.com/tanner87661
Setting up an MQTT Broker
I've set up an MQTT broker "mosquitto" on a raspberry pi. It needs no user interface, so it can be a "displayless" pi. Follow the guidance of this web page: https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/
It site behind a firewall on a private network. I've allowed anonymous access and started external access with these two lines added to /etc/mosquitto/mosquitto.conf:
listener 1883
allow_anonymous true
That's enough that an MQTT client on my android phone can access the broker.
Setting Up Node Red
Similarly, Node Red acts like a server. Even though it has a GUI, it is accessed through a web browser; so the program can run on a displayless Raspberry pi.
Follow the instructions on the Node Red web page to install to the raspberry pi:https://nodered.org/docs/getting-started/raspberrypi
After installation you will need to install Node-Red-Dashboard; after that Hans Tanner's code can be imported.
https://github.com/tanner87661/IoTT-SmartPhoneToolbox
Hans Tanner's code has evolved since the smartphone toolbox code was produced. He has changed the MQTT topics in the current M5stick code. Three topics are available:
- IoTT_LNPing (devices send a "ping" message every 3 minutes)
- IoTT_LNEcho
- IoTT_LNBroadcast (this is the "normal" topic to use)
The MQTT input node needs to be configured for the MQTT broker address (in my case "localhost") and for the M5 stick the topic needs to be changed from "lnIn" to "IoTT_LNBroadcast".
Opce "deploy" has been clicked, the flow will publish a web page at address xxx.xxx.xxx.xxx:1880/ui and can be viewed on a smartphone
(xxx.xxx.xxx.xxx is the IP address where your Node-Red server runs)