Quick Start Guide
This guide walks you through setting up a Multiflexmeter device from scratch.
Prerequisites
Section titled “Prerequisites”Hardware
Section titled “Hardware”- Multiflexmeter V3 board (ATmega1284P)
- USBasp ISP programmer
- FTDI USB-to-Serial adapter (for debugging)
- Sensor module (I2C address 0x36)
Software
Section titled “Software”- PlatformIO (VS Code extension recommended)
- Git (for cloning the repository)
Setup Steps
Section titled “Setup Steps”-
Clone the Repository
Terminal window git clone https://github.com/your-org/Multiflexmeter.gitcd Multiflexmeter -
Initialize Submodules
The LMIC library is included as a Git submodule:
Terminal window git submodule update --init -
Build the Firmware
Terminal window pio runThis compiles the firmware for the
mfm_v3_m1284pboard target. -
Program EEPROM Credentials
Before flashing, you must program the EEPROM with LoRaWAN credentials. Create a programmer sketch:
#include <EEPROM.h>// Get these from The Things Network consoleconst uint8_t APP_EUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // LSB firstconst uint8_t DEV_EUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // LSB firstconst uint8_t APP_KEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // MSB firstvoid setup() {// Magic bytesEEPROM.write(0, 'M');EEPROM.write(1, 'F');EEPROM.write(2, 'M');EEPROM.write(3, 0);// HW Version (1.0)EEPROM.write(4, 0x10); // MSB: major=1, proto=0EEPROM.write(5, 0x00); // LSB: minor=0, patch=0// APP_EUI (8 bytes at offset 6)for (int i = 0; i < 8; i++) EEPROM.write(6 + i, APP_EUI[i]);// DEV_EUI (8 bytes at offset 14)for (int i = 0; i < 8; i++) EEPROM.write(14 + i, DEV_EUI[i]);// APP_KEY (16 bytes at offset 22)for (int i = 0; i < 16; i++) EEPROM.write(22 + i, APP_KEY[i]);// Measurement interval: 300 seconds (0x012C)EEPROM.write(38, 0x01); // High byteEEPROM.write(39, 0x2C); // Low byte// TTN Fair Use Policy: enabledEEPROM.write(40, 1);// Wheel teeth count: 91EEPROM.write(41, 91);}void loop() {} -
Flash the Firmware
Connect the USBasp programmer and flash:
Terminal window pio run -t upload -
Verify Operation
Connect the FTDI adapter and monitor serial output:
Terminal window pio device monitorYou should see:
- Build date/time on startup
- LMIC initialization messages
- Join request attempts
- “EV_JOINED” when successfully connected to TTN
Register Device on TTN
Section titled “Register Device on TTN”-
Log in to The Things Network Console
-
Create or select an application
-
Register a new device with:
- Activation mode: OTAA
- LoRaWAN version: 1.0.x
- Regional Parameters: EU868
-
Copy the credentials:
- AppEUI: Use LSB format (reversed byte order)
- DevEUI: Use LSB format (reversed byte order)
- AppKey: Use MSB format (same as shown)
Troubleshooting
Section titled “Troubleshooting”| Issue | Possible Cause | Solution |
|---|---|---|
| No serial output | Debug disabled | Enable #define DEBUG in include/config.h |
| ”EV_JOIN_FAILED” | Wrong credentials | Verify EEPROM contents match TTN registration |
| No join attempts | Radio not responding | Check SPI connections to RFM95 |
| Immediate reset | Watchdog timeout | Check power supply, verify LMIC init |
Next Steps
Section titled “Next Steps”- Hardware Specifications - Pin mappings and board details
- Protocol Reference - Understand uplink/downlink messages
- Development Guide - Modify and extend the firmware