Mark DiVecchio's O-Gauge Train Layouts

1992 Layout Page

2006 Layout Page

2009 Layout Page

P&LE Postcards by Howard Fogg 

Plasticville Buildings

Portable Layout Page

Train Clubs

Bing Track

Remote Train Control Program

YouTube Channel

OOK Radio Support

Technical Videos

3D Prints for my Layout

More RTC Videos

ADPCM - Playing clips from .mth sound files

P&LE McKees Rocks Locomotive Shop
3D Printer Project

White Tower Restaurant
3D Printer Project

RFID Train Detection

Engine and Car Operation
Hints and Tricks

RFID Tag Programmer using PN532

RTC Control Language - Scripting


More RFID Tag Videos

RTC Control Language - Signaling


WiFi Support for RTC

This Page last updated on .

I started developement of this web page in January 2022. It will be under construction for a while.

On this page, I describe the work that I've been doing to implement the use of WiFi to connect to my layout. I started on the coding around September of 2021.

When I started my work on RTC, I used a wired interface to connect the PC to the TIU. Later, I learned how to use a CC1101 radio to connect directly. The radio was connected to the PC using a USB cable. Now the ultimate(?) implementation - I can get rid of the USB cable by using WiFi to connect to the Radio. I extended this so that now I can also connect using WiFi to my RFID tag detectors distributed over the layout.

Though connecting to the TIU via WiFi is nice, the real advantage to reduced wiring is having a dozen or more RFID tag detectors around my layout and not having to have them wired together in series and then wired to my computer. If you look on my RFID tag detectors page, you can see the "old" RS232 wired connection scheme.

This is based on the work that I did for the Remote Train Control (RTC) program and OOK Radio Support.



Prior Art 

Mike Hewett

Mike always seems to be acknowledged on my web pages and he deserves it. Mike learned about the ESP8266 based NodeMCU board and started to use it in his projects. After I saw his success and how easy it was to use, I started to rewrite my RTCModemE and RTCNFCIRQ programs to use that device.



My Ideas

I figured that could replace the USB connections for both my CC1101E radio (which lets the RTC program talk with the TIU) and for my RFID tag detectors (which send tag information to the RTC program).

Here is a block diagram for reference:





ESP8266

    features
        1MB program memory
        64KB data memory
        3MB data space ( see the LittleFS below. Simulates a small hard disk.)

    web page

ebay

    there are many on eBay. Here is one example.

   All are under $5 each as of July 2022.

Adruino IDE

    Use Arduino IDE 1.8.16



CC1101 Radio by Elechouse


The radio I use is a TI CC1101 based radio from Elechouse. Note that the image on their web page says RF1100SE but I received the correct version labeled RF1191SE-V3.1. This is a 3.3V deviceand no signal pin can be connected to a 5V Arduino output. In my original wired system, I used an Infiduino that could be run off of 3.3V. With the ESP8266, its even easier since that is a 3.3V device.




Compiling a sketch which uses the CC1101 radio from Elechouse requires my libraries CC1101E_OOK_ESP and C1101E_OOK_ESP_SPI. You can download it from here. In your local Arduino Library folder, create a folder named "CC1101E_OOK_ESP" and put the CC1101E_OOK_ESP library files in it, then create a folder "CC1101E_OOK_ESP_SPI" and put the CC1101E_OOK_ESP_SPI library files in it.


Ported the RTCModemE sketch to the ESP8266 without using WiFi - RTCModemESP

The current version of the RTCModemE sketch runs on a Seeeduino/Infiduino. This porting effort moved the sketch to run on an ESP8266. This was done in two steps. This section describes step 1.

 
Cost:
ESP8266                         $5.00
RS1101E-V3.1 Radio    $18.90 (as of Oct 2022)

https://www.elechouse.com/product/915mhz-cc1101-wireless-module/
The illustration shown is labeled RF1100SE but this specific 915Mhz version is V3.1.

This setup is powered by the USB cable.

Wiring


Signal Name ESP8266
Pin
Elechouse CC1101E
Radio
Pin
VDD/VCC 3V VDD/VCC
GND G GND
MOSI D7 SI
MISO D6 SO
Select D8 CSN
SCLK D5 SCLK
GDO2 D2 GDO2
GD00 D1 GDO0



