Serial Communication between 2 ESP8266(black color)

Farhan Nov 28, 2018

  1. Farhan

    Farhan New Member

    7
    1
    1
    Hello,
    I have created a throttle based on Mega and a touch screen shield that is using TX (from throttle) RX(to DCC++) wires for the serial communication to send commends from throttle to DCC++ , I do have 2 ESP8266(black color) and want to perform a wireless serial communication instead of wired connection between Throttle and DCC++ without using WIFI , is it possible with the available hardware and no code changes to DCC++ side? I know it is possible with HC12 but I don't have HC12 around and ordering will take ages to come from china.

    Please advise if this is possible
     
  2. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Hi. This certainly is possible, I have done this myself using 2 x esp8266's. Unfortunately I am midway through a house move so my layout and computers are all boxed up for a couple of months. However basically what I did was set up the Esp that's connected to the dcc++ basestation (via tx and RX) as an Access point (ap mode), and set up the Esp that's connected to the throttle as a client (station mode). So it is WiFi but it is its own network, and there is no router involved. I seem to remember that I used a websocket library for the esp's because it made the comms more reliable and faster.

    Here's a demo of the throttle I made earlier this year. This was a later version where I incorporated the throttle sw into the esp8266 (-07) thus not needing the arduino, but the principle is the same. The earlier throttle also shown in the video does use an arduino nano and an esp8266-01.

    m.youtube.com/watch?v=Ps27clLfT0Y
     
    Last edited: Nov 28, 2018
    Farhan likes this.
  3. Farhan

    Farhan New Member

    7
    1
    1
    Thanks for the quick response I saw your video ans subscribed too. looks awesome.
    Quick question about DCC + side, did you apply any code changes to DCC++ code or they were unchanged? if they were changed was that significant or minor.
    How are you driving turnouts is it through Accessory decoder ? this will be my next topic as soon as I get my Optocoupler
     
  4. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    I didn't change any base station code in order to use the esp's for the comms link. The esp's basically replaces the wires between bs and throttle. (However I have since modified the bs code for other functionality eg the bs is only an arduino nano and I needed more input pins for magnetic sensors, so I added a multiplex library.)
    An advantage of using the esps compared with the hc12 modules is that the esp comms when using websockets is bi-directional, so the throttle will receive data from the bs, as my video demonstrates. For example the throttle's screen shows the live status of the turnouts. This is acheived using the serial data that the bs returns when the throttle asks for a turnout status every couple of seconds.

    Regarding the turnouts I only have 4 on my layout (servo operated), I use another arduino nano running geoff bunza's decoder code. It works perfectly.
     
  5. Farhan

    Farhan New Member

    7
    1
    1
    Awesome and once again thanks for the response
    Good luck with you move
     

Share This Page