MQTT NOAH Baseboard

ESP8266 NodeMCU baseboard for adding some physical control to your home automation projects

Public Chat
Similar projects worth following
I recently designed this board as part of my bigger home automation project. It is primarily designed as a baseboard to house the ESP8266 NodeMCU module and bridge it out to 5 relays and 5 inputs.

Currently, it runs an Arduino sketch to allow the unit to be controlled using MQTT and thus be controlled by my OpenHAB home automation server. The sketch can, however, be easily modified to connect to your MQTT broker of choice or use the multitude of ESP8266 libraries out there to control it using a different interface.

For reference, the NOAH stands for Network of Automated Hardware as this board forms part of my larger set of hardware controllers for my home.

NOAH Baseboard

The GSM controller that came with my gate motor when I bought my house recently decided to give up the ghost. Now I could go out and buy a replacement unit but where is the fun in that. So with a bit of time spent and some parts lying around waiting for a project I decided to design my own controller for the garage and gate.

Now the new controller will not have its own GSM module as I already have a few tied into my existing home automation system and will be using a call from them to trigger the gate. However, I have been itching to try out a Telegram/MQTT/Wireless control chain as part of something else I am working on so thus the MQTT NOAH Baseboard was born.

This unit had to fulfill the following requirements:

  1. 5 x Relays (Gate01, Gate02, Garage Door, Garage Light and one Optional)
  2. 5 x Inputs (Common ground as most gate and garage controllers use this output)
  3. 5V Supply (Fed from a power bank for easy backup power)
  4. Fit the ESP8266 NodeMCU module
  5. MQTT controlled
  6. Wireless

A very important note: NEVER RELY ON WIRELESS FOR CRITICAL CONTROL. You don't want to be stuck in a situation where you are unable to open/close/receive alerts because your neighbor decided to connect a telecoms level wireless transmitter and point it at your house.

These things should be connected using wires, but since I have backup remote controls and enterprise-grade WiFi covering my yard I thought what the heck, this unit will be wireless. Guess in this case I am actually the neighbor with the telecoms equipment mmm..., but I digress. 

Software Needed:

  1. Arduino IDE
  2. Installed ESP8266 board library for NodeMCU
  3. Installed PubSub library (Thanks knolleary)
  4. Working MQTT broker (Any of the following: CloudMQTT, Mosquito, Adafruit MQTT)
  5. MQTT.fx 


The unit is controlled by subscribing and publishing to a set of MQTT topics. For the purpose of this post I will not go into detail about how MQTT works, there are brilliant videos on the internet that do an excellent job. 

If you want to test the unit, change your Arduino sketch to include your WiFi credentials and MQTT broker. Then publish a 1 to the SET topics below to trigger the relays. Monitor the STATUS topics for the state of the input pins.

My topics work as follows:


Output Topics:

  1. Relay 1  - GARAGE/GATE01/SET
  2. Relay 2 - GARAGE/GATE02/SET
  3. Relay 3 - GARAGE/DOORV/SET
  4. Relay 4 - GARAGE/LIGHT01/SET

Input Topics:

  1. Input 1  - GARAGE/GATE01/STATUS
  2. Input 2 - GARAGE/GATE02/STATUS

I will go through detailed notes on setting up everything in the logs below on this project. 

- Build, connect, control!

Adobe Portable Document Format - 320.47 kB - 03/30/2019 at 21:06


Adobe Portable Document Format - 101.13 kB - 03/30/2019 at 21:06


Baseboard FW

Arduino sketch containing the example firmware

x-zip-compressed - 2.64 kB - 03/30/2019 at 17:30


MQTT PubSub libary from knolleary

x-zip-compressed - 40.78 kB - 03/30/2019 at 17:29


BaseBoard HW

Eagle CAD Schematics, Board Layout and Gerbers

