HerdTag

Source: hardware/BUILD.md

HerdTag v1: hardware build plan

Batch: 10 working tags plus 2 spares (buy for 12), and 1 gateway. Band: US915. Builder: comfortable with soldering and firmware. Makerspace: FDM printer, SLA printer, soldering stations.

Every price below is an estimate from listings checked on 2026-11-07. Prices move, and RAK's own store doesn't always include US tariffs. Anything marked VERIFY couldn't be confirmed online and needs checking before you order or build.


1. Architecture

Each tag is an off-the-shelf RAKwireless WisBlock stack:

The fence logic runs on the tag (firmware/, a C port of src/herdtag/controller.py). The tag sends 11-byte position reports over LoRaWAN to one farm gateway, which forwards them to The Things Stack and then by webhook to our backend. Fences come back down as fragmented downlinks.

                 ┌──────────────── tag (in sealed case, bolted to ear-tag panel) ────────────────┐
 GNSS patch ─────┤ RAK12500 (slot A, I2C)      RAK1904 LIS3DH (slot C, INT1→WB_IO3)            │
 antenna         │          \                    /                                              │
 915 MHz FPC ────┤  RAK4631 core (nRF52840 + SX1262)  ── WB_A1 ─▶ MOSFET ─▶ piezo (cue)         │
 (+ BLE FPC)     │          │                         ── WB_IO1 ─▶ MOSFET ─▶ coin motor (opt.)   │
                 │  RAK19007 base: charger ◀── LiPo (JST PH 2.0) ◀── solar 5 V (JST ZH 1.5)      │
                 └───────────────────────────────────────────────┬───────────────────────────────┘
                                                                  │ LoRaWAN US915 FSB2, 11 B FPort 1 ↑ / fence frags FPort 2 ↓
                                         RAK7268V2 gateway (Ethernet/Wi-Fi backhaul)
                                                                  │
                             The Things Stack Sandbox (nam1) ── webhook ──▶ backend POST /ingest/ttn

2. Platform check: what I verified

Part Verified facts Source
RAK4631 core nRF52840 + SX1262. The US915 variant is "RAK4631(H)"; the DigiKey PN for the 915 MHz version is RAK4631-9-WB-I. 20 × 30 mm. About 2 µA sleep. Antennas ship in the box: VERIFY (RAK links the RAKARB03 902–928 MHz antenna) RAK datasheet, DigiKey
RAK19007 base 30 × 60 mm. Slots: CPU, IO, sensor A–D. Battery: JST PHR-2, 2.0 mm pitch, 3.3–4.3 V, max 4.3 V. Solar: JST ZHR-2, 1.5 mm pitch, 5 V panel, max 5.5 V. Header J11 = AIN1 / IO1 / IO2 / VBAT, J12 = 3V3 / GND / SCL / SDA, J10 = BOOT / UART1. Buy ver C (ver B also listed) RAK datasheet, DigiKey RAK19007-0-BB-N
RAK12500 GNSS u-blox ZOE-M8Q, UART + I2C, slot A (UART/I2C) or slot C (I2C only), 10 × 23 mm. Retailers list a GPS antenna (IPEX) in the box. ⚠ Rokland says u-blox has sunset the ZOE-M8Q and the RAK12500 will be discontinued once stock runs out. RAK datasheet, Rokland, Core Electronics (box contents)
RAK12501 GNSS (fallback) Quectel L76K, UART only, slot A or D. About 18 mA tracking, 7 µA power-save. Power switched via WB_IO2. Antenna in box: VERIFY RAK datasheet
RAK1904 accel ST LIS3DH, I2C, slots A/C/D(/E/F). Interrupt per slot: A→IO1, B→IO2, C→IO3, D→IO5. Avoid slot B (IO2 switches 3V3_S). 10 × 10 mm RAK datasheet
RAK7268V2 gateway WisGate Edge Lite 2, 8-channel indoor, US915 non-LTE about $170 at a US reseller RAK datasheet, reseller listing
Arduino pin numbers WB_IO1=17, WB_IO2=34, WB_IO3=21, WB_IO4=4, WB_IO5=9, WB_IO6=10, WB_A0=5, WB_A1=31, I2C SDA 13 / SCL 14, UART1 RX 15 / TX 16 RAK BSP variant.h
Battery ADC PIN_VBAT = WB_A0, divider compensation 1.73 in RAK's example. RAK staff say nominal is 1.667. Calibrate against a multimeter, on battery, USB unplugged RAK example, forum

