Geoff Bunza geoffb
Model railroaders running JMRI have the capability of connecting  their cell phone or wireless tablets as a remote throttle for DCC control. I have often heard modelers who would like newcomers to operate their layouts with a simplified throttle, with a speed control knob.  Also reducing the possibility of inadvertently changing things visitors know nothing about. This article describes the construction of a simple WiFi throttle that connects directly to the JMRI WiFi server. It is not dependent on your DCC base station connected to JMRI. It will support loco address selection, six (or more) function switches, speed and direction control, running on a standard nine volt battery. While providing basic throttle functions, it can be customized and expanded by the inventive modeler to perform multiple functions at the touch of a button. You can also limit its functionality as you wish. It uses simple readily available parts for a one or two evening project. Throttle sketch updated 7 May 2019 to V5.2 minor bug fix.
_Opening.jpg 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 6
Logger01

Antenna - LNWI - Pin Hell!

Greetings Geoff and Prof. K,

Quote:

2.4GHz Mini Flexible WiFi Antenna with uFL Connector from Adafruit.com

I have been using some 2.4 GHz monopoles I scavenged from other projects, but I am planning to try several patch and PCB antennas, including the Adafruit, when I test the boards mounted in the Large Scale Engines. I am hoping that the antennas can be hidden in the tops of the cabs. Current range with the monopoles is over 50 meters (> 155 ft) except behind the big red thing (caboose).

Digitrax LNWI interface

I loaned my LNWI's to the club, but if I can scarf together a prototype throttle, I will test on a Digitrax system the next time I have time at the club.

Pin Hell!

Prof, I did warn about the potential for Heaps of Frustration.

Ken K

gSkidder.GIF 

Reply 1
Geoff Bunza geoffb

@Kevin re: Questions

Hi Kevin,
Quote:
So it's just a build the controller and load the software. No coding involved technically to make it work other than changing password, wifi name such...function switch assignments?
Correct.
Quote:
Will this work with Steve Todd's RPi wifi/jmri
setup?
Correct. I am using an RPi with this throttle right now, with an extended variant of Steve's disk image. It will work with his disk image as is, after setting the appropriate WiFi settings,
Quote:
Does our roster listing from jmri show up on the LCD screen for address selection or we flipping thru numbers to program the loco we want address?
No, not as it is presented here. The JMRI WiFi server does send the roster to the throttle upon connection. But someone (not me and no commitment whatsoever to do so) can take the roster sent to the throttle and use that for throttle address selection -- requires more time and effort coding. As I stated earlier... "this is left as an exercise for the reader."
 
Note: I built this as a limited function throttle for visitors (like kids) so I have no intent to add lots more features. While I completely believe this can be done, I would rather spend my time looking to enhance this to coordinate animations and other "essential" ingredients! 
 
Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
Raphael

Prof, how many I/O pins do you need?

Prof, how many I/O pins do you need?

An easy solution is to add a second small Arduino. For example an Arduino Nano has around 18 I/O pins usable from memory, and you can then communicate with the wifi one using i2c or serial -- if you use i2c, make sure they have compatible voltage levels, e.g. 3.3V vs 5V. I often prefer serial because it's trivial (just make sure the serial pins on the ESP are not multiplexed with the usb port). 

I don't know the specs for your multi-contact design, but another alternative is to use a multiplexer (e.g. SN74HC153 or anything similar) and to sample one at a time. Reminds me of the good old 80s designs...

 

One thing to be wary about are the ESP32 dev boards with integrated OLED displays. I've used them such as the Heltec WIFI_Kit_32 and they are quite handy for prototyping (makes debugging so much easier) but the board takes away a good chuck of the usable IO (for OLED + flash + button + LED) and this is a good example of board where the only usable serial pins are shared by the USB chip. Note that on that one the pin-out shows you still end up with about 24 free I/O (6 digital input-only, 16 digital input-output-PWM, or 16 available Analog-to-digital ADC, 4 with pre-amps). If you can play with the limitations, these are really handy.

I actually almost expected this throttle to use a board like this, as having the OLED integrated is quite convenient.

Ralf~
[ web site ]

Reply 1
DannyDont

Connectivity?

A friend connects JMRI to his layout using Loco Buffer (?) with Digitrax. Am I right in thinking that this WILL NOT connect in that environment? I connect JMRI to my layout using an EasyDCC serial connection. However, I have installed WiFi and have used WiThrottle. Am I right in thinking that this WILL connect in that environment?

It looks like a very interesting and doable (by me even) project. I am thinking I will give it a shot!. Thanks for the detailed description and build instructions!

I am all here because ...

  I am not all there.

Dan 

Reply 1
RossA

Demo Day

One if the presenters at our divisional NMRA event today was Geoff Bunza showing us his latest WiFi throttle. Geoff had it connected up to a DCC++ command station. It was very cool ! Thanks Geoff for all you do for the hobby.

Ross A

DE64341.jpeg 

75D1C44.jpeg 

Reply 1
AzBaja

I did not see a cost per

I did not see a cost per unit,  listed.  I'm sure you listed it.  I just somehow missed it.

AzBaja
---------------------------------------------------------------
I enjoy the smell of melting plastic in the morning.  The Fake Model Railroader, subpar at best.

Reply 1
Geoff Bunza geoffb

@AzBaja re: Cost