Ported the RTCModemE sketch to the ESP8266 using WiFi - RTCModemWiFi

The current version of the RTCModemE sketch runs on a Seeeduino/Infiduino. This porting effort moved the sketch to run on an ESP8266. This was done in two steps. This section describes step 2.



Cost:
ESP8266                          $5.00
RS1101E-V3.1 Radio     $18.90 (as of Oct 2022)

This setup is powered by track voltage.

Wiring


Signal Name ESP8266
Pin
Elechouse CC1101E
Radio
Pin
VDD/VCC 3V VDD/VCC
GND G GND
MOSI D7 SI
MISO D6 SO
Select D8 CSN
SCLK D5 SCLK
GDO2 D2 GDO2
GD00 D1 GDO0


Ported the RTCNFCIRQ sketch to the ESP8266 - RTCNFCWiFi


The current version of the RTCNFCIRQ sketch runs on a Seeeduino/Infiduino. This porting effort moved the sketch to run on an ESP8266.


Again I have to thank Mike Hewett for reminding me of wirewrap.

My original test bed connections were done with what is call "Dupont" wires. These are nothing more than wires with push on connectors on each end. Nice and easy to use but prone to coming loose. Good for prototyping. Mike showed me some of his work using wirewrap. When I started in the computer design business in 1970, wirewrap was still common and acceptable even for production work. Look here : National Advanced Systems.
Mike used a hand wirewrap tool but I had a couple very old Gardner-Denver wirewrap guns. I dug them out and replaced the long dead rechargable battery with 2 D cells and I was off. I used the small green proto board from MPJA.com as a base.


Cost:
ESP8266                                     $5.00
Tag Reader from Elechouse        $34.50 (as of Oct 2022)   

https://www.elechouse.com/product/pn532-nfc-rfid-module-w-external-antenna-updated-version/

The ESP8266 has enough pins to control two tag readers. I have 13 tag readers on my layout controled by 8 ESP8266.

Signal Name ESP8266
Pin
Elechouse PN532 RFID Module #0
Pin
Elechouse PN532 RFID Module #1
Pin
VDD/VCC 3V VDD/VCC VDD/VCC
GND G GND GND
MOSI D7 MOSI MOSI
MISO D6 MISO MISO
S Clock D5 SCL SCL
IRQ #0 D2 IRQ --
SS #0 D0 SS --
IRQ #1 D3 -- IRQ
SS #1 D1 -- SS


Wrote a new sketch to emulate an AIU using WiFi - RTCAIUWiFi

Once we understand the basic WiFi operation, we can extend our hardware to do a lot. In this case, I've written an new sketch, called RTCAIUWiFi, which emulates either 8 AIU accessory channels or 4 AIU switch channels.

Each ESP8266 runing that sketch can emulate 8 Accessory channels or 4 Switch Track channels. With each ESP8266, you specify the TIU number, AIU number and the starting channel number. Then the sketch will respond with relay activation for the next 8 Accessory channels or the next 4 Switch Track channels. You can have as many of these ESP8266 + 8 Relay Bank as you want. The TIU number can be any number from 1 to 5 - even if you don't have an actual TIU with that number.




Cost:
ESP8266            $5.00
8 Channel Relay Module Optocoupler LED (blue)  - Many on eBay          Here is the one I bought. At the time, it was $6.99 (as of Oct 2022)


Here is a block diagram for reference that adds an AIU Emulator:

The 8 relay module requires 5v to operate the relays. remove the jumper on the VCC to JD-VCC pins.




Signal Name ESP8266 8 Relay Module
-- GND
IN1 D0 IN1
IN2 D1 IN2
IN3 D2 IN3
IN4 D3 IN4
IN5 D5 IN5
IN6 D6 IN6
IN7 D7 IN7
IN8 D8 IN8
-- VCC
GND G GND
VCC 3V VCC
JD-VCC (5v) VIN JD-VCC




Power supply

Converts  track AC to 5 volts

Many available on eBay. https://www.ebay.com/itm/284059932130.






RTCModem WiFi Configuration