Substitution decision:

3. Firmware pin map (for firmware/tag/pins.h)

Define Value Arduino # Where it physically is Notes
PIN_CUE WB_A1 31 (P0.31) RAK19007 header J11 "AIN1" Used as a digital PWM output; the nRF52 PWM can route to any GPIO. Drives the piezo MOSFET gate
PIN_VIBE WB_IO1 17 RAK19007 header J11 "IO1" Optional coin motor. VERIFY in the WisBlock Pin Mapper that the RAK12500 in slot A doesn't use IO1. If it does, leave the motor unpopulated
PIN_GNSS_POWER WB_IO2 34 (internal) switches 3V3_S Cutting 3V3_S loses the GNSS hot-start state. Measure u-blox power-save/backup modes against a full rail cut on the PPK2
GNSS bus Wire (I2C) SDA 13 / SCL 14 Slot A u-blox DDC address 0x42
PIN_ACCEL_INT WB_IO3 21 Slot C → INT1 LIS3DH I2C address 0x18 or 0x19: VERIFY with an I2C scan
PIN_VBAT WB_A0 5 (internal) divider Compensation 1.73, then calibrate per board

Firmware conflict: the current placeholders in firmware/tag/pins.h (PIN_CUE WB_IO3, PIN_VIBE WB_IO4) need changing. WB_IO3 is the accelerometer interrupt in slot C, and WB_IO4 isn't broken out on the RAK19007 headers. Use the values above.

4. Cue driver ("cue board"): one per tag, on a 20 × 30 mm perfboard

 VBAT (3.7 V from J11 pin 4)
   │                         │
   ├──────────┐              ├───────────┬─────────┐
   │          │              │           │         │
 [PIEZO]   [R3 1k]        [MOTOR]     [D1 ▲]    [C2 100n]
   │  AT-1442 │           10 mm coin  1N4148W    (across motor)
   │          │              │      (cathode→VBAT)  │
   ├──────────┘              ├───────────┴─────────┘
   │ D                       │ D
  Q1 AO3400A               Q2 AO3400A           Q = N-MOSFET, SOT-23 (logic-level, Vgs(th) ≤ 1.45 V)
   │ S                       │ S
  GND                       GND

 PIN_CUE (WB_A1) ──[R1 100Ω]──┬── G(Q1)        PIN_VIBE (WB_IO1) ──[R4 100Ω]──┬── G(Q2)
                              [R2 100k]                                       [R5 100k]
                               │                                               │
                              GND                                             GND
 Decoupling: C1 10 µF + 100 nF from VBAT to GND at the board's VBAT entry.

5. Bill of materials (buy for 12 tags)

5a. Per-tag electronics

Part Part number Qty Est. unit Est. line Buy from Notes
WisBlock core, US915 RAK4631-9-WB-I (RAK4631(H) US915) 12 $21 $252 DigiKey / Rokland / RAK store Make sure it's the 915 variant
WisBlock base RAK19007 (ver C) 12 $11–15 $156 DigiKey / Rokland / RAK store RAK store lists $9.99 + shipping + tariff
GNSS module RAK12500 (fallback RAK12501) 12 $27 $324 Rokland (US stock) Includes IPEX GPS patch antenna per retailers. Sunset part: order early
Accelerometer RAK1904 12 ~$8 VERIFY $96 Rokland / RAK store Slot C
LoRa antenna, 915 MHz FPC, U.FL/IPEX RAK RAKARB03 or Molex 211140-0100 (VERIFY 915 band and U.FL) 12 $3–4 $45 RAK / DigiKey Skip if the RAK4631 box includes one
BLE antenna, 2.4 GHz FPC, U.FL Any 2.4 GHz U.FL FPC (e.g. Molex 146153-0100, VERIFY) 12 $3 $36 DigiKey Needed for BLE DFU and debug. Skip if included
Subtotal ~$909

