Reads light switches using an Arduino and publishes events to MQTT
Switch branches/tags
Nothing to show
Clone or download
Latest commit 40fed7a Oct 4, 2017
Failed to load latest commit information.
LightSwitchControllerMQTT.ino Renamed sketch Oct 4, 2017 Many documentation cleanups prior to release Oct 4, 2017

Light switch manager

Written by Jonathan Oxer for SuperHouse Automation Pty Ltd


Reads digital inputs on an Arduino Mega (or compatible board with on-board Ethernet, such as a Freetronics EtherMega) to detect button presses.

When a button press is detected, the event is reported to MQTT.

Can optionally display events locally using a Freetronics 128x128 colour OLED module.

See more at

Required Libraries

  1. PubSubClient.h

  2. FTOLED.h NOTE: Only required when using the OLED display option.


  1. Change directory to Arduino's main sketchbook directory
  2. git clone .
  3. Start Arduino IDE.
  4. Go to File--->Sketchbook--->LightSwitchControllerMQTT

Pin Allocations

Assuming a Freetronics EtherMega or EtherDue:

2 DHT temperature / humidity sensor 3 External watchdog "pat" (output) 5 Tilt sensor input (biased high internally) 16-47 Button inputs 48 OLED CS 49 OLED DC 53 OLED reset 54-69 Button inputs

Button Mappings

Each button is connected to a digital input.

Skips 62 and 64 in east switchboard using EtherDue. I can't remember why!

Port 1: D54-D61 (A0-A7) Port 2: D62-D69 (A8-A15) Port 3: D40-D47 Port 4: D16-D23 Port 5: D24-D31 Port 6: D32-D39


Copyright (C) 2015-2017 SuperHouse Automation Pty Ltd

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.