ESP32 Command Station

Atani Dec 10, 2017

  1. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Ahh, that may be true. I haven't settled on the L298 exclusively yet as I still need to design the PCB and order some parts for it. I have a few L298 boards which I may sacrifice to test with (no current sense but does have the IC that I can pull).

    Two things the PCB will have will be on board CAN connectors and an external antenna for WiFi. With everything on one board (using premade esp32 board) it will be important to have an external antenna to ensure a strong signal and with a few "off-the-shelf" parts it will be easy for people to assemble from a kit or for me to assemble in bulk.

    I'm also exploring a few extra PCBs for signals, turnouts, control panels (touch inputs!), DCC boosters, block detectors, etc. Each with a PCB of some sort.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  2. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    I've looked at this project for a while, following the progress but not too much in the last year. Very interested but if I'm using a rpi3 and JMRI as a WiFi AP/server would a WiFi base station be right for me? If I understand correctly, the RPi can't handle WiFi throttles AND the connection to the WiFi BS (?). So the throttles would have to connect to the BS and it would update changes back to RPi/JMRI.
    I had envisioned:
    Throttles (Clients)-->WiFi-->RPi3/JMRI (as server)-->USB-->Arduino/DCC++.
    So with the DCC++ESP the model would be:
    RPi3/JMRI (as Client)<-->WiFi<-->DCC++ESP (as Server)<--WiFi<--Throttles (Clients).

    I would like to keep all 'train related' wireless traffic off of my WiFi router. Sorry if this has been asked before, but I haven't seen this 'overall system' discussed.
    Bill
     
  3. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    DCC++ESP32 doesn't replace JMRI (nor should it!) so your first approach with the Arduino is going to be the same for DCC++ESP32. The only difference would be instead of a physical connection from the RPI to DCC++ESP32 it would be via WiFi with the RPI providing a soft-ap with the DCC++ESP32 CS connecting to that as part of it's startup process.

    There is a request to create a soft-ap on the DCC++ESP32 side but that would be very limited in scope and usability as the CS needs to be available for its other duties (mainly generating DCC signals).
     
  4. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Thanks for the response, that clears things up for me a little. I'll have to look into the JMRI pages a little closer.
    I've got an ESP32 ordered and will be digging into the project soon :)
    Bill
     
  5. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Great! For JMRI you can keep using DCC++ as the system type and switch it from a COM port (/dev/ttyXX on RPI) to a network connection, you should be able to use "DCCpp32.local" as the hostname and the default port of 2560. The automatic mode may or may not work with the default mDNS service name that it uses, you can set the service name under advanced settings I believe and set it to "_dccpp._tcp" (without quotes). That should work but I haven't tested it in a long time. I do know the hostname approach shoudl work reliably though.

    If you run into any issues feel free to post them on the forum here and we can go through things and get some better documentation out there if needed.

    Also, what ESP32 are you planning to use?

    Mike
     
    William E Van Buskirk likes this.
  6. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Oh thanks so much, very helpful!! I'll bookmark this page ;)
    I ordered a TTGO T1 (with SD socket), https://www.ebay.com/itm/152827883041 , as it was mentioned at your github. Looks like it's almost the same pinout as the ESP32 Dev Board (there is +5V on the TTGO where the other board has a GND but all other pins are 1 for 1). The only other differences is most other boards have an RF shield over the ESP32 chip but this board doesn't and it has an ext antenna connector ( I'm not sure if I'll need to find a antenna or if there is one built-in on the board).
    I had already setup the ESP32 in Arduino IDE 1.8.8 for another project and assume that I would select the ESP32 Dev Brd as there is no entry for the TTGO. So I'll be installing the libs for this project in the next few days.
    Bill
     
    Atani likes this.
  7. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Perfect, I'm developing a PCB using that board that I'll have available in the near future that will integrate the L298 and a pair of RJ45 jacks for LCC (with MCP2551 for can)

    Sent from my ONEPLUS A5010 using Tapatalk
     
  8. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    The board sounds great, I like the LCC support. Should be interesting
     
  9. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    DCC++ESP32 Command Station v1.2.0 has been released!

    In all there have been 200 commits to the v1.2.0 release since v1.1.1 and many new features. This release is *NOT* compatible with Arduino IDE building nor is it a direct upgrade from v1.1.1 to v1.2.0 for stored configuration settings. The stored configuration settings could not be migrated to the new version unfortunately and will need to be reconfigured after upgrade.

    The Arduino IDE support is not feasible at this time due to a custom partition map which the Arduino IDE does not support at this time without editing one of the default partition maps (not recommended!).

    I'm already working on v1.2.1 for any bug fixes that didn't make it into v1.2.0. I'm also working on expanding the LCC support as it is currently very limited and has a few bugs that need to be resolved.

    v1.2.0 can be found here. If you find any issues please post them on GitHub or here and I'll add them to the tracking list.
     
    chi.sp likes this.
  10. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Ohh boy new Version :)
    So going thru my parts, had stashed some ESP32 boards last year, they are nodeMCU ESP-32S; in addition i just bought a couple new ezSBC (one is for Dr Bunza's simple WiFi throttle). Both carry the same ESP-WROOM-32 module, even the same FCC ID#. They both have ample analog inputs, IOP32 to 39, and more or less the same IOP pins, just different layouts. So feeling I have more then enough for the build.

    As to a motor shield, have a Deek-Robot Motor shield, a couple of the little red heat sinked L298N H Bridge boards and a couple IBT-2s. I'm sure that the red L298 boards can handle a higher max current (3 amps ? but have to find the datasheet), with the beefy heat sink tab, but they don't bring out the current sense lines. My plan is to isolate pins 1 and 15 (currentSen A & B) and jumper to an external LM358 op amp (copy of the motor shield circuit). Seeing as I have to add the PWM inverters anyway, adding an op amp is not a big deal. Any thoughts on adjusting the gain Rs, planning on following the 1K/10K as per the Arduino shield but it would be simple to raise or lower the gain on the external circuit. OTOH it's prob just as easy( or easier) to scale the readings in software.

    On the software tool side, already had the Arduino IDE setup for ESP32s but as the new version is PlatformIO dependent, I jumped into the deep end. Was a little reluctant as there was a post (old) about problems on Win10 (just upgraded from an old XP box to a new quad core Win10 and didn't want to hose the fresh OS install) but I have to say it was real painless installing VS Code and getting the PlatformIO extension. I didn't need to install Git or Python (It didn't ask for them, don't know if I will have to eat these words later ;). Seems like they have streamlined the process alot.
    Bill
     
  11. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Both of these boards are virtually identical, they should have almost identical pin layout. I'm in the process of shifting over to a TTGO-T1 board as it supports an external antenna which can boost the signal strength a bit over the PCB antenna that is on the WROOM-32 boards typically. But that is more of a preference for a "standardized" board type since I'm also shifting to a custom PCB that integrates the ESP32, L298 and LCC components onto one PCB.

    L298 supports up to 2A per channel max per data sheets, the v1.2.0 code sets the current limit to 1.75A max per channel (prog is restricted lower though).

    The Op Amp may be optional, you can follow the same setup as the arduino motor shield uses (100ohm to gnd on 1/15 with pin to Op Amp) and route the output to the analog inputs on the esp32. no code changes should be required.

    Using VS Code is by far the easiest way to do development for arduino/esp32/etc and is far superior to the Arduino IDE since it is a full IDE and not just an editor with a compiler command.

    The Platform IO extension will install a python interpreter as part of it's installation process. If you do find that you need Git or Python at a later date it should be easily installed via the extensions manager or via external installer (though you shouldn't need either tool unless you are using bleeding edge libraries/frameworks).

    There were a few reasons why I have opted to drop the Arduino IDE and that is mostly because of the lack of extendability of the IDE for features which are not available at this time (custom partition map is one). The index_html piece is a bit bigger of an issue due to the hardware timer usage for the DCC signal which will cause crashes if the ISR is active (always is while track is energized) and the flash is accessed (SPIFFS as an example).

    Mike
     
  12. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Looking over the datasheet it doesn't state a higher current handling for one package over the other except for thermal resistance degrees/watts. Sooo not necessarily higher current but more robust(?). The datasheet DID suggests higher output current by running in parallel, IN1 &3 and IN2 & 4. Not sure how one would handle the current sense monitoring but not a major concern for me ATM, 2 amps seems more then enough for me.
    For the moment I'll just copy the Arduino Op Amp circuit as it's known and tested. Simplifies things as it should 'look' like the common Motor shield.
    I'll have to go thru the help files to learn my way around it but looks good. As long as it will handle uploading to the boards we're go to go.
    Bill
     
  13. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Running parallel outputs would require significant changes to the code and the motor shield unfortunately. I wouldn't expect it to be very useful either, it is by far cheaper to put a booster in the place of having the ESP32 (or even an Arduino) feed more than a few amps of power to a single output.

    Click the alien looking icon on the left side and it will bring up the Platform IO command list on the left side and there is an "upload" option in there. It is also available at the bottom of the window as a right arrow icon and the monitor feature is available as an electrical plug like icon. I usually use the upload and monitor option from the Platform IO pane when testing experimental code and when I'm ready to roll it out onto the layout I am now using the OTA option from the web interface to upload the firmware.bin file that Platform IO generates.
     
  14. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Thanks for the pointers. Was poking around the IDE and had a question.

    I was looking at the ESP32 supported boards and while there are several pages of boards, two out of the three I have on hand or on order are missing. Both the TTGO T1 and ezSBC ESP32-01 are not listed. So my question is how to deal with this. Seems to me, many of these boards have the same specs due to the ESP WROOM 32 module being used and only differ by the routing of pins on the carrier board. So should I just declare a similar board when setting up a project?

    I assume these button will show up after I start/load a project.
    Bill
     
  15. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    For most boards I just use a board type of "esp32dev" which is a generic esp32 DevKit-C board type (also the default you would get in Arduino IDE). Switching board types really doesn't do a whole lot other than define a few pin constants for specific boards (Heltec and TTGO-LoRA mainly) that have onboard OLED screens. Almost every board exposes the same pins and footprint but there are a few odd ones that don't expose all of the pins or uses them for specific purposes (OLEDs, LoRA, SD, Audio, etc).

    For the TTGO-T1 be sure to override the SCL and SDA pins, pin 22 is connected to the onboard LED and I have seen some issues with it being used for SCL. I use 21 (SCL) and 23 (SDA) for the TTGO-T1. Other than that I haven't needed to alter any pin mappings for this board from the default esp32dev board type.

    it should show up once you have the platform io extension installed. It may be tied to having an open project though, I haven't looked for that specifically. If you click on the left side bar on the squares icon (Extensions, Ctrl+Shift+E) you will want to have PlatformIO IDE and C/C++ installed/enabled. Other extensions would be optional.

    Mike
     
  16. William E Van Buskirk

    William E Van Buskirk TrainBoard Member

    40
    22
    3
    Thanks again and sorry to be asking so many questions. Yea I have the alien icon for PIO but no upload, been poking around the PIO extension thinking I missed it. I'm sure 'build' & 'upload' is added when a project is opened. I'll get to test building a sample project later but for now got to rest my gray cells ;)
    Bill
     
    Atani likes this.
  17. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    I firmly believe that adding boosters rather than complicating the base station is the way to go. So I actually have gone back to using the original arduino motor shields for my dcc++ projects. No extra hardware and a couple jumpers. I can add a booster on the end to get plenty of power to the track.

    I have an arduino mega running 2 ibt2 drivers and have a seperate current sense module. It works but it looks like a freak show and I would want to make a custom board etc. Rather then that I'm happy to use a no circuit hat version and use 2 jumpers and have no external circuits.

    I am though very interested in the custom board being discussed. If something is clean and easy I'm all for it.
     
    Atani likes this.
  18. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Fyi this project also got me to load platformio. I have figured it out and loaded a board etc so it's good. I fully get that from a technical point of view it is much better. I still though miss the simplicity for us "not as advanced types" of the Arduino IDE.
     
    Atani likes this.
  19. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    If I can ever get the Arduino IDE working for this project I'll definitely document the steps needed for it. But with how PlatformIO makes it relatively easy to build and upload the project, I'm not sure when it might happen. There are also a few other environments that PlatformIO supports which are close to the Arduino IDE like Atom.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  20. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    The only bad question is the one left unasked! You might be right on the extra options. If you download the v1.2.0 release archive and explode it to a directory you can add it to the VS Code workspace (right click and choose add folder to workspace) you might be all set to build and upload.

    Sent from my ONEPLUS A5010 using Tapatalk
     

Share This Page