User Tools

Site Tools


wio:firststeps-en

Deutsche VersionEnglish VersionFrench Version

WIO ESP/Pico First Steps

Introduction

WIO is the abbreviation of Wireless I/O.

On the basis of small microcontroller boards (also battery-operated) hardware solutions can be build for many model railway tasks. The GCA hardware family can be used for larger tasks. If no wired data connection is possible, software updates can be carried out via OTA (Over The Air). Configuration files can be updated at any time using a web browser.

UIO can also be used for microcontrollers without WLAN (e.g. older Arduinos); the data traffic then takes place via a USB interface. See also WIOhub.

With the help of the WIO modules, almost all control and feedback tasks for the model railway can be covered:

  • Outputs for LED or relay with optocoupler
  • Inputs for feedback, e.g. light barriers and occupancy detectors
  • Servos
  • Stepper motors
  • RFID
  • NeoPixel RGB LED
  • Displays e.g. OLED I2C Display 128 x 32/64 pixels
  • Charlyplexing for signals (multiplexing)
  • DCC signal generator
  • hand held locomotive controllers
  • Sounds


For more complex processes, scripts for the start with Crontab, for outputs IOScript and for NeoPixel LEDScript can be created, which are then executed on the WIO.

Hardware

There are two hardware platforms for WIO:
- the microcontrollers from Espressif ESP8266, ESP32 and
- the RP2040(Pico W) from the Raspberry Pi Foundation.

Microcontrollers supported by the Rocrail forum

  • ESP8266 D1 Mini
  • ESP32 D1 Mini
  • LOLIN D32 V1.0.0
  • Raspberry Pi Pico W RP2040


Espressif Raspberry_Pi_Foundation
ESP8266 ESP32 RP2040(Pico W)
D1 Mini mit ESP8266-12F ESP32 D1 Mini Raspberry Pi Pico W RP2040
16 pin (2 x 20) 40 pin 40 pin
34,0 x 25,0 x 6,0 mm 39,0 x 31,0 x 4,9 mm 21,0 x 51,0 mm
9 I/O; UART, GPIO, ADC, PWM, SPI, I2C 15 I/O; UART, GPIO, SPI, I2C, I2S, CAN 26 I/O; UART, GPIO, SPI, I2C
802.11b/g/n (2,4GHz) 802.11b/g/n (2,4GHz) 802.11b/g/n (2,4GHz)
LOLIN D32 V1.0.0
32 pin
X x Y x Z mm
23 I/O; UART, GPIO, SPI, I2C
802.11b/g/n (2,4GHz)


GCA boards for WIO

These boards and kits are available from GCA for WIO modules. GCA also contains a good overview of the WIO family.

Function WIO-01 WIO-02 WIO-03 WIOpico
chip Lolin D1 ESP8266 Lolin D32 ESP32 D1 Mini Pico W
16 onboard I/O x x
32 I/O with MCP23017 x x
4 onboard servos x x x only 12 I/O x
2x RFID with RC522 x x
2x display onboard via I2C;
10 displays with I2C multiplexer.
x x x x
Railcom via GCA214 x
NeoPixel
an external power supply may be necessary.
x 64/192 onboard x 64/192 Onboard x 64/192 Onboard x 100/300 Onboard
Stepper over driver board x x only 12 I/O x only 12 I/O
I2C connector onboard;
possibly with signal amplifier.
x x x x
4x charlyplexing onboard with 3.3 volts;
5 volts with level shifter
x
no NeoPixel
x
no NeoPixel
Battery Sensor Lipo
see the schematics of the respective boards
x x
DCC;
via H-Bridge
x x
Onboard RCAN/MBUS x
Sound Onboard x

¹ as WIO_Drive, WIO_Boost and WIO-VC-1
² as WIO_CAN MBUS/RCAN WiFi interface for the MS2 track box.
³ only ID-12LA

The pin assignment of the respective boards can be found here:


Software

ESP - Installing the software

Depending on the operating system and the user's skills, there are several ways of transferring the WIO software to an ESP.
This description is suitable for all operating systems and requires as less as possible knowledge.

Users of the Raspberry Pico W can sit back and then come back there Raspberry Pi Pico W - Installing the software.

The WIO software is transferred to the ESP in two steps:
- first the OTA Sketch (OTA Software) (Over-The-Air) is transferred to the ESP and
- then the actual installation of the WIO software takes place.

To load the OTA sketch, we need the Arduino IDE on a computer; this can be downloaded here for the corresponding operating system (Windows, macOS, LINUX, …).

After the installation, the "board administrators" for the ESP's must be added at "File / Settings",



