User Tools

Site Tools


French VersionDeutsche VersionEnglish Version

WIO - Throttle - 32 I/O - LEDs - Servos - RFID - Displays - DCC



W o r k - I n - P r o g r e s s


This solution is based on the LOLIN D1 Mini. (ESP8266)
It can be used as:

  • Wireless Throttle

or as wireless I/O with:

and one of the following four options:

  1. LED control WS2812
  2. 4 Servos
  3. 2 RC522 readers
  4. DCC Generator



Exhibition used WiFi channels...

  1. The Rocrail server must run on a PC which dus not automatically suspend or sleep in case of no user activity. Check the energy setting to prevent communication loss.
  2. The used WiFi Router should be state of the art; Only use maintained hardware.
  3. Make sure the SSID is not visible to prevent extra public traffic.
Using WIO is at your own risk.
Peter Giling and Robert Jan Versluis can not be held responsible for any damage or problems by using the proposed hard- and firmware.
The published hardware are prototypes, are incomplete and not ready for release.
Only original GCA Kits are supported.

Arduino IDE

Tested with version 1.8.10
Prepare the Arduino IDE with the following boards and libraries:

Board manager

Add in the preference dialog to "Additional board manager" the following URL:

And install the ESP8266 board library.

Board selection

LOLIN(WEMOS)D1 R2 & mini


  • ESP8266WiFi (Board Manager)
  • Wire (I2C)
  • FastLED (WS2812)
  • RotaryEncoder
  • MFRC522 (RC522)
  • Servo

Dark Theme

For those who wants a Dark Theme for the Arduino IDE:

WIO Sketch

Copyright © 2002-2019 Robert Jan Versluis,

WIO is firmware for controlling Throttle, I2C, LEDs, Servos, RFID, Displays and DCC.

The source code is public but not open source licensed, and it should be used only to compile and load it on the LOLIN D1 Mini.


esp-downloadtool.jpg Use the Espressif tool to upload the WIO Binary.

Compile output

The red FastLED pragma messages, which is information only, can be ignored, as long as the last two white lines show up:

 #    pragma message "FastLED version 3.003.002"
 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

Sketch uses 293716 bytes (28%) of program storage space. Maximum is 1044464 bytes.
Global variables use 33104 bytes (40%) of dynamic memory, leaving 48816 bytes for local variables. Maximum is 81920 bytes.
Pratfall: Many Micro USB cables do only provide 5V and no data, and cannot be used to program.

Setting up the WiFi can be done with the Arduino Serial Monitor 9600bps, or by modifying the USERCNF.h:

#1CConnecting to [secure.home]
#13WiFi try to connect
#13WiFi try to connect
#17WiFi connected RSSI=-55

Output after a ? command:

version=0.85 WIO 20191031d (c)Rocrail
MCP23017 status: 0x20=OK 0x21=OK
I2C device found at address 0x20
I2C device found at address 0x21
I2C device found at address 0x3C
I2C found 3 devices
loco1=0 loco2=3 active=0

Change settings by typing:
*ssid=<your WiFi SSID>
*pwd=<your WiFi password>
*server=<your Rocrail server IP/host>
*port=<your Rocrail server port>
*name=<Node name>
*id=<Node number>
*io=<type> <throttle> or <i2cled> or <i2cservo> or <i2crfid> or <i2cdcc>
*i2c=<oooooooobbbbbbbboooooooobbbbbbbb> o=output, i=input, b=block, p=pulse
*steps=<number of rotary steps>
*pulse=<output pulse length in 100ms units>
*display=<geometry1><geometry2> 0=96x16 1=128x32 2=128x64
*dccsc=<short circuit detection> 0=off 1=on
*railcom=<use RX for detection> 0=off 1=on
*maxpower=<set max. WiFi power> 0=off 1=on (Needs a reboot)

User Configuration

The USERCNF.h file can be used for initial, first boot, WiFi and Rocrail server values.
The values must be set before compile and upload.
Afterwards those values can be changed with monitor commands.

Monitor commands

Command Description Default
? Shows the current settings and how to change them.
! Dumps the used Flash memory.
*ssid=<value> Set the WiFi access point SSID. -
*pwd=<value> Set the WiFi password. A WiFi reconnect is triggered. -
*server=<value> Set the Rocrail Sever IP or Name. -
*port=<value> Set the Rocrail Sever port. 8051
*name=<value> Optional node name. -
*id=<value> Node number/throttle ID; Should be unique. 33
*io=<value> I/O configuration. throttle
*i2c=<value> I2C port configuration. oooooooobbbbbbbboooooooobbbbbbbb
*steps=<value> Number of rotary steps. 127
*pulse=<value> Output pulse length in 100ms units. 5
*display=<value> Default display geometry: 0=96x16 1=128x32 2=128x64 00
*dccsc=<value> Short circuit detection in case the booster reports it. 0
*railcom=<value> Try to read RailCom data with the RX pin; The monitor is not available in this mode. 0
*maxpower=<value> Set the WiFi output power to the maximum of 20.5 dBm. 0

