Recently I published a simplified version of the Always-On project hardware. Read this post for details. Today I publish a firmware example for the Always-On project.
I chose this approach, because it works on every operating system. Also, the Visual Studio Code development environment has code completion and all modern editor features one would expect. It works seamlessly with my HAL layer, to write rock solid and easy to understand code.
How to Setup the Project
- Install PlatformIO with Visual Studio Code as described here: https://platformio.org/platformio-ide
- Clone the
AlwaysOnWorkshoprepository with all submodules:
git clone --recurse-submodules email@example.com:LuckyResistor/AlwaysOnWorkshop.git
- Open the project in Visual Studio Code from the PIO home page.
That is all you have to do. The required platform libraries for the project should be installed automatically after you open the project the first time.
About the Firmware Example
The firmware assumes the following hardware configuration:
- The workshop light is attached to the (
- The switch in the workshop is configured as push button and attached at the (
- Two motion sensors are attached at
S2, rising the line from GND to V3.3 if motion is detected.
- A simple four LED display is attached using a
TCA9534IO-expander chip on the
SCApins. See the following schema:
If you enter the workshop, the light is automatically turned on. If you leave it, it will automatically turn off after one hour.
To shorten the duration to turn the light off, you simply press the light switch once when you leave the workshop. If no motion is detected in the next 30 seconds, the light will turn off.
The provided example code should give you an excellent start for your firmware. The Always-On project is meant to provide a reliable bridge between the mains power installation and any smart controlling system.
If you have any questions, missed any information, or simply want to provide feedback, feel free to comment below. 😄