ESP8266 MQTT Client

Special solutions for outdoor model railroading.

Re: ESP8266 MQTT Client

Postby gramels » 22.01.2017, 07:57

Hi Dagnall,

I presented your solution at the Rocrail User meeting in Speyer with great feedback and increased interest. Keep up the good work. I will make an instruction page in the rocrail wiki soon.

Please find my slides at

Thanks for the great work.

openDCC - MultiMaus - (MERG RFID) - testing a planned garden layout in IIm -

Re: ESP8266 MQTT Client

Postby Dagnall » 15.02.2017, 14:09

I thought you might like to see my "Station" wiring using the NodeMCU.
I have connected cheap ebay modules together very simply using standard breadboard push connectors. There is a Dual Motor driver, an AC-DC 5V regulator and a NodeMCU.
These are all located on a 3d printed "plugboard".
I then added four long 3 way extensions, (2 servos and 2 sensors). these plug neatly on the 5V regulator, with additional short wires to connect to the relevant ESP8266 pins.
There are then two ESP outputs sent to the two motor drivers (one each, reversing!..).
I use the PWM drivers to adjust some filament lights in the servo points.
The 5V regulator has been modified to send "raw" DC to the motor driver, but that (and a correction to the 5V regulator circuit (!)) was the only real soldering.

Perhaps we can persuade Peter Gilling to improve on this to make a PCB for it that is smaller and neater ? :wink:

You do not have the required permissions to view the files attached to this post.

Updates to ESP8266 MQTT Client

Postby Dagnall » 10.10.2017, 13:12

I have updated my ESP8266 NodeMCU client.
It now reports that it has a Pi 02 and a Pi 03, rather than a random selection!. (although you can easily change it so it reports neither if you prefer!)
{FYI, the hardware supports 8 I/O that can each be programmed as digital IO (like a Pio2), or as Servo/PWM (like a Pi03).}

I have significantly improved the servo codes, as the previous versions were very slowed down by some debug serial messages.
I have also added a debug that works over MQQT, so you can easily see which nodes are on line and when they send messages. (useful for debugging).
I have added Over The Air software updating , This works with the Arduino interface and means that you do not have to kneel in the mud with a USB interface to update the nodes in the garden!.
I have also updated the Mobile part of the code and it works as a single channel controller for a Loco with front and rear lights and a servo controlled motor. (with 4 spare I/o for other things if you need them).

My hardware now uses the "L293D Motor Shield Module", easily available from E-Bay and other places.
As well as providing some screw terminals and the L293 IC, this useful and inexpensive module takes all the NodeMCU ports out and provides them on a row of standard servo type 3 pin interfaces. --- Unfortunately it supplies the V+ to this row from the NodeMCU 3.3V regulated output, so it is not immediately useful for standard 5V servos, but a very simple cut of one track on the back of the board isolates the V+ on this row and allows you to connect these instead to "Vin". BY then adding a simple external 3 terminal 5V regulator between the +12V and "Vin" screw terminals, you can use the module with a single 12V power source, provide +5 regulated to the NodeMcu (and the servos/ sensors). The ModeMCU ports D1- D4 are connected to the inputs of the L293 and can be used for two motors or PWM (12V) outputs.

NodeMCU Mods.jpg


Code is still at
You do not have the required permissions to view the files attached to this post.

Re: ESP8266 MQTT Client

Postby Dagnall » 10.01.2018, 19:36

I have been working :coding: on the Loco with Sounds and I have put an initial version of my ESP8266 (nodeMCU) code on GitHub.

A video of the code (without the loco hardware, but with a steam generator) is here:


Re: ESP8266 MQTT Client

Postby Liviu M » 10.01.2018, 21:48

Hi Dagnall,

really nice!

Thanks for sharing it,
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
Liviu M

Re: ESP8266 MQTT Client

Postby Dagnall » 27.02.2018, 19:07

The latest version of the mobile version can now play 2 sounds simultaneously, so chuffs and sound effects can play together. A great improvement, and all thanks to Earle Philhower's ESP8266 Audio Library.
There is a YouTube video of the latest version here:
The code is available on Github.


Return to Garden Railroads