# Reference

Source code references, build configuration, hardware datasheet pointers, useful commands and the pre-deployment checklist. If you made it till here, you a true G.☮️

## Source Code References

### Main Application

<table id="bkmrk-main-app-table"><colgroup><col></col><col></col></colgroup><tbody><tr><th>File

</th><th>Purpose

</th></tr><tr><td>src/sensor\_board/main.c

</td><td>Main entry point, MainTask, sensor loop, packet handlers

</td></tr></tbody></table>

### Sensor and Actuator Drivers

<table id="bkmrk-drivers-table"><colgroup><col></col><col></col></colgroup><tbody><tr><th>Component

</th><th>Location

</th></tr><tr><td>IMU

</td><td>components/sensor\_board/imu/imu\_sensor.h / .c

</td></tr><tr><td>pH

</td><td>components/sensor\_board/ph/ph\_sensor.h / .c

</td></tr><tr><td>Load Cell (HX711)

</td><td>components/sensor\_board/load\_cell/load\_cell\_sensor.h / .c

</td></tr><tr><td>Pressure (FSR)

</td><td>components/sensor\_board/pressure/pressure\_sensor.h / .c

</td></tr><tr><td>Flow Sensor

</td><td>components/sensor\_board/sampling/flow\_sensor/flow\_sensor.h / .c

</td></tr><tr><td>Pump

</td><td>components/sensor\_board/sampling/pump/pump.h / .c

</td></tr><tr><td>Utilities

</td><td>components/sensor\_board/sensor\_basics/sensor\_basics.h / .c

</td></tr></tbody></table>

### Shared Components

<table id="bkmrk-shared-table"><colgroup><col></col><col></col></colgroup><tbody><tr><th>Component

</th><th>Location

</th></tr><tr><td>Networking (LwIP glue, UDP)

</td><td>components/common/networking/

</td></tr><tr><td>Network addresses and port

</td><td>components/common/networking\_constants/ip\_mac\_constants.h

</td></tr><tr><td>Packet dispatcher

</td><td>components/common/packet\_dispatcher/

</td></tr><tr><td>Protobuf encode/decode helpers

</td><td>components/common/pb\_message/

</td></tr><tr><td>Result codes and TRY macro

</td><td>components/common/result/

</td></tr><tr><td>Logging

</td><td>components/common/logging/

</td></tr></tbody></table>

### Protobuf Definitions

<span style="white-space: pre-wrap;">Message definitions (PBEnvelope, SensorBoardPHInfo, SensorBoardIMUInfo, SensorBoardLoadCellInfo, SensorBoardPressureInfo, SensorBoardFlowSensorInfo, SensorBoardPumpInfo, SensorBoardDiagnostics) live in the </span>**ERC-Protobufs**<span style="white-space: pre-wrap;"> git submodule and are compiled to C by nanopb during the PlatformIO build. If the build cannot find the .pb.h headers, initialize the submodule:</span>

```bash
git submodule update --init ERC-Protobufs
```

### Build Configuration

<table id="bkmrk-build-config-table"><colgroup><col></col><col></col></colgroup><tbody><tr><th>File

</th><th>Purpose

</th></tr><tr><td>platformio.ini

</td><td>Build configuration for all boards (env:sensor\_board for this one)

</td></tr><tr><td>components/sensor\_board/firmware/firmware.ioc

</td><td>CubeMX device configuration

</td></tr><tr><td>components/sensor\_board/STM32H753XX\_FLASH.ld

</td><td>Linker script

</td></tr></tbody></table>

## Development Workflow

### Useful Commands (PlatformIO CLI)