5b. Cue actuators and cue board

Part Part number Qty Est. unit Est. line Buy from Notes
Sealed piezo transducer PUI AT-1442-TT-WP-R 14 $3 $42 DigiKey 14 mm body: measure it into the CAD
N-MOSFET, logic level AO3400A (SOT-23) 50 $0.15 $8 DigiKey / LCSC Alt: DMG2302U
SOT-23 to DIP breakout generic 30 $0.30 $9 Amazon / Adafruit Or dead-bug onto perfboard
Coin vibration motor, 10 mm, 3 V e.g. Adafruit 1201 12 $2 $24 Adafruit / DigiKey Optional for the first build
Diode 1N4148W, resistors 100 Ω / 1 k / 100 k (0805 or TH), caps 100 nF, 10 µF assortment 1 $15 $15 DigiKey
Perfboard, 30 AWG silicone wire, heat-shrink 1 $25 $25
Subtotal ~$123

5c. Power

Part Part number Qty Est. unit Est. line Buy from Notes
LiPo 3.7 V 1000 mAh with protection PCM, JST PH 2.0 503450 size (~50 × 34 × 5 mm) 14 $7 $98 Adafruit #258-class / Amazon Polarity varies by vendor: check with a meter before every first plug-in. About 20 g. For weight-optimized tags later, 503035 500 mAh (~10 g)
Solar panel, 5 V, ~0.5–1 W, small generic 5 V mini panel 4 $4 $16 Amazon / Adafruit Bench and charging test only. Never over 5.5 V
JST ZH 1.5 mm 2-pin pigtails 1 pack $8 $8 Amazon For the solar input
Subtotal ~$122

5d. Gateway

