Building a Meshtastic Solar Repeater and Conducting Enhanced Range Testing

by topdng in Circuits > Electronics

44 Views, 1 Favorites, 0 Comments

Building a Meshtastic Solar Repeater and Conducting Enhanced Range Testing

Screenshot 2024-11-10 at 4.33.22 PM.png

This guide goes through the steps needed to build a solar-powered Meshtastic repeater and conduct automated range testing with GPS to map out your coverage. The supporting video is here: https://youtu.be/wQws7cLrRo4


This was initially inspired by the following Hackaday post: https://hackaday.io/project/194509-harbor-breeze-meshtastic-hack


We make some minor enhancements to the above setup, and go through a deep dive of the software configuration and modifications needed to realize an enhanced version of Meshtastic's built-in range testing module.

Supplies

Screenshot 2024-10-27 at 3.37.46 PM.png

You will need the following items:

  1. WisBlock Meshtastic Starter Kit -- https://amzn.to/4e57QRS (~$35)
  2. Harbor Breeze Garden Light -- https://www.lowes.com/pd/Harbor-Breeze-60LM-Solar-Flood-Light-0-6-Watt-Black-Solar-LED-Flood-Light/1002689960 (~$15)
  3. Protected Li-Ion 18650 -- https://www.digikey.com/en/products/detail/jauch-quartz/LI18650JLS-HB-3-35AH-PROTECTED/16837989 (~$13), or conversion circuit -- https://amzn.to/3NJmzY6 (~$7)
  4. Double-sided Tape -- https://amzn.to/3Urv4uG (~$6)
  5. JST connector -- https://amzn.to/4fkabtn (~$7)

The following items are optional:

  1. Upgraded antenna and extension cable -- https://amzn.to/4fDYkXp (~$25) -- this is for the US 900MHz band, if you are in Europe, you will need to get one for the 800MHz band.


