Arduino Smart Lighting Control System - SHProject 3

by DeviceCtrl in Circuits > Arduino

137 Views, 4 Favorites, 0 Comments

Arduino Smart Lighting Control System - SHProject 3

PXL_20240614_023112938.jpg

I have a small IT closet that houses the Internet ONT, WiFi router, network printer and Ethernet switches along with data and media servers. It also serves as a distribution point for the low voltage wiring and all the Cat6 Ethernet cable for my home.

So it seems logical to create and install a smart home lighting and device controller here. This device has a simple User Interface that can control any of the relays. It will also monitor the Arduino serial connection (via USB) that allows a PC to programmatically control the relays.

In my home I will integrate the manual light switches so lighting / devices can be controlled by an app on my phone, or software on my PC or by just manually flipping a light switch.

While this device can function as a stand-alone controller, it is designed to be permanently connected to a PC via its USB port.

Supplies

arduino uno pinout.png

Arduino Uno

2) 4 Channel 5V Relay Module with Opto-coupler

ST7920 128X64 Display

Red momentary switch

Black momentary switch

project box

USB type B 3 foot cable

Solid State Relay DC to DC (optional)

Arduino Schematic

itcloset_controller.png
PXL_20240614_163657563.MP.jpg

I like to begin my Arduino projects by mocking up the wiring using bread boards and jumper wires. Adding each component one by one, ensuring that I have hooked them up correctly and they are giving the expected results. So follow the above diagram to construct the control unit.

Downloads

UI Display

124x64_display.png
itcloset_UI.png
blue_button.png
red_button.png

I used a 128 x 64 LCD display that is compatible with the U8glib graphics library. This creates a User Interface (UI) to the 8 relays. The black momentary button will allow you to select a relay. The Red button will invert the current state of the relay (like a light switch).

Connect:

  • pin 14 (A0) to SCK
  • pin 15 (A1) to CS
  • pin 16 (A2) to SIO
  • GND to ground
  • +5V to VCC
  • pin 2 to black momentary switch
  • pin 3 to red momentary switch

Assemble in Box

PXL_20240614_164334866.jpg
4channel-opto-relay.png
716-DNs2AQL._SL1500_.jpg
FSDLW3KLXD9SM9L.jpg

Now that the UI display is working and you are able to trigger relays, it's time to assemble all the components in the project box. And connect the display and relays to the Arduino. You might notice that the relay on the left bottom (ie relay #1) is not used. It has been replaced with a solid-state relay (SSR). The reason is that relay #1 turned the Stereo System on/off. The mechanical relay introduced EM noise into the system and you could always hear a faint buzz from the speakers. The SSR helped solve this problem.

If you dont want or need the SSR, just edit the Arduino code and set useSSR = false;

Once assembled, you can test all the functionality by using Arduino IDE Serial monitor interface. Valid commands sent via serial interface are always enclosed in square brackets:

  • [ve] - get current software version
  • [id] - get device id
  • [re] - reset all relays to OFF
  • [99] where 1st digit is relay (ie 1 - 8) 2nd digit can be 0,1 or 2 0=OFF, 1=ON, 2=Invert state
  • ex: [31] = turn relay 3 ON, [52] = if relay 5 is ON turn it OFF. If relay 5 is OFF turn it ON

Note: when the device receives a command (valid or not) it will always respond with a 9 character string.

Like: 00000000; or 01100010; Characters 1-8 represent the state of the relays 1-8 and will have a value of 0 or 1. The string always terminates with semi-colon.

In the 1st example, all the relays are OFF. The 2nd example, relays 2,3 and 7 are ON.

Wiring Lighting and Devices

low_voltage_lighting.png
decklights_wiring_diagram.png

Setting up relays for the low voltage light is a snap when using the existing low voltage wiring. It can be easily adapted to AC voltage as these relays are rated for 120/240 VAC. Be careful handling any voltage AC or DC. If your not sure, get a professional or someone very experienced.

If this device is your sole means to active your lights or devices then your done! If want to be able to turn on lights or a printer manually or programmatically (ie from your PC or smart phone) then you have to wire the device/light like you would a 3-way switch. Fortunately, these opto-coupler relays are built the same way a 3-way switch from the hardware store was built.

Review the 2nd wiring diagram and you see how a light can controlled by this device or a regular light switch. Note that on the wiring diagram: nc = normally closed, no = normally open