# Reference

Checkout the embedded simplified from ERC

## Source Code References

<span style="white-space: pre-wrap;">If you made it till here, you a true G. Also, this was rather useful, check this out... </span>[ERC Embedded Simplified Official](https://creations.mtdv.me/Rick-ZarolERC-Embedded-Simplified-Official "ERC Embedded Simplified Official")

### Main Application

<table id="bkmrk-filepurposesrc%2Fsenso"><colgroup><col></col><col></col></colgroup><tbody><tr><th>File

</th><th>Purpose

</th></tr><tr><td>`<span class="editor-theme-code">src/sensor_board/main.c</span>`

</td><td>Main entry point and sensor loop

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

### Sensor Drivers

<table id="bkmrk-sensorheadersourcegp"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><th>Sensor

</th><th>Header

</th><th>Source

</th></tr><tr><td>**GPS**

</td><td>`<span class="editor-theme-code">components/sensor_board/gps/gps_sensor.h</span>`

</td><td>`<span class="editor-theme-code">gps_sensor.c</span>`

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

</td><td>`<span class="editor-theme-code">components/sensor_board/imu/imu_sensor.h</span>`

</td><td>`<span class="editor-theme-code">imu_sensor.c</span>`

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

</td><td>`<span class="editor-theme-code">components/sensor_board/ph/ph_sensor.h</span>`

</td><td>`<span class="editor-theme-code">ph_sensor.c</span>`

</td></tr><tr><td>**Load Cell**

</td><td>`<span class="editor-theme-code">components/sensor_board/load_cell/load_cell_sensor.h</span>`

</td><td>`<span class="editor-theme-code">load_cell_sensor.c</span>`

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

</td><td>`<span class="editor-theme-code">components/sensor_board/pressure/pressure_sensor.h</span>`

</td><td>`<span class="editor-theme-code">pressure_sensor.c</span>`

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

</td><td>`<span class="editor-theme-code">components/sensor_board/sensor_basics/sensor_basics.h</span>`

</td><td>`<span class="editor-theme-code">sensor_basics.c</span>`

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

### Protobuf Definitions

**For detailed protobuf message format documentation, see:**<span style="white-space: pre-wrap;"> </span>[Sensor Board Protobuf](https://bookstack.roboteamtwente.nl/books/communication-system/page/sensor-board-protobuf "Sensor Board Protobuf")

```
ERC-Protobufs/components/sensor_board/
├── diagnostics.proto       - Board-level diagnostics and health status
├── sensor.proto            - Aggregated sensor state message
├── gps_sensor.proto        - GNSS positioning data
├── imu_sensor.proto        - Inertial measurement (acceleration, gyro, mag)
├── ph_sensor.proto         - Water quality pH measurement
├── load_cell.proto         - Force measurement (gripper control)
└── pressure_sensor.proto   - Pressure measurement (gripper control)
```

### Build Configuration

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

</th><th>Purpose

</th></tr><tr><td>`<span class="editor-theme-code">platformio.ini</span>`

</td><td>Build configuration for all boards

</td></tr><tr><td>`<span class="editor-theme-code">.mxproject</span>`

</td><td>STM32 CubeMX configuration

</td></tr><tr><td>`<span class="editor-theme-code">firmware.ioc</span>`

</td><td>CubeMX IOC file (device config)

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

## Test References

### Test Suites

```
test/sensor_board/
├── test_gps_sensor/
├── test_imu_sensor/
├── test_load_sensor/
├── test_ph_sensor/
├── test_pressure_sensor/
└── test_sensor_basics/
```

### Running Tests

```bash
// Build all tests
pio test -e sensor_board

// Run with verbose output
pio test -e sensor_board -v

// Build only (no run)
pio test -e sensor_board --no-run
```

## Hardware References

### Microcontroller

- **STM32H753ZI**<span style="white-space: pre-wrap;"> - ARM Cortex-M7, 480 MHz, 1 MB Flash</span>
- **Datasheet**: ST Microelectronics STM32H7 reference

### Ethernet

- **LAN8742**<span style="white-space: pre-wrap;"> - Ethernet PHY</span>
- **Interface**: RMII (Reduced Media Independent Interface)
- **Link Speed**: 10/100 Mbps auto-negotiation

### Sensors

<table id="bkmrk-sensormodelprotocoln"><colgroup><col></col><col></col><col></col><col></col></colgroup><tbody><tr><th>Sensor

</th><th>Model

</th><th>Protocol

</th><th>Note

</th></tr><tr><td>GPS

</td><td>GY-NEO6MV2 (NEO-6M)

</td><td>UART 9600

</td><td>Default NMEA config

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

</td><td>Reference design TBD

</td><td>I2C/SPI

</td><td>Dual IMU planned

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

</td><td>DFRobot SEN0161

</td><td>ADC Analog

</td><td>40-sample averaging

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

</td><td>Application specific

</td><td>ADC

</td><td>Dual cells (×2)

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

</td><td>Application specific

</td><td>ADC/I2C

</td><td>Dual sensors (×2)

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

## Development Workflow

### Building Firmware

```bash
// Build for sensor_board
pio run -e sensor_board

// Upload to board
pio run -e sensor_board --target upload

// Monitor serial output
pio device monitor -b 115200 -p COM4
```

### Development Cycle

```bash
// 1. Edit source code
// 2. Build
pio run -e sensor_board

// 3. Upload
pio run -e sensor_board --target upload

// 4. Monitor
pio device monitor

// 5. Run tests
pio test -e sensor_board
```

## Useful Commands

### PlatformIO CLI

```bash
// List available boards
pio boards

// Show board info
pio boards nucleo_h753zi

// Clean build
pio run -e sensor_board --target clean

// Full rebuild
pio run -e sensor_board --target clean --target upload
```

## Troubleshooting Guide

### Serial Monitor No Output

1. Check USB connection
2. Verify COM port in platformio.ini
3. Check baud rate (115200)
4. Verify UART initialization succeeded

### Sensor Shows IDLE

1. Check physical connection (UART/I2C/SPI)
2. Verify baud rate (for UART sensors)
3. Check pull-up resistors (for I2C)
4. Verify device address (for I2C/SPI)

### Network Packets Not Received

1. Check IP address configuration
2. Verify MAC address filtering
3. Check firewall settings
4. Verify UDP port 7 not blocked

### Low Heap Warning

1. Check for memory leaks in sensor drivers
2. Reduce buffer sizes
3. Verify UDP queue sizes
4. Check for recursive allocations

## Quick Reference Checklist

### Before Deployment

- [ ] All sensors connected and responding
- [ ] Network IP/MAC configured correctly
- [ ] Calibration parameters set for pH/load cells
- [ ] Serial monitor showing sensor data
- [ ] Heap usage monitored (&gt;8KB free)
- [ ] UDP packets reaching destination
- [ ] Protobuf encoding verified

### Monitoring in Production

- [ ] Check sensor status codes
- [ ] Monitor heap usage trend
- [ ] Verify data ranges match expectations
- [ ] Track error rates per sensor
- [ ] Review network packet statistics

---

**Hope you had fun☮️**

**END OF DOCUMENTATION FOR SESOR BOARD**☮️

**Last Updated: April 14, 2026**