Skip to main content

Serial Module Configuration

The serial module config options are: Enabled, Echo, Mode, Receive GPIO, Transmit GPIO and Sender. Serial Module config uses an admin message sending a ConfigModule.Serial protobuf.

This is a simple interface to send messages over the mesh network by sending strings over a serial port. Anything you send the node will be turned into a message sent out over the mesh, and anything received from the mesh will be sent to the serial port. Note that this module does not (yet) allow arbitrary protobuf commands to be sent over the serial connection.

image

Serial Module Config Valuesโ€‹

Enabledโ€‹

Enables the serial module.

Echoโ€‹

If set, any packets you send will be echoed back to your device.

Modeโ€‹

Defaults to 'Simple'.

Available Values:

  • DEFAULT
  • SIMPLE operate as an dumb UART tunnel. What goes in will come out, Requires a channel named 'serial'.
  • PROTO Exposes the Protobuf Client API on this serial port. You can use this to connect from another device. API Reference
  • TEXTMSG Will send the string received over the serial port as a Text Message for Display on the other devices.
  • NMEA Will output a NMEA 0183 Data stream containing the internal GPS or fixed position and other node locations as Waypoints (WPL).

Receive GPIO Pinโ€‹

Set the GPIO pin to the RXD pin you have set up.

Transmit GPIO Pinโ€‹

Set the GPIO pin to the TXD pin you have set up.

tip

Connect the TX pin to the other device's RX pin, and vice versa. Connect their grounds to each other (not necessary if they're both plugged into the same USB power source.)

Baud Rateโ€‹

The serial baud rate.

Timeoutโ€‹

The amount of time to wait before we consider your packet as "done".

tip

Once module settings are changed, a reset is required for them to take effect.

Serial Module Config Client Availabilityโ€‹

info

All serial module config options are available on iOS, iPadOS and macOS at Settings > Modules > Serial.

danger

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.

This module requires attaching a peripheral accessory to your device. It will not work without one.

Examplesโ€‹

Default is to use RX GPIO 16 and TX GPIO 17.

Basic Usageโ€‹

  1. Enable the module by setting serial.enabled to 1.

  2. Set the pins (serial.rxd / serial.txd) for your preferred RX and TX GPIO pins. On tbeam boards it is recommended to use:

    • RXD 13
    • TXD 14
  3. Set serial.timeout to the amount of time to wait before we consider your packet as "done".

  4. (Optional) set serial.mode to TEXTMSG if you want to send messages to/from the general text message channel

  5. Connect to your device over the serial interface at 38400 8N1.

    With tio โ€“ tio -e -b 38400 -f none /dev/myserialport

  6. Send a packet up to 237 bytes in length. This will get relayed over the mesh network.

  7. (Optional) Set serial.echo to 1 and any message you send out will be echoed back to your device.

Interfacing PIR Sensor With External Microcontrollerโ€‹

The following is an example of using a Raspberry Pi Pico connected to a PIR sensor to detect motion. When motion is detected, a message is sent via. serial to the T-Beam. The T-Beam transmits the message as text over the default channel by utilizing the serial module in TXTMSG mode.

BOMโ€‹

Meshtastic Software Configurationโ€‹

  • Serial module enabled, mode: TXTMSG
  • GPIO Pins (For T-Beam) RX 13, TX 14
  • 38400 Baud

Wiringโ€‹

image

  • TX pin 14 on the T-Beam to RX pin 2 on the Pico
  • RX pin 13 on the T-Beam to TX pin 1 on the Pico
  • PIR sensor Vcc and GND pins to Vcc/GND on breadboard respectively
  • PIR sensor trigger line to Pico GPIO28 (Pico pin 34)
  • GND pin on T-Beam to GND pin 38 on the Pico
  • GND pin 38 on the Pico to breadboard ground rail
  • 3V3 pin 36 on the Pico to the breadboard positive voltage rail
  • Optional, to power the Pico off of the T-Beam instead of USB:
    • Connect 5V pin on T-Beam to Vbus pin 40 on the Pico

Circuit Python Codeโ€‹

import time
import board
import busio
import digitalio

# Setup PIR sensor on GP28
pir = digitalio.DigitalInOut(board.GP28)
pir.direction = digitalio.Direction.INPUT

# Setup serial UART connection TX/RX on (GP0/GP1)
uart = busio.UART(board.GP0, board.GP1, baudrate=38400, timeout=0)

while True:
if(pir.value == True):
uart.write(bytes("Motion Detected", "ascii"))
time.sleep(30)
time.sleep(0.5)