DCC++ BaseStation with WiFi (ESP)

Atani Feb 11, 2017

  1. UK Steve

    UK Steve TrainBoard Member

    426
    624
    11
    Serial to WiFi is just that!

    It has nothing to do with the original coding, and with a good 'Wang Tongze' shield is a sound solution for WiFi connectivity, no modification is required for it to work. The 'bad' Wang Tongze shields have caused the the problems. I have proposed that users build a shield with a simple proto board and a NodeMCU dev board. The cost is around the same as Wang Tongze, and well within beginner level building skills.

    Such a shield would just require two rows of female headers to accommodate the NodeMCU with connections to 5v Gnd Tx and Rx, easy :)
    download.jpg
     
    Scott Eric Catalano, Atani and esfeld like this.
  2. TexasRailroader

    TexasRailroader TrainBoard Member

    61
    16
    3
    I'm currently using a Mega not an Uno. Don't know if this makes any difference.
     
    Scott Eric Catalano likes this.
  3. TexasRailroader

    TexasRailroader TrainBoard Member

    61
    16
    3
    I assumed the DCC++ sketch would need to be modified in order for JMRI to recognize the wifi shield and connect to the Arduino base station.
     
    Scott Eric Catalano likes this.
  4. Atani

    Atani TrainBoard Member

    187
    197
    6
    The only change that is required in dcc++ is to tell it what your wifi details are and re-upload. JMRI will connect automatically via WiFi when you give it the ip address etc.

    This is true for my version of dcc++. If you use the standard dcc++ and use an esp strictly as a bridge device you connect the TX/RX lines to the arduino and you are done. You configure the esp with static ip or ship and go.

    Sent from my ONE E1005 using Tapatalk
     
    Scott Eric Catalano likes this.
  5. TexasRailroader

    TexasRailroader TrainBoard Member

    61
    16
    3
    What makes the Wang Tongze esp shield problematic is the TX/RX pins line up with the Mega's TX/RX pins requiring additional code in the DCC++ sketch to set up a software serial to reroute the esp's TX/RX pins and change the baud rate.

    Not in my skill set unfortunately.
     
    Scott Eric Catalano likes this.
  6. UK Steve

    UK Steve TrainBoard Member

    426
    624
    11
    I don't see how this is problematic. Once you have set up the WiFi, you have no further need to be using the USB connection for command data. Wang Tongze also has DIP switches to isolate Tx/Rx should you need to go back to USB/Serial for whatever reason. What I'm trying to say is you would not need USB/Serial and WiFi/Serial at the same time for normal operation. So connecting at standard Tx/Rx for both Mega and Uno is the correct way of using the shield.
     
    Scott Eric Catalano likes this.
  7. TexasRailroader

    TexasRailroader TrainBoard Member

    61
    16
    3
    I attempted to get it to work and was unsuccessful. I shipped it off to a fellow DCC++ user, that knows code, for him to take a crack at it.

    Stay tuned.
     
    Scott Eric Catalano likes this.
  8. Atani

    Atani TrainBoard Member

    187
    197
    6
    Life has been a bit too busy for me to do much more than read a few posts here and there for a while now. I am still around though and have finally pushed a bunch of changes into the repository today that have been ready for a while now. There is at least one bug that I have not yet figured out with the new code though, it seems that hitting the emergency stop button causes the socket to close midstream. It goes back to working again if you hit disconnect and while disconnected hit status. I am not 100% sure what is going on yet but will figure it out somehow.

    In any case the libraries have now been included and the issue with webServer.end() being invalid has been resolved. Also a new feature was added via pull request today to support spaces in AP names, it isn't 100% ideal but it does work. I am going to review it further after I have a chance to nail down the bug in the html page.
     
    Scott Eric Catalano likes this.
  9. BandO Fan

    BandO Fan New Member

    7
    0
    1
    I also used a shield. Had to bend a couple of pins out of the way and then add 2 jumpers. Works fine with this software setup. See the pictures and laugh at my board set up.[​IMG][​IMG]

    Sent from my SM-G935P using Tapatalk
     
  10. BandO Fan

    BandO Fan New Member

    7
    0
    1
    The Arduino and esp programs work great! Great job. I have one problem. On my phone when the cab buttons are double pressed it just zooms in and out. Changed the index file and downloaded it to get the correct cab numbers. What am I doing wrong.

    Sent from my SM-G935P using Tapatalk
     
  11. Atani

    Atani TrainBoard Member

    187
    197
    6
    It sounds like the double click event is not being sent, most likely due to the phone intercepting it and doing as you say it is doing. We will likely need to add a secondary option for changing cab numbers, something like : select cab A, click "change loco" and it will fire the double click event. I don't know if I can get this in right away but will see what I can come up with.

    When I tested it on my phone it was sending the double click event, the only other thing i can think of is the taps are not close enough to the same spot or maybe they are too close. I don't remember doing anything special on my phone for testing this though.
     
  12. William E Van Buskirk

    William E Van Buskirk New Member

    5
    0
    1
    Great work Atani. I'm very interested in setting this up and have a few dumb questions.

    I've got Arduino 1.6.13 installed with the ESP8266 core installed via Boards Manager option. If I understand correctly, this includes the required libs OTA, DNS and WiFi and the other two, ESPAsyncTCP and ESPAsyncWebServer, are included in your package? So I don't need to install other packages? Been looking over David Bodnar's ESP page and think it's out dated.

    Another slight question about the SPIFFS setting. With this IDE ver, under Tools there is 'Flash Size' with options for '4M(3M SPIFFS)' or '4M(1M SPIFFS)' when set for a HUZZAH board. I have a couple ESP8266 WiFi Witty Cloud dev boards coming, which aren't listed in the IDE. I read that I could set the Board to the AdaFruit HUZZAH for the Witty Cloud board, but don't know for sure. I assume that 'File Size' settings replaces the 'Tools>ESP8266 Sketch Data Upload' option you mentioned on your GIT Repo page?

    Thanks agasin for your efforts,
    Bill
     

Share This Page