Answers.Body: <h1>Power and Data</h1>
  
  <p>The classic solution to this for model trains is <a href="https://en.wikipedia.org/wiki/Digital_Command_Control" rel="nofollow noreferrer">Digital Command Control (DCC)</a>. Basically, when you provide power over the rails, you also include a data signal riding on top of it. Each locomotive or car with a remote controlled function needs an electrical connection to the track and a modest microprocessor to decode DCC instructions. You can do something similar with LEGO trains, but it requires some customization.</p>
  
  <p>For example, here's a modification that I made to one of my 9V motors to include a small microprocessor that controls the wheels instead of driving them directly:</p>
  
  <p><a href="https://i.sstatic.net/GpZNZ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GpZNZ.jpg" alt="9V motor mod"></a></p>
  
  <p>This solution requires that you are using either 9V or 12V powered rails, and is also very expensive as it requires a number of motors that are no longer in production and are expensive on the secondary market.</p>
  
  <h1>Data Only</h1>
  
  <p>Assuming that you are just powering a few LED lights in your cars or perhaps a small unloading mechanism that is used infrequently, you can probably get away with using a small lipo or similar battery for your cars. In that case, you just need to figure out a way to get access to control data.</p>
  
  <p>If you just need one way data, you could use a very basic RF receiver/transmitter pair (e.g. <a href="https://www.sparkfun.com/products/10532" rel="nofollow noreferrer">receiver</a>, <a href="https://www.sparkfun.com/products/10534" rel="nofollow noreferrer">transmitter</a>). This gets tricky to scale up, as you need a separate frequency and transmitter for each car, but could work with a small number of controlled cars.</p>
  
  <p>The solution that I would probably use if I were trying to do this would be to put an <a href="https://en.wikipedia.org/wiki/ESP8266" rel="nofollow noreferrer">ESP8266</a> in each car:</p>
  
  <p><a href="https://i.sstatic.net/BIqmg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BIqmg.png" alt="ESP-12f"></a></p>
  
  <p>These parts are quite cheap ($2 - $5) USD, can consume very little power if programmed properly, and provide a ton of flexibility. They provide and 80 MHz CPU and connect to Wifi networks, so you can control everything from a computer if you'd like. They also provide plenty of I/O pins and are more than fast enough for PWM, so you can have fine-grained control of everything and integrate sensors into locomotives and cars if desired.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-13T11:41:03.163Z
Answers.LastActivityDate: 2017-04-13T11:41:03.163Z
Answers.UserDisplayName: jncraton
Body: <p>I'm trying to find a way to create a power/data coupling between train cars that can be connected/disconnected like the car coupling magnets.  Has anyone done anything like this?</p>
  
  <p>Background: This is so that I can supply power and control to LED lights (and maybe other devices) in the cars being pulled behind the engine, which will provide the power and control unit (Arduino based MCU)</p>
  
  <p>I've tried using a micro USB magnetic connector, but they are too bulky and don't flex easily enough for this.</p>
  
  <p>I'd love to find if anyone has engineered anything similar.</p>
  
Tags: <trains><electronics>
Title: How could I provide power and/or data coupling between train cars?
UserDisplayName: Arlo
ThreadText: # How could I provide power and/or data coupling between train cars?
  
  (Asked by: username_0 on 2017-04-13)
  
  I'm trying to find a way to create a power/data coupling between train cars that can be connected/disconnected like the car coupling magnets. Has anyone done anything like this?
  
  Background: This is so that I can supply power and control to LED lights (and maybe other devices) in the cars being pulled behind the engine, which will provide the power and control unit (Arduino based MCU)
  
  I've tried using a micro USB magnetic connector, but they are too bulky and don't flex easily enough for this.
  
  I'd love to find if anyone has engineered anything similar.
  
  **Tags:** trains, electronics
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-13. Score: 4
  
  # Power and Data
  
  The classic solution to this for model trains is [Digital Command Control (DCC)](https://en.wikipedia.org/wiki/Digital_Command_Control). Basically, when you provide power over the rails, you also include a data signal riding on top of it. Each locomotive or car with a remote controlled function needs an electrical connection to the track and a modest microprocessor to decode DCC instructions. You can do something similar with LEGO trains, but it requires some customization.
  
  For example, here's a modification that I made to one of my 9V motors to include a small microprocessor that controls the wheels instead of driving them directly:
  
  [![9V motor mod](https://i.sstatic.net/GpZNZ.jpg)](https://i.sstatic.net/GpZNZ.jpg)
  
  This solution requires that you are using either 9V or 12V powered rails, and is also very expensive as it requires a number of motors that are no longer in production and are expensive on the secondary market.
  
  # Data Only
  
  Assuming that you are just powering a few LED lights in your cars or perhaps a small unloading mechanism that is used infrequently, you can probably get away with using a small lipo or similar battery for your cars. In that case, you just need to figure out a way to get access to control data.
  
  If you just need one way data, you could use a very basic RF receiver/transmitter pair (e.g. [receiver](https://www.sparkfun.com/products/10532), [transmitter](https://www.sparkfun.com/products/10534)). This gets tricky to scale up, as you need a separate frequency and transmitter for each car, but could work with a small number of controlled cars.
  
  The solution that I would probably use if I were trying to do this would be to put an [ESP8266](https://en.wikipedia.org/wiki/ESP8266) in each car:
  
  [![ESP-12f](https://i.sstatic.net/BIqmg.png)](https://i.sstatic.net/BIqmg.png)
  
  These parts are quite cheap ($2 - $5) USD, can consume very little power if programmed properly, and provide a ton of flexibility. They provide and 80 MHz CPU and connect to Wifi networks, so you can control everything from a computer if you'd like. They also provide plenty of I/O pins and are more than fast enough for PWM, so you can have fine-grained control of everything and integrate sensors into locomotives and cars if desired.
  
  
  ---
  
  