Categories
Android Arduino Meshtastic Microcontroller Raspberry Pi Pico Uncategorized

Meshtastic Serial

I wanted to see about connecting a Raspberry Pi Pico to a LillyGo TTGO T-Beam v1.1 device. I noticed that Meshtastic supports serial communications, so I decided to give it a go to see how it worked.

There are several serial modes but the ones that seem the most useful are TXTMSG and PROTO. First attempt will be with the TXTMSG Mode as that seems straight forward. Once the TXTMSG Mode is working, I will look into how to use the PROTO Mode.

Wiring

We need to connect the grounds between the two devices, then connect the transmit (TX) from one to the receive (RX) of the other device. Below is a table showing the connections used in my setup.

T-BeamPico
RX pin 13TX pin 1 (GP0)
TX pin 14RX pin 2 (GP1)
GNDGND
T-Beam and Pico wiring
Wiring between T-Beam and Raspberry Pi Pico

Meshtastic Setup

Meshtastic firmware was installed using the Web Installer at https://flasher.meshtastic.org/. The T-Beam came with Meshtastic preinstalled. You may need to use another method to install the firmware if the Web Installer does not work.

Meshtastic Web Installer
Meshtastic Web Installer

T-Beam TEXTMSG Mode

Once Meshtastic has been installed on the T-Beam device and connected to the Android or Apple application, go to the Module Settings to setup the serial connection on the T-Beam device. The Module Settings is accessed by clicking on the kebab menu (aka three vertical dots menu) and selecting “Module Settings”.

kebab menu
Kebab Menu
Module Settings menu item
Module Settings menu item

Once the Module settings are displayed, scroll down to the “Serial Config” section and set the following items.

  • Serial enabled: turn on
  • RX: Set it to the T-Beam pin number for receive, which is 13 in my setup.
  • TX: Set it to the T-Beam pin number for transmit, which is 14 in my setup.
  • Serial baud rate: May leave it at the default setting or set it to “BAUD_38400”. I think it is best to set it as the default baud rate may change in other versions. I believe I read that it did change in the past.
  • Serial mode: Set it to TEXTMSG
  • Once everything is set, click the “Send” button.
Serial Configuration
Serial Configuration

Pico Arduino Code

The Pico code is written in C++ using the Arduino IDE. It is necessary to configure use the Pico Board provided by Earle F. Philhower, III. First, add the URL, https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json, to the Additional Boards Manager URLs by going to File > Preferences in the menu.

Arduino Preferences Menu Item
Arduino Preferences Menu Item
Arduino IDE Preferences
Arduino IDE Preferences

Click the icon to the left of the “Additional boards manager URLs” entry. Add the URL to the a new line in the textbox and click the “OK” button.

Additional Boards Manager URLs
Additional Boards Manager URLs

Open the boards manager by clicking on the boards manager icon, type “Pico” in the search textbox, and install the board, Raspberry Pi Pico/RP2040 by Earle F. Philhower, III.

Boards Manager
Boards Manager

Once the board is installed, you may select it from the boards dropdown selection in the IDE, when the Pico is connected to the PC.

Pico selected in the boards drop-down list
Raspberry Pi Pico selected in the boards drop-down list
/*
  Sample code to allow the Pico to act as a serial bridge between the PC and the Meshtastic device.

  Data sent to the Pico using the Arduino Serial Monitor, PuTTY, or other terminal software is sent
  to the Meshtastic device over the Pico UART0/Serial1 connection. Any data received from the Meshtastic
  device to the Pico is relayed to the PC over the Pico's serial over USB connection.

  REFERENCES:
    - https://meshtastic.org/docs/settings/moduleconfig/serial
    - https://github.com/earlephilhower/arduino-pico/discussions/210
*/

void setup() {
  // PC to Pico
  Serial.begin(9600);
  // Pico to Meshtastic device
  Serial1.begin(38400);
  while (!Serial)
    ;  // Serial is via USB; wait for enumeration
}

void loop() {
  // If data is received from the Meshtastic device, send it to the PC over the USB connection
  if (Serial1.available()) {
    String receiveMessage = Serial1.readString();
    Serial.print("Message received on Serial1 is:  ");
    Serial.println(receiveMessage);  // Send to serial monitor
  }

  // If data is received from the PC, send it to the Meshtastic Device
  while (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}

Upload the code to the Raspberry Pi Pico. Once the code is loaded, open the serial monitor and type some text and hit enter. The message will be received on the other node(s).

Sending message from PC
Sending message from PC
Message received on other node
Message received on other node

Sending a message from another node, will be received and shown in the serial terminal.

Sending message from another node
Sending message from another node
Receiving message on PC
Receiving message on PC

Now the simple TEXTMSG is working, we can try to get the PROTO working. The PROTO mode is interesting as it may be possible to configure the Meshtastic device, and query it for additional information. I will look into the PROTO Mode in the near future.

Categories
Psion Raspberry Pi Pico

Re-creation of Psion Organiser II

In 1984, Psion launched the first practical pocket computer, the Psion Organiser I. Psion followed up with the Psion Organiser II.

Andrew Menadue has a project which recreates the Psion Organiser II with the Raspberry Pi Pico and ESP32-WROOM-32. He has several videos on YouTube and some GitHub repositories. Andrew was nice enough to send me a set of boards, which I’m in the process of building.

Bill of Materials

The bill of materials is an Excel document located on GitHub.

Power Supply

Categories
Raspberry Pi Pico

Armachat

I have been working on the Armachat project by Peter Misenko. I rewrote the code to implement functions that Peter had not completed and added a few more. Some of the added features include:

  • Implemented detection of a long keypress
  • Dedicated keys when not in the editor
    • Q – Toggle the keyboard backlight
    • A – Toggle the display backlight
    • V – Increase volume / Long keypress to decrease volume
    • B – Increase display brightness / Long keypress to decrease display brightness
  • Ability to receive messages in all screens including editor
  • Validation of editor input
  • Confirmation prompts

I have been working on an issue with editor text input. The display update procedure takes 400 to 500 milliseconds which causes an issue as keypresses are dropped when typing quickly. Initially it was taking nearly 1 second to update the screen so some improvement has been made but it is still not good enough. I continue to work on improving the screen draw time and may deploy a few things to allow all keys to be detected and handled.

Another area for improvement is the long keypress detection. I noticed that removing the long keypress detection speed up the code enough to catch all key presses however the added functionality that the long keypress provides is too much to ignore.

GitHub locations for Peter’s code and my rewrite.