Notifications
Clear all

Controlling trains with ESPNOW

10 Posts
5 Users
3 Reactions
161 Views
(@dazza2502)
Member
Joined: 4 weeks ago
Posts: 3
Topic starter  

I saw a previous topic on this but no information on how it works or a sketch to view the pin connections. I would like to make a remote controller for my model trains and looking at ESPNOW it looks like the way to go but all there are no tutorials I have found on this subject. 

My questions are:

Does anyone have a link to any recommended tutorials? or

Has anyone successfully made ESPNOW for HO Scale model trains?

Thank you for the great forum.

Regards

Darren


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7283
 

@dazza2502 You can look at two articles that Bill has done in esp-now. search for 'ESP-NOW', then click ..more, then click the first link. You can copy the code to load into the IDE to get a feel for how it works. Place cursor in the sketch, now hover over the icons that pop up until you see 'copy'.

Hopefully one or more of the many model train folks here will pipe up, but in my limited experience, I think most model train layouts use one of a few standard electrical/electronic/train hardware setups. Have you tried google? I just tried it and one of the top hits was 'Traintastic'. Here is the LINK

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@dazza2502)
Member
Joined: 4 weeks ago
Posts: 3
Topic starter  

@zander Hi and thank you for the reply.

I have searched google and youtube but only a couple of things come up for ESP-NOW mostly in broken english that is hard to understand. What I want to do is make a remote transmitter and have a receiver in the engine.

The link you have provided for is a computer based system and I would prefer manual control via wifi, all the options I have come across have been DCC systems hard wire but again I would like remote control for external use.

I tried to find Bill's post but I could not find the ..more option can you send me the URL please.

Sorry not very good with ESP and sort of understand code I am on a steep learning curve.

I appreciate your help very much.

Regards

Darren


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1131
 

@dazza2502

ESPNow is a way of communicating between ESP boards (ESP8266 and ESP32 variants thus a good candidate for remote applications where your controller is based on an ESP module as is your receiver.   You then need to attached various peripherals to your controller such as joysticks and buttons that the ESP controller unit turns into ESP Now messages that can be received by the ESP receiver.    The receiver will also be attached to various peripherals such as relays or other circuity you create that your program will action when appropriate EPS Now messages are received.   

Forgive if I has just stated the obvious of which you are fully aware but to send and receive ESP Now messages no Pins or circuitry is involved.    Of course many pins and circuitry is required for the ESP to control all the peripherals, and this would be very dependant on your particular arrangements.  You can probably find examples of using ESP Now for this sort of remote control application but probably for controlling rover wheeled bots etc.  Indeed the following dronbot link shows using ESP Now to control a bot with peculiar wheels -

 Of course the principal of using the ESP Now for remote control would be the same whatever its controlling, bot or model trains.

But just to note that for the comms, you may find that Wifi is also an option (perhaps with another router you dedicate to your model railway setup).  This could have the advantage that you then have a much wider range of board to work with instead of just ESP boards. 

You will probably find the comms part, wifi or Esp Now is the easier bit and its sorting out how your receiver will control all the things you want to do on your model train arrangement is the harder part.  But if indeed its just finding an example of how to communicate between two ESP boards with ESP Now to get you started then the Dronebot article will get you started.  

Should you need to be considering how a microcontroller could be used to control your train set up than start by ignoring the comms bit for now, just get the 'receiver' board to take some action, perhaps on a button press, to do something like make the 10:30 currently waiting in Paddington Station to commence its journey to Lands End.  Just make sure the train runs on time 😎 

This post was modified 3 weeks ago by byron

   
dazza2502 reacted
ReplyQuote
(@dazza2502)
Member
Joined: 4 weeks ago
Posts: 3
Topic starter  

@byron 

Thank you for the reply. I think the Mecanum is what I am looking for I  am not sure about editing the sketch to reflect things like a button to turn on lights, forward and reverse for the motor etc.

I guess what I need to do is put the hardware together and have a play with the sketch and see if I can progress from there.

Thanks mate for the great help.

Regards

Darren


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7283
 

@dazza2502 Here is the link LINK

And a pic showing where the ..more is for future ref.

Don't forget Bill also has a Mecanum sketch but if youj are not a strong coder, then stick with the simple stuff. Don't forget , once you install the esp-now library, there will be examples under menu File/Examples now look for the library name in the 'Examples from Custom Libraries'

Screenshot 2024 05 23 at 07.23.00

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@kfellows)
Member
Joined: 3 weeks ago
Posts: 4
 

You could look at something like this, Control model trains wirelessly with your smartphone.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7283
 

@kfellows Did you forget something?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
huckOhio reacted
ReplyQuote
(@kfellows)
Member
Joined: 3 weeks ago
Posts: 4
 

@zander Here is the link, removed link


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1096
 

@kfellows Try it again. As a new member, you are not allowed to post links or images in your first three posts, so your link was automatically removed. Now that you have three posts under your belt you will be fine.

Sorry about that, it's a new rule that we had to implement last week due to spammers hijacking unused new accounts. It seems to be working, but I know it's a real inconvenience for new users.

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote