12v bluetooth in model train

Hi Folks,

Noob question.

Which bits and pieces should i look at to achieve this ?

Standard OO gauge model trainset with 12-14v pickups at the wheels. I want to control each train via bluetooth or wifi so putting electronics inside each train to achieve that. i.e. we want to vary the voltage to the motor via a bluetooth or wifi signal. There will be about 15-25 trains running at any one time. However I'm a programmer professionally so the programming etc will be easy enough for me, its just choosing the right electronics and it will be controlled overall via a windows laptop

  • Small space for the electronics so prob no room for heat sinks or large boards I think a MKR1000 would fit with something like a l293e motor controller
  • Motor needs 12v max 1amp and supply is 12v only. Usually trains only use about 250-500ma
  • Occasionally the 12v will blip on and off as the train passes over gaps or hits dirt etc

So after heaps of googling I came up with MKR1000 and L293E single motor controller, but is there a simpler/better way of doing this and if not will these components work. Its 35 years since I've done any electronics so a bit rusty on whats possible and how to do things. I would need to know how to step down the voltage also

I can mock it up on a breadboard but didn't want to buy lots of stuff that won't work in the final solution.

thanks in advance
Paul

ESP32 or ESP8266 would be a perfect WiFi choice. But use a module, where you can attach an external antenna.

Fun Project if playing with electronics is the major interest. If You want a well running railroad, buy commercial receivers and train controll. Using the scale H0, 1:87, there was no choice regarding the space available.

ESP8266 would also fit at 48x25mm. Thanks for that.

How would the voltage be adjusted from 12v to 3.3v? (sorry if thats annoyingly noobish :slight_smile: )

Also is L293e a good choice for 12v <=1amp with this module ?

thanks

Get a RC motor controller for brushed motors from the car/boat fraction. Choose one for 3s, then you have 5V to feed into the 3.3V regulator on the ESP. Stay away from the L293 - they kind of work, bit are a "bit" dated. Better use the Servo library for the RC controller.

I have been using nRF24L01+ wireless transceivers for 00 scale model train control. My trains are battery powered. This pic shows one of my receivers - an nRF24, Attiny84 and a ROHM BD6212 h-bridge. The BD6212 has a max of 7v as I use a 1S LiPo for power. The BD6222 can work at up to 18v.

Recently I got an ESP32-CAM module and created a demo where I could control an O-16.5 narrow gauge loco with first-person-view using my phone. However the ESP32-CAM module is too large for an OO scale train.

...R
Simple nRF24L01+ Tutorial

Thanks for these. I'll get googling

zwieblum:
Get a RC motor controller for brushed motors from the car/boat fraction. Choose one for 3s, then you have 5V to feed into the 3.3V regulator on the ESP. Stay away from the L293 - they kind of work, bit are a "bit" dated. Better use the Servo library for the RC controller.

Despite I hope being reasonable at googling I've failed to find anything matching your suggestion, but not sure on what the magic keywords are. Could you please post an example ?

Perhaps the difficulty is Im starting with 12v dc not 5v ?

plamby:
Despite I hope being reasonable at googling I've failed to find anything matching your suggestion, but not sure on what the magic keywords are.

The magic keyword is ESC (electronic speed control). The HobbyKing website has a large selection. Just be careful that many of them (intended for model airplanes) don't have reverse.

Model cars and boats usually have very much more powerful motors (with currents of 20 or 50 amps) compared to model trains.

For control purposes they appear to the Arduino as a servo.

...R

1 Like

Thank you Robin

One thing that I overlooked. In your Original Post you say " I want to control each train via bluetooth"

Bluetooth is a 0ne-to-One communication system so not really convenient for multiple trains and a single controller.

I think the newer BLE can be operated in a one-to-many role but I have never come across a tutorial that explains how it is done.

...R

BT LE has a "new" mesh mode. There are some nice application notes on the ST websites for their BlueNRG2 series.

Since my original post I've come to realise that WIFI is a great solution because its very low cost, and you can now get wifi programmable chips which are really tiny. Key seems to be to find a solution that has the appropriate voltage for the wifi chip and the h bridge. So BT is out now really

I've ordered a some breadboard kits and arduino stuff to get it started anyway, plus an ESP8266 and a cheap motor controller which had a 5v on it, L298n I think - although that was not recommended on here I can at least prototype it and get used to programming arduinos etc, then I can get some smaller chips and make them fit

On other forums everyones on about going dcc because its the best solution and people are being somewhat rude t me but my layout is gonna have 25 locos running concurrently and more on sidings and I'm doing it all for minimal cost, if I can come up with a solution that's really low cost I can buy dirt cheap trains off ebay and low cost (even used) chips and do it for a tiny fraction of the cost :slight_smile:

I also think a lot of people don't use DCC because the locos can be £100-200+ - if I could open-source a low cost way to RC a non DCC loco and control it from a PC then there would be a lot of happy modellers out there. Perhaps :slight_smile:

Running 25+ trains will not be solved by the way of communication, BT or Wifi. It calls for a central control and train administrating system. Get that system, one that can interface with Your project. Else You will be driving 1 or 2 trains at time as maximum. All You have managed is spending money.
I have been running 30+ trains using a commercial control system, a commercial interface and a commercial train detecting system for some 5 yeras now. Starting Your way calls for a lot of technical work, and money, done by You.