Hi Az (Sorry, I know you told me your name before but I just can't remember it! -- Senior moment!),

There is some variation in costs but you can build this for $15-19 depending on how fancy a box and knob you want to use. I know that sounds a little strange but those costs vary widely. The ESP32 costs $11 ea qty 2 and is about the biggest expense. I buy 10 at a time for $9.50 each. I usually hunt around for surplus bargains for C&K miniature switches which can cost more retail. Ebay has lots of low cost parts, but I have been more and more disappointed with the delivery time and the quality coming out of China direct in the last few years. The cost will also vary based on how many functions (switches) you want on the throttle -- you don't have to put any on! I also used a small monochrome OLED display -- really cheap off ebay. I have been very happy with these. They are easy to use and consume very little power at 3.3 Volts.
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Neil Erickson NeilEr

Cost

  • I ordered the controller and display today (two of each actually) and have most of the other components. It will be less than twenty bucks. 
  • Geoff mentioned that he uses an RPi to run JMRI and that intrigued me as well. Has this been posted somewhere and is the WiFi included? 
  • Waiting for parts in the middle of nowhere everywhere isn’t fun when something like this comes along. Thanks Geoff!

Neil Erickson, Hawai’i 

My Blogs

Reply 1
jgeorgius

DCC++ interface?

Hi, will the JMRI wireless base station connect to a DCC++ controller? Just a thought id like to entertain, i did some research on the notion but did not come up with much as of yet. It would be nice to use loconet to keep cross platform compatability. Thoughts? Jesse
Reply 1
B-dubs

@Neil - RPi WiFi

@Neil - Third generation Raspberry Pis (3B, 3B+, 3A+) do have WiFi built in. 

-Brad

Reply 1
Geoff Bunza geoffb

@Neil & Jesse re: RPi and DCC++

Hi All,

If you look at the picture of the setup on the table that Ross posted a few comments back, you will find an Raspberry Pi 3 B+ on the table along with an Arduino/DCC++ DCC interface driving the loco on the track. JMRI on the RPi will interface to any of the standard base stations it normally supports including DCC++. As Brad just pointed out, the RPi 3 B+ has WiFi capability to act as an independent WiFi server for the JMRI WiFi service. This is exactly what my simplified WiFi throttle interfaces to, and exactly what was being demonstrated. Also demonstrated side by side was an android cell phone running the engine driver app communicating with the RPi WiFi as well -- with the exact same control protocol.
 
Joe F. has an article in his queue for publication that describes how to cobble all these pieces together straightforwardly for modelers. You can looby Joe for a quick publication date.
 
Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
Geoff Bunza geoffb

@Dan re: Questions

Hi Dan,
Regarding your questions:
Quote:
A friend connects JMRI to his layout using Loco Buffer (?) with Digitrax. Am I right in thinking that this WILL NOT connect in that environment?
Correct. This is not a direct connection to your base station, but with this setup if you connect the computer using JMRI to a WiFi setup, then you can run the JMRI WiFi server, which this throttle does connect to.
Quote:
I connect JMRI to my layout using an EasyDCC serial connection. However, I have installed WiFi and have used WiThrottle. Am I right in thinking that this WILL connect in that environment?
Correct. This throttle connects in nearly exactly the same way as your WiThrottle, and can be run at the same time.
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
jgeorgius

RPi & DCC++

Geoff Forgive me for my ignorance, im still trying to wrap my head around jmri and how its interfacing with the arduino/H bridge drivers, im a hardware guy, not so much software. Im going to build this as i have all pieces in house and give it a whirl...track to throttle. Thanks Jesse
Reply 1
Geoff Bunza geoffb

@Jesse From a Hardware perspective

Hi Jesse,

From a hardware perspective:

The RPi is the main computer running JMRI in its entirety -- here equivalent nearly entirely to a PC. There is an RPi USB connection to an Arduino Uno/Arduino Motor shield combo. The Arduino has the DCC++ sketch loaded, but is essentially acting as a communications/protocol interface from JMRI generating DCC timing and power. That is about all the DCC++ package is doing in this case. The RPi has a WiFi hardware interface with software stack that the JMRI WiFi server (another part of JMRI) uses to talk to the WiFi throttles (like mine and like the cell phone apps). All the WiFi hardware (receiver/transmitter) is on the RPi. So this is a completely self-contained system.

'Hope this helps. Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
KHaus41369

Stick instead of knob

I'm going to be building a industrial city type layout. Could the throttle be more of a lever like on the proto throttle. Say rc gimble setup ?? If so. Where might a good place to find a single stick setup.

Kevin

Modeling something to do with the Grand Trunk Western.

Reply 0
Michael Tondee

A slightly off topic question

I'm seriously considering selling my existing Digitrax unit and going with a DIY DCC++ setup. I don't want to take this thread too far off topic but I have a question I'm not clear on and you seem like the man to ask Geoff.

The Arduino based DCC++ setups I've seen won't run more than a couple of locos at once. That's not a problem for me but what I'm not sure of is if they will program sound locos and if not what DIY item would be needed to do so? Don't sound locos need a programming boost?

Michael, A.R.S. W4HIJ

Model Rail and "mad scientist" for over 50 years.

Member of "The Amigos", Co-Inventor of the A.O.S.T.

I call what I do "An artistic impression of reality" and the Island is "lost" somewhere in the Pacific Northwest, see it here...

The Blackwater Island Logging & Mining Co.

Reply 0
Geoff Bunza geoffb

@Kevin re: Stick Sources

Hi Kevin,

Quote:
Could the throttle be more of a lever?
Sure no reason why not. You have at least 2 choices: a side mounted potentiometer with a vertical lever attached, and a multiposition switch (like a wafer switch) where you could select different resistor positions. This could also take on different orientations.
Quote:
If so. Where might a good place to find a single stick setup.
That's a very different question. The likely suspects include, Digikey.com, mouser.com for the electrical bent, ebay too, but you might look into suppliers of arcade games and the like for customized controls and sticks. Azbaja, another modeler on this forum, restores pinball machines, and may have some very good insights where to look.
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

@Michael re: DCC++ power

Hi Michael,
Quote:
The Arduino based DCC++ setups I've seen won't run more than a couple of locos at once. That's not a problem for me but what I'm not sure of is if they will program sound locos and if not what DIY item would be needed to do so? Don't sound locos need a programming boost?
The DCC++ setup as built with the original Arduino motor shield, will peak at a maximum of 2 Amps and in normal continuous running, may only tolerate something a bit lower than than before overheating. If you program in Ops mode "on the main" the vast majority of decoders seem to program well, including sound decoders. If you have one loco on your track you may do just fine.
 
Now for the rest of the story...
You should be able to increase the power out of a DCC++ setup to 5 Amps or more. Dave Bodnar has published some info already, and I will likely publish something soon that will up the power out too. So there are alternatives to running more trains. If you are going to abandon your Digitrax system, have you considered using your Digitrax base station as a booster for your DCC++ setup? A DCS100 can be configured to act as a booster.
 
Programming decoders, in my personal opinion, is getting more complicated not simpler as time goes on, and keep-alive caps are not helping. I have several different manufacturers programming interfaces for configuring sound decoders -- purchased entirely because the "standard" programming interfaces never did allow me to make all the internal changes I wanted to make -- consistently. I offer no specific data, only the frustrations of experience believing that the tools I already had on hand would work for another vendors decoders or for the next generation decoder family. I have been using DCC since Lenz delivered its product to the American market (I think before the NMRA had developed the DCC standards). DCC is a tremendous advance for the hobby. DCC sound is another tremendous advance too. But decoder vendors have not paid much attention to ergonomics, particularly in programming. Have you ever taken a close look at ESU, QSI, or Digitrax internal re-programming? OMG!!!  If the brilliance, yes brilliance, of others were not embedded into the simplicity of JMRI, this hobby would be stuck in a quagmire of decoder programming. And while I am on this rant (in my own blog) let me end by stating categorically that designing/engineering simplicity into a product takes far more work than leaving it complex! And most vendors do not want to make the investment.
 
OK. now that I'm passed that... DCC++ has 2 issues left that are relevant to your question and my rant: DCC++ is not supported with consistent, planned, ongoing development. To the best of my knowledge Gregg has not released anything new for years. Others have taken up the development challenge and are posting changes but I could not reasonably advise anyone if any of the releases are good or bad. Second, I have found problems programming normal CV's with DCC++. The last time I did such, a number of other modelers came and said they had no problems. That's fine... but I have had problems, and there is no responsible group or person to address these concerns on an ongoing basis. So I do most of my programming with vendors decoders interfaces, and via JMRI, locobuffer and Digitrax. I have several small DCC++ systems set up. In the long run I will use these for controlling lighting and animation, and perhaps some limited signaling. I have had much better success programming with Digitrax and SPROG via JMRI, so I will stay with that.
 
'Hope this helps. Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
kledbetter

Thanks Again

Another really nice, extremely relevant post!

 

I can't wait to get components and play. Will be perfect to give my 5 year old as throttle!

A couple comments for folks as I have explored the code at least a bit:

1)  you need to get a library to support the OLED (since SSD1306Wire.h is included)  here is one place to get https://github.com/ThingPulse/esp8266-oled-ssd1306.  If you get a different display then linked in article you might need a different library and a different include statement.

