Reference README for a LoRa sensor/transmitter node designed to work with the companion gateway repo lora-gateway. It sends compact LoRa frames that the gateway parses and relays to MQTT.
This document is intended to live in the separate Node repository: https://github.com/diegohat/lora-node
Gateway repository for reference: https://github.com/diegohat/lora-gateway
- MCU + LoRa radio used in this repo:
- Arduino Uno + SX1276/SX1278 module
- Antenna matching your regional frequency
- Sensors (examples used in code):
- Soil hygrometer (digital DO + analog AO)
- Tilt sensor (digital)
- LoRa pins (as used in
src/main.cpp):SS10,RST9,DIO02
- Sensors:
- Hygrometer DO →
D3, AO →A0 - Tilt sensor →
D4
- Hygrometer DO →
The gateway expects a one-byte address followed by a UTF-8 text payload containing fields in Portuguese separated by commas:
- First byte: destination address (use the gateway
myAddressor0xFFfor broadcast) - Text payload example produced by this node:
Solo=SECO,Umidade=73.00%,Inclinacao=NORMAL
Fields parsed by the gateway and forwarded to MQTT JSON:
Solo: soil conditionUmidade: soil moisture (may include%symbol)Inclinacao: tilt state
Tip: Keep payloads short to reduce airtime and collisions.
- Frequency: default
915E6(change per region: 433/868/915 MHz) - Spreading Factor:
SF12 - Coding Rate:
4/8
To interoperate, the node must use identical frequency/SF/CR (and ideally bandwidth) as the gateway.
byte dest = 0x01; // or 0xFF for broadcast
String payload = "Solo=123,Umidade=45%,Inclinacao=2";
LoRa.beginPacket();
LoRa.write(dest); // address byte first
LoRa.print(payload); // text payload
LoRa.endPacket();- Respect regional regulations (e.g., duty-cycle, maximum EIRP)
- Use sleep modes to extend battery life (this repo uses
rocketscream/Low-Powerto sleep ~15 minutes between transmissions)
This repo includes a PlatformIO configuration for Arduino Uno:
[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 9600
lib_deps =
sandeepmistry/LoRa
rocketscream/Low-Powerpio run
pio run -t upload
pio device monitor -b 9600Ensure wiring matches the pins above and your antenna is connected before powering.
- With the gateway running, send a packet and watch the gateway serial monitor and MQTT topic (default
diegohat/lora). - Verify that JSON arrives with
solo,umidade,inclinacao,rssi, andsnr.
If your sensor names differ, either:
- Update the node to send
Solo,Umidade, andInclinacao, or - Modify the gateway parser in
lora-gateway/src/main.cppto match your field names.
- Gateway repo: firmware receives LoRa and publishes to MQTT over TLS
- Node repo: this transmitter (sends address byte + text payload)
Keep both READMEs aligned so team members can configure frequency, addressing, and formats consistently.