I have built a WiFi connected throttle that I can use to control my trains. It is based on the Adafruit Huzzah32 Feather module, an ESP32 device, that has builtin WiFi, and this module has circuitry for being powered from, and recharging, a LiPo cell.
Why build a throttle, when mobile phones can be easily used as throttles with DCC systems?
I decided to build this for 2 main reasons:
- This throttle is very tactile. It has a speed control knob to turn to set the speed, which can be easier to use than a touch screen – especially for children.
- It is simpler in its design and operation than a mobile phone acting as a throttle, again making it easier for children to use.
I based my throttle on the excellent design made available by Geoff Bunza on his blog at Model Railway Hobbyist. As Geoff mentioned in his article on this throttle, he hoped people would take his initial design and modify it to suit their own requirements. Several other people did modify Geoff’s design, and share their ideas and code, but none worked the way I envisioned, so I took their ideas, filtered out the bits I didn’t want, then added my own and ended up with a device that works exactly the way I want.
I have coded my throttle just the way I want. Its main features are:
- Every WiFi network I will be using this throttle on (and hence every layout) is assigned in the code, so when the throttle is turned on, it searches for the strongest WiFi signal it knows about, and connects automatically to it. As I won’t ever be using the throttle where multiple WiFi networks are present, this should not be a problem, and it makes connection to the WiFi system very easy.
- All my locomotives are pre-programmed in to the device, so once the throttle has found and connected to the JMRI WiFi system, I am presented with a screen allowing me to choose which of my locomotives I want to operate.
- If I want / need to operate a locomotive that isn’t pre-programmed, I can choose a “Custom” loco, then assign a name, DCC Address, and function numbers to operate with the switches / pushbuttons.
- Once the loco is chosen, the system advises JMRI of the loco in use, and is ready to go.
- The Speed control knob is also a push button, and if the loco is travelling and needs to stop quickly, pressing the Speed control knob immediately stops the loco.
- If the current loco is stopped, and sitting in Neutral, a press of the speed control knob will release the loco from JMRI, and I can then select another loco to operate.
- The loco Functions assigned to each switch / pushbutton are fully customised in the throttle, so I can operate the most relevant functions for each loco, even if they are different functions due to different manufacturers.
This is the layout of the front panel:
As you can see, the throttle has 2 on / off switches for loco functions, it has 2 momentary push buttons for loco functions, direction control, and a speed control.
The speed control is performed with a rotary encoder, a device that doesn’t have any end stops like a normal speed control, and also has indents that the knob sits in as you rotate it. This encoder has 30 indents over the full rotation. The advantage of an encoder like this is that the speed value is “locked in” once the dial has been turned to the desired speed, whereas a normal potentiometer would often fluctuate 1 or 2 steps without any movement, due to the way this type of control is read.
This doesn’t mean that the speed control has to be turned over 4 full rotations to go from stopped (speed level 0) to full speed (speed level 127). The rotary encoder library I used allows for acceleration, so turning the speed knob slowly gives a single step per click, but turning it quickly gives multiple steps per click. In practice this makes it easy to adjust the speedas required.
The rotary encoder is also used during the initial startup sequence, to perform the various selections mentioned above.
Power for the throttle comes from a single 14500 size LiPo battery, which connects directly to the ESP32 module.
The case it is built in has a battery compartment for 2 x AA batteries, and 14500 LiPo batteries fit perfectly in this compartment. As the module needs to be powered from a single LiPo cell, I have removed the connection from one end of the series battery connections in the battery compartment. This means one battery is connected to the module, while the other is sitting there as a spare, just in case the one in use goes flat.
On the top edge panel, I have fitted a Power On / Off switch, and a second function push button.
Coding of the ESP32 module is performed via a Micro USB connection on the ESP32 module. I have positioned the module so that this port is accessible from the right hand side of the throttle.
This port can also be used to power the throttle, and recharge the LiPo cell at the same time, so with the combination of a spare LiPo cell, and the ability to recharge on the go, I should never run out of power for the throttle.
With the throttle in use, the display panel is used to show the operator the state of the Loco under control. All the important pieces of information are shown:
Although not very clear in this photo, the display itself is very clear and easy to read. As you can see, it shows:
- The name of the loco being controlled
- The DCC Address of the loco
- The speed the loco is currently travelling at (0 – 127 speed steps)
- The direction of travel (Fwd, Rev, — for Neutral, or STP for an emergency stop)
- What functions are currently active (‘L’ for Lights in the above photo)
- The current LiPo battery level
- It also shows a heartbeat in the bottom right hand corner. This is a signal to JMRI to keep the throttle registered with JMRI and prevent JMRI from dropping the throttle and stopping the Loco that was being controlled.
I’m very happy with this throttle. Testing it has shown it seems to work very well, and I like the tactile feel of the speed control knob, more than the touch screen slider on a mobile phone.
Also, as the throttle is an open source project, I have been able to develop the throttle to work just how I want it to, and the layout of controls is again just how I want them. It makes this throttle just right for me.
Just like the DCC++ EX DCC Control system that I mention elsewhere on this site, if you have some spare time and are not put off by building and coding your own device, I recommend making one of these devices. It is a very rewarding project.
I’ll post some code snippets and comments here soon.