After you download the RTCModemWiFi program into the ESP8266, it will start an Access Point. If you look on your phone, you will see the new AP listed as RTCModem. Tounch on that AP to connect to it.

The phone will proceed to connect to the RTCModem AP.


The phone should connect up and you should see the RTCModem AP "connected without internet".








Then startup a web browser such as Firefox or Chrome. Enter this IP address into the Address Bar:  192.168.4.1. Press GO. You should see this screen. Here is were we enter the information that the RTCModemWiFi program needs to communicate with your computer via the WiFi Router.
Enter:
The SSID of your router
The WiFi password of your router
DO NOT change the Port number as the RTC expects this value.

Then click on [Setup CC1101E Radio WiFi].

You should see this screen indicating that the device is rebooting and will connect up the WiFi Router.











RTC RFID Tag Detection Configuration



After you download the RTCNFCWiFi program into the ESP8266, it will start an Access Point. If you look on your phone, you will see the new AP listed as RTCRFID. Tounch on that AP to connect to it.

The phone should connect up and you should see the RTCRFID AP "connected without internet".

Then startup a web browser such as Firefox or Chrome. Enter this IP address into the Address Bar:  192.168.4.1. Press GO. You should see this screen. Here is were we enter the information that the RTCNFCWiFi program needs to communicate with your computer via the WiFi Router.
Enter:
The SSID of your router
The WiFi password of your router
The detector number of this device
The number of tag readers connected to this device.

Then click on [Setup RFID WiFi].

You should see this screen indicating that the device is rebooting and will connect up the WiFi Router.














RTC AIU Emulator Configuration



After you download the RTCAIUWiFi program into the ESP8266, it will start an Access Point. If you look on your phone, you will see the new AP listed as RTCAIU. Tounch on that AP to connect to it.

The phone should connect up and you should see the RTCAIU AP "connected without internet".

Then startup a web browser such as Firefox or Chrome. Enter this IP address into the Address Bar:  192.168.4.1. Press GO. You should see this screen. Here is were we enter the information that the RTCAIUWiFi program needs to communicate with your computer via the WiFi Router.
Enter:
The SSID of your router
The WiFi password of your router
Don't change the Port number as the RTC expects this value.
The TIU number that this device should respond to
The AIU number that his device should respond to
The starting channel number for this device

Then click on [Setup AIU Emulator WiFi].

You should see this screen indicating that the device is rebooting and will connect up the WiFi Router.














Running Setup in the RTC Program

Though the changes to the RTC Program to support WiFi were spread throughout almost every module in the program, for you, the user, the Setup window is where you tell the RTC Program to use WiFi .

After you start the program, press the [Setup] button. You will see this window:

First, as a review, look at the "Serial Ports" tab. You may have seen this before because this is how to tell RTC which USB serial port to use for the Radio and RFID detectors. This tab works just the way it worked back when it was the only option possible.

You can press the [Scan] button to find all of the available USB serial devices on your computer. Click on the [X] Enable button and use the up/down arrows in the spinners to set the port number.

I still use a wired USB  port for the Radio communications. I have developed RTCModemWiFi to do this over WiFi but the wired USB is simplier to use. In this window, I have selected COM11.

This setup window also lets you choose a wired connection to the RFID tag detectors - but now the WiFi connection is a much better choice. Continue reading.
Now if you are going to use WiFi, you have to have built up one or more of the ESP8266 devices described above.

Click on the "Host IP Address" tab. Press the [Scan] button. If only one Ethernet interface is present on your computer, the IP address for that interface should appear in the drop down box. If it does not or if you have to select from several IP addresses, do that so that the correct IP address appears.

The vast majority of home computers only have one Ethernet interface so it should rarely be necessary to make a selection.

Now click on  the "WiFi Ports" tab.

Here is where we do the heavy lifting.

If you have created one or more, RFID detectors, enable the RFID WiFi by clicking on the [X] Enablebutton next to it. You don't have to do any selection as the RTC program and the RFID detectors will find each other. RTC can communicate with up to 254 RFID detectors over WiFi. Note that WiFi routers usually have a limit on the number of WiFi devices that can connect. I have 8 tag detector ESP8266 on my layout so I had to make sure that my router could connect to 8 WiFi at the same time. You may have other devices also connected to WiFi (like printers, cell phones, etc) so you have to take this into account.
If you are using ESP8266 based AIU Emulators. You have to enable them here. Click on the [X] Enable button. The IP address of 239.255.200.3 and port of 8890 should not be changed.

