Ethernet Shield Frustrations

TwinDad Jan 26, 2017

  1. Will G

    Will G TrainBoard Member

    19
    13
    2
    Had some success with a new ESP8266 D1 mini clone tonight.

    Once past the teething problems (duff USB cable), I flashed it with serial-WiFi bridge code. Haven't tested it with the Mega running DCC++ yet but at least I can now Telnet into it and use AT commands to set the AP details, and I have seen it connected to my home WiFi network. Hopefully wiring up the RX and TX pins to the Mega will allow me to send serial input directly to the Mega and control DCC++.


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.
  2. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Is this what I'll want to do in order to use the ESP8266 as a wi-fi adapter for my Mega?
     
    Scott Eric Catalano and KC Smith like this.
  3. Will G

    Will G TrainBoard Member

    19
    13
    2
    I think so. I believe you (and I) want the ESP8266 to function as a serial-WiFi bridge, just echoing the commands it receives over WiFi to its serial port and vice versa.

    The D1 mini has way more functionality that required to do this job, one of the ESP-01 modules would do, however I think trying to get my Mac to communicate with it would be just as frustrating an experience as with my original ESP-12E module.

    Unless you're proficient with serial port connections or prepared to spend quite a bit of time learning, my recommendation would be to get an ESP8266 module with built-in USB port (it should therefore have the USB-TTY converter built-in too). That's just my experience though! It may be different on a PC.


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.
  4. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    do you have an in circuit serial programmer (ICSP)? i use a USBasp clone from eBay. it would allow you to still program the board, and even reload the bootloader. if the USB is truly dead, then at least you could program it. it would still work for an ethernet connected base station.

    ~Travis
     
    Scott Eric Catalano likes this.
  5. Will G

    Will G TrainBoard Member

    19
    13
    2
    Ok, now I think I was wrong - setting the COMM_INTERFACE to 1 in DCC++ Config.h, in order to get it to act as a server, means that it will be trying to send commands over the SPI. So the commands from the Mega won't be coming over the serial interface (Tx & Rx pins), meaning the code on the ESP8266 needs to echo the commands received over SPI out over WiFi - I think. Change in code on the ESP needed.


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.
  6. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    I will be posting later today the DCC++ base station and ESP code that has the web throttle integrated into it as well. This version handles the needs for both DCC++ and the ESP in a decent manner and does not rely on the rather slow AT command set.
     
    Scott Eric Catalano likes this.
  7. Will G

    Will G TrainBoard Member

    19
    13
    2
    Atani, will that be code to make the ESP work as a WiFi shield, or as a throttle?

    Will you be posting it to the DCC++ GitHub?


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.
  8. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    The code I have uses the ESP as an i/o device for DCC++ base station and exposes a web socket based throttle interface. Eventually it may also expose a WiThrottle interface as well.

    Mike
     
  9. Will G

    Will G TrainBoard Member

    19
    13
    2
    Mike,
    That sounds promising, I was trying to get to the point where I could use WiThrottle, so that I didn't have to develop any code to control locos from my phone.

    I've been digging around on the web trying to work out whether someone has already written the code to make the ESP function as a WiFi-SPI bridge, so far without luck. As you've probably gathered I'm pretty new to serious interface coding; I'm happy using and arduino to control motors based on input from sensors, just have no experience of real data transfer.

    The code I've got on the ESP at the moment allows me to send serial commands over WiFi using telnet and control the Mega like that, but that's only a small step towards getting WiThrottle (or some other iOS throttle) to work.


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.
  10. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Instead of looking for WiFi-SPI bridge, why not tweak the Base Stations's interface code to point to whatever serial port (not the default serial/USB port) the WiFi card is attached to? That should be easier... and the Mega has four to choose from...
     
    Scott Eric Catalano likes this.
  11. Will G

    Will G TrainBoard Member

    19
    13
    2
    I've thought about doing that but I think I'd then lose the WiThrottle server aspect offered by the Mega, wouldn't I?


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.
  12. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    That is pretty close to what I have done with my modifications. I am using Serial1 on the Mega and SoftwareSerial on others. I am planning on allowing both Serial and Serial1 to be used for input once I get to that point so Serial can still be used for debugging if necessary from PC.
     
    Scott Eric Catalano likes this.
  13. chi.sp

    chi.sp New Member

    7
    12
    7
    Hi Will G and all,

    Have you tried the server sketch shared by UK Steve on the Ethernet & Wifi thread (http://www.trainboard.com/highball/index.php?threads/dcc-ethernet-wifi-shield.90352/page-3) , post # 42 ? I think it gives you what you want. It sets up an ESP8266 as a TCP and Websocket to Serial interface so you can run 1 TCP and up to 3 Websocket connections simultaneously. I flashed it on a ESP-01 using Arduino IDE and have JMRI and Controller connected to basestation with any issues. You only have to prepare Arduino IDE to be able to compile ESP boards, download two libraries (Esp Async Webserver and Esp Async TCP) and connect RX/TX ESP terminals to Arduino TX/RX. The great advantage I see in this solution is that you have a Wifi connection with original default DCCpp software configuration (serial interface without ethernet) so you can even use an Uno driving basestation, because all connection tasks is carried by ESP chip.

    I have no experience with all these protocols programming. I'm just trying to learn reading all postings on DCCpp threads and experiment with them, so I would like to know what is the difference between UK Steve's solution and what Atanis is developing with ESP boards? Are they almost the same thing? Sorry for the inexperience and also my English (it's not my native language) :)

    Thank you all!
     
    Scott Eric Catalano and UK Steve like this.
  14. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    chi.sp

    Your grasp of English is very good!

    And thank you kind Sir for bringing this to everyone's attention once again, it is as you are trying to say all old news. We've been there and done that so to speak. I'm pleased at least you found some use of my earlier work.
    There is more to come, keep watching......

    Regards

    Steve (UK).
     
    Scott Eric Catalano likes this.
  15. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Hey Steve can your sketch be configured for say 3 TCP and 1 websocket or 4 TCP or 2/2?
     
    Scott Eric Catalano and UK Steve like this.
  16. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Mark

    For sure, but can you think of a setup were you would need such configurations?

    If you connect JMRI on TCP , then throttles and other JMRI instances would connect via JMRI servers.

    WebSockets can serve multiple instances of my throttle and JMRI on the one TCP.

    Multi instances of your WiThrottle on TCP??? Well yes and that's right were we are at in development no?
     
    Scott Eric Catalano likes this.
  17. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Yeah... I'm thinking of my personal interest... a shelf switching puzzle powered by DCC++ ... it will "live" in my office at work... I *might* want one web throttle, but I mostly would want phones to be connected... again, likely not more than one, but ya never know... I was just wondering about the capability.

    The layout needs to be fully self-contained, so JMRI would have to be on... e.g. a Raspberry PI. Totally do-able, but if I could have only the Arduino stack, that would be preferable.
     
    Scott Eric Catalano and UK Steve like this.
  18. chi.sp

    chi.sp New Member

    7
    12
    7
    Hi Steve,

    Thank you for your kind words, but especially for all your great contributions to DCCpp project.
    Maybe Atani's approach show us other usage concepts.
    So for those like me, on the non pro side, we're very grateful with all knowledge shared by all of you and we're following with much interest and pleasure.

    I know it's not the right thread, but as I am already here, I have to extend my thanks to other great contributors like Dave Bodnar, w8one and dj79 (software alternative solution for dcc signal generation works beautifully)

    And, of course, Gregg, who deserves a statue for sharing this revolutionary project and TwinDad for the JMRI bridge, among other good ideas, and his amazing VSD project, IMHO so revolutionary as DCCpp for model railroad world.

    Sorry for the thanks session, but it's been in the throat for a long time.(y)
    Thank you all guys!!
     
  19. Simon Mitchell

    Simon Mitchell TrainBoard Member

    113
    105
    7
    +1 on everything chi.sp just wrote.
     
    Scott Eric Catalano and sboyer2 like this.
  20. Will G

    Will G TrainBoard Member

    19
    13
    2
    Hi chi,
    Thanks for the pointer to Steve's code, I was certain there was something out there that did what I wanted! I have flashed the code to the ESP but so far haven't managed to get anything connected to a web socket. More experimentation needed!


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.

Share This Page