Note: Replace <value> to meet the local WiFi environment and setup.

Port type Description
i Input
o Output
b Block: Input with a 2 second off delay.
p Pulse: Output with auto off.

IO Type Configuration

IO Type I2C 32I/O FastLED Servo RFID Display DCC
throttle - - - - - -

RIC - Throttle

Note: RIC controls locos by address, not by ID. So the first one in the list will be used if multiple locos share the same address.
The pocket throttle I/O mode needs a rotary switch, one LED and four buttons.
The LED can also be the build in one. (D4)

Proto Type 1

Pin Usage Click Long click
D5/D6 Rotary - -
D7 Rotary switch Change direction Wait/Release loco
D4 Onboard LED - -
D1 F1 F1 F5
D2 F2 F2 F6
D3 F3 F3 F7
D0 F4 F4 F8
A0 Battery - -


F0 is flipped if both F3 and F4 are pressed.

Emergency Break

An emergency break will send to the server if both F1 and F2 are pressed.

Loco selection

Loco 1 is selected by default.
Select loco 1 if both F1 and F4 are pressed.
Select loco 2 if both F2 and F3 are pressed.

LED Meaning
On No WiFi connection.
Very fast flashing 10Hz No Rocrail server connection.
Off Idle mode.
Fast flashing 5Hz Waiting for a dispatch.
Slow flashing 1Hz Operating mode.


At boot the LED will turn on until a WiFi connection is established.

Catch a Locomotive

  1. In case the LOLii did not catch a dispatched loco, and the rotary is pressed long, about 2 seconds, the LED will start flashing fast.
  2. If the LOLii sees in this mode a loco dispatch, it will catch it and the LED will start flashing slow.
  3. This loco catch will be saved in the flash memory and reused at reboot if it was not released.

Speed Control

  • Turn the rotary for speed changes.
  • A short rotary press will flip the loco direction.

Function Control

The four function buttons represents F1 to F4.
With a long click F5 to F8 can be accessed.
A function will be flipped after releasing the button to be able to process long clicks. (Same as with smartphones.)

Release a Locomotive

  1. Press the rotary long, about 2 seconds,
  2. A release message is send.
  3. The LED will go off.

Battery Control

The analog input will check the battery voltage.
If the voltage is below a certain level, LOLii will send automatically a zero speed command to the locomotive and a release command.
The LED will start blinking very fast as long the battery is not drained completely.

Server discovery

UDP Multicast drains heap space and is therefor disabled.

If the Rocrail Server has R2RNet active on multicast address, the LOLii can retrieve the server name/IP to connect it to the 8051 client port automatically.


  • Connects directly to the Rocrail Server Client port 8051.
  • WiFi and Server connection recovery.
  • 32 digital I/O compatible with all GCA interfaces.
    • Input
    • Output
    • Block
    • Pulse
  • 128 LEDs compatible with WS2812 on D8. (Color type output in Rocrail.)
    • RGB color
    • Brightness
    • Dimming
    • Flashing
  • 4 Servos
    • Adjustable movement speed
    • Positions are saved in the plan.xml, Output/Switch, which makes swapping of hardware easier.
    • Reached end positions are saved in flash to provide a stable reboot.
  • DCC Command Station
  • Up to 255 units in the same WiFi network. (Depending on the IP configuration and availability.)
  • An alarm will be generated if 'a live' messages are no longer come in.
  • Output/Switch commands are acknowledged after they have been processed. (Blink outputs are not acknowledged.)
  • Input events must be acknowledged within 100ms. After this timeout a resend will occur. (Max. 5 retries.)


Rocrail WIO
Interface ID "WIO"
Bus ID
Address I2C Port
Address LED Port
Address Servo Port

This addressing schema is used for:

  • Outputs
  • Switches
  • Signals
  • Sensors

The output blink and delay options can be used to blink an I2C port.
If the delay is zero the default pulse length will be used.


ws2812.jpgws2811-chip.jpg The addressing is the same as normal outputs.


  1. WIO-ID: Bus
  2. LED number: Address
  3. LED range: ON parameter
  4. The Interface → Color option and type light must be set
  5. Brightness is set by Interface → Value
  6. Dimming step is set by Interface → Delay (0…15) (A value of zero deactivate dimming.)
  7. The Interface → Blink option may be used to flash the LED
  8. The LED color is set by Color → RGB


  1. WIO-ID: Bus
  2. LED offset: Address
  3. Port type: LED
  4. Control type: Aspect number (Max. 6 sub LEDs → 2 x WS2812)
  5. Brightness

The aspect values are compatible with RocNetNode Pi08. (WIO version 0.81+)