Part Part number Qty Est. unit Est. line Buy from Notes
LoRaWAN gateway, 8-ch, US915, no LTE RAK7268V2 (WisGate Edge Lite 2) 1 $170 $170 Rokland / RAK / reseller Indoor: mount by a high window or in a vented weatherproof box
Outdoor antenna option RAK 915 MHz fiberglass ~5.8 dBi + low-loss cable (N to the gateway's connector; VERIFY the RP-SMA vs. SMA gender on the V2) 1 $60–90 $75 RAK / Rokland Height beats gain. Get it on the roof line
Outdoor gateway (alternative) RAK7289V2 / RAK7267 class — ~$400+ — If indoor coverage fails the walk test
Subtotal ~$245

5e. Tools and consumables (skip what the makerspace already has)

Item Part number Qty Est. Notes
Power profiler Nordic PPK2 (NRF-PPK2) 1 $100 Replaces the guesses in src/herdtag/power.py
Digital calipers 1 $25
USB-C data cables 4 $20 Data, not charge-only
JST PH crimp tool + housings Engineer PA-09 or similar 1 $40 To re-pin LiPos with reversed polarity
Conformal coating MG Chemicals 422C (silicone) 1 $20 Mask the connectors, U.FL, GNSS module, and piezo
Silicone O-ring cord, 1.5 mm 2 m $10 Glue into a ring with cyanoacrylate
Silicone grease + RTV silicone 1 each $15 Grease for the gasket; RTV to seal the piezo
Acoustic vent membrane, adhesive, 10 mm e.g. Gore/Saati-style sticker 15 $20 VERIFY Or skip; the piezo itself is IP67
M2 × 8 screws, M2 heat-set inserts, M3 inserts, M3 × 10 bolts + nyloc kit 1 $25 Stainless
Potting compound (optional) 2-part polyurethane 1 $30 Only after the design freezes
Silica gel packets, small 50 $8 One per case
SPL meter (or calibrated phone app) 1 $30 For the cue loudness cap
PETG filament, 1 kg + SLA tough resin 1 + 1 L $22 + ~$60 Ask what resin the makerspace stocks
Subtotal ~$425

5f. Mounting

Item Part number Qty Est. Notes
Large blank visual ear tags (female panel + male button) Allflex Global large blank, or Z Tags large (VERIFY SKU) 25 $30 The case bolts to the panel with 2 × M3
Tag applicator matching that brand Allflex universal 1 $25 The vet or experienced handler applies
Subtotal ~$55

Grand total (estimate)

Per-tag electronics $909
Cue board $123
Power $122
Gateway $245
Tools and consumables $425
Mounting $55
Sum ~$1,880
Shipping, tax, 10% contingency ~$250
All-in ≈ $2,100 (≈ $1,750 if the makerspace has the tools)

The cost of goods per tag is about $95. That's prototype pricing on dev modules; the v2 target is under $50 BOM.


6. Makerspace sessions

Session 1: bring up ONE tag (about 4 h)

Tools: soldering station, multimeter, PPK2, laptop with Arduino IDE / PlatformIO + RAK nRF52 BSP, calipers.

Pass when:

Pitfalls:

Session 2: build the other 11 (about 5–6 h)

Pass when 12 out of 12 join and uplink. Any board failing the sleep current check gets set aside as a spare or for debugging.

Session 3: enclosures, sealing, abuse tests (about 4 h plus printing beforehand)

Session 4: walk tests, no cattle (half a day, outdoors at the farm or a park)


7. The Things Stack Sandbox + gateway setup

  1. Create an account on The Things Stack Sandbox, cluster nam1 (nam1.cloud.thethings.network).
  2. Gateway: Console → Gateways → Register. Enter the EUI from the RAK7268V2's web UI. Set the frequency plan to "United States 902–928 MHz, FSB 2 (used by TTN)".
  3. On the gateway's WisGate OS: LoRa → work mode Packet Forwarder → Basic Station (or Semtech UDP) → server nam1.cloud.thethings.network. Set region US915 and sub-band 2 (channels 8–15, plus 65 for 500 kHz).
  4. Application: create herdtag. Register end devices manually: LoRaWAN 1.0.3, regional parameters RP001 1.0.3 rev A, same FSB2 plan, OTAA, JoinEUI 0000000000000000, DevEUI and AppKey generated. Bulk-register 12 with the CLI: bash ttn-lw-cli login for i in $(seq -w 1 12); do ttn-lw-cli end-devices create herdtag herdtag-$i \ --dev-eui $(openssl rand -hex 8) --join-eui 0000000000000000 \ --frequency-plan-id US_902_928_FSB_2 --lorawan-version 1.0.3 \ --lorawan-phy-version 1.0.3-a --with-root-keys done ttn-lw-cli end-devices list herdtag # copy DevEUI/AppKey into each tag's firmware
  5. Uplink webhook: Application → Integrations → Webhooks → Custom webhook. - Format: JSON. - Base URL: https://<backend-host>. - Enable Uplink message with path /ingest/ttn. - The backend reads the standard TTS v3 uplink JSON (uplink_message.frm_payload, base64, 11 bytes on FPort 1). - No payload formatter is needed; the backend decodes the bytes itself. - Add a shared-secret header, and have the backend check it.
  6. Fence downlinks: create an API key with "write downlink" rights. - The backend queues fragments on FPort 2 through POST /api/v3/as/applications/herdtag/webhooks/<id>/devices/<dev>/down/push. - Tags are Class A, so a downlink only arrives right after an uplink, one fragment per uplink. - The firmware should send a short follow-up uplink while the network reports more downlinks pending (the frame-pending bit), so a fence doesn't take hours to arrive. - 51-byte fragments fit the US915 RX1/RX2 data rates.

8. First cattle fitting: safety and welfare (Phase 2, not before Sessions 1–4 pass)

9. Path to v2 (after Phase 2 data)