---
title: "Example Application: Garage Overhead Light Controller"
url: "https://maker.wiznet.io/teju/projects/example-application%3A-garage-overhead-light-controller/"
markdown_url: "https://maker.wiznet.io/teju/projects/example-application%3A-garage-overhead-light-controller/md"
type: "UCC: User Created Content"
author: "Glen Akins"
author_url: "https://bikerglen.com/blog/p1am-100-open-source-plc-custom-add-on-modules/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Glen Akins"
original_url: "https://bikerglen.com/blog/p1am-100-open-source-plc-custom-add-on-modules/"
published: "2022-09-27"
language: "en"
hardware: ["WIZnet W5500"]
likes: 8
views: 1087
comments: 2
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Example Application: Garage Overhead Light Controller

> software to control the overhead lights in my garage based on the state of the garage door. Here are the requirements for the software:

Original author: Glen Akins (source: https://bikerglen.com/blog/p1am-100-open-source-plc-custom-add-on-modules/)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

[Embedded media](https://www.youtube.com/embed/sEBg51bWkn8)

For an example application, I decided to write some software to control the overhead lights in my garage based on the state of the garage door. Here are the requirements for the software:

1. At startup:
  1. Initialize the hardware.
  2. Display “Hello, world!” on the LED display.
  3. Read the Ethernet MAC address from the serial EEPROM.
  4. Display the Ethernet MAC address on the LED display.
  5. Initialize the P1AM-ETH hardware with the Ethernet MAC address and get an IP address and DNS server via DHCP.
  6. Once the Ethernet hardware is ready, display the IP address and DNS server on the LED display.

2. While idle:
  1. Move a dot around on the LED display to indicate that the software is still running.

3. When the garage door is opened:
  1. Display “Garage Door Opened” on the LED display.
  2. Send a message over the network to an Insteon controller to turn on the garage overhead lights.
  3. Send a message over the network to a custom board to turn on an industrial stack light inside the house to indicate the door is open.
  4. Turn on the P1AM-100’s builtin LED to indicate the door is open.

4. When the garage door is closed:
  1. Display “Garage Door Closed” on the LED display.
  2. Start a five minute timer.
    1. While the timer is running, display the time remaining on the LED display.
    2. After the timer expires, send a message over the network to an Insteon controller to turn off the garage overhead lights.
  3. Send a message over the network to a custom board to turn off an industrial stack light inside the house to indicate the door is closed.
  4. Turn off the P1AM-100’s builtin LED to indicate the door is closed.

All these things can be done on the local network without encryption and were successfully implemented. Rather than dive into the code here, I’ll let the (lack of) comments in the source code speak (or not) for themselves. The [Arduino sketch for the project](https://github.com/bikerglen/p1am-proto-experiments/tree/master/p1am-isolated-2x2-gpio/sketches/p1am-100-garage-door-monitor) is on GitHub. Let me know if you have questions on Twitter [@bikerglen](https://twitter.com/bikerglen) and I’ll try my best to answer them.

I initially wanted to send a message to the IFTTT maker channel to indicate the state of the door and to send a text message when the door was opened using Twilio but these tasks require SSL/TLS and basic authentication. There is an [SSLClient library for the ATSAMD21 and Arduino](https://github.com/OPEnSLab-OSU/SSLClient). I may look into using it at a later date.

## Hardware and Software Design Files

The hardware and software design files as well as the Eagle PCB library for a board to fit the prototype enclosure are located in [this GitHub repository](https://github.com/bikerglen/p1am-proto-experiments). This project is in the p1am-isolated-2×2-gpio subdirectory.

The software in the repository includes both applications. The first application is for testing out all the hardware and is a good starting point for seeing how to control different parts of the hardware. The second application is the garage door monitor application described above and demonstrated in the YouTube video.

---

Source: https://maker.wiznet.io/teju/projects/example-application%3A-garage-overhead-light-controller/
