Introduction: UK Train and Weather Display
This instructable is for a battery powered UK train departures and weather display. It used the National Rail OpenLDBWS database to get real time train departure information for a particular local railway station and display it. It uses openweather database to get 5 day forecast for a city and display it
It has the following features
- Accesses National Rail station database
- Can filter list to show trains going to specific destination
- Accesses openweather database to get 5 day forecast
- ESP8266 based processing, hooks onto local wifi network
- Battery powered (rechargeable LIPO) with inbuilt charger
- Very low quiescent current for long battery life
- 320 x 240 LCD display with 3 control buttons
- Automatic sleep
- Editable configration data
- Over the Air software update
- 3D printed enclosure
Step 1: Usage
The unit is turned on by a short press of the middle button.
On first use it will create an Access point for local Wifi configuration. Use a phone to connect to this network.Use the phones browser to access 192.168.4.1 and you will get a wifi configuration page. Select the network and enter its password. The unit will save this and restart to acess the local network. This step may be needed again if moving to a different network or the password is changed.
Once connected to the local wifi network the unit will access the National rail database or openweather database and query it to find departures for the configured station and destination or the weather forecast. This will be repeated at the interval set in the config file.
The button usage is as follows
- Top button - Short press. Page up if more services that fit on the screen
- Top Bottom - Long press. Show battery volts and ip address. Short press will take it back to normal display.
- Middle button - Short press. Turns on unit. Then toggles between trains and weather.
- Middle button - Long press. Force into sleep.
- Bottom button - Short press. Page down if more services that fit on the screen.
- Bottom button - Long press. Step on to next pair of start and end destination stations or weather cities if multiple ones entered.
The unit will automatically go into sleep as configured.
The config file may be accessed using http:/ip/edit (after fully set up).
The config includes trainsStation and trainsDestinations entries.The first is the crs code for the local station you are interested in seeing departures from. The second is a station crs that the departing train must pass through. This is used to filter departures down to those of interest (say in one direction). It may be left blank to show all departures. Either entry may contain up to 4 codes separated by ','. If there are less than 4 then the last item is repeated to make up 4. The Bottom button Long Press is used to step around these pairs when showing departures.
It also includes weatherCityCodes and weatherCityNames.
New software may be updated by building a new binary in Arduino and doing an over the air update using http:/ip/firmware
Step 2: Components and Tools
The following components are needed
- 320x240 3.2" LCD display with 3 buttons. Originally intended for use with Raspberry Pi but can be used by anything with SPI
- ESP-12F Esp8266 module
- 18650 LIPO battery
- Battery Holder
- Micro USB LIPO charger module
- Header plug to plug into LCD display
- XC6203E 3.3V regulator
- 200uF 6.3V tantalum capacitor
- AO3401 P channel MOSFET
- Zener Diodes x 3
- Resistors 4k7,4k7, 470k
- Hook up wire
- Capacitor 4.7uF
- perf board or euivalent for mounting a few components
- Resin Glue
- Double sided tape.
The following tools are needed
- Fine point soldering Iron
Step 3: Electronics
The electronics are based on the ESP-12F modulewith a few extra components to facilitate sleep operation.
One of the switches activates the MOSFET transistor which then powers up the display and enables the ESP8266. A GPIO pin then maintains the power even when the switch is released.
The display is hooked to the standard SPI pins on the ESP8266
Step 4: Assembly
I did the following steps
- Print 3D enclosure and ensure display fits. It should be a snug fit and there are cut outs around the buttons
- Print 3D Lid and extra parts including charger module bracket
- Make up the regulator extra circuitry on prototyping board.
- Mount onto ESP8266 and connect through to header plug which can fit into the display.
- Add small spots of resin glue around edge of display to secure in place.
- Wire up battery holder and charger module
- Resin Glue charger module to bracket and then glue bracket to side of case making sure USB is visible through its access point
- Stick battery holder to back of display using double sided tape.
- Complete wiring. I include a simple plug socket in the power lead from battery / charger to the regulator to facilitate disconnection.
Note that some versions of the LCD display module have slightly different power supply wiring and do not have the 3.3V voltage input on pins 1 and 17. They rely on using the 5V input on pins 2 and 4 and then use the on board 1117 regulator to provide the 3.3V needed. These can still be used OK but will need the 3.3V display output from the electronics to be made direct to the middle leg of the display board regulator bypassing the regulator and providing the 3.3V directly.
Step 5: Software and Config
The software is Arduino based and the repository is at https://github.com/roberttidey/trainsWeatherAccess
As the ESP8266 is limited in memory the interface to the Rail and weather databases and the processing of its response have been optimised to use minimal memory. The query used to access the database is contained in the config file and has various parameters like station names which are substituted.
The Readme includes instructions for use. In particular note
- You must get an Access Tokens from National rail and openWeather. Registration and normal usage is free.
- You should change the default passwords in the ino file before compiling.
- You need to change the trainsWeatherConfig.txt file to contain your access token and to change station data and any personal preferences.
- You will need to get your own local station and destination 'CRS' codes and weather city codes. The ReadMe has links to get these.