HardFOC driver
FDO2 Driver¶
A C++17 driver for the PyroScience FDO2-G2 optical oxygen sensor. It identifies the module, measures oxygen partial pressure and temperature, reads the raw optical, pressure and humidity data and decodes the status and error codes, on any MCU with a UART.
The driver has no platform code. You give it a small class that writes bytes to a UART and returns one reply
line; it does the rest: the ASCII commands, reply parsing, unit scaling, status bits and #ERRO codes.
- Measures
- Oxygen partial pressure 0 to 1000 hPa (0 to 100 % O2 at 1013 mbar), plus temperature, pressure and humidity inside the housing
- Accuracy
- ±5 hPa at 200 hPa (10 °C to 40 °C); response time t63 under 2 s
- Host interface
- UART, 3.0 V levels (3.3 V absolute maximum), 19200 baud 8N1 after power-up, ASCII commands
- Supply
- 3.3 V to 5.0 V DC (5.5 V absolute maximum); about 8 mA standby, 40 mA peak
- Connector
- Molex 560020-0420, four pins: GND, TXD, RXD, VCC
- Driver uses
#VERS,#IDNR,#MOXY,#MRAW,#LOGO; no command that writes the module's flash
What you get¶
- One object per sensor.
fdo2::Driver<YourUart>sends a command and returns a typed result. See API guide. - Engineering units. hPa, °C, mbar, mV and %RH, scaled from the module's integer fields, and volume percent O2 from the internal pressure sensor. See UART protocol.
- Status you cannot miss. Every reading carries the status word, and
MoxyStatusOkForOxygen()applies the datasheet's rule. See API guide. - Blocking or split.
MeasureMoxy()waits for the reply;SendMeasure()andTryReadReplyLine()let a loop serve other devices during the measurement. See API guide. - Zero-overhead portability. The port is a CRTP class with three methods: no virtual calls, no heap, no RTOS dependency. See Porting.
- Tested without hardware. Host unit tests run the driver against a model of the sensor's command interface. See Testing and CI.
Where to go next¶
-
Wire the sensor, write the port, read oxygen in about 15 lines.
-
Connector pinout, UART settings, timing and power.
-
The three layers and what each one owns.
-
Identify, measure, read raw data and handle errors, task by task.
-
Implement the UART interface for your MCU.
-
Every class and member, generated from the headers.