Arduino wireless remote control, prototype

rcmodeler Feb 19, 2019

  1. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    I'll try to explain :)

    Imagine that we have 3 locomotives.
    Loc 1 takes power and commands from track and thus have a dcc-decoder installed (this is what most people have).
    Loc 2 takes power from track and commands via wifi (in this case mqtt-commands).
    Loc 3 runs on battery and take commands via wifi (in this case mqtt-commands).

    All these 3 locomotives can be controlled by this handheld control, at the same time, on the same track.
    You can even drive them coupled together in multipel drive (do you call it consist, or something).

    The handheld control doesn't know if a locomotive is dcc or something else.
    It just sends out mqtt-commands, f ex:
    Loc 1 forward speed 10
    Loc 2 horn
    Loc 3 stop

    That's why I have a "mqtt-hat" on the Arduino Mega, so that it can translate mqtt-commands to serial.

    My brother is building a layout in scale 0, and I have built a small locomotive with my 3D-printer.
    It is equipped with dcc-decoder. It works but the drivetrain need a lot of improvement.

    My next locomotive will take power from track and commands via wifi/mqtt, like Loc 2.
    In my opinion that should work in H0 to, but be a problem in N.


    There is quite a lot of pictures of the throttle earlier in this thread.
    The latest changes is that all components is mounted on a PCB, and thus there is some modifications on the lower (black) 3D-printed part.
    [​IMG]

    [​IMG]

    [​IMG]

    [​IMG]
     
    Mark Ricci likes this.
  2. Mark Ricci

    Mark Ricci TrainBoard Member

    481
    652
    13
    A projection coming to reality for me. OUTSTANDING! The Loc 3 option is something probably beyond my lifetime for n scale but it sounds GREAt and IMHO the way future hobby will go! No worries with track feeders, crisscross's or reverse loop issues and such. Do you, or are you planning to, have a website with any info?
     
  3. Sumner

    Sumner TrainBoard Member

    2,834
    5,969
    63
    I've seen it in operation in HO and N will be a squeeze but I'll bet it happens. Might be able to happen now if the components are in a car or two that stay behind the engine. I won't be attempting this though ;).

    rcmodeler you have done some very nice work on this. Very impressive!!

    Sumner
     
    Mark Ricci likes this.
  4. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Sorry, don't have any website. Only posts in forum and Youtube.

    Still working on the upgraded handcontrol. Noticed that someone wanted a physical button for horn.
    Not a bad idea. Should be possible to fit in, at least with the 3.2" display.
    Had a look at the 3.5" display, and it is maybe(!) possible to squeeze that in too.

    Another thing, as I use mqtt for communication the code I'm using is not so interesting for most of you.
    But have anyone tested ESP-NOW? I think that could be useful for multiple handcontrols to DCC++ master.
    Link to my favourite ESP-site:
    https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/
     
    Mark Ricci likes this.
  5. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    I saw a new thing on DCC++ website, Turntable-EX.
    Quite funny, actually, because I am building something like that since a couple of months.
    It's not controlled by DCC, but wifi and mqtt. But apart from that it is quite similar.

    It is located on my brothers scale 0 layout. He asked me if it would be possible to make some kind
    of turntable for his little KLV 12. The main problem was that the tracks were already in place,
    so we could not make any major work with the plywood.

    Well, it's not ready yet but here is a couple of pictures of how it looks right now:
    [​IMG]

    My brother an I doesn't live in the same town so I built it at my place with a similar construction of what's underneith:
    [​IMG]

    I'm using the same geared stepper motor with ULN2003 driver, but have two photo interrupters for end stops.
    And, of course, a Wemos D1 mini. All parts are 3D-printed except for a 5mm brass tube.
    The turntable are just going 180 degrees with 3 fixed positions 0-90-180 degrees.
    Track polarity will be changed with 2 microswitches (not in photo).

    The precision of the stepper motor is not that great, but I hope it will be enough for this small turntable.
     
    BoxcabE50, sidney and Sumner like this.
  6. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    And now the turntable is ready and in function, works better then expected.
    Here are a couple of short videos:





     
    BoxcabE50, Mark Ricci and Sumner like this.
  7. sidney

    sidney TrainBoard Member

    1,244
    2,112
    38
    that is really cool. maybe one i can figger out how to do something like this. Thanks for sharing..its very nice
     
    Sumner likes this.
  8. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    My brothers layout is in scale 0 so we need a little moore power.
    The layout is still under construction and so far we have a small Arduino 2A motordriver to our DCC++ system.
    I'm testing a IBT_2 motordriver and built a small all-in-one box for it. This is just for test and not a final solution.
    Planning for 5A per section, hope that will be enough.

    Arduino Mega with DCC++EX 4.0 on the bottom and on top of that Wemos D1 mini for MQTT communication.
    On the lid is the IBT_2. Made some minor mistakes (as usual) but it seems to work.
    [​IMG]

    [​IMG]

    [​IMG]
     
    french_guy and Mark Ricci like this.
  9. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Made an upgraded version on my handheld control a couple of months ago,
    and I was planing on upgrade the software as well, but had so many other projects....

    Then I saw that the DCC-EX guys released an Arduino library, DCCEXProtocol :)
    and I thought I could take a look at that.

    I've just played around with it over christmas and it is interesting.
    This is my test setup:
    [​IMG]
    On the right is Arduino Mega with DCC-EX, wifi card, motor controler, and on top a power device.
    In the middle is my new handheld control, with some new stuff both inside and outside (and logo).
    And on the left is a tablet with Engine Driver.

    I have got so far that I can get a locomotive to run both directions from my handheld control.
    I have also created a roster in "myAutomation.h", and it works fine on the tablet
    but it seems to be a little tricky to get it in my handheld control.

    Well, I just started so I guess I will figure it out.
     
    Sumner and BNSF FAN like this.
  10. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Made some more programming and I think this could be something.
    I haven't done anything with the roster yet, but almost everything else is done and working.
    The handheld can control up to 24 locomotives and save speed, direction and function 0-8 for all 24.
    If you drive any of the 24 locos on the tablet then the data is updated on the handheld, and vice versa.

    Since this use WiThrottle I don't need the Raspberry Pi for the MQTT anymore.

    Maybe it could be possible to make some kind of diy control to share.
    Not the one I'm working on here, but something that could be simpler to build :unsure:
     
    Sumner likes this.
  11. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    I have managed to get the loco name and address from the roster,
    but not the functions.
    In the roster example code there is no functions either.
    I've checked the library but obviously I don't understand how to do it.
    Any ideas? :(
     
  12. Sumner

    Sumner TrainBoard Member

    2,834
    5,969
    63
    Nice work, DCC-EX is great and expanding all the time. I love the $50 wireless throttles I made. Never hurts to have more options so nice to see you working on this. Have you gone to their Discord Group ( HERE )? Might be answers for you there. Sorry I can't help with them.

    Are you getting the functions on the tablet with EngineDriver? With the throttle I have, designed by Peter (EngineDriver designer), if I have edited and saved the functions with JMRI they show up on the throttle. He has it so you page through them with the throttle if there are many like with a sound decoder install.

    He might be able to help and is on Discord almost every day (Australia time).

    Sumner
     
  13. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Yes, everything works fine on the tablet. You can se on the left side on the tablet that all functions are present.
    So "myAutomation.h" seems to be correct.
    DCCEXProtocol code examples for roster does not contain code for functions, just loco name and address.

    I'm not familiar with Discord, but I just signed up. Maybe can get some help there.

    I'm trying to make a basic but competent wireless control that uses the same protocol as Engine Driver.
    Hopefully it will be easy to build, and easy to use.
    It will look like the yellow one on the picture with a Nextion display and a rotary encoder.
    The ones we have used now for a couple of years works fine but they are way more complicated and not suitable for sharing to diy.

    I can take some photos tonight to show a basic setup that I made.
     
  14. Sumner

    Sumner TrainBoard Member

    2,834
    5,969
    63
    Have patience with it. I don't use it much and it took a while and still don't like it but for them it works well. I've tried pushing also connecting with DCC-EX users and potential users in a manner more familiar to us......a spot on a forum like here where we are posting now.

    A number of the users there don't like forums for various reasons so it hasn't gone anywhere although some of the guys there do monitor this site on occasionally and are helpful here.

    I"ll try and keep up with what you are doing but I'm sure a lot of it will be over my head. With two phone throttles and two of those wireless WiTcontroller Throttles (posted a link above) I'm not in need of another throttle now. Sure others that are considering one will be following also.

    Sumner
     
  15. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    I've read a bit of the dccexprotocol thread on Discord and most of it is way over my head.
    But I posted a question there.
     
  16. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    And got a quick response with a solution.
    So now I'm back on track :D

    Thank you for kicking me in the right direction, Sumner :)
     
  17. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Here is a picture of the basic controller I'm working on.
    This is a complete wireless throttle running dccexprotocol/withrottle:
    [​IMG]
    There are very few components:
    1: ESP32 dev board
    2: Nextion display (basic)
    3: 2 resistors (voltage divider from Nextion TX to ESP)
    4: Powerbank with USB-cable
    5: Rotary encoder with switch
    (Can of course add on buttons or anything else, there are plenty of free pins)

    The basic configuration can handle up to 12 locos with functions 0-8.
    Can get list of locos and functions from roster or local memory.

    Can easely be upgraded to handle more locos and functions.
    And turnouts, routes, turntables or what the dcc-ex guys comes up with.

    The code isn't ready yet but I don't see any problems now, but probably will....
    Then print some fancy box with a batteryholder and we are home :)
     
    Sumner likes this.
  18. Sumner

    Sumner TrainBoard Member

    2,834
    5,969
    63
    Sounds very intriguing. I'll be following and who knows might need another throttle after all. Don't spend unwanted time on 'my wants' but I'd want at least....

    [​IMG]

    ..... most of the buttons I have on my current throttle. I find them very handy.

    I'd assume that instead of the keypad the Nextion display would be used? I looked at Nextion displays before and found them to be a little expensive at the time but haven't checked back. Also I have large fingers that don't work well with doing things on my phone even with a larger screen but if the screen was only used for basic setup and not operation I'd be good to go.

    Sumner
     
  19. rcmodeler

    rcmodeler TrainBoard Member

    47
    40
    7
    Yes, the Nextion display is the most expensive part but it is also a very flexible part that can do a lot of things.
    My fingersize is probably normal and it is not easy for me either with small buttons on a small screen.
    But the trick is to tap on the buttons with a fingernail, it works great.

    I like to have some buttons to, that is one of the reasons for making a new control.
    The rotary encoder have a switch, when pressed it change direction. Saves 2 buttons?
    If you press it before you set the speed to 0, then it can be emergency brake. Save 1 button?
    Horn and bell buttons can be a 3-way rocker switch (1)-0-(1).
    Just examples.

    I like to do normal driving without looking att the control, I can have it in one hand behind my back.
     
    Sumner likes this.
  20. Sumner

    Sumner TrainBoard Member

    2,834
    5,969
    63
    I have it set up to toggle to the next loco if I have the throttle set up for more than one loco at the time. Peter makes it pretty easy to change the function of any buttons you have added along with the label that appears on the screen in a config file ......
    -------------------------------------------------------------------------------------------------------------------------------------------------

    [​IMG]

    More about that here.....

    https://1fatgmc.com/RailRoad/DCC/page-503.html

    ... I'd think you are probably doing something similar.

    [​IMG]

    I was worried about reading the smaller .96 inch Oled display so used the slightly larger 1.2 inch. He gets a lot on the screen and I don't find it hard to read so happy with it. A larger display could show more though.

    Sumner
     
    newt749 likes this.

Share This Page