For firmware versions > 2.5.3, this module requires you to compile your own firmware and remove the `-DMESHTASTIC_EXCLUDE_REMOTEHARDWARE=1` build flag in `platformio.ini`.
Additionally, while configuring this module may be available in clients, setting and reading GPIO's is currently only possible using the [Meshtastic Python CLI](/docs/software/python/cli)
GPIO access is fundamentally dangerous because invalid options can physically damage or destroy your hardware. Ensure that you fully understand the schematic for your particular device before trying this as we do not offer a warranty. Use at your own risk.
- Receive a notification over the mesh if any GPIO changes state.
Note that it cannot detect fast changes like button presses. For this, look at the [Detection Sensor module](/docs/configuration/module/detection-sensor) instead.
The result of reading a GPIO or notifications of GPIO changes will also be sent over MQTT (if enabled) in JSON format (if enabled).
You can get the latest python tool/library with `pip3 install --upgrade meshtastic` on Windows/Linux/OS-X. See the [python section](/docs/software/python/cli/installation) for more details.
To prevent access from untrusted users, you must first make a `gpio` channel that is used for authenticated access to this feature. You'll need to install this channel on both the local and remote node. Furthermore, you need to enable the module on both units.
Now both devices should be able to talk over the `gpio` channel. Send a text message from one to the other to verify. Also run `--nodes` to verify the second node shows up.
A mask is used to set the GPIOs to control. For GPIO 1, bit 1 of the mask is set (0x2 in hexadecimal), for GPIO 2, bit 2 of the mask is set (0x4 in hexadecimal), and so on.
To determine the appropriate mask for the pin(s) that you want to know, the python program (and output) below might help:
You can programmatically do operations from your own python code by using the Meshtastic `RemoteHardwareClient` class. See the [Python API](/docs/software/python/cli/installation) documentation for more details.
You can add a simple LED and resistor to validate that the GPIO operations work as expected. Use [this tutorial](https://www.instructables.com/Slide-Switch-With-Arduino-Uno-R3/) as a guide.
### Requirements
- (x2) Meshtastic devices (one device could be on a local computer, and the other one just has to be powered and is the one with the LED to be connected to it)
- (x2) wires (black and yellow; they can be any color but typically black is used for ground)
- (x1) LED
- (x1) 220Ω resistor (somewhat optional, but recommended)
- (x1) Breadboard (optional)
### Preparation
1. Disconnect the remote device from power (battery/usb)
2. Connect the resistor to the longer (positive) lead of the LED and the yellow wire to the other end of the resistor
3. Connect the other end of the yellow wire to a GPIO pin that will not cause any issues (ex: for TLoraV1, we can use GPIO21)
4. Connect the black "ground" wire from the ground pin on the device (ex: for TLoraV1 it is the end pin next to the RST button) to the shorter (negative) lead of the LED
5. Power on the device
### Validation
By default, the pin may be "off" or "on". (It will most likely "off".) See the steps below for running commands. In the example of GPIO21, the mask would be `0x200000`.