The following must be entered to the field "Additional board manager URLs".


https://arduino.esp8266.com/stable/package_esp8266com_index.json
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json


Now the board properties for the ESP8266 and ESP32 must be added at "Tools / Board:" by clicking on "Board Management".



Now the data for the new boards will be downloaded by the Arduino IDE first; this can take a few minutes.
The progress is shown at the bottom right corner.

Once this is complete, the ESP8266 and ESP32 can be added to the boards.
Search for "8266" and click "INSTALL".


Repeat this with "esp32".

With that the basic setup of the Arduino IDE is completed.

ESP - Transferring the OTA Sketch

First the zip file "WPS-OTA-Sketch" is downloaded, unpacked and then the "RROTA.ino" file is opened with a double-click.

Confirm the question:
- "The "RROTA.ino" file must be in a sketch folder called "RROTA". Do you want to create the folder, move the file and then continue?"
with OK.

Lines 1, 2 and 4 need to be adjusted:

#define WIFI_SSID "MYWLAN" // Accesspoint name
#define WIFI_PWD "topsecret" // Password
#define WIFI_HOSTNAME "RROTA" // ESP hostname
#define WIFI_WPS false // true or false for ESP8266 for using WPS

Enter the SSID of the WLAN (WiFi) in line 1.
Enter the associated password in line 2.
Deactivate WPS by changing true to false in line 4. *

*Optionally, WPS can be used for the ESP8266, for this leave line 4 set to "true".
However, this can also lead to problems, so the recommendation is to change line 4 to "false" and enter the data in lines 1 + 2.

Please note!
SSID name and password, without blanks, to use for the WiFi connection.
Max. length is 32 characters incl. the zero termination.
:!: Only 7 bit ASCII is supported.

At "Tools / Board: / esp32 /" select the board used (in this example the "ESP32 D1 Mini").
(For the "esp8266" use "Tools / Board: / esp8266 /" and select "LOLIN(WEMOS)D1 R2 & mini").



Now connect the ESP with an USB-data-cable to the computer.
The USB port must now be selected inside the Arduino IDE; with Linux this is usually "/dev/ttyUSB0".
With MS Windows check the device manager.
With macOS this may be "/dev/cu.usbserial-110".



Now use the right arrow button in the top left to compile and upload the sketch.

After uploading the sketch, open the "Serial monitor" with baudrate 115200.
If everything was successful, the following appears there:

WiFi waiting to connect: MYWLAN...
WiFi connected to MYWLAN
setup OTA...192.168.0.109

The ESP is now in OTA mode.

Transfer the ESP-WIO software with Rocview

First, the BIN file for the used ESP can be found at Daily & Regular Builds at "RaspberryPi / WIO".
In this example, the file "WIO ESP32 D1 Mini32" is used and saved on the computer.

Start Rocrail, open the WIO dialog and select the "Update" tab. With the button "Binary WIO file:" open the just downloaded BIN file.
Enter the IP address from the monitor of the Arduino IDE in the "IP" field and fill out the "Port" field, in this example enter "3232" for the ESP32 board.
Now click "Start OTA"; the BIN file will be transferred to the ESP. If "9999 OTA: OK [OK]" appears in the server window, the transfer was successful.



Close the Arduino IDE, or at least close the serial monitor, as this hinders any further setup.

Raspberry Pi Pico W - Installing the software

(The ESP users can read along here briefly, but it is not relevant for them.)

Press the Pico W's "BOOTSEL" button and connect the Pico W to the computer with an USB-data-cable.

The Pico W appears as a storage medium on the computer and is displayed with the identifier "RPI-RP2".

Download the "WIO Pico-W USB" file from Daily & Regular Builds and save it on the Pico W.
The Pico W then restarts and is no longer visible as a drive.

The Pico W is now loaded with the WIO software and can be set up further.

Connect WIO to Rocrail

Go to the "Maintenance" tab in the Rocrail WIO dialog.

The WIO connected to the computer with Rocview is recognized via the "Scan devices" button.

When "Connect" is clicked, something similar should appear in the window of the dialog:

Rocrail - Model Railroad Software
Copyright (c) 2002-2022 Robert Jan Versluis, Rocrail.net
All rights reserved.
WIO 664
.......

The existing WLAN SSIDs are now displayed at "WLAN" via "Search".
Select the WLAN and enter the password for this WLAN. The connection is established via the "Set" button.

Please note!
SSID name and password, without blanks, to use for the WiFi connection.
Max. length is 32 characters incl. the zero termination.
:!: Only 7 bit ASCII is supported.


The WIO should now be connected to the Rocrail server and should appear in the "Query" tab. Otherwise the button  "Query" must be pressed.

