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.
LEGO traffic lights-20200131 000742.JPG

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

Wemos D1 mini pinout

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

Git-alt-brands.svg
Arduino sketch is available in a git repository:
https://github.com/thomasjsn/WeMos-Traffic-lights-controller-MQTT

Gallery

Schematic diagram

WeMos-traffic-lights-controller-circuit.png

Parts used

Qty. Part
1 × Darlington-driver, 7 step, ULN2003A, DIL16, In: 2.7K/5V
1 × DIL socket, 16-pin, 7.62mm
1 × Diode, rectifier, 1 A, 400V, 1N4004
1 × PCB, stripboard prototyping, 94x53mm, 50cm2
16 × Straight pin header, female, Single row, 2.54mm
15 × Straight pin header, male, Dual row, 2.54mm
16 × Straight pin header, male, Single row, 2.54mm
1 × WeMos D1 mini, WiFi dev. board, ESP8266

References