Skip to main content

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

File

Purpose

src/sensor_board/main.c

Main entry point, MainTask, sensor loop, packet handlers

Sensor and Actuator Drivers

Component

Location

IMU

components/sensor_board/imu/imu_sensor.h / .c

pH

components/sensor_board/ph/ph_sensor.h / .c

Load Cell (HX711)

components/sensor_board/load_cell/load_cell_sensor.h / .c

Pressure (FSR)

components/sensor_board/pressure/pressure_sensor.h / .c

Flow Sensor

components/sensor_board/sampling/flow_sensor/flow_sensor.h / .c

Pump

components/sensor_board/sampling/pump/pump.h / .c

Utilities

components/sensor_board/sensor_basics/sensor_basics.h / .c

Shared Components

Component

Location

Networking (LwIP glue, UDP)

components/common/networking/

Network addresses and port

components/common/networking_constants/ip_mac_constants.h

Packet dispatcher

components/common/packet_dispatcher/

Protobuf encode/decode helpers

components/common/pb_message/

Result codes and TRY macro

components/common/result/

Logging

components/common/logging/

Protobuf Definitions

Message definitions (PBEnvelope, SensorBoardPHInfo, SensorBoardIMUInfo, SensorBoardLoadCellInfo, SensorBoardPressureInfo, SensorBoardFlowSensorInfo, SensorBoardPumpInfo, SensorBoardDiagnostics) live in the ERC-Protobufs 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:

git submodule update --init ERC-Protobufs

Build Configuration

File

Purpose

platformio.ini

Build configuration for all boards (env:sensor_board for this one)

components/sensor_board/firmware/firmware.ioc

CubeMX device configuration

components/sensor_board/STM32H753XX_FLASH.ld

Linker script

Development Workflow

Useful Commands (PlatformIO CLI)

# 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

Device

Model

Protocol

Note

Microcontroller

STM32H753ZI (NUCLEO-H753ZI)

n/a

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

Ethernet PHY

LAN8742

RMII

10/100 Mbps auto-negotiation

pH

DFRobot SEN0161

Analog ADC

40-sample averaging, 5 V board (scale output below 3.3 V)

IMU

Reference design TBD

I2C1 (PB8/PB9)

Poll function is a placeholder

Load Cell ADC

HX711 (×2)

GPIO bit-bang

24-bit, channel A gain 128

Pressure

FSR pads (×2)

Analog ADC

Compile gated, needs ADC in CubeMX

Flow

FM-PS2216

GPIO EXTI pulses

40 to 150 ml/min, 5.5 pulses/ml

Pump

Grothen 12 V DC mini peristaltic

PWM (TIM3 CH3)

Single MOSFET, unidirectional, open loop

Network Quick Reference

Item

Value

Board IP

192.168.0.111 (static, no DHCP)

Destination (sample board)

192.168.0.222

UDP port

1500

Netmask / Gateway

255.255.255.0 / 192.168.0.1

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

Hope you had fun.☮️ End of documentation for the Sensor Board.

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