x-zip-compressed - 1.02 MB - 03/30/2019 at 15:30


  • 1
    Building The Board


    This is the fun part of most things I do, building the PCB. I used Eagle CAD 7.6.0 for my PCB design because hey, I have a license and I know it already. If you have a CAD tool like KiCAD just make sure after importing the files that everything still looks good.

    You have the option of sending this board out for production using a PCB service like OSH Park, JLC PCB or any of the others or etching it yourself. I generated the gerbers and they can be found under the Baseboard HW file that you can download from this project. As I etched this board myself, I cannot vouch for the correctness of the gerbers in any way. I will however have a few made at a later stage using a PCB service and will update the files if that process results in any glaring errors.

    Important Electrical Notes:

    A few things you need to know about this board:

    1. The design of the Baseboard uses a 5V supply to drive the NodeMCU module and the relays. However keep in mind that the NodeMCU runs on 3.3V (on board 3.3V regulator) and thus its pins are only 3.3V tolerant. 
    2. The 74HC595 shift register IC has a TTL level input that triggers on 3.3V so this is used to drive the ULN2803A and optional outputs.
    3. The 74HC595 output pins and ULN2803A input pins are connected together but in reverse order(single sided layout has its glamour). So to trigger output 1 you need to write the value of 128 out to the shift register. See schematic for details.
    4. The inputs are common ground and have pull-up resistors to the 3.3V rail to keep them high. When pulled low this triggers the input.
    5. The input for the IR motions sensor is shared with input No 5. If you use the IR Motion header your cannot use input No 5 for something else and vice versa.
    6. Revision 1 of the hardware has the IR Motion header located next to Relay 1 (the stupidity burns). Toggling of Relay 1 when it is used to switch a heavy load like AC can cause accidental triggering of the IR Motion/Input No 5 pin.
    7. Isolation cutouts in the PCB need to be added for better electrical safety if used to toggle high voltage AC load.
  • 2
    Software Setup


    The most important part to get any electronics project you download from the internet up and running is the software tool chain. If you don't manage to get this set up it causes hours of frustration long before you get to the interesting part. 

    I am going to give as detailed a description of the setups as possible starting with MQTT. I will also link to any external tutorials I used and give full credit to those people for their hard work in putting those guides together.

    Grab <applicable high caffeine content drink> and buckle up as there is a hell-a-lot of steps.


    Step 1: Setup a MQTT broker

    For ease of use I am going to make use of CloudMQTT but almost any MQTT broker will do. You can even install your own using the MQTT Mosquito on Windows/Mac/Linux

    1. Go to
    2. Register for a free account (This gives you 5 concurrent devices and 10 Kbit/s transfer speed for free)
    3. Create a new MQTT instance
    4. Make note of your username, password and the CloudMQTT server/port you are assigned


    Step 2: Install MQTT.fx

    1. Go to:
    2. Download the version of MQTT.fx applicable to you e.g. Mac/Windows or 32/64bit
    3. Open MQTT.fx and add your MQTT server using the details from Step 1 above
    4. Connect to the new server
    5. Subscribe to the following topic: GARAGE/CONTROLLER/STATUS
    6. Now use the Publish option and publish the value ONLINE to GARAGE/CONTROLLER/STATUS
    7. Going back to your Subscribe window you should now see the message has been received.

    It is crucial to get the above working as MQTT.fx will be your designated diagnostic and testing tool as we go further.



    Step 1: Install Arduino IDE

    1. Go to
    2. Download the version of the Arduino IDE applicable to you e.g. Mac/Windows
    3. Once installed, open the IDE and see if you can compile the default sketch using the check mark icon


     Step 2: Install the ESP8266 library

    1. Go to
    2. Follow the instructions to get the NodeMCU ESP8266 library installed
    3. Connect your NodeMCU module to your computer and wait for it to install the relevant drivers
    4. In the case of Windows check under Device Manager to see what COM port the NodeMCU unit is connected to
    5. In your Arduino IDE go to Tools-> Board-> Select NodeMCU V1.0
    6. In your Arduino IDE go to Tools-> Board-> Port-> Select the COM port your NodeMCU unit is connected to
    7. Once completed, compile and flash the default Arduino sketch to the NodeMCU just to check everything in the tool chain is working.


    Step 3: Install the PubSub library

    1. Go to
    2. Download the latest PubSub library or download the V2.7 one I used from this project's files
    3. Place the library under your library folder for Arduino IDE e.g. On Windows: Documents\Arduino\libraries


    Step 4: Flash the NOAH Baseboard firmware

    1. Download the latest firmware from this project Baseboard FWV1.0 or newer
    2. Open the file in the Arduino IDE
    3. Change the following details:
      1. Set your WiFi SSID
      2. Set your WiFI Password
      3. Set your Device ID
      4. Set your Device Topic
      5. Set your MQTT Broker Server address
      6. Set your MQTT Port
      7. Set your MQTT Username (if used otherwise leave blank)
      8. Set your MQTT Password (if used otherwise leave blank)
    4. Flash the sketch to your NodeMCU board
    5. If successful install the NodeMCU boad in the Baseboard
    6. Power up the Baseboard and if the WiFi and MQTT server connection was successful the STATUS LED should turn on

    Step 5: Test

    1. Make sure that MQTT.fx is connected to our MQTT broker (See the MQTT section)
    2. Make sure that MQTT.fx is subscribed to the topic GARAGE/CONTROLLER/STATUS
    3. Now press the reset button or power up the Baseboard and you should see a ONLINE message appear
    4. Using MQTT.fx publish a 1 to the topic GARAGE/GATE01/SET
    5. The moment you publish the above message, Relay 1 should turn on for 1 second and then off again
  • 3


    As anyone will tell you, home automation is no joke and it can get very complicated very fast. The Baseboard was designed for my specific needs so the MQTT topics are very specific, but nothing stops you from changing them to your own. For the purposes of testing the board I will assume that you used my default topics that the firmware I provided came with.

    The testing step assumes you manged to get the software all set up and working. If not... avoid this part.

    Startup Testing:

    1. Using MQTT.fx connect to your MQTT Broker Server  (If you are not already connected)
    2. Subscribe to the topic GARAGE/CONTROLLER/STATUS
    3. Connect the Baseboard to 5V power or press the reset button if already powered up
    4. If the Baseboard starts up successfully the STATUS LED will light on the board (If not, check your WiFi and MQTT Broker details)
    5. Using MQTT.fx under the topic GARAGE/CONTROLLER/STATUS you should see a ONLINE message appear

    Output Testing:

    1. Using MQTT.fx connect to your MQTT Broker Server (If you are not already connected)
    2. Publish the value of 1 to the following topic GARAGE/GATE01/SET
    3. Repeat the above steps on the following topics to test relay 2-5
      1. GARAGE/GATE02/SET

    Input Testing:

    1. Using MQTT.fx connect to your MQTT Broker Server (If you are not already connected)
    2. Subscribe to the following topic GARAGE/GATE01/STATUS
    3. Using a wire bridge the G & I pins for input 1 on the Baseboard
    4. If the trigger was successful a value of 1 should appear in MQTT.fx under GARAGE/GATE01/STATUS
    5. Repeat the above steps on the following topics

    If you managed to make it this far and the testing was successful you now have a working board. Feel free to re-write the firmware, make use of any of the ESP8266 libraries for control of the board other than with MQTT. Or dive in to the world of OpenHAB to setup your boad as a device to be controlled.

View all 3 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates