2022-01-18 14:27:59 -08:00
---
2022-03-08 23:10:41 -08:00
id: canned-message-module
2022-01-18 14:27:59 -08:00
title: Canned messages
sidebar_label: Canned messages
2022-04-24 15:32:31 -07:00
sidebar_position: 3
2022-01-18 14:27:59 -08:00
---
2022-04-01 14:07:46 -07:00
2022-03-18 05:53:08 -07:00
import PluginModule from '@site/docs/_blocks/_plugin_module.mdx';
2022-03-08 23:10:41 -08:00
2022-01-18 14:27:59 -08:00
## About
2022-03-08 23:10:41 -08:00
The Canned Message Module will allow you to send messages to the mesh network
2022-01-18 14:27:59 -08:00
from the device without using the phone app.
You can predefine text messages to choose from.
## Hardware
To navigate through messages and select one, you will require some
hardware attached to your device.
2022-03-08 23:10:41 -08:00
Currently, the module is tested with a generic rotary encoder, but this is
2022-01-18 14:27:59 -08:00
not a limitation further input methods can be added in the future.
### Rotary encoder
Meshtastic supports hardwired rotary encoders as input devices.
2022-03-08 23:10:41 -08:00
(Technically the Canned Message Module is independent of rotary
2022-01-18 14:27:59 -08:00
encoders. It is described here, because no other module utilizes rotary encoders just yet.)
You will need a generic rotary encoder. The types listed below has five legs
where two is dedicated to a "press" action,
but any other types will likely do the job. You can also use a
three-legged version, where the "press" action should be wired from
an independent switch.
2022-03-08 23:10:41 -08:00
- [Amazon link](https://www.amazon.com/Rotary-Encoder-Washers-Digital-Potentiometer/dp/B07Y619CZR/ref=sr_1_21?keywords=rotary+encoder&qid=1642317807&sprefix=rotary+enco%2Caps%2C186&sr=8-21)
- [Amazon.DE link](https://www.amazon.de/-/en/sourcing-Degree-Rotary-Encoder-Digital/dp/B07RLZPX5K/ref=sr_1_12?keywords=rotary+encoder&qid=1642320025&sprefix=rotary%2Caps%2C105&sr=8-12)
- [Aliexpress link1](https://www.aliexpress.com/item/32992227812.html?spm=a2g0o.productlist.0.0.1afe21a50SLvi2&algo_pvid=a19c4182-08aa-406d-bfdf-132582ef5ebb&algo_exp_id=a19c4182-08aa-406d-bfdf-132582ef5ebb-23&pdp_ext_f=%7B%22sku_id%22%3A%2266940265509%22%7D&pdp_pi=-1%3B1.66%3B-1%3B-1%40salePrice%3BUSD%3Bsearch-mainSearch)
- [Aliexpress link2](https://www.aliexpress.com/item/32946444853.html?spm=a2g0o.productlist.0.0.1afe21a50SLvi2&algo_pvid=a19c4182-08aa-406d-bfdf-132582ef5ebb&aem_p4p_detail=2022011523263276283624312400022072680&algo_exp_id=a19c4182-08aa-406d-bfdf-132582ef5ebb-6&pdp_ext_f=%7B%22sku_id%22%3A%2266223434642%22%7D&pdp_pi=-1%3B1.91%3B-1%3B-1%40salePrice%3BUSD%3Bsearch-mainSearch)
- [Aliexpress link3](https://www.aliexpress.com/item/10000056483250.html?spm=a2g0o.productlist.0.0.1afe21a50SLvi2&algo_pvid=a19c4182-08aa-406d-bfdf-132582ef5ebb&algo_exp_id=a19c4182-08aa-406d-bfdf-132582ef5ebb-9&pdp_ext_f=%7B%22sku_id%22%3A%2220000000116682147%22%7D&pdp_pi=-1%3B2.51%3B-1%3B-1%40salePrice%3BUSD%3Bsearch-mainSearch)
2022-01-18 14:27:59 -08:00
Connect your rotary encoder as follows. The rotary encoder has two
rows of legs. One of the rows contains two legs, the other contains three
legs. Bottom side view:
B o --- o PRESS
GND o | |
A o --- o GND
The two legs is to sense the press action (or push). Connect
one of the two to GROUND and the other to a GPIO pin. (No matter which one
goes where.) Let's call this connected ports 'PRESS'.
2022-03-08 23:10:41 -08:00
The three legs is to sense the rotation action.
2022-01-18 14:27:59 -08:00
Connect the middle leg to GROUND and the ones on the side
to GPIO pins. Let's call these ports 'A' and 'B', according to
the scheme below.
A --||
GND --||]========
B --||
Recommended GPIO pins for connecting a rotary encoder.
2022-03-08 23:10:41 -08:00
- TTGO LoRa V1:
- A - GPIO-22
- B - GPIO-23
- PRESS - GPIO-21
2022-01-18 14:27:59 -08:00
There is a reference case 3D-design utilizing the rotary encoder for TTGO LoRa V1:
[Case for TTGO-ESP32-LORA-OLED-v1.0 with rotary encoder](https://www.thingiverse.com/thing:5178495)
### Configuration of the rotary encoder #1
rotary1_enabled
Enable the rotary encoder #1
rotary1_pin_a
GPIO pin for rotary encoder A port.
rotary1_pin_b
GPIO pin for rotary encoder B port.
rotary1_pin_press
GPIO pin for rotary encoder Press port.
rotary1_event_cw
Generate input event on CW of this kind.
2022-03-08 23:10:41 -08:00
For using with CannedMessageModule you must choose value "UP" here!
2022-01-18 14:27:59 -08:00
rotary1_event_ccw
Generate input event on CCW of this kind.
2022-03-08 23:10:41 -08:00
For using with CannedMessageModule you must choose value "DOWN" here!
2022-01-18 14:27:59 -08:00
rotary1_event_press
Generate input event on Press of this kind.
2022-03-08 23:10:41 -08:00
For using with CannedMessageModule you must choose value "SELECT" here!
2022-01-18 14:27:59 -08:00
The rotary encoder #1 will send input events under name "rotEnc1".
2022-03-08 23:10:41 -08:00
## Configuration of the module
2022-01-18 14:27:59 -08:00
2022-04-22 09:13:30 -07:00
<PluginModule name="canned_message_plugin" rename="canned_message_module" />
2022-03-18 05:53:08 -07:00
2022-03-08 23:10:41 -08:00
Following configuration can be set for the module.
2022-01-18 14:27:59 -08:00
2022-03-08 23:10:41 -08:00
canned_message_module_enabled
Enable/disable CannedMessageModule.
2022-01-18 14:27:59 -08:00
2022-03-08 23:10:41 -08:00
canned_message_module_allow_input_source
Input event origin accepted by the Canned Message Module.
2022-01-18 14:27:59 -08:00
Can be e.g. "rotEnc1" or keyword "_any"
2022-03-08 23:10:41 -08:00
canned_message_module_messages
Predefined messages for CannedMessageModule separated by '|' characters.
2022-01-18 14:27:59 -08:00
2022-03-08 23:10:41 -08:00
canned_message_module_send_bell
CannedMessagemodule also sends a bell character with the messages.
ExternalNotificationModule can benefit from this feature.
2022-01-18 14:27:59 -08:00
## Usage Notes
For setting up the rotary encoder #1 using the Python CLI you will
need to execute a sequence like this:
meshtastic --set rotary1_pin_a 22
meshtastic --set rotary1_pin_b 23
meshtastic --set rotary1_pin_press 21
meshtastic --set rotary1_event_cw KEY_UP
meshtastic --set rotary1_event_ccw KEY_DOWN
meshtastic --set rotary1_event_press KEY_SELECT
meshtastic --set rotary1_enabled True
2022-03-08 23:10:41 -08:00
For setting up the module you will
2022-01-18 14:27:59 -08:00
need to execute a sequence like this:
2022-03-08 23:10:41 -08:00
meshtastic --set canned_message_module_allow_input_source "_any"
meshtastic --set canned_message_module_messages "I'm fine|I'm out|I'm back|Need helping hand|Help me with saw|I need an alpinist|I need ambulance|Keep Calm|On my way|I will be late|I'm already waiting|We have company|Beer is cold|Roger"
meshtastic --set canned_message_module_enabled True
2022-01-18 14:27:59 -08:00
2022-02-22 01:42:32 -08:00
meshtastic --set-canned-message "What am I doing?|I'm fine|Don't follow me|I'm out|I'm back|Need helping hand|Help me with saw|I need an alpinist|I need ambulance|Keep Calm|On my way|Need 5 mins|I will be late|I'm already waiting|I couldn't join|We have company|Beer is cold|Roger"
2022-01-18 14:27:59 -08:00
:::note
2022-02-22 01:42:32 -08:00
You can define up to 50 messages with a total length 800 bytes.
2022-01-18 14:27:59 -08:00
Use short texts as end of line will be truncated on the screen.
:::
:::note
2022-03-08 23:10:41 -08:00
The device must be restarted after the settings have been changed for the module to take effect.
2022-01-18 14:27:59 -08:00
:::
## Known Problems
2022-03-08 23:10:41 -08:00
- Rotary encoder input uses a technology called "interrupts". Using the
rotary encoder might cause unexpected software problems. This needs to be
tested.