<span style="white-space: pre-wrap;">Check this out for compiling code and more about project structure- </span>[Project Structure](https://bookstack.roboteamtwente.nl/books/embedded-infastructure/chapter/project-structure "Project Structure")

```bash
# Build the sensor board firmware
pio run -e sensor_board

# Flash to the Nucleo board
pio run -e sensor_board -t upload

# Serial monitor (115200 baud)
pio device monitor -b 115200

# Run the unit tests
pio test -e sensor_board
```

### Development Cycle

1. Change peripherals in CubeMX (firmware.ioc), regenerate with Keep User Code
2. Implement or update the driver in components/sensor\_board/
3. Build and run unit tests on the host
4. Flash, watch the serial log, verify the per-sensor status lines
5. Enable sendUDP and verify packets on the network

## Hardware References

<table id="bkmrk-hw-ref-table"><colgroup><col></col><col></col><col></col><col></col></colgroup><tbody><tr><th>Device

</th><th>Model

</th><th>Protocol

</th><th>Note

</th></tr><tr><td>Microcontroller

</td><td>STM32H753ZI (NUCLEO-H753ZI)

</td><td>n/a

</td><td>ARM Cortex-M7, 480 MHz capable (running at 64 MHz), 2 MB Flash; ST STM32H7 reference manual

</td></tr><tr><td>Ethernet PHY

</td><td>LAN8742

</td><td>RMII

</td><td>10/100 Mbps auto-negotiation

</td></tr><tr><td>pH

</td><td>DFRobot SEN0161

</td><td>Analog ADC

</td><td>40-sample averaging, 5 V board (scale output below 3.3 V)

</td></tr><tr><td>IMU

</td><td>Xsens Avior

</td><td>I2C1 (PB8/PB9), Xbus

</td><td>Address 0x6B, 100 Hz; driver untested on hardware (mtidocs.xsens.com)

</td></tr><tr><td>Load Cell ADC

</td><td>HX711 (×2)

</td><td>GPIO bit-bang

</td><td>24-bit, channel A gain 128

</td></tr><tr><td>Pressure

</td><td>FSR pads (×2)

</td><td>Analog ADC

</td><td>Compile gated, needs ADC in CubeMX

</td></tr><tr><td>Flow

</td><td>FM-PS2216

</td><td>GPIO EXTI pulses

</td><td>40 to 150 ml/min, 5.5 pulses/ml

</td></tr><tr><td>Pump

</td><td>Grothen 12 V DC mini peristaltic

</td><td>PWM (TIM3 CH3)

</td><td>Single MOSFET, unidirectional, open loop

</td></tr></tbody></table>

## Network Quick Reference

<table id="bkmrk-network-ref-table"><colgroup><col></col><col></col></colgroup><tbody><tr><th>Item

</th><th>Value

</th></tr><tr><td>Board IP

</td><td>192.168.0.111 (static, no DHCP)

</td></tr><tr><td>Destination (sample board)

</td><td>192.168.0.222

</td></tr><tr><td>UDP port

</td><td>1500

</td></tr><tr><td>Netmask / Gateway

</td><td>255.255.255.0 / 192.168.0.1

</td></tr></tbody></table>

## Quick Reference Checklist

### Before Deployment

- ERC-Protobufs submodule initialized, firmware builds clean
- All connected sensors responding (OPERATING | OK in the log)
- Network IP/MAC configured and sendUDP enabled
- Calibration set for pH (offset/slope) and load cells (tare/scale)
- Serial monitor showing sensor data at 115200 baud
- Heap usage healthy (well above the 4096 byte critical threshold)
- UDP packets reaching 192.168.0.222:1500 and decoding as PBEnvelope

### Monitoring in Production

- Watch per-sensor state/status codes in the log lines
- Monitor the free heap trend printed each loop
- Verify data ranges match expectations (pH 0-14, flow below 150 ml/min)
- Track error rates per sensor and pump/flow cross-check warnings

<span style="white-space: pre-wrap;">Hope you had fun.☮️ End of documentation for the Sensor Board. </span>

May The Force Be With You or Live Long and Prosper, depending on what you like.... but remember the Dark Side always has cooler toys

**The Sensor Board is the coolest board ~ Mybrosky**