Meshtastic
Project Meshtastic | |
---|---|
![]() | |
Experiments with Meshtastic | |
Status | In progress |
Contact | bertrik |
Last Update | 2025-03-12 |
1. Intro
The plan is to use Meshtastic to transfer citizen science measurement data.
Stuff to figure out:
- network coverage: meshnet.nl map
- do nodes forward packets that do not belong to their "own" network? -> appears to be so!
My node: https://db.meshnet.nl/da639b54.html
Done:
- I know the basics of meshtastic
- Understand how the encryption works, how keys are constructed, how nonce/salt is constructed
- Can pick up messages sent through the network and shared via MQTT back into a local application and decrypt them
TODO
- create a particulate matter sensor that sends meshtastic
- figure out the LoRa settings for a LoRa transceiver
- actually build it and test it out
- write a backend/plugin for my sensor-data-bridge
2. Design
2.1. Option 1
plans:
- just use the 'default' channel: longfast + default key
- put my data on an unused port number, e.g. 300
pro&con:
- + simple
- + my data is routed
- - there are only 256 (or so) port numbers globally, so cannot really differentiate
- could combat this with a kind of secure checksum
2.2. Option 2
plans:
- use my own channel: probably 'longfast' + own key
- use a port number > 256
pro&con:
- + data is separate from other data
- + data *should* be routed (not 100% sure)
- - have to do my own decryption -> no problem?
3. Protocol
See https://meshtastic.org/docs/overview/mesh-algo/
Quick links:
- data structure:
- Service Envelope, wraps a MeshPacket: https://buf.build/meshtastic/protobufs/docs/main:meshtastic#meshtastic.ServiceEnvelope
- MeshPacket https://buf.build/meshtastic/protobufs/docs/main:meshtastic#meshtastic.MeshPacket loosely based on the message as sent over-the-air
- Service Envelope: https://buf.build/meshtastic/protobufs/docs/main:meshtastic#meshtastic.ServiceEnvelope
- Port number: https://buf.build/meshtastic/protobufs/docs/main:meshtastic#meshtastic.PortNum
- MQTT topic organization: https://meshtastic.org/docs/software/integrations/mqtt/#mqtt-topics
- decryption code used on the liam cottle map: https://github.com/liamcottle/meshtastic-map/blob/master/src/mqtt.js#L632
- Meshtastic encryption https://meshtastic.org/docs/overview/encryption/
4. Hardware
Nice antenna? https://nl.aliexpress.com/item/1005007301116616.html
5. MQTT
In the netherlands, data is typically sent to the 'boreft' MQTT server, for example
mosquitto_sub -h mqtt.meshnet.nl -u boreft -P meshboreft -t "#" -v
Examples of typical data:
msh/7460-7463/2/stat/!da5857c0 online msh/EU_868/NL/2/e/LongFast/!eb66115c �%]�g(=���gx�� H5��Aw=]�gE��H`���������LongFast␦
5.1. Example data
Examples of data as decoded from MQTT using the meshtastic python service wrapper:
packet { from: 2732702784 to: 4294967295 decoded { portnum: POSITION_APP payload: "\r\224\234\024\037\025\303\266\233\002\030\n\270\001 " } id: 663882246 rx_time: 1741511999 rx_snr: -18 hop_limit: 2 rx_rssi: -128 hop_start: 3 } channel_id: "LongFast" gateway_id: "!da544e50"
Packet with encrypted data:
packet { from: 1128181476 to: 4294967295 channel: 8 encrypted: "\007\355{o\340e\352\221\204\3112\365h\304[0\321&\351^{]\264\334\373\320\313>\213\2635\023\345'" id: 4272151039 rx_time: 1741512321 rx_snr: 5.75 hop_limit: 4 rx_rssi: -83 hop_start: 5 } channel_id: "LongFast" gateway_id: "!da5c87d4"
Packet with encrypted data:
packet { from: 2893499041 to: 4294967295 channel: 8 encrypted: "t\235\250XV\314\256\211\222\253~\245"\357z\252\314U<VZn\210\031\272\230.5\322\345\272\035\212?f\214" id: 3551320943 rx_time: 1741514045 hop_limit: 3 priority: BACKGROUND hop_start: 3 relay_node: 161 } channel_id: "LongFast" gateway_id: "!ac774aa1"