Railroader:
Running 25+ trains will not be solved by the way of communication, BT or Wifi. It calls for a central control and train administrating system. Get that system, one that can interface with Your project. Else You will be driving 1 or 2 trains at time as maximum. All You have managed is spending money.
I have been running 30+ trains using a commercial control system, a commercial interface and a commercial train detecting system for some 5 yeras now. Starting Your way calls for a lot of technical work, and money, done by You.

WIFI will support 25+ trains on one wifi router easily. In fact since I can program the wifi at a low level with light sleep mode, I can simply issue instructions and "where am I" reads once per second, so the traffic and power use will be really low.

I'm a professional programmer, so the programming side of it (central control) will be easy. Although I mostly work in .net I've got a strong background in c++ and low level programming in asm, as well as database management and multi threaded programming, so I think that side of it will be fine both in the onboard code and the central management system. Also might put some AI concepts in here, again free libraries exist in .NET which I can use to control train management logic

ESP8266 + L298N would be about £5/$7 per train.

My time is free, I like reinventing wheels :slight_smile:

plamby:
I also think a lot of people don't use DCC because the locos can be £100-200+ - if I could open-source a low cost way to RC a non DCC loco and control it from a PC then there would be a lot of happy modellers out there. Perhaps :slight_smile:

Oh, go on, Go all the way. Battery power. Track power is so last-year :slight_smile:

An L298 is big and very inefficient - that's why they are so cheap. Inefficient means they get hot and need a huge heat sink.

How many amps do you want to be able to control?

And don't forget that if Clumsy Joe puts the loco on the track the wrong way round the + will become the - and the smoke may escape. You will need a full-wave rectifier between the track and the electronics.

...Rf

Your skills and experience is impressive, at the level of mine. Do You recall the thinking "Top down design"? That's the way to build a well working system. To me, I might be wrong, Your approach looks like "Down to Top" design and, maybe, waisting a lot of time, brain power and money.

I use a very powerful control system named iTrain. That system is universal couvering a lot more than I use. However, due to imperfects, some dirt on the tracks, loss of power, engine stop, etc. I know it's really a hard task to adminstrate 25+ trains in order of not collaiding, not run into dead locks etc..
How do You intend to read the position of the trains within an inc or two, calculate braking action to stop accurately? That's very important.

Of course, You are hedaing for a lot of fun, and hard, work to build it all from the bottom and the administration of the trains. I can only wish You the best and good luck.

@Robin2
You don't know how close You are to a real mishaps of that kind.

Hope this is allowed publish in Forum...

Once the second guy, just down the president, in a Swedish car producer company asked his boss for permission to be absent in an important staf meeting. The guy was asked to come to a quite important modell railroad that he had build for an "importan Iron Company" in Sweden. He got the blessing to go.

The railroad refused to start. It closed down immedeately upon powered up. After some time of tearing the hair the guy found the reason to it.
It showed up that the cleaning lady had brought her Young son with her, in order to show him the railroad. The boy had then placed an AC car on the DC track making a short circuit.
The costs?

Robin2:
Oh, go on, Go all the way. Battery power. Track power is so last-year :slight_smile:

An L298 is big and very inefficient - that's why they are so cheap. Inefficient means they get hot and need a huge heat sink.

How many amps do you want to be able to control?

And don't forget that if Clumsy Joe puts the loco on the track the wrong way round the + will become the - and the smoke may escape. You will need a full-wave rectifier between the track and the electronics.

...Rf

Thanks, yes I bought the L298 just for prototyping, but as soon as I've found "the one" I'll switch to that

I've heard that relatively new engines only consume about 0.25A, but I should allow for 1 amp

Thanks for the tip about the rectifier, I had hoped the chips would cope with swapping polarity since the trains could be running in either direction, but I guess not. I'll take that into consideration.

BTW not sure about battery power in OO, since there's not a lot of space in there. The goal is a large layout with lots of trains, and many of the trains will be older (low cost) and the track will also not be new but of course I will solder it all or bridge-wire it - still lots to go wrong so do you want a DCC signal through that?

So my strategy is starting at the top - architecturally, whats the best way of doing this - 25 DCC trains would be what £4000 or $5000 ?

What I came up with is a track which is constant 12v and each train being radio controlled will work well if the rc chips are small enough, and using wifi means no hardware at the controller end, just a windows pc and a wifi router. Obviously as before trains can move in two directions, so polarity has to be reversible

I'm playing with DCC also, since that may come into the solution if I can manufacture or buy cheap dcc converters, or I may just steal some of its concepts.

As for knowing where trains are, I'm thinking sensors but not sure which yet. Wifi/RFID is pretty cheap now, and there's probably distance sensors (EDM), or just track sensors at key points and a sensor on each train - I'm sure all that is a couple of dollars per train ?

I'm thinking that each train has a driver who is following a set of english instructions, such as "take loco x, refuel it, get 20 wagons, fill them with coal, and take them to the power station, then reverse out and get them back to sidings", that will map to a sequence of steps which a computer program can issue. Each driver will be a thread of a computer program following these instructions, and obeying signals/waiting for points along the track. The system won't care about relationships between trains

Festering :slight_smile: