DCC++ BaseStation with WiFi (ESP)

Atani Feb 11, 2017

  1. Shtirlits

    Shtirlits TrainBoard Member

    37
    3
    9
    I talk to this guy. He covers the station by return policy. He has 100% positive score. I will buy from him.
     
    Scott Eric Catalano likes this.
  2. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    I'm also curious in trying to set this up on an ESP32, but I haven't found any schematics on your github page. Will one of the L298N motor driver boards (not a hat) work for this? I have not been able to find anything that I would consider a full schematic for the DCC++ base stations, so I'm missing key pieces like what is used to supply power to the rails (I think it's supposed to be something around 15VAC?).

    Does anyone have pointers on a website that goes through how to get things set up from scratch? I have no existing DCC hardware, but I have been working with the ESP8266 mounted to an HO loco and running from wifi commands. I just thought it would be nice to build in DCC-compatibility before I got too far along on my project.

    [EDIT] well there's my first problem... finally found some reference info and see that this system in fact takes a DC power supply rather than AC. Makes it easier for me to get started them as I already have an 18VDC supply rated at 3A, so I should have all the components needed to start testing with a single loco.
     
    Last edited: Dec 19, 2017
    Scott Eric Catalano likes this.
  3. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    For the ESP32 we should discuss this under http://www.trainboard.com/highball/index.php?threads/dcc-esp32-base-station.112634/

    Depending on the L298 board yes, if you get one that does not have the current sense lines routed to a connection that can be wired to the base station (Arduino or ESP32) you will need to modify the L298 motor board to expose pins #1 and #15 of the L298 chip. I will post some details on that as soon as I receive the boards I ordered from China earlier this month (hopefully in the next week or so).

    Sorry about that, a lot of the details are in this forum under one of the many topics.

    That depends mostly on scale, but a 15VDC supply should cover most cases. Note that it is DC and not AC.

    I will add more details on the DCCppESP32 wiki page showing how to connect everything together. I have been trying to document things more completely since there are areas that are not documented at all or the information is scattered over a number of places.

    I know there is a project that is similar to what you describe but I don't have a link to it. It is using an ESP with motor driver and batteries for deadrail DCC operation. You could simplify this by using the rails to power the ESP and motor driver via track pickups and have the ESP control the motor shield directly. You wouldn't need to worry about current sense or creating the DCC signal for a decoder to interpret in this case. You could use the smallest ESP and motor driver board (even an I2C one). The ESP would receive the DCC++ data packets from a throttle and convert the commands to control the motor driver which is connected to the motor(s) in the locomotive.
     
    Scott Eric Catalano likes this.
  4. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Hmm double-checked my settings, but I didn't receive an email that you had responded. Glad I checked back!

    Will check your thread on the esp32 in a moment. I'm working in HO scale so 18VDC seems generally recommended, which matches the power supply I'm already using.

    My current setup uses as esp8622-12. I use an L293D to drive the motor (bridged across both sides of the chip). I have a rather simple and compact power circuit I made up of ebay components to provide both 3.3V and 5V signals, however it appears the 293 will switch just fine at 3.3V so I may simplify that circuit a bit. For software, I wrote everything myself. I use MQTT on a server to manage the 2-way communications between the loco and web interface controller, which has worked really well. I'm thinking I may want to shoehorn MQTT into a DC++ installation somehow because of the benefits. My overall goal is to have the ESP on the locos be somewhat intelligent... for example reading track occupancy signals and reacting accordingly, or waiting for certain conditions to occur and then navigating a programmed route. My software allows a controller to query the loco directly, which is handy but could be reproduced under MQTT. The locos would also need to be able to make queries, such as finding out when a load is ready to pick up.

    Anyway I decided awhile back that instead of plowing forward blindly building my own software from scratch, I should step back and start again with existing software to retain at least a little bit of compatibility. So that's why I've been looking at DCC++, to get a DCC system in place and start building around that. I've seen other articles where folks have started adding custom DCC commands, and that looks like something I could build off of.
     
    Scott Eric Catalano likes this.
  5. Simon Mitchell

    Simon Mitchell TrainBoard Member

    113
    105
    7
  6. Shtirlits

    Shtirlits TrainBoard Member

    37
    3
    9
    Did anybody buy the DCC++ station on eBay? It has been listed again as
    "DCC Digital Command Station w/ WiFi. DCS Mega 2560. 5 amps. Z N HO O scales."
     
  7. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    Sorry don't think anyone has. Many of us have all of the components already and just needed the ESP-01 board to add WiFi support to our Arduino base stations.

    One thing to be cautious of though on that listing is that it is a 12VDC 5A power supply that based on pictures on the listing will power *EVERYTHING* including the track!! You will very likely experience problems if you rely solely on that power supply for everything. I would highly recommend a standalone 12-15VDC power supply for powering the tracks. You will need to cut traces on the back side of the Deek Robot motor shield that is pictured in the listing.

    Also the Deek Robot motor shield provides ~2A total between the A and B motor outputs, if you are in larger scales you may need a booster if you plan on having sound locomotives.
     
  8. Andrei

    Andrei New Member

    4
    2
    8

    I setup DCC++ using your BaseStation, without Wifi. It works.
    However, as a second step, I was adding the WiFi shield (Tongze). DCC++ is uploaded to ESP device, however, I have no info on how to connect. What should is the name /IP of the WiFi network?
     

    Attached Files:

  9. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    I would highly recommend an i2c LCD screen long term, but you can find the IP assigned to the esp8266 by monitoring the serial console on the arduino side. Look for <N1:xxx.xxx.xxx.xxx> in the output from sending <s> or restarting the Arduino.

    As for hostname, that should be configurable in the config.h file IIRC. It may be available as an mDNS entry as well, likely as dccpp.local or something similar.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  10. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Not sure if I should start a new thread or revive this one. What is the status of this project?
     
  11. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    This project is no longer maintained, full code can be found here. I opted for a ground up rewrite of the project and shifted over to using the ESP32 instead of AVR+ESP8266 to allow for more expansion capability (and it has been utilized).
     
  12. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Is there a general help document or could you share how you implement this and what it does or doesn't have over using an Uno or Mega? I searched and it looks like the current thread for this is called "ESP32 Command Station", right?
     
  13. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    This project built on the Uno/Mega by adding a WiFi interface to it. There were also a few other fixes included on the Uno/Mega side but I can't remember what they were now, but you would need to use the DCC++ code that matches this project to use the ESP8266 side.

    And yes the ESP32 CS thread is the currently maintained project, it is not based on the DCC++ code but does support the text based protocol as well as a few other interfaces.
     
  14. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    If I remember right, there were also issues using the original aurduino motor shield board that could be fixed by cutting some traces, but an updated shield board was released that included jumpers?

    One of the nice things I like about the ESP32 CS code that Atani is writing is the fact that it provides its own web interface, including a throttle. If you have a loco with a standard DCC decoder installed then you can get up and running pretty quickly with just the command station and a cell phone reading the web interface, and you don't have to buy a lot of expensive equipment to play with DCC.
     
  15. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    There definitely are a few issues with various motor shields on the AVR side, I haven't looked at any that have jumpers on them specifically for the AVR side.

    and at some point in the near future it will be even cheaper :)
     
  16. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Atani, it looks like you were contributing with bjorniuppsala in a fork of the DCC++ code. If you remember, does this work on either a Mega or an ESP8266? What dependencies were added? The last posted versions were coded using PlatformIO which I would like to not have to download and install and learn. The code references <atomic> and <algorithm> (not used in the original DCC++) that appear to be in the "Embedded Template Library". I tried installing that in the Arduino Library Manager, but it installs a large, tree of folders instead of just putting the .h files in the root of that library folder like I am used to. So I need to verify that is the correct library and see if all I need to do to get it to compile is move the .h files buried down in the folder structure up to the root and delete all the rest.
     
  17. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    I haven't contributed to anyone's fork of DCC++, it is more likely someone picked up my previous code and is continuing the work. All of my efforts are focused solely on the ESP32 side of things now. But this project was maintained here previously.

    Understandable but it will complicate things a bit for you in placing libraries in the right places etc. The older code linked above should be able to compile for the Uno/Mega and ESP8266 with only a few adjustments.

    Which code are you trying to use? The ESP32 Command Station code will *NOT* work on the Uno/Mega or ESP8266. It is also have not feasible to support Uno/Mega/ESP8266 from the ESP32 Command Station code base as there are a number of dependencies that will not work on 8bit MCUs with limited memory (Uno/Mega) or the ESP8266 (single core with very limited pins).
     
  18. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Thanks for the reply. I was looking here:

    https://github.com/bjorniuppsala/BaseStation

    and trying to see what he did. Looking at the commits, I see the library that has <algorithm> was added to do something related to scheduling packets and done last. I could use the build before this and it would compile on Arduino IDE. I will probably bite the bullet and install PlatformIO ;)

    I'm starting to sift through it all, including your excellent ESP32 offering. I was hoping to keep up the DCC++ code for my Mega (and help others), and learn about yours and your board.

    If you happen to look at Bjorn's site, maybe you can see when he diverged from your code what of value he added and pass that along. Thanks again!
     
  19. Atani

    Atani TrainBoard Member

    1,467
    1,739
    37
    From a very quick look at that code, it was based on my older code linked above. I am unsure if it will be suitable for usage on the Uno/Mega/ESP8266. It appears to have a hard dependency on C++14 which may or may not be available with the Arduino IDE and does require some work to have it reliably working on PlatformIO (PlatformIO forces gnu++11 and you need to disable that via build_unflags to have the build_flags switch to C++14 or later).

    If that is your goal, I'd suggest sticking with my original version as it is known to work with the Uno/Mega with the ESP8266 providing a WiFi interface to it. The ESP32 Command Station code (and soon the PCB!) are a considerable improvement over the original code as far as features and there are a number of major changes coming on the ESP32 code base once the development branch has been stabilized and features ported over (recent major rework started).

    The primary feature is dropping all support for Uno/Mega (AVR) and ESP8266 by shifting everything to run natively from the ESP32. The code appears to use the RMT peripheral of the ESP32 to generate the DCC signal (similar to how I do in ESP32 Command Station). There are other changes but they appear to be minor tweaks to the changes that he has made to the codebase as part of porting it to the ESP32.
     
  20. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    One more question @Atani, to convert back to using the Arduino IDE if I want to provide this to non-programmers just so they can use something simple to upload it to a board, is there anything other than renaming the main .cpp file to .ino and making sure any libraries are installed that are referenced in #includes? Any specific version of something or a library you added?
     

Share This Page