-
1Building The Board
Intro:
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:
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Isolation cutouts in the PCB need to be added for better electrical safety if used to toggle high voltage AC load.
-
2Software Setup
Intro:
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.
MQTT:
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
- Go to https://www.cloudmqtt.com/
- Register for a free account (This gives you 5 concurrent devices and 10 Kbit/s transfer speed for free)
- Create a new MQTT instance
- Make note of your username, password and the CloudMQTT server/port you are assigned
Tutorial: http://www.steves-internet-guide.com/create-mqtt-broker-cloudmqtt/
Step 2: Install MQTT.fx
- Go to: https://mqttfx.jensd.de/
- Download the version of MQTT.fx applicable to you e.g. Mac/Windows or 32/64bit
- Open MQTT.fx and add your MQTT server using the details from Step 1 above
- Connect to the new server
- Subscribe to the following topic: GARAGE/CONTROLLER/STATUS
- Now use the Publish option and publish the value ONLINE to GARAGE/CONTROLLER/STATUS
- 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.
Tutorial: https://www.alibabacloud.com/help/doc-detail/86706.htm
ARDUINO IDE:
Step 1: Install Arduino IDE
- Go to https://www.arduino.cc/en/main/software
- Download the version of the Arduino IDE applicable to you e.g. Mac/Windows
- Once installed, open the IDE and see if you can compile the default sketch using the check mark icon
Tutorial: https://www.arduino.cc/en/guide/windows
Step 2: Install the ESP8266 library
- Go to https://www.teachmemicro.com/intro-nodemcu-arduino/
- Follow the instructions to get the NodeMCU ESP8266 library installed
- Connect your NodeMCU module to your computer and wait for it to install the relevant drivers
- In the case of Windows check under Device Manager to see what COM port the NodeMCU unit is connected to
- In your Arduino IDE go to Tools-> Board-> Select NodeMCU V1.0
- In your Arduino IDE go to Tools-> Board-> Port-> Select the COM port your NodeMCU unit is connected to
- Once completed, compile and flash the default Arduino sketch to the NodeMCU just to check everything in the tool chain is working.
Tutorial: https://www.teachmemicro.com/intro-nodemcu-arduino/
Step 3: Install the PubSub library
- Go to https://github.com/knolleary/pubsubclient/releases/tag/v2.7
- Download the latest PubSub library or download the V2.7 one I used from this project's files
- Place the library under your library folder for Arduino IDE e.g. On Windows: Documents\Arduino\libraries
Tutorial: https://pubsubclient.knolleary.net/
Step 4: Flash the NOAH Baseboard firmware
- Download the latest firmware from this project Baseboard FWV1.0 or newer
- Open the file in the Arduino IDE
- Change the following details:
- Set your WiFi SSID
- Set your WiFI Password
- Set your Device ID
- Set your Device Topic
- Set your MQTT Broker Server address
- Set your MQTT Port
- Set your MQTT Username (if used otherwise leave blank)
- Set your MQTT Password (if used otherwise leave blank)
- Flash the sketch to your NodeMCU board
- If successful install the NodeMCU boad in the Baseboard
- Power up the Baseboard and if the WiFi and MQTT server connection was successful the STATUS LED should turn on
Step 5: Test
- Make sure that MQTT.fx is connected to our MQTT broker (See the MQTT section)
- Make sure that MQTT.fx is subscribed to the topic GARAGE/CONTROLLER/STATUS
- Now press the reset button or power up the Baseboard and you should see a ONLINE message appear
- Using MQTT.fx publish a 1 to the topic GARAGE/GATE01/SET
- The moment you publish the above message, Relay 1 should turn on for 1 second and then off again
-
3Testing
Intro:
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:
- Using MQTT.fx connect to your MQTT Broker Server (If you are not already connected)
- Subscribe to the topic GARAGE/CONTROLLER/STATUS
- Connect the Baseboard to 5V power or press the reset button if already powered up
- If the Baseboard starts up successfully the STATUS LED will light on the board (If not, check your WiFi and MQTT Broker details)
- Using MQTT.fx under the topic GARAGE/CONTROLLER/STATUS you should see a ONLINE message appear
Output Testing:
- Using MQTT.fx connect to your MQTT Broker Server (If you are not already connected)
- Publish the value of 1 to the following topic GARAGE/GATE01/SET
- Repeat the above steps on the following topics to test relay 2-5
- GARAGE/GATE02/SET
- GARAGE/DOORV/SET
- GARAGE/LIGHT01/SET
- GARAGE/OTHER/SET
Input Testing:
- Using MQTT.fx connect to your MQTT Broker Server (If you are not already connected)
- Subscribe to the following topic GARAGE/GATE01/STATUS
- Using a wire bridge the G & I pins for input 1 on the Baseboard
- If the trigger was successful a value of 1 should appear in MQTT.fx under GARAGE/GATE01/STATUS
- Repeat the above steps on the following topics
- GARAGE/GATE02/STATUS
- GARAGE/DOORV/STATUS
- GARAGE/DOORN/STATUS
- GARAGE/OPTIONAL/STATUS
- GARAGE/MOVEMENT/STATUS
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.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.