Controlling a Cheap "Neon" LED, Pt 1
Table of Contents
This all started with a spare “Neon” light that was meant for my sons room but it never went up. Something I found odd about this light was that it had the ability to be powered by either a USB connection OR a 3 AA battery pack. The thing that struck me was how they were both spliced together. I figured the amount of Volts must be similar.
If you want to skip the story and get to the good stuff, scroll down to Final Setup.
Let me preface this with: I know very little about electronics. This was my attempt at going from the “absolute beginner control a LED on a breadboard” to something I actually wanted.
Research #
I started looking at how much voltage a USB connector would provide. I found out it was about 5v. I had a spare microcontroller and I saw that it also had a 5v output.
I cut the line for the lights and tried connecting each end to either the ground and the 5v and success! So that would be always on, which I wasn’t looking for so the next step was using a digital pin to try to toggle it on.
I plugged in the neutral line to the ground and connected the digital pin to the light and ran some sample code that would flip on the pin every 5 seconds. And LIGHT! Well… more like “light”. The brightness was much lower. After I looked it up, I found the pins output 3.3v. Good but not good enough.
Relays and Transistors #
After consulting with a friend (thanks Oyvind!) I was suggested to check out relays. At the start of this journey I bought a cheap starter electronics pack with a bunch of components. After watching a few YouTube videos I settled on using the relay I had.
Relays are electric switches that use electromagnetism to convert small electrical stimuli into larger currents. These conversions occur when electrical inputs activate electromagnets to either form or break existing circuits. - Google
So now we can use our 3.3v digital pin to flip the relay on and off. That relay is fed 5v and when it’s on we have our bright LED!
To safely control the relay we use a transistor to control when the relay connection is completed.
Random Starter Pack I used:
Microcontroller (ESP8266) #
So I ordered a 5 pack of ESP8266 microcontrollers from Amazon for around $10. These are great because they’re super cheap and they come with easy to use WiFi library.
MQTT Broker #
I have small docker setup at my house running on a NUC. I read that
HomeAssistant can easily talk to a MQTT server so I searched for a simple broker
to run in docker. eclipse-mosquitto
was easy enough to run.
Final Setup #
This will likely be a 2 part post since I’m still writing the client and I want to talk a bit about the home assistant integration which could use some more polishing. Stay tuned!
Schematic #
Final Prototype Board #
Docker Config #
My MQTT broker is eclipse-mosquitto
My network iot
is an external docker network that routes to a vlan just for my
IOT devices.