The ButtinoRAK library is an opinionated library for Arduino that allows you to easily put your RAK3172 device into sleep mode by pressing a button. This simplifies power management and conserves battery life in your projects.
This library assumes you have are using a RAK3172 and a momentary button.
- Sleep activation: Put the device into sleep mode by pressing the button a configurable number of times (default: 5).
- Device reboot/power-on: Trigger a system reboot or power-on by performing a long press on the button.
You can install the ButtinoRAK library through the Arduino Library Manager or manually as a ZIP file.
- Open the Arduino IDE.
- Go to Sketch -> Include Library -> Manage Libraries.
- In the Library Manager, search for "ButtinoRAK".
- Click on the ButtinoRAK library and click the Install button.
- Download the ButtinoRAK library as a ZIP file from the GitHub repository: https://github.com/placeholder.
- In the Arduino IDE, navigate to Sketch -> Include Library -> Add .ZIP Library.
- Select the downloaded ZIP file of the library and click Open.
- Connect a the momentary button to a digital pin (default:
WB_IO4
) of the RAK3172. - Connect the RAK3172 to the pc using a USB cable.
To begin using the ButtinoRAK library, include the library header at the beginning of your sketch:
#include <ButtinoRAK.h>
Next, create an instance of the ButtonHandler
class:
ButtinoRAK buttinoHandler;
In the setup()
function, initialize the ButtinoRAK library by calling the begin()
method:
void setup() {
buttinoHandler.begin(WB_IO5); // or buttinoHandler.begin(); for default pin
}
NOTE: The begin()
method takes an optional parameter to specify the pin number of the button. If you don't specify the pin number, the default pin number WB_IO4
will be used.
NOTE2: pinMode
is set to INPUT_PULLUP
by default.
The ButtinoRAK library uses the Serial
object to print debug messages and it enabled by default right now. If you want to disable it, you can by defining the BUTTINORAK_DEBUG
build variable to 0
before building your sketch.
We welcome contributions to the ButtinoRAK library! Please fork the repository on GitHub and submit pull requests for any changes or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.