DCC++ Wifi Controller on an ESP8266-07

Jimbo20 Nov 1, 2017

  1. Jimbo20

    Jimbo20 TrainBoard Member

    274
    177
    10
    After a few weeks experimenting, I have managed to get my mini controller working! My layout is a very small (41"x9") N-Gauge Inglenook Sidings plank layout. DCC++ is installed on an Arduino Nano, which has an ESP8266-01 connected to it to provide the WiFi comms. This ESP also automatically runs a railbus to and fro, pausing at either end for a minute before making the return journey.

    The Handheld controller contains an ESP8266-07, and a 0.96" OLED display. As I am not likely to need to manually control more than one loco at a time I am using a standard pot for the speed control. There are nine push buttons, not all of which are used yet. The code is based on Dave Bodnar's controller (Thanks Dave!). The 4 buttons labelled A-D set the points for each of the four possible routes that the shunter can make from left to right of the layout. The pause & start buttons control the railbus automatic sequence, and the Uncouple button operates the electro-magnet for the uncoupling of wagons.

    I am using a websockets library in the ESPs, this means I can easily make use of duplex (bi-drectional) comms to the controller. The controller monitors the data packets from the DCC++ Basestation, and for example constantly shows the points (turnouts) settings in a pictorial format on the OLED display.

    I've disabled the store/read functions in EEPROM - Apparently that works differently in the ESP, so until I've found how it works, I've hard coded the Loco address in.

    The code is not pretty - it is still very much work in progress.....

    Attached is the code so far and the schematic of the controller. I haven't shown the necessary pullups/downs that the ESP-07 needs to operate or flash etc.

    cont1.jpg cont2.jpg wifi-cont-1_schem.jpg
     

    Attached Files:

  2. esfeld

    esfeld TrainBoard Member

    436
    381
    15
    Jim
    Thank you .... a beautiful job of construction, coding and documentation .... much appreciated. Not to burden you further but I would love to see pics or video of the layout.
    Steve F
     
    Scott Eric Catalano and Jimbo20 like this.
  3. Jimbo20

    Jimbo20 TrainBoard Member

    274
    177
    10
    Hi, thanks for your comments Steve. I am hoping to get some photos of the layout and perhaps a vid of it on here in the next day or two....
    Jim
     
    Scott Eric Catalano likes this.
  4. Jimbo20

    Jimbo20 TrainBoard Member

    274
    177
    10
    As promised here's a couple more photos and a (slightly blurred) video of the controller in action...


    general1.jpg
    underneath1.jpg



    Jim
     
  5. esfeld

    esfeld TrainBoard Member

    436
    381
    15
    Jim
    If I was impressed before, I am even more impressed seeing it in action ....... very well done indeed!
     
    Scott Eric Catalano and Jimbo20 like this.
  6. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    I was checking out youtube videos this morning, and then ran across your post. So I gotta ask -- is this you?

    If not, it's quite a coincidence. The yard is identical except you have one extra leg, and the trains look like the same brand.
     
    Scott Eric Catalano and Jimbo20 like this.
  7. Jimbo20

    Jimbo20 TrainBoard Member

    274
    177
    10
    Scott Eric Catalano likes this.
  8. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    I found some other videos by the same guy, and it looks like he did add that extra leg later on...

    So are you using an arduino as the loco decoder or does it use a commercial unit? I spent the holiday getting the DCCppESP32 base station running, now I just need to find some code to load into the loco's computer.
     
    Scott Eric Catalano likes this.
  9. Jimbo20

    Jimbo20 TrainBoard Member

    274
    177
    10
    My Locos both have commercial decoders (Laisdcc) The DCC++ BaseStation is an Arduino Nano (with an ESP8266-01 for Wifi comms), the points (turnouts) decoder is an Arduino Nano, and the handheld WiFi Throttle is an ESP8266-07.
     
    Scott Eric Catalano likes this.
  10. Shdwdrgn

    Shdwdrgn TrainBoard Member

    250
    182
    11
    Nice setup, I can't wait to also get something operational. I just ordered some parts last night to try and set up an attiny85 with an I2C board that controls 16 servos, hoping to use that for turnouts. I'm also using a raspberry pi to manage dhcp and create a self-contained network. So much more work to do still, but I'm having fun along the way.
     
    Scott Eric Catalano likes this.
  11. Jimbo20

    Jimbo20 TrainBoard Member

    274
    177
    10
    Because my house router is at the opposite end of my house, I found that the wifi signal strength to the ESP's were a bit flakey. I now have the layout set up as a local network, so the ESP8266-01 on the Basestation is the AP, and the Throttle(s) are clients, but with the IP's hard coded in. This has the advantage that I can take my layout offsite and I don't have to change any of the wifi settings. Also having the IP's hard coded makes the connection time very fast (- it doesn't have to wait for any DHCP)

    jim
     

Share This Page