You will also need some screwdrivers and some kind of Epoxy (I use JB Kwik -- https://amzn.to/4fkabtn (~$9)

Software Setup on the Starter Kit

  1. Plug in the BLE and Lora antenna to the starter kit. This is important because running the radio without an antenna attached can damage the internal circuitry! Be mindful of the markings and which antenna you are using (they have the same connector)
  2. Plug in the starter kit to your computer with a good quality USB-C cable.
  3. Upgrade the firmware to the latest (stable) version. There are many ways to do this, but the most straightforward is to use the online flasher at https://flasher.meshtastic.org. Note that it is more straightforward to do this when you only have a single Meshtastic device plugged in at a time -- it's best to disconnect all other serial devices from your computer as well.
  4. Once flashed, set the following configurations on the device:
  5. Lora Region to US (or wherever you are)
  6. Device Role to ROUTER
  7. Bluetooth Enabled to FALSE
  8. There are many ways to set these configurations, I highly suggest installing the Meshtastic CLI and running the following commands from the terminal (after each command, wait a moment for the device to reboot):
  9. meshtastic --set lora.region US
  10. meshtastic --set device.role ROUTER
  11. meshtastic --set bluetooth.enabled false
  12. meshtastic --set position.gps_mode NOT_PRESENT
  13. If you are not comfortable using the terminal, you can use the Web Client and go through the GUI settings after connecting to your starter kit via serial in the web browser. You will likely need to reconnect between each reboot though if you choose to use this tool.
  14. Finally, you can also use the Meshtastic App from your phone or computer to connect to your device via Bluetooth, but since we are disabling bluetooth make sure that is the last step you do because you will not be able to reconnect with the app. We turn off bluetooth to save power.

Optional Steps:

  1. If you want to separate yourself from the default mesh, you can change the Lora Modem Preset to something other than LONG_FAST and also change the Lora Channel Number and default pre-shared key. I go through these steps in my video, but they are not necessary and are only for experiments. You will get the best range results in general by participating in a large mesh.

Assembling the Hardware

  1. Take apart the garden light and discard the light portion (if you do not wish to use it).
  2. Remove the internal battery
  3. Drill a hole with a 7/32" bit below the negative terminal of the battery holder
  4. Screw the SMA connector into this hole with a 9mm wrench and glue it down securely
  5. Solder the JST connector leads to the battery holder's terminals (keep in mind the colors on the linked connector are swapped!!)
  6. Mount the starter kit with double sided tape to the empty space in the solar panel housing below the solar charging circuit.
  7. Plug in the antenna connector and the JST connector.
  8. Screw the antenna to the SMA connector.
  9. Insert the battery and screw the housing back together making sure not to pinch any wires.

Communicating With and Checking on the Repeater From Another Node

  1. Make sure your repeater is powered on and charged
  2. Power on another node which has the same radio settings as the repeater (but with Device Role set to CLIENT or CLIENT_MUTE).
  3. Send a broadcast message through the CLI with the command below or in the Web GUI/App to the Primary channel from the CLIENT(_MUTE) node
  4. meshtastic --sendtext 'Hello Mesh!'
  5. Check that the repeater is visible in the nodes list with the following command
  6. meshtastic --nodes
  7. Once you identify your repeater ID, you can request battery information with the following command
  8. meshtastic --request-telemetry --dest '!xxxxxxxx'
  9. If this doesn't work, you may need to reset the node DB on BOTH the ROUTER and CLIENT device with the following command (this will require you to take apart your repeater and plug in the USB cable again)
  10. meshtastic --reset-nodedb
  11. Try from step 3 above again.

Overview of Meshtastic's Built-in Range Test Module

Meshtastic ships with a module called Range Test that works with a sender and receiver node. The receiver node will save data to a file when it receives a special message from the sender. The sender node is configured to emit these special messages at an interval set by a parameter in seconds (range_test.sender > 0).


At the time of reception, the receiver will log the timestamp of the received message along with the sequence number. It will also log the last known position of the sender and its own position (if available, in our setup we only have position on the sender). Both nodes should be ESP based nodes (for Filesystem writing and web-server functionality), unlike our repeater node which is Nordic based (for low power consumption).


This is convenient, but has a lot of limitations. The main limitations are:

  1. Position and range test messages are not reliably sent from the sender because they are configured to be "polite," meaning they will not be sent if the channel utilization is more than 25%
  2. We have no insight into what messages were sent and missed versus what messages were not sent at all. This means our analysis on coverage/range is limited.


In the next step, we are going to look at the modifications needed to enhance the built-in range test process.

Modifying the Firmware to Enhance the Range Test Process

First, make sure you can Build and flash the Meshtastic Code locally.

I've attached a patch file which you can try to apply with git, but it may not work as the main branch diverges from the time I wrote this guide (commit ec9e562a770aa0eeac57aea8354c930927bc6ab6 on Meshtastic Firmware), so I will explain the changes below:

  1. In /src/mesh/NodeDB.cpp we add some code to delete the new CSV file we are going to have the sender node create.
  2. In /src/modules/PositionModule.cpp we comment out the code that makes the position sending polite.
  3. Similarly, in /src/modules/RangeTestModule.cpp we comment out the code that turns off the Range Test module after a period of time and also comment out the code that makes the sending of the range test messages polite.
  4. In the same file, we add a new call to a new function called appendSenderFile() which will log every message that the sender sends out to a new CSV file.
  5. Below, still in the same file, we create this function by copying and renaming the existing appendFile function and we rename the saved file from rangetest.csv to rangetestout.csv; we also modify the contents of this file by removing a few un-needed fields from being written.
  6. In /src/modules/RangeTestModule.h, we add the function definition for our new function.
  7. You need to increase the hard-coded hop limit from 0 to 1 if you want to use a repeater for range testing! (This is not included in the patch below, please take note). This is in the sendPayload function in RangeTestModule.cpp

And that's all!

I suggest that you set some parameters in /userPrefs.h so you don't need to keep re-setting these every time you do a factory reset (which we need to do to clear the CSV files out from the file system).

Downloads

Configuration for the Range Test Nodes (TX and RX)

After we flash our modified code to the sender and receiver nodes, we need to do some extra configuration. These steps assume you have already set the region code, modem preset, channel number, and PSK with the /userPrefs.h file -- if you have not, you will need to also manually set those each time you factory reset or flash from a full-erase along with the steps below:

  1. For the Sender node, we need to enable GPS with frequent position updates and broadcasts. Make sure your GPS module is wired correctly according to the settings below:
  2. meshtastic --set position.position_broadcast_secs 10 --set position.gps_update_interval 10 --set position.rx_gpio 45 --set position.tx_gpio 46 --set position.gps_mode ENABLED --set position.position_broadcast_smart_enabled false
  3. For BOTH nodes we need to set the WiFi settings so we can download our CSV files:
  4. meshtastic --set network.wifi_ssid 'Your WiFi SSID' --set network.wifi_psk 'Your WiFi Password' --set network.wifi_enabled true
  5. For the Sender node, make sure the position is sent with high precision:
  6. meshtastic --ch-set module_settings.position_precision 32 --ch-index 0
  7. For the Sender node, make sure the range test is configured to send messages (every 15 seconds here):
  8. meshtastic --set range_test.enabled true --set range_test.sender 15
  9. For the receiver node, make sure the range test is configured to be on and save the file (our sender will ALWAYS save the file no matter what with the custom firmware changes, that is why we did not need to specify it above):
  10. meshtastic --set range_test.enabled true --set range_test.save true

Analyzing Results From the Range Test CSV Files

Now all you need to do is power on both nodes and collect data! You can repeat the test with a repeater in-between your nodes to see how much you've expanded the coverage.


To get the files off your nodes, simply navigate to their IP address on your WiFi network and put /rangetest.csv (for receiver) or /rangetestout.csv (for sender) after the URL. You can check the IP address by scrolling through the OLED display screens or checking it via the CLI.


Once you download the files, you can analyze them with a Python script or similar tool. Attached is a simple script to plot the data from each file.

Downloads