Difference between revisions of "Project:Traffic Lights"

From London Hackspace Wiki
Jump to navigation Jump to search
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  
== USB Traffic Lights ==
+
'''The traffic light no longer exists as it went missing :('''
  
The traffic lights above Lovelace are currently connected to Babbage via USB. Theyre a USB HID device (Vendor ID  0x03EB, ProductID = 0x2044 - LUFA stack testing vid/pid) that is controlled by a Daemon running on Babbage.
+
'''Warning: You should read and understand this document ''in full'' before opening or hacking on the traffic light'''
  
To control them directly you need to send a Set_Report request to the Control Endpoint with the data part being 8 bytes long. The first 3 bytes are uints that represent the 3 lights, the rest of the values can be left as zero. A non-zero value means the light is on
+
'''Please speak with [[User:marrold|marrold]] prior to hacking to find out the current status of the Project.'''
  
You can also read from the first Interrupt Endpoint to get a report of the current light status.
+
[[File:TrafficLightOutside.JPG|250px|thumb|right|Traffic Light]]
  
 +
=== Safety ===
  
== Babbage Daemon ==
+
* '''Mains voltage''' is present in the traffic light.
 +
* '''Always''' isolate the power before opening up any of the sections.
 +
* '''Always''' isolate the power before programming the ESP8285 - otherwise your risk damaging your computer or yourself.
  
The daemon running on Babbage (under my account) listens for UDP packets on port 9009. Simply send a 3 character string terminated by carriage return and newline to set the light status, for example:
+
=== Hardware ===
  
100\r\n <- green light on<p>
+
The traffic light is a PEEK Elite Traffic Light in a RAG (Red - Amber - Green) configuration, manufactured around 2001. It's currently fitted with Pedestrian hoods as these are more compact than the Primary or Secondary hoods.
101\r\n <- green and red lights on<p>
 
  
This daemon handles the USB stuff for you.
+
=== Controller ===
  
== Current uses ==
+
The traffic light is controlled by a [https://www.itead.cc/wiki/Sonoff_4CH "Sonoff 4CH"] 4 channel relay board, a commercially available device that costs around £15-25. The relay board itself is controlled by an Espressif ESP8285 System on Chip (SoC), which is almost identical to the popular ESP8266, but contains additional memory. The ESP8285 has onboard WiFi and supports the Arduino platform and libraries, making it ideal for an "IoT" device.
  
Since I changed the API none of the IRC commands that use the lights work.
+
=== Wiring ===
  
There is a doorbot listener on babbage that listens for unknown cards at the door and blinks the Red light 5 times. It Erases the current light state after doing this
+
The traffic light is powered from 90-250v AC (50/60Hz). The controller contains an AC-DC convertor to bring it down to the 3.3V required by the ESP8285. The 4 relays output mains voltage, which is then dropped down to ~12v AC by an individual transformer ''per bulb''.
 +
 
 +
It was suspected that the transformers were generating Electromagnetic Interference (EMI) when switching on and off, so an off the shelf snubber has been put in parallel with each. A commercial filtered IEC socket has also been added. Since these modifications no further EMI problems have been reported.
 +
 
 +
====Lamp to GPIO mapping====
 +
{| class="wikitable"
 +
! style="font-weight:bold;" | Function
 +
! style="font-weight:bold;" | GPIO Pin
 +
|-
 +
| style="background-color:#ffffff;" | Red Lamp
 +
| style="background-color:#ffffff;" | IO12
 +
|-
 +
| style="background-color:#ffffff;" | Amber Lamp
 +
| style="background-color:#ffffff;" | IO5
 +
|-
 +
| style="background-color:#ffffff;" | Green Lamp
 +
| style="background-color:#ffffff;" | IO4
 +
|}
 +
 
 +
=== Bulbs ===
 +
 
 +
The "real" bulbs for these traffic lights are 12V, 50W Halogen Bulbs with a GY6.35 base from General Electric, however they have been replaced with generic 4W GY6.35 LED bulbs to reduce the brightness and power consumption.
 +
 
 +
There is 2x spare LED bulbs inside the amber section of the traffic light.
 +
 
 +
'''Note:''' It turns out G4's will fit in the bulb holders. These are cheaper than GY6.35s and much easier to get hold of - Poundland stocks 3x 20W Halogen G4s for £1, or you can get LED G4s from £1 each on Ebay. My suggestion would be to use G4s in future.
 +
 
 +
=== Programming ===
 +
 
 +
The Sonoff 4CH can be programmed via serial using the Arduino IDE, Platformio, or any other software capable of programming an ESP8285.
 +
 
 +
To get into flashing mode, you must press and hold the L1 button down as you power up the board.
 +
 
 +
Some USB to Serial adapters are unable to supply the required current to the Sonoff. If you see weird behaviour like the board restarting, you may need to power it externally with 3.3V (NOT MAINS!).
 +
 
 +
{| class="wikitable"
 +
! style="font-weight:bold;" | Colour
 +
! style="font-weight:bold;" | Use
 +
|-
 +
| style="background-color:#cbcefb;" | Violet
 +
| style="background-color:#cbcefb;" | VCC (3.3V)
 +
|-
 +
| White
 +
| Tx
 +
|-
 +
| style="background-color:#c0c0c0;" | Grey
 +
| style="background-color:#c0c0c0;" | Rx
 +
|-
 +
| style="background-color:#000000; color:#ffffff;" | Black
 +
| style="background-color:#000000; color:#ffffff;" | Ground
 +
|}
 +
 
 +
'''N.B: Remember to "invert" the UART connections'''
 +
 
 +
=== Current Use ===
 +
 
 +
The traffic light currently cycles through the light cycle displayed at road junctions.
 +
 
 +
 
 +
== Pictures ==
 +
 
 +
{|
 +
| [[File:TrafficLightInside.JPG|thumb|Inside, showing the controller. ]]
 +
| [[File:TrafficLightController.JPG|thumb|A close up of the controller, showing the programming lead. ]]
 +
| [[File: TrafficLightBulbs.JPG|thumb|The "real" 50W GY6.35 bulbs.]]
 +
|}
 +
 
 +
[[Category:Projects]]
 +
[[Category:Space_Infrastructure_Projects]]

Latest revision as of 20:03, 22 September 2023

The traffic light no longer exists as it went missing :(

Warning: You should read and understand this document in full before opening or hacking on the traffic light

Please speak with marrold prior to hacking to find out the current status of the Project.

Traffic Light

Safety

  • Mains voltage is present in the traffic light.
  • Always isolate the power before opening up any of the sections.
  • Always isolate the power before programming the ESP8285 - otherwise your risk damaging your computer or yourself.

Hardware

The traffic light is a PEEK Elite Traffic Light in a RAG (Red - Amber - Green) configuration, manufactured around 2001. It's currently fitted with Pedestrian hoods as these are more compact than the Primary or Secondary hoods.

Controller

The traffic light is controlled by a "Sonoff 4CH" 4 channel relay board, a commercially available device that costs around £15-25. The relay board itself is controlled by an Espressif ESP8285 System on Chip (SoC), which is almost identical to the popular ESP8266, but contains additional memory. The ESP8285 has onboard WiFi and supports the Arduino platform and libraries, making it ideal for an "IoT" device.

Wiring

The traffic light is powered from 90-250v AC (50/60Hz). The controller contains an AC-DC convertor to bring it down to the 3.3V required by the ESP8285. The 4 relays output mains voltage, which is then dropped down to ~12v AC by an individual transformer per bulb.

It was suspected that the transformers were generating Electromagnetic Interference (EMI) when switching on and off, so an off the shelf snubber has been put in parallel with each. A commercial filtered IEC socket has also been added. Since these modifications no further EMI problems have been reported.

Lamp to GPIO mapping

Function GPIO Pin
Red Lamp IO12
Amber Lamp IO5
Green Lamp IO4

Bulbs

The "real" bulbs for these traffic lights are 12V, 50W Halogen Bulbs with a GY6.35 base from General Electric, however they have been replaced with generic 4W GY6.35 LED bulbs to reduce the brightness and power consumption.

There is 2x spare LED bulbs inside the amber section of the traffic light.

Note: It turns out G4's will fit in the bulb holders. These are cheaper than GY6.35s and much easier to get hold of - Poundland stocks 3x 20W Halogen G4s for £1, or you can get LED G4s from £1 each on Ebay. My suggestion would be to use G4s in future.

Programming

The Sonoff 4CH can be programmed via serial using the Arduino IDE, Platformio, or any other software capable of programming an ESP8285.

To get into flashing mode, you must press and hold the L1 button down as you power up the board.

Some USB to Serial adapters are unable to supply the required current to the Sonoff. If you see weird behaviour like the board restarting, you may need to power it externally with 3.3V (NOT MAINS!).

Colour Use
Violet VCC (3.3V)
White Tx
Grey Rx
Black Ground

N.B: Remember to "invert" the UART connections

Current Use

The traffic light currently cycles through the light cycle displayed at road junctions.


Pictures

Inside, showing the controller.
A close up of the controller, showing the programming lead.
The "real" 50W GY6.35 bulbs.