2) the I2C connection is great but you will need to verify the address is correct.  Default in program is 0x3c but I would strongly suggest you run an I2C address finder sketch such as this to test and make sure.  https://playground.arduino.cc/Main/I2cScanner

3) I believe and please correct me if I'm wrong its super simple to remap the functons. For my example I lowered  the function number to 4 (all I need is lights,bell, horn, and mute)  lights are F0, bell F1, horn F2 (same as original) but I need the 4th function to be F8 (mute).  All I believe I need to do is change the 3 to an 8 in this line (line 55ish)  int function_map [ ]  ={ 0, 1, 2, 8, 4, 5, 6, 7};   // this will map the pin list to actual functions  note change here from 3 to 8 which will leave everything else as is which will mean F3Pin and TC will be assigned to function 8. I could rename all, etc but seems this should work fine

4) I would suggest that folks modify the statement from the power on section(~line 252)

if ((digitalRead(TDirFwdLow)==HIGH)&&(digitalRead(TDirFwdLow)==HIGH)  // Set Neutral
       &&(digitalRead(F0_pin)==HIGH)&&(digitalRead(F1_pin)==HIGH)          // All SW Functions ON == Power ON
       &&(digitalRead(F3_pin)==HIGH))  {

to be their number of functions (4 in my case, with F2  being a button). Problem being if you don't have anything connected on those pins but include them in digitalRead logic statements like this they could be floating and potentially cause issues.  Maybe not but better safe than sorry.  Note that Geoff did this with 6 functions in his example omitting F6_pin and F7_pin.  And he did a brilliant bit of work avoiding it by you telling it the # of functions so you avoid floating issues elsewhere as you never transmit anything over you defined function numbers so those pins can float around all they want.

 

Once again thanks so much for your awesome work and I'll repost after I build mine!

Reply 1
Eugene Griffin EGRX

If only I could finish my project

Reading this I want to head back home and complete my project using the ESP32.

  https://forum.mrhmag.com/post/diy-wifi-engine-control-project-12211875

The ESP32 and ESP8266 were surprisingly quick to program and are very interesting devices.

But for now, I will have to put up with this.

8F125DD.jpeg 

Eugene

Reply 1
Prof_Klyzlr

Eugene's in Sydney?

Dear Eugene, Looks awfully like you're in Sydney, Australia, overlooking Darling Harbour. If so, be advised there are friendly MRHers quite nearby... Happy modelling, Aim to Improve, Prof Klyzlr PS there used to be steam and diesel-hauled freight (goods) trackage and yards to your lower left, heading towards those finger wharfs...
Reply 1
Eugene Griffin EGRX

Yes indeed it is.Beautiful

Yes indeed it is.

Beautiful city, first time here, wish I could spend more time looking around and visiting, maybe in the future. Very warm yesterday and today, the “strong breeze” In the late afternoon today was a refreshing change. 

Interesting, seems more than one city has changed old rail yards into modern people oriented areas. (CYVR, yaletown) also saw an old trolley? track near The Rocks. 

Leaving tomorrow, definitely glad I visited.

Eugene

Reply 1
Logger01

Arduino Libraries

kledbetter,

Quote:

1)  you need to get a library to support the OLED (since SSD1306Wire.h is included) ...

