Arduino wireless remote control, prototype

rcmodeler Feb 19, 2019

  1. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Building a wireless remote control based on Arduino Nano and Nextion touchdisplay.
    3D-printed box and battery from DeWalt, 10,8V.
    Transceiver nRF24L01 for communication to another Nano and Rx/Tx to DCC++ base station.
    This is just a prototype so I re-use a lot of code and hardware from my RC-models.
    Next version, which will take a while, is supposed to be with wifi.
    Prototype is supposed to be ready in a week or two :whistle:

    [​IMG]
     
  2. Onizukachan

    Onizukachan TrainBoard Supporter

    752
    1,198
    24
    Interested, especially when you get to the WiFi version.
     
    Mark Ricci likes this.
  3. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Are you willing to share the sketches and schematic?
     
    Mark Ricci likes this.
  4. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    The prototype code is not much to share, maybe bits and pieces.
    There is almost 1000 lines of uncommented code, most of it is communication between Nano and Nextion.
    But when I start with wifi I am absolutely willing to share, I cuold also use some tips and tricks myself.

    Next week or so I'm probably going to order a bunch of Wemos D1 mini, small and hopefully qualified for the job.
    I've never used these little wifi things before so it's going to take some time to learn, I guess.

    Here is a picture of what's inside this prototype.
    Going to take some pictures of the display in function, too.
    [​IMG]
     
    Mark Ricci likes this.
  5. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Here is a couple of pics of the display in action.
    Startpicture, just for fun, not necessary.
    (It's the locomotor I'm building in scale 0, picture from CAD-program)
    [​IMG]

    Next page is "select locomotive". It can control 12 locos at the same time (if the driver can).
    My brother have 7 Lenz locos (1-7) and I have 2 (11-12).
    [​IMG]

    Let's choose V 160, then we get to "loco control". Here you can control speed, direction and function F0 - F8.
    It is also possible to have the functions in text, different for each loco i you like. I'm only using F0 - F4 for now.
    [​IMG]

    Horn and Telex buttons are "momentary" (is that right expression?) so you don't have to push twice.
    Horn sounds as long as you press the button.
    Speed is controlled via encoder (the black knob) and press for direction.
    [​IMG]

    If you press "Turnout" button you get to the turnout meny, of course.
    [​IMG]

    My long term plan is to be able to control turnouts both from remote control and a track plan (not a pc).

    I just have one meter of track, one turnout motor and my two locos, so I can not test it more than this,
    but it works so far.
    Going to visit my brother, who's just started to build a new layout, in a week or two. He as at least 15 meters of track
    and 5-6 turnouts at this moment. And all of his locos :)
     
    Onizukachan likes this.
  6. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Well, it's been more than a year but now I have updated the wireless sender
    and replaced Arduino Nano with ESP32
    [​IMG]

    ESP32 has a lot more memory, is much faster, has built in wifi and bluetooth and this one has sd-card reader
    [​IMG]

    The only extra thing in the box is a voltage converter to feed the microcontroller and display from the DeWalt battery
    [​IMG]

    USB-port for uploading new program and SD-card (for future functions) is accessible from outside
    [​IMG]

    And as I was at it, I made three :D
    [​IMG]

    They are identical except for their "device name", sender 1, 2 and 3
    [​IMG]

    and can be used independent or all at the same time, there is no master or slave.
    When startpicture shows it is connected to the mqtt broker
    [​IMG]

    Everything else works the same, for now. There will be more functions later on.
    [​IMG]

    Tested and working fine
    [​IMG]

    My brother, who is building a new layout, has been working to, so now there is a lot more track
    and turnouts, And 12 locos and I don't know how many waggons.

    So it is quite fun to be able to drive several trains at the same time with this home-brewed,
    low-budget system. And everything else works fine to, with wifi and mqtt, such as signals, servos,
    street-and house lights, ir-detectors and so on.
     
    Mark Ricci and Onizukachan like this.
  7. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Just to clarify, these are ESP32 .. nextion ... and WiFi compatible to a DCC++ base station? If so I would be very happy to see your wiring diagram and especially the ESP32 code and nextion HMI.
     
    Onizukachan likes this.
  8. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Yes and no :unsure:
    To make a short story long:
    In MY opinion DCC has passed its best-before-date.
    I was looking for some wireless solution that is "relatively" easy to understand for a hobby builder, like me.
    One system that can control everything, not just locomotives or turnouts or signals or.....
    There are probably other ways but I found that MQTT was a really good choice for model railroading.
    It is widely used for wireless home automation and there is a lot of info and examples online.

    So for the system I am building DCC is not needed if the locomotives had a wifi receiver that I could configure.
    But they don't!

    To get the things that have a DCC-decoder to work I built a standard DCC++ base station with Uno and motorcontroller on top.
    And made an "interpreter" from mqtt messages to "DCC++ Commands" that I feed to the base station via Tx-Rx.
    There is no computer or JMRI involved.

    Other things, like servos, signals, light, ir-detectors, whatever are connected to small mcu (mostly Wemos D1 Mini)
    and reacts to mqtt messages directly, and give feedback. There are a number of those under the layout.

    The code for the sender is well over 1000 lines and the vast majority is communication with the display.
    And that is just for the sender. Then there is the "interpreter", and then there is all the other parts.
    I'm not posting all this and I think very few is interested in a system I've built to fit my interest,
    but relevant bits and pieces, sure.

    For those of you that are interested in my process so far there is a thread in Spur Null Magazin Forum,
    english section (I'm from Sweden so German or English is not my language):
    https://forum.spurnull-magazin.de/0...trol-model-railroad-with-wifi-and-mqtt-21390/
     
    Mark Ricci likes this.
  9. Mani

    Mani TrainBoard Member

    76
    15
    4
    I have similar idea where the trains receive commands from wifi installed in them without BaseStation. Researching on the module/custom board that will fit in N scale loco to run motor & sound.
     
    Mark Ricci likes this.
  10. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Mani likes this.
  11. Mani

    Mani TrainBoard Member

    76
    15
    4
    Yeah N is challenging.. Please share your updates on O scale loco..

    Thanks
    MK

    Sent from my GM1901 using Tapatalk
     
  12. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Of course :)
     
  13. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    As I don't have any stationary layout at home I've started to build some modules in scale 0,
    and maybe attend to some meetings in the future. At those meetings they have another system
    for dcc control but at home I would like to use my wireless system.

    I have a lot of battery powered machines and thus I also have a lot of batteries,
    so I made a battery powered DCC++ master station with wifi and mqtt so
    I can use my wireless controls.

    Made a short (bad) video on how it works:
     
    David Clemson, Sumner and esfeld like this.
  14. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Well done ..
     
  15. Sumner

    Sumner TrainBoard Member

    2,830
    5,950
    63
    Very impressive!! I read your progress to this point ....

    https://forum.spurnull-magazin.de/thread/21390-control-model-railroad-with-wifi-and-mqtt/

    Didn't understand all the components or detail but enough of the overall concept to really appreciate what you have accomplished in a pretty short period of time. Hope you put up more details on the wireless throttles and the system as a whole. I have DCC++ up and running with a pi and Arduino combination and the parts to build Dave's wireless throttle. Do you have plans to publish what you are doing along with the code where someone who can follow basic instructions could put together what you have done?

    Thanks for all the effort you have put into this,

    Sumner
     
    Mark Ricci likes this.
  16. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    It is my plan to publish it somewere but it will probably be next winter.
    My code is not so easy to understand and not well commented yet.
    I would think that my code is in 0.94 state, when it reach 1.0 I will be ready to publish.
    In the mean time I can certainly share bits and pieces, for example servocontrol or lights.
    Or just the basic mqtt communication that I use.

    I have made some PCB's in Kicad for controlling different things on the layout.
    First time I have done something like this so it's not pretty but it works.
    [​IMG]
     
    Mark Ricci and Sumner like this.
  17. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    I have become quite familiar with Kicad (for making PCB) and tried to make some cards with the more efficient microcontroller ESP32.
    It has a lot more I/O pins so I don't need as many cards to control everything.
    There is an ESP32 in my handheld control but there I only use a few pins.

    So my first ESP32 card looks like this
    [​IMG]
    Made some minor flaws on the design that doesn't make any difference, will fix it for the next version.
    It has 24 pins (4 are just inputs) and can control leds, servos, buttons, whatever.
    Just solder the components needed, not all of them.
    An extra bonus is that ALLPCB sent me these cards for free, no charge, not even for freight.
    I have soldered two of these cards and will install the first one next week.
     
    NormHal likes this.
  18. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    DCC++EX does all this now in the new release coming in the next few days. Would your share what you had to if someone wants to pick up the project, we could? Case design files and STLs, Schematic, Software? Thanks!
     
    Mark Ricci likes this.
  19. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Excating with the new release :)
    The Flextrain project is in slow progress, but it is in use and working fine.
    The problem with sharing this is that it is NOT "relatively" easy to understand for a hobby builder. Unfortunally.
    You need quite a lot of things and knowledge to get it to work.

    I made a "MQTT-hat" that I put on top of Arduino Mega, which has DCC++EX on it.
    The hat translates MQTT-commands to serial DCC-commands. So DCC++EX is part of the system so that we can control DCC equipped things.
    So I can drive locomotives, control light and turnouts that is equipped with dcc decoder.
    But I can also, at the same time, on the same track, with the same handheld control, drive a wifi-controlled locomotive.
    And control turnout motors with servo, street lights, house lights and much more, that doesn't have dcc-decoders.
    And, if we want to (we don't) from anywhere in the world that has an internet connection.

    But if anyone would like to build a handheld control with some other software, that maybe would communicate directly with DCC++EX
    instead of MQTT, I could absolutely share the hardware and the Nextion stuff.
    There is a special PCB in the handheld control. Going to take a photo of that later. I can share the gerber-file for that PCB.

    There is another problem with the handheld control. It use a Nextion 3.2" display which seems to be hard to get now.
    Out of production?
     
    Sumner likes this.
  20. Sumner

    Sumner TrainBoard Member

    2,830
    5,950
    63
    Is that a loco that is getting DCC commands from the DCC++EX command station that has wifi or does the loco itself have wifi. If so what scale? Sounds interesting.

    Could you also post a couple pictures of the throttle?

    Thanks and sounds like you have put a lot of time/work into this project,

    Sumner
     

Share This Page