I've included this window for information only - I don't think the AIU Emulator is ready for prime time yet. If you
want to use it, send me an email.

Click on [Hide & Save] to save all of your settings.


Sketch source code and pre-compiled binary

I'll try to keep these zip files up to date but if you are going to seriously work with them, email me to be sure you have the latest versions.

RTCModemWiFi        This is an ESP8266 NodeMCU based sketch using WiFi to connect to the CC1101E - 900MHz radio which communicates with the TIU.

RTCNFCWiFi            This is an ESP8266 NodeMCU based sketch using WiFi to connect RFID tag detectors to the RTC program.

RTCAIUWiFi            This is an ESP8266 NodeMCU based sketch using WiFi which emulates either 8 accessory channels or 4 switch channels of the AIU.

RTCEngineWiFi          This is an ESP8266 NodeMCU based sketch using WiFi which emulates an engine.

If  you try to compile these yourself, I used the Arduino IDE version 1.8.16.

The following additional libraries are needed:

    Needed for all sketches:
DoubleResetDetector v1.0.3 by Stephen Denne
ESP_DoubleReset_Detector v1.3.2 by Khoi Hoang
esp8266_mdns v 1.1.8 by mrdunk
ESP8266TimerInterrupt v1.6.0 by Khoi Hoang
RTC_NFC by Mark DiVecchio
    Download from:

    Needed for RTCModemWiFi
CC1101E_OOK_ESP v2.0.0 by ElecHouse, modified by Mark DiVecchio
CC1101E_OOK_ESP_SPI v2.0.0 by ElecHouse, modified by Mark DiVecchio
   Download from :
    http://www.silogic.com/trains/RTC/CC1101E_OOK_ESP-2.0.0.zip
    http://www.silogic.com/trains/RTC/CC1101E_OOK_ESP_SPI-2.0.0.zip

    Needed for RTCNFCWiFi
PN532_SPI by Adafruit Industries and Seeed Studio modified by Mark DiVecchio
PN532_modified by Adafruit Industries and Seeed Studio modified by Mark DiVecchio
NDEF by Adafruit Industries and Seeed Studio
    Original at   https://github.com/elechouse/PN532
    Download modified library from:




Newest WiFi based RFID Detectors on my Layout

I have 8 Detectors with 13 Tag Readers on my layout. I've hidden the 8 Detectors inside of buildings - mostly Plasticville but one 3D printed shed.

In some of these photos, you can see LED's lit up. The tag reader itself has a red power led and the ESP8266 has a blue led under control of the sketch running. My RTCRFIDWiFi sketch blinks the blue led on each tag detection.

All of these ESP8266 NodeMCU devices has Over-the-Air (OTA) programming enabled. With OTA, I can update the sketch running in the device over WiFi directly from the computer running the Arduino IDE. Sure better than my previous wired scheme where I had to walk around my layout with my notebook computer and a USB cable, plugging into each ESP8266 one at a time to reload a sketch.


Detector 1 with 1 Tag Reader Attached
Plasticville Log Cabin

Detector 2 with 2 Tag Readers Attached
Plasticville Hobo Shack

Detector 3 with 1 Tag Reader Attached
3D printed Servo Shed - a "Make" on Thingiverse:
https://www.thingiverse.com/make:1065442 

Detector 4 with 2 Tag Readers Attached
Plasticville Manufacturing Company

Detector 5 with 2 Tag Readers Attached
Plasticville Signal Tower

Detector 6 with 2 Tag Readers attached is inside a tunnel so a photo of it would be all black!

Detector 9 with 1 Tag Reader Attached
Plasticville Cape Cod House

Detector 10 with 2 Tag Readers Attached
Plasticville Grocery Store




UDP vs TCP






This site prepared and maintained by Mark DiVecchio

email :  markd@silogic.com

SD&A HOME
 
 Mark's Home Page

The DiVecchio genealogy home page
The Frazzini genealogy home page

This site will be under construction for a while.