A Nextion Based Controller for DCC++ and DCC-EX

NormHal Sep 6, 2022

  1. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    In the spirit of building on the excellent work done by Greg and the DCC-EX "Team", I'd like to share my efforts to extend the range of controllers already available for the platform, hopefully retaining affordability and range of features at the same time.

    I attach some pictures of the project for you to get an idea of the scope of what's been done:)

    In a nutshell, 3 Nextion models are supported - 3.2, 3.5, and 5.0in versions in either Basic or Enhanced form. The Arduino Sketch runs on UNO right up to ESP32 microcontrollers all with similar capabilities, but increasing capacity. No specific Arduino libraries are used, so compilation and implementation is kept as straightforward as possible.

    Just over 5 years ago I posted a variation of Dave Bodnar's DCC++ Nextion Throttle. See: (https://www.trainboard.com/highball...-to-dave-bodnars-dcc-nextion-throttle.108041/)
    This project is a complete re-work and re-write of what I had done back then, accompanied by a completely new Nextion HMI design and features as well. The ESP8266 and ESP32 support add WiFi connection using the DCC++ protocol in order to provide as much compatibility between DCC++ and DCC-EX systems, as well as Direct Connection and WiFi capability.

    In view of the possibility that the project might result in a fair bit of support (I don't claim to be much of a programmer:-(), I'm keen to start a conversion group or SIG, for anyone interested. By means of that, I will be able to share downloads and version releases without cluttering up this forum:)

    Here are some pics:)
    IMG_20220906_122231.jpg
    IMG_20220906_122231.jpg
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
     

    Attached Files:

  2. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Some update news... Version 1.1 of the Nextion Based Controller is now available. Changes include a revised "Throttle" page showing more Loco details. In addition, a number of the inevitable "bug-fixes" have been incorporated.

    To make things easier, the code and Nextion binaries are now available on GitHub:)

    https://github.com/normhal/DCCppEX-Nextion-Controller

    I have also announced the project on Discord, so let's see if we get any takers:)
     
    Last edited: Oct 3, 2022
    Sumner and Erik84750 like this.
  3. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
    Norm, now you really sound timid :D: you did a top programming job and to be honest, this is a ground breaking project. All honours to you!

    Cheers,
    Erik
     
  4. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
    It's all there for the taking.

    All software, readily tested and debugged.
    A Nextion screen; and a Uno, Pro Mini, Nano, ESP8266 or ESP32.
    And a rotary encoder; and a battery and a housing bougth from your electrical supply store.

    The next best thing since sliced bread; and DCC++ (EX).
     
    Sumner likes this.
  5. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    Great work Norm(y)(y).

    Down the road are you planning on putting together more of a step-by-step tutorial on how to put one together. There are some of us that can follow something like what Dave put together but don't have the knowledge to use GitHub to do it.

    I'd be interested in what I might be able to put together in the way of a 3D printed handheld case to hold a display and house the encoder and possibly other physical controls.

    Sumner
     
  6. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thanks for your kind words Sumner, but what's not evident is the bunch of guys who worked with me on the project over the last 9 months! Steve (esfeld), Erik (erik84750) and Francisco (jbsorocaba) underestimate the value they've been through their testing, suggestions, requests and encouragement!

    To answer your post though, you sound like you would be a great asset to the team:) I've been so caught up with the conceptualizing and coding (and re-coding, and re-coding, and...) that the very obvious need to package it has taken a back seat:-(. I've been personally thinking of knocking together an MDF box of some sort to hold it all together, but haven't yet got down to it...

    Your suggestion to add more meat to the "How-To" is also very valid. I'll get down to adding to the Readme on Github as soon as possible:)

    All the best
    Norm
     
    Erik84750 likes this.
  7. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    Yes definitely a big thanks to the whole team also (y)(y).

    I'm in the midst of trying to do to much at the moment but...........Looks like the one to put together is the ESP version. I have lots of Arduinos but no ESP. Is this the one ( HERE )? I use the development boards usually with an Arduino what do you plug that into to do the wiring (I'm sure we would want the smallest footprint). Does one need to make a PCB? I'd probably get all the components and start with a case if I knew all that was going to be needed to go into it, minus the Nextion. Batter? Charging circuit? The encoder (have some of those). Any other physical switches?

    I couldn't find a wiring diagram, probably just missed it?

    If I could get all the components, which I'm willing to do, I could see if I could come up with a 3D printable handheld case.

    Sumner
     
    Erik84750 likes this.
  8. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Yes, that ESP32 will do just fine, however, if you're going to buy, it might be an idea to get one which has a battery charging circuit on it - there's not too much difference in price. We're about to lose our power again for the evening, and I have some things I need to do, so I'll look for some pics to send you tomorrow if that's OK? To get started, the circuit is very straightforward - power to the ESP32 can come from a USB cable, four wires to the Nextion (5V, Ground, TX and RX) and you're in business:) The Rotary Encoder is optional, but most guys seem to prefer it. That's an additional 3 wires for the Reverse button and the Left and Right direction pulses. It "can" work like that, but some filter caps could be a good idea... I'll consult with the guys and see what we can come up with... A Power on/off switch would also be needed if a battery is to be used.

    To be quite honest, my original idea was to make a Command Station attached Controller getting its power from the DCC++/EX system.. This has been expanded to be wireless, and I haven't really given it too much thought...

    Do you have a Nextion? We've had some thoughts regarding the model of choice and there are varying preferences. The 5.0in gives a really nice viewing area and is much easier on big fingers, but the price is a bit against it. My choice is the 3.5in Basic version running on an ESP32. 3..2in is by far the most cost effective, but small fingers, or rather, the use of the Rotary Encoder is perhaps the best option...
     
    Erik84750 likes this.
  9. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
  10. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Oops, my bad:-( Thanks Erik, you're right. Must have been my rush last night... I will also find a pic of one of the esp32 models with integrated battery holder and charger. We'll discuss some options during the course of today
     
    Erik84750 likes this.
  11. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    I must qualify what I said about the versions with a built-in Battery and Charger...
    Be careful to NOT buy this model...
    https://www.aliexpress.com/item/32841683088.html
    Whilst its price and features look great, it doesn't generate the 5V needed by the Nextion. A better option would be to get one of these Battery "Shields"...
    https://www.aliexpress.com/item/33005503423.html
    and then a separate ESP32 like one of these:
    https://www.aliexpress.com/item/4000090521976.html
    Note that there are a few options - I see they have some which need/can take an external aerial. I guess the size of your train room could make this decision...
     
    Erik84750 and Sumner like this.
  12. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
    A note of caution on battery usage; when equipped with Nextion: the 3.2" uses around 150mA, the 5" needs 0.45A approx.
    On top the current used by the ESP32 must be taken into accout: average 100mA.
    So a 6V 3.2Ah battery depleted to about 35% (more is not a good idea) then, with a 5" Nextion, you will play around for about 3.8hrs.
     
    Last edited: Oct 5, 2022
    Sumner likes this.
  13. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
    ... and the distance from your wifi access point.
    To measure the wifi signal strength a nice Android app is WiFiAnalyzer.
     
    NormHal and Sumner like this.
  14. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    I've had next to no experience using batteries, so I'm a bad reference. What is the capacity of a 18650 Lithium Ion battery for example Erik? I see the battery holder I referred to can deliver 4A at 5V, but its Amp Hours are not clear, and I have a suspicion that our eastern friends tend to use creativity when it comes to mAH ratings...
     
    Erik84750 likes this.
  15. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    I was pleased to see that the versions which can take an external aerial seem to be more widely available - they were scarce when I was "stocking-up":-(
     
    Erik84750 likes this.
  16. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    Thanks guys for the updates. Clear this up for me. On the battery shield I see an input voltage of 5-7 volts yet see a 3.7 volt battery. I'm assuming they can take a 3.7 volt battery and 'boost' the voltage to 5 volts. Is that right?

    Been looking at the Nextion displays and they are more expensive than I thought they would be. If I do this I'd like to go with the 5 inch as it is more comparable to my phone throttle screen size. Looks like about $70 at least. The pictures you have shown Norm are with the screen in the vertical portrait mode. I'm assuming that would be the screen orientation for the 5 inch also????

    Sumner
     
    NormHal and Erik84750 like this.
  17. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
    Battery capacity is expressed in Ah: Ampère-hours. That is how long the battery will last with a specific load. 10Ah means 20 hours if discharged at 500mA.

    A 18650 Li-I battery has 3.2Ah, but be carefull with Li-I batteries: deep discharge results in dangerous situations.
     
    NormHal likes this.
  18. Erik84750

    Erik84750 TrainBoard Member

    334
    134
    12
    Orientation is vertical, for all Nextion screens in this project.

    I would not boost voltages: low efficiency, hence higher than normal battery usage.

    If you need 5V, either use a 5V stabilized source, or a >6.5V source and a Low Dropout Regulator: like this
     
    Sumner and NormHal like this.
  19. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Yes to both Sumner, it uses a 3.7v battery and has a step up circuit to produce the 5v,

    And The 5.0in Nextion is also Portrait style:)
     
    Sumner and Erik84750 like this.
  20. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi Sumner, I've done a bit of editing to the "Readme" on Github, as well as adding two more files in the "Docs" folder. Please can you do me a favor and look at what I've done and pass any comments, questions or critique?
     

Share This Page