servo.jpg The addressing is the same as normal outputs.

Control Output Switch Range
WIO ID Bus Bus 1…255
Servo port Address Address 1…4
Extra options - Single gate -
Position 1 Parameter ON Parameter 0…180°
Position 2 Parameter OFF Value 0…180°
Moving speed Delay Switch time 1…10
Target Port type "Servo" Port type "Servo" -


Make sure that there are no servos and LEDs connected when switching to RFID.


  1. Two Mifare RFID RC522 readers are supported.
  2. It needs 5 extra ports; Parallel Servos are not possible.
  3. Reporting addresses are 100 and 101. (In Rocrail 101 and 102.)
  4. Automatic sensor off event after 1500ms. (Before it must be acknowledged by the server.)
  5. Four times retry until acknowledge, then give up.

Signal D1 Mini RFID RC522
Slave Select 1 D3 1 (SDA) reader 1
Slave Select 2 D0 1 (SDA) reader 2
SCK D5 2 (SCK)

Pins I2C

Pin Usage
A0 Power monitoring
D4 Build in LED
D8 LEDs (FastLED)

Display SSD1306

Two displays can be connected to the I2C of Type SSD1306 with the I2C addresses 0x3C and 0x3D.
Formatted text is compatible with RocDisplay.
WIO supports only a subset, and some new lower case commands are introduced.
Code page is ISO 8859 Latin for font {F0}; {F1} is 7 bit ASCII only.


The Bus is used for the WIO ID, and the Display number for selecting between 1 and 2. (0x3C or 0x3D)
The Address value is not used.

Supported Formatting

Formatting commands are enclose in curly brackets. Example:

{g1}{E}{L0}{X0}Hello World!{P}
Command Parameter Description Remark
{Bn} n=0-19 Draw a bitmap on the current position.
{E} - Erase display buffer. An extra {P} is needed to erase the display.
{Fn} n=0-2 Select font. 0=7x5 1=6x5w 2=6x5n Font 5x5 is not supported because its unreadable.
{Hn} n=0-255 Set the display contrast.
{In} n=0-1 Invert the display. 0=normal 1=inverted
{Ln} n=0-3 Goto line. The range depends on the display size.
{P} - Copy buffer to the display.
{Rn} n=0,2 Set display mapping rotation. 0=0° 2=180°
{?V} - Show firmware version.
{Xn} n=0-127 Goto column. The range depends on the display size.
{Yn} n=0-32 Goto row. The range depends on the display size.
New command Parameter Description
{cn} n=0-16 Draw an analog clock with the given radius on the current position.
{gn} n=0,1,2 Set display geometry. 0=96x16, 1=128x32, 2=128x64 (1 is default) This is for testing only. To save CPU load set the display option.
{i} - Toggle inverted text.
{sn} n=1-x Draw scrolling text on the current position, with a view width of n characters. Example: {s12}Scrolling text to show…{s}
{d} - Scroll one text line down.
{f} - 7-Segment fast clock.

Note: If the geometry is not default, 128x32, the text MUST start with a {gn} command for selecting the right geometry.


The bitmaps are sized 20 x 8 pixel.

Number Description Original
13 Nederlandse Spoorwegen (NS) ns.jpg

DCC Generator


WIO supports following DCC packets

  • Loco speed and direction. (No support for 14 speed steps.)
  • Loco functions 0-28.
  • POM set/get. (A RailCom detector is needed for POM get.)
  • Accessories.
  • BinState


  • 100% NMRA timing conform.
  • Automatically Power OFF after a Rocrail Server connection loss.
  • Shows activity on a display if a one is connected.
  • 64 slot refresh stack with auto purging.
  • 16 accessory command queue.

Pins DCC

Pin Usage Remark
D6 & D7 DCC symmetric signal.
D5 Short circuit detection. Needs a 10k pull-up resistor.


To use the 3.3V level a 470 Ohm resistor must be add parallel to R1.

Mobile Addressing

IID WIO Remark
Address DCC decoder address. Addresses > 99 are regarded as long DCC address.
Speed steps 28 or 128


The WIO can also be used as mobile RFID reader and I/O.
The WIO ID must be set in the loco Secondary Address field.

Sensor setup

Loco [ICE-CAM] reports RFID event 56:101 [] ON

The reported RFID must mach with a Sensor-ID in Rocrail.
This sensor should have its address set to zero.
The ID must be set in this notation: RFID Notation
The Rocrail traces can be used to copy this ID or the Sensor Monitor.

Function setup

To dispatch functions to a WIO the function must be setup with Function address and FX.


The firmware for IO-Type RIC does not function without pull-up resistors on the button inputs, including the rotary switch.

Schedules & PCBs

The published hardware are prototypes, are incomplete and not ready for release.
Only original GCA Kits are supported.

arduino/wio-en.txt · Last modified: 2019/11/15 08:26 by rjversluis