DCC++ BaseStation with WiFi (ESP)

Atani Feb 11, 2017

  1. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    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

    90
    26
    7
    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

    90
    26
    7
    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

    1,460
    1,697
    36
    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

    90
    26
    7
    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

    453
    683
    12
    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

    90
    26
    7
    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

    1,460
    1,697
    36
    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
    2
    4
    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
     
    Scott Eric Catalano likes this.
  10. BandO Fan

    BandO Fan New Member

    7
    2
    4
    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
     
    Scott Eric Catalano likes this.
  11. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    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.
     
    Scott Eric Catalano likes this.
  12. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    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
     
    Scott Eric Catalano likes this.
  13. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Yes, everything should be available provided you are using the Arduino IDE or Eclipse plugins. David's page is a great starting point for learning the ESP devices, things have evolved since he set up the page likely but I wouldn't consider the page entirely out of date.

    Flash Size is not the same as SPIFFS. The Flash Size setting is used by the IDE to compile the code and leave a certain portion of the memory on the ESP device available for SPIFFS, think of it as a flash drive where the ESP can read/write files via the web server. As long as you have the ESP project open and have it associated with an ESP device type you should be able to find the SPIFFS/data upload option under the tools menu.

    For the Witty Cloud boards, I haven't seen or used these but they should be able to fit into an existing board type (one page I saw said to use WeMos D1 as the board type).
     
    Scott Eric Catalano likes this.
  14. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I have stopped development on the ESP8266 portion of the base station at this point and will be focusing on a new approach... Eliminate the Arduino..

    Coming soon...
    https://photos.app.goo.gl/LdT518CNtmmjZ9IJ3
    and
    https://photos.app.goo.gl/CANzuUFOPVlB9QZ33

    There is currently a bug in the signal generator code which I will be resolving this weekend but otherwise this is going to be my new base station, an ESP32 with an Arduino motor board and an OLED screen for status. The base station itself will serve up the WiFi and web based access for JMRI etc.

    The code that is running on this ESP32 is not the same as in my forked repository and will be in its own repository as soon as finish the cleanup and testing this weekend.
     
    Scott Eric Catalano likes this.
  15. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    been a while since i posted, but i pop in now and then.

    first thoughts are... What???:eek:

    Can't say as i have used a WeMos, and due to Aspergers (among other things), i am resistant to change. but i kind of like the modular aspect of the Arduino, as whatever hardware the user needs (serial, ethernet, WiFi, direct command), can be plugged in and used with a few code changes. personally i don't like being locked in to an option. (although i suppose using only Arduino is a sort of locked in option...)

    I haven't found space to dust off my DCC++ hardware yet, but i wonder if it will all be obsolete when i do. I suppose i do still have my rendition of the code (pre-ESP8266, ethernet shield).

    ~Travis
     
    Scott Eric Catalano and esfeld like this.
  16. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I like the Arduino for the same reasons as you do but I am reducing the complexity of the base station by eliminating one component that is not needed since the ESP32 can provide the same functionality and more.

    The WeMos labeled board I showed before is not actually from WeMos, it is a third party clone of a different board that was "branded" with that logo as a way to sell it easier. It is a clone of an Espuino32 board with the USB port changed.

    I have three different ESP32 boards..
    https://photos.app.goo.gl/qm2uCmhkL1SIn4YA2

    The one on the left is close to the standard ESP32 dev board, it is a clone likely though. The one in the middle is the one I have been using so far since it has the Uno R3 headers for compatible shields. The one on the far right is another WeMos clone board, it is similar to the WeMos D1 Mini (side by side: https://photos.app.goo.gl/eVONDjXkWHANgQKN2)

    I also included an ESP-01 for size reference in the three board picture.
     
    Scott Eric Catalano likes this.
  17. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    well, i will follow allong in the background, but i still like my Arduino's ;) i recently discovered this from Adafruit: https://www.adafruit.com/product/3060, and i may port my copy of DCC++ to it, when i dust off my train. it connects quick, and seems to be rock solid.

    seems like where you see value in an all-in-one board, i see value in off-board modules to facilitate future expansion upgrades. to each their own, i guess. :D

    ~Travis
     
    Scott Eric Catalano and esfeld like this.
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Small update on this project to remove the Arduino and use the ESP32 as the base station... Almost everything is working perfectly, I need to sort out an issue with the current sense on the arduino motor board (A0/A1 are wired to ADC2 which is not usable with WiFi active, more on this once I publish the code). But the basics work so far and now to move towards code cleanup and testing.
     
    Scott Eric Catalano and UK Steve like this.
  19. Shtirlits

    Shtirlits TrainBoard Member

    37
    3
    9
    Some guy sells it in eBay now. It is listed as "DCC Digital Command Station w/ WiFi. DCS Mega 2560. 5 amps. N HO O scales." Probably the station works without troubles now.
     
    Scott Eric Catalano likes this.
  20. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Not much can be done about eBay sellers when the code is open source. The most that can be done is submit a takedown if they do not link to the source code. But that is mostly counter productive.

    And no it being listed on eBay does not mean it is bug free or stabilized. It just means someone has bundled free software with hardware together. It will likely not work out of box either.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.

Share This Page