Skip to content

Configuration

All firmware configuration lives in a single file: firmware/node/include/config.h. You edit this file before each build to set the node’s role and tune its behavior. This page explains every setting.

The most important setting is NODE_TYPE. This determines what the node does after boot:

#define NODE_TYPE NODE_RECEIVER // 0 - Listen and forward to serial
// #define NODE_TYPE NODE_TEMPERATURE // 1 - Read TMP102, transmit, relay
// #define NODE_TYPE NODE_PRESSURE // 2 - Read BMP280, transmit, relay

Uncomment the line for the role you want and comment out the others. You must rebuild and reflash the firmware every time you change this setting.

These settings control the LoRa radio. All nodes in your network must use the same radio settings or they will not be able to communicate.

SettingDefaultDescription
LORA_FREQUENCY902.25Frequency in MHz. Use 902.25 for North America, 868.0 for Europe.
LORA_BANDWIDTH500.0Bandwidth in kHz. Wider is faster but shorter range.
LORA_SPREADING_FACTOR7Spreading factor (7-12). Higher means longer range but slower data rate.
LORA_CODING_RATE5Error correction coding rate (denominator of 4/x). Higher means more redundancy.
LORA_SYNC_WORD0x34Network identifier. Only nodes with the same sync word hear each other.
LORA_TX_POWER21Transmit power in dBm. 21 is the maximum for this chip and region.

For most indoor demonstrations, the defaults work well. If you need more range (for example, between buildings or across a large outdoor area):

#define LORA_SPREADING_FACTOR 10 // Was 7 -- longer range, slower
#define LORA_BANDWIDTH 125.0 // Was 500.0 -- narrower, longer range

The trade-off is data rate. At SF10 with 125 kHz bandwidth, each packet takes roughly 8 times longer to transmit than at SF7 with 500 kHz bandwidth. For the small packets Sensor Net uses (22-30 bytes), this is usually acceptable.

These settings control how often things happen:

SettingDefaultDescription
REPORT_INTERVAL_MS5000Milliseconds between sensor readings and transmissions.
PEER_TIMEOUT_MS15000Receiver drops a node from its active list after this many milliseconds of silence.
PEER_PRUNE_INTERVAL_MS5000How often the receiver checks for stale peers.
DISPLAY_UPDATE_MS1000OLED display refresh interval in milliseconds.

For a classroom demonstration, the 5-second default is a good balance between responsiveness and radio congestion. For a larger network with many nodes, consider increasing REPORT_INTERVAL_MS to reduce the number of packets in the air.

These settings control the mesh relay behavior:

SettingDefaultDescription
MESH_MAX_HOPS3Maximum number of relay hops before a packet is dropped. Acts as a time-to-live (TTL).
MESH_SEEN_TABLE_SIZE32Number of message IDs stored for deduplication. Uses a ring buffer; oldest entries are overwritten.
MESH_RELAY_JITTER_MS200Maximum random delay in milliseconds before relaying a packet. Prevents simultaneous relay collisions.

The default of 3 hops means a packet can travel through up to 3 intermediate nodes before being dropped. For a small network in a single room, this is more than enough. For a larger deployment spread across multiple buildings, you may want to increase it.

If you are using non-default I2C addresses for your sensors (for example, because you connected the address pin to VCC instead of GND), update these:

SettingDefaultDescription
TMP102_ADDRESS0x48I2C address for the TMP102 temperature sensor.
BMP280_ADDRESS0x76I2C address for the BMP280 pressure sensor.

The pin assignments in config.h match the Heltec WiFi LoRa 32 V3 hardware. You should not need to change these unless you are using a different board or have modified the hardware.

See the Pin Map Reference for the complete list.

Here is what config.h would look like for a temperature sensor node using all default settings:

// Node role
#define NODE_TYPE NODE_TEMPERATURE
// Radio (must match all nodes)
#define LORA_FREQUENCY 902.25
#define LORA_BANDWIDTH 500.0
#define LORA_SPREADING_FACTOR 7
#define LORA_CODING_RATE 5
#define LORA_SYNC_WORD 0x34
#define LORA_TX_POWER 21
// Timing
#define REPORT_INTERVAL_MS 5000
// Mesh
#define MESH_MAX_HOPS 3
#define MESH_SEEN_TABLE_SIZE 32
#define MESH_RELAY_JITTER_MS 200

With your configuration set, proceed to Building and Flashing to compile and upload the firmware.