Skip to content

bpatram/arduino-status-light

Repository files navigation

Relay Stack Light

Control a stack light via serial communications through an Arduino! To get this project setup and running will require minimal knowledge for wiring up an Arduino (and shield) to a light fixture.

Hardware Requirements

This project uses the following hardware to operate:

Usage

Setup

You can use the following diagram to guide you in wiring everything together:

wiring guide

It's worth noting that although the relay shield has 4 relays, we are only using 3 since the stack light we are using only has 3 lights (red, green, yellow). We do not use the fourth relay, but it can still be controlled in commands sent.

Interacting

Right now you can only communicate to the Arudino via serial communication. You can use the following to assist in this:

  • screen /dev/cu.usbmodel3111 19200
  • Using the Serial Monitor in the Arduino IDE or VS Code extension

The Arudino software is set to run at 19200 baud. If you are seeing malformed/odd characters then make sure you have set the correct baud rate.

Commands

Each command will return the final relay status, which can be parsed as needed.

Command Description Example
? Print commands available ?
! Print relay status (on or off) !
+ [relayNumber] Turn on a single relay or all relays (if not defined) + 1
- [relayNumber] Turn off a single relay or all relays (if not defined) - 1
/ Toggle a single relay or all relays (if not defined) / 1
: [relayNumber] [iterationCount=1] [onTime=500] [offTime=500] [dwellTime=0] Flash one or all relays at once : ? 3 500 500 500
~ [iterationCount=1] [onTime=200] [offTime=0] [dwellTime=0] Flash each relay in order ~ 3 500 500 500
% Run demo mode %

Contributing

It's much easier to use VS Code or another text editor/IDE instead of the very basic/limiting Arudino IDE.

Setup VSCode

  1. Install Arudino IDE for all system packages
  2. Add the Arduino extension to VSCode (vsciot-vscode.vscode-arduino)
  3. Add the EditorConfig extension to VS Code (EditorConfig.EditorConfig)

Setup Protobuf

This is only needed if you are looking to re-compile the Protobuf messages. This repo includes the current header files representing the current Protobuf messages.

  1. Install Python brew install python
  2. Install Protobuf brew install protobuf
    • If you see a message about not being able to import the module run the suggested command: echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
  3. Install the NanoPB library
    1. Download the NanoPB repo as a .zip file
    2. Extract the .zip file contents to ~/Documents/Arduino/libraries/nanopb-master
      • Alternatively you can do this within Arudino IDE via the Sketch > Include Library > Add .ZIP Library... menu item
    3. Run make in the generator/proto directory
  4. Install the NanoPB Arduino bridge library
    1. Download the NanoPB-Arduino repo as a .zip file
    2. Extract the .zip file contents to ~/Documents/Arduino/libraries/nanopb-arduino-master
      • Alternatively you can do this within Arudino IDE via the Sketch > Include Library > Add .ZIP Library... menu item
    3. Within the nanopb-arduino-master directory, move the contents of the src folder up a level

Compiling Protobuf Messages

  1. Make changes to the commands.proto file as needed
  2. Navigate to the arduino-controller/proto directory
  3. Run ./compile_pb.sh to output header files
    • NOTE: Recompiling the entire Arduino project will be needed after to utilize the changes made

Roadmap

  • Arudino to interface Relay shield to serial communications
  • Code documentation
  • Javascript wrapper library to assist with interfacing to Arudino via serial
  • Expand Javascript library to connect to various application monitoring services

About

Arduino + Relay + Stack Light for service monitoring goodness

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published