Another alternativ is to enter manually the "Server" IP address in the "Maintenance" tab. In this case, the checkmark for "Automatic" must also be removed.


With this the initial setup is completed.

WIO Configuration

Set up WIO as a Controller

Add the WIO via "File / Rocrail Properties" in the "Controller" tab and close the dialog with "OK".



Then restart Rocrail.

Basic settings

At the beginning, the following settings should be made in the WIO dialog at the "Query" tab:

First change the identifier (ID) of the WIO; the DEFAULT identifier for newly set up WIOs is 33. If this is not changed, no further WIO can be added.

Now the name can be changed; this is used for identification in the network and in the Rocrail dialogs. The identifier (ID) is used for the actual control. The maximum length of the name is 8 characters.

The changes are saved with the "Set" button.



Set the WIO type

The WIO type must now be defined for the ESPs. This documentation is limited to the types "LED", "Servo" and "I/O16". Further WIO types can be found in the wiki: WIO - Set - Type.

Nothing needs to be set on the Raspbery Pi Pico W, as it is only available as type "I/O16".

In this example, the WIO type "I/O16" is set for the "ESP32 D1 mini".
Further settings are not necessary because the WIO type "I/O16" automatically determines the real type based on the first command after the restart.

With WIO-01 and WIO-02 it must be defined whether "Servo" or NeoPixel "LED"s (WS2812,WS2811) should be controlled with the WIO.

The WIO type is saved using the "Set" button.

Set up inputs/outputs


Select the WIO to be configured in the WIO dialog and switch to the "Settings" tab.



On the left the port configuration (Port Configuration) is located:



The use of a WIO input/output pins can be defined here; there are 4 options available:

  • "i" input / input
  • "o" output / output
  • "p" pulses / output with switch-off e.g. for magnet articles
  • "b" block / input debounced for feedback such as contact rails, light barriers, ….
  • Invert (o,p) inversion of the outputs; the default state of an output is "Low" (minus); when activated, this changes to off as "high" (3.3 volts plus).


First only 8 of the 16-32 I/O's can be seen. The arrow keys in the lower area can be used to switch to the other I/Os.
Attention: save any changes with the "Set" button before leaving the actual 8 I/O's.

WIO Usage

Rocrail output with WIO

In the following example, the first output of the WIO is set up with the WIO ID 1.
In the Rocrail plan, right-click on the output symbol to open the settings and switch to the "Interface" tab.



Select "WIO" for the interface identifier, enter the ID of the WIO in this example "1" in the "Node ID" and also enter the "1" in the "Address" field for the first output pin.

Rocrail Sensors by WIO

In this example, the sensor is connected to port 3 of WIO-ID 1; the configuration of this port is set to "b" = "block".


However, it is much easier to make the setting via the Sensor Monitor:
- click on "Delete all" in the sensor monitor,
- trigger the sensor.



- drag and drop the entry onto the Rocrail sensor,
- the Rocrail sensor is then set up as follows.

Magnetic articles by WIO

A magnetic article can be a semaphore signal or a point (switch, turnout, …).
In this example port numbers 4 and 5 are used.
At first the "Configuration" must be set to p = "Pulse" in the WIO dialog. As a result, the output switches itself off again; the duration is set to 500 ms ("Pulse" = 50 x 10 ms corresponds to 500 ms). This should prevent the coil from burning.



In the Rocrail signal settings in the interface tab, select the interface identifier "WIO", enter the ID of the WIO, enter address 4 for RED and activate "Switch" as type.
There is no need to enter the second address; the following IO address (5) is used.



The procedure is identical for a point (switch, turnout, …).

Light signals by WIO

German Main Signal
HP0 stop red light
HP1 go green light
HP2 slow green + yellow light

In this example the ports 6, 7 and 8 are used for a 3-aspect light signal. These must be defined as o="Output".



Enter the addresses 6, 7 and 8 at the settings for RED, GREEN and YELLOW.
Invert must be activated for signals with a common anode.


To be able to display HP2 ("slow", green/yellow, …), "Aspect numbers" must be activated at "Interface / Control". This is not necessary for a signal with 2 aspects.
Open the "Details" tab for further settings of HP2. Enter the "Aspect numbers" there.
RED = 0, GREEN = 1 and YELLOW = 2


At "Patterns / Aspects" click on the "Value" field with the 3 dots "…" behind the "Number" field.

When RED set LED 2 to "On" If green, set LED 1 to "On" Set YELLOW LED 1+3 to "On"

Info:
WIO also supports Charlieplexing for Viessmann multiplex signals.

NeoPixel by WIO

