Skip to content

Platforms & Build

The firmware is built with PlatformIO using the Arduino framework. A single platformio.ini defines multiple environments — one per MCU family — so you can target any supported board without touching the source.


  1. Install PlatformIO Core or the VS Code extension.
  2. Clone the firmware repository:
    Terminal window
    git clone https://github.com/rpi-seism/reader.git
    cd reader
  3. Select your target environment and build:
    Terminal window
    # STM32 (recommended)
    pio run -e stm32 -t upload
    # RP2040
    pio run -e rp2040 -t upload
    # ESP32
    pio run -e esp32 -t upload

[env:stm32]
platform = ststm32
framework = arduino
board = genericSTM32F103C8 ; Blue Pill — swap for your target
build_flags =
-D PLATFORM_STM32
-D SERIAL_RX_BUFFER_SIZE=512
lib_deps =
robtillaart/CRC@^1.0.0

Notes:

  • HAL_NVIC_SystemReset() is available on all STM32 families.
  • Hardware UART1 is used for RS-422; USB virtual COM is available for debug.
  • The MAX490E DE/RE pins must be toggled around each transmission burst.

The firmware uses robtillaart/CRC to compute the Ethernet/PKZip polynomial CRC-32, matching the daemon’s binascii.crc32():

#include "CRC32.h"
CRC32 crc;
crc.reset();
crc.add(packet_buffer, 14); // header + 3 × int32
uint32_t checksum = crc.calc();
memcpy(&packet_buffer[14], &checksum, 4);

If the RS-422 link goes down (daemon crash, cable fault), the UART TX FIFO eventually overflows. The firmware tracks consecutive TX failures. After a configurable threshold it calls the platform reset function to reinitialise the UART hardware:

// Platform-specific reset
#if defined(PLATFORM_STM32)
HAL_NVIC_SystemReset();
#elif defined(PLATFORM_ESP32)
ESP.restart();
#elif defined(PLATFORM_RP2040)
rp2040.reboot();
#else
wdt_enable(WDTO_15MS); // AVR watchdog
while(1) {}
#endif

The daemon detects the MCU’s absence through its own RX timeout and in_waiting heartbeat monitor — both sides recover independently.


ADS1256 PinMCU PinSignal
SCLKSPI CLKSPI Clock (1–4 MHz)
DINSPI MOSIData to ADC
DOUTSPI MISOData from ADC
CSGPIO (active low)Chip Select
DRDYGPIO (interrupt)Data Ready (falling edge)
PDWN3.3 VAlways powered
RESETGPIO or VCCPull high for normal operation