I have started migrating content to my Hugo blog at https://blog.cavelab.dev, already migrated pages will redirect there.
LEGO traffic lights (WeMos, Wi-Fi and MQTT)
From CaveLab
(Redirected from LEGO traffic lights)
This project is a work in progress. Please check back later for additional changes.
Two channel traffic lights controller, using a WeMos microcontroller.
Sequence and timing
I've followed the standard set by the Norwegian Public Roads Administration, in handbook 303[1] and 310[2].
- Yellow time: 3-4 seconds, depending on speed limit (above or below 50 km/h)
- Red/yellow time: 1 second
- Yellow and red/yellow time for two conflicting flows of traffic must not overlap
- Switching time:
- Yellow flash: 60 times per minute (1 hz), 50% interval
Cold start
- 5 seconds yellow flash
- 5 seconds yellow solid
- 5 seconds red (minimum), all directions
- 1 second red/yellow main direction
- Green main direction
Videos
- First test with single traffic light output and MQTT communication.
- Added second traffic lights and auxiliary output.
- Faster MQTT command response.
- Added cold-start sequence on first boot or when ending yellow flash mode.
- Made two traffic light LED test boards.
I/O
Outputs
- GPIO 4 : Traffic light 1, green
- GPIO 0 : Traffic light 1, yellow
- GPIO 16 : Traffic light 1, red
- GPIO 14 : Traffic light 2, green
- GPIO 12 : Traffic light 2, yellow
- GPIO 13 : Traffic light 2, red
- GPIO 15 : Auxiliary (e.g. street lights)
- GPIO 2 : Built-in LED, MQTT connection status
Source code

https://github.com/thomasjsn/WeMos-Traffic-lights-controller-MQTT