One WIO can drive up to 64 (128 PicoW) NeoPixel WS2812/WS2811 RGB LEDs, which can be used for signals, normal lighting and so on.
Using GCA WIO-01 and WIO-02, the "LED" type must be activated

Setup a Rocrail output

Make the following settings in the “Interface” tab:

Output / Interface
field value range
Interface ID "WIO"
Node ID the WIO ID number
Address index number of the WS2812/2811 LEDs (1-64)
Value the brightness of the LEDs (1-255)
Options "Color"
Accessory no
Type "LED"


Make the following settings in the "Color" tab:

Output / Color / RGB
field RGB "WS 2812" GRB "WS 2811" range
red red color green color (0-255)
green green color red color (0-255)
blue blue color blue color (0-255)

"Type" = "RGB" for the "WS 2812" protocol or
"Type" = "GRB" for the "WS 2811" protocol.


Additional options in the "Interface" tab:

Output / Interface
field value range
Parameter on number of consecutive LEDs (0-64)
Delay fade in and fade out (0-15)

If "Blink" is activated, the LEDs will flash. The frequency is set via "Dim" in the “Interface” tab.

NeoPixel signal settings

The setup for the WS2811 boards is explained below.
It is important to note that red and green are swapped in the WS2811 protocol.
So: Red is Green, Green is Red and Yellow is Blue on the chip.

WS2811-R WS2811-G WS2811-B
green LED red LED yellow LED


Make the following settings in the "Interface" tab:

Signal / Interface
field value range
Interface ID "WIO"
Node ID the WIO ID number
Address index number of the WS2812/2811 LEDs (1-64)
Brightness the brightness of the LEDs (1-255)
Control "Aspect numbers"
Type "LED"
Dim optionally fade in/out (0-50)



In the "Details" tab, proceed as follows for a signal with 3 aspects:

  • First fill the field "Number" with the values 0, 1 and 2


At "Patterns / Aspects" click on the "Value" field with the 3 dots "…" behind the "Number" field.

Patterns/Aspects
Aspect value:
LED 1 LED 2 LED 3 German Main Signals
RED A1 off ON off HP0 (stop; red light)
GREEN A2 ON off off HP1 (go; green light)
YELLOW A3 ON off ON HP2 (slow; green + yellow light)
HP0 HP1 HP2
When RED set LED 2 to "On" If green, set LED 1 to "On" Set YELLOW LED 1+3 to "On"

If "Blink" is activated, the LEDs will flash. The frequency is set via "Dim" in the “Interface” tab.


To build a signal with more than 3 LEDs add another WS2811 to the configuration and continue with the LEDs 4, 5 and 6 in the aspect value.
The outputs from the following WS2811 board are then used.
Please note: even if only one additional LED (No. 4) is connected, it is not possible to use the unused LED outputs (5 and 6) for something else.

Patterns/Aspects
Aspect value:
LED 1 LED 2 LED 3 LED 4 LED 5 LED 6 German Light Signal
RED A1 off ON off off - - HP0 (stop; red light)
GREEN A2 ON off off off - - HP1 (go; green light)
YELLOW A3 ON off ON off - - HP2 (slow; green + yellow light)
WHITE A4 off ON off ON - - HP0/SH1 (shunting; red + white light)
WS2811 #1 WS2811 #2
HP0 HP1 HP2 HP0/SH1
When RED set LED 2 to "On" If green, set LED 1 to "On" Set YELLOW LED 1+3 to "On" If red+white, set LED 2 and 4 to "On"

If "Blink" is activated, the LEDs will flash. The frequency is set via "Dim" in the “Interface” tab.

Setup servos

With WIO, up to 4 onboard servos can be controlled; this can be done from the objects "output", "switch", "signal" and "turntable".
With the GCA WIO-01 and WIO-02, the "Servo" type must be activated for this.
With the ESP32 type "I/O16" the IO addresses 1 to 4 are omitted, as these are used to control the servos.

In this example, the setup is explained using the "Switch" object, the different fields for "Output", "Signal" and "turntable" can be found here addressing servo objects.

Enter the interface identifier "WIO" and the node ID of the WIO in the interface of the switch.
Indicate the number of the servo (1 to 4) in the "Address" field.
The first and second position of the servo are set in fields "Parameter" and "Value".
The speed (1 to 10) can be set in the "Switch time" field.
Deactivate the "Accessories" option and select the Type = "Servo".



A window for setting the servo can be called up via the button element with the 3 dots to the right of the "Value" field.
This element is only available at type "Switch".

Finally

wio/firststeps-en.txt · Last modified: 2024/01/03 10:39 by rjversluis