There is a standard Arduino SSD1306Wire library which can be installed with the Library Manager - Sketch Include Library Manage Libraries (Ctl + Shift + I). Search for "ESP8266 and ESP32 Oled"  or "SSD1306" and install the library noted below. It will take several minutes to install.

img.png 

Easier than manually installing a library from GitHub. There are a bunch of other display libraries listed for who may want to incorporate another display. I will probably be using a larger color display I have on hand which will work with one of the Adafruit drivers.

Ken K

gSkidder.GIF 

Reply 1
Geoff Bunza geoffb

SSD1306 Library ffor the ESP32

Gents:

The esp-oled-ssd1306 library was left out of the download by mistake. It is now included.

Download the throttle sketches from here:   http://mrhpub.com/files/users/geoffbfiles/Throttle_Sketches.zip
and unzip.

Move the folders and their contents labeled ESP32_Throttle and Blink7f_ESP32 into your …\Documents\Arduino\ folder and move the folder esp-oled-ssd1306 into your …\Documents\Arduino\libraries\ folder.

I do not recommend using another SSD1306 library. The ESP32 is not an Atmel processor. I have had problems with the other libraries, and this particular library is smaller than most. Try others at your own risk.
Have fun!  [smile]
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
kboy_1

SMA30 A Simplified WiFi Throttle You Can Customize

Super mon ami, j'ai tellement hâte d'avoir mes pièces pour faire ton projet. Merci et continu ton bon travail

Reply 1
Reply