RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::QSFS01 Class Reference

QS-FS01 anemometer wind-speed sensor, read as an analog voltage through an ADC channel. More...

#include <QSFS01.h>

Inheritance diagram for RumPi::QSFS01:
[legend]
Collaboration diagram for RumPi::QSFS01:
[legend]

Public Member Functions

 QSFS01 ()
 Builds a default anemometer with no ADC wired yet and a zero peak wind speed. More...
 
 QSFS01 (IAnalogDigitalConverterComponent *analogToDigitalConverter, const unsigned int &analogToDigitalConverterIndex)
 Builds an anemometer bound to the given ADC and channel index, with a zero peak wind speed. More...
 
virtual ~QSFS01 ()
 Destroys the sensor, turning it off first. More...
 
virtual void TurnOn () override
 No-op: the anemometer is passive and reads on demand, so there is nothing to turn on. More...
 
virtual void TurnOff () override
 No-op: the anemometer holds no resources that need releasing when turned off. More...
 
double CalculateWindSpeed () const
 Calculates the current wind speed (m/s) from the ADC's output voltage using the datasheet's 0.4V-2.0V linear range mapped onto 0 to the sensor's max wind speed. More...
 
double ConsumePeakWindSpeed ()
 Returns the peak wind speed seen since the last call, then resets the peak for the next window. More...
 
virtual void ProcessRawValues () override
 Samples the current wind speed and keeps the highest value seen since the last snapshot consumed the peak. More...
 
int ReadRawAnalogValue () const
 Reads the raw analog value from the ADC, or -1 if no ADC is wired. More...
 
virtual std::string ToString () const override
 Serializes the anemometer's raw analog value and calculated wind speed to a string. More...
 
unsigned int GetAnalogToDigitalConverterPinIndex () const
 Gets the ADC channel index this sensor reads from. More...
 
IAnalogDigitalConverterComponentGetAnalogDigitalConverter () const
 Gets the ADC this sensor reads through. More...
 
void SetAnalogToDigitalConverterPinIndex (unsigned int pinIndex)
 Sets the ADC channel index this sensor reads from. More...
 
void SetAnalogDigitalConverter (IAnalogDigitalConverterComponent *analogDigitalConverter)
 Sets the ADC this sensor reads through. More...
 
- Public Member Functions inherited from RumPi::BaseComponent
 BaseComponent ()
 Builds a base component with an unknown type and an empty name. More...
 
virtual ~BaseComponent ()
 Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More...
 
virtual void TurnOn ()=0
 Turns the component on (e.g. More...
 
virtual void TurnOff ()=0
 Turns the component off. More...
 
virtual std::string ToString () const =0
 Serializes the component's current readings to a string (usually JSON). More...
 
virtual void ProcessRawValues ()=0
 Reads and processes the component's latest raw values (called once per poll). More...
 
virtual EComponentType GetComponentType () const
 Gets the component's type. More...
 
const std::string & GetName () const
 Gets the component's unique per-instance name. More...
 
void SetName (const std::string &name)
 Sets the component's unique per-instance name. More...
 

Protected Attributes

unsigned int myAnalogToDigitalConverterPinIndex
 The ADC channel index this sensor reads from. More...
 
IAnalogDigitalConverterComponentmyAnalogToDigitalConverter
 The ADC this sensor reads through. More...
 
double myPeakWindSpeed
 Highest wind speed (m/s) seen since the last read. More...
 
- Protected Attributes inherited from RumPi::BaseComponent
EComponentType myComponentType
 The kind of component this is (set by each concrete subclass). More...
 
std::string myName
 A unique per-instance name, assigned when the component is added to the manager. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from RumPi::BaseComponent
static std::string ComponentTypeToString (const EComponentType theComponentTypeToConvert)
 Maps an EComponentType to its string name. More...
 
static EComponentType StringToComponentType (const std::string &theComponentTypeName)
 Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More...
 

Detailed Description

QS-FS01 anemometer wind-speed sensor, read as an analog voltage through an ADC channel.

References: https://www.adafruit.com/product/1733 https://cdn-shop.adafruit.com/product-files/1733/C2192-002_datasheet.pdf

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ QSFS01() [1/2]

RumPi::QSFS01::QSFS01 ( )

Builds a default anemometer with no ADC wired yet and a zero peak wind speed.

Author
Eddie O'Hagan
Date
8/13/2026
QSFS01 windSensor;
QSFS01()
Builds a default anemometer with no ADC wired yet and a zero peak wind speed.
Definition: QSFS01.cpp:15

◆ QSFS01() [2/2]

RumPi::QSFS01::QSFS01 ( IAnalogDigitalConverterComponent analogToDigitalConverter,
const unsigned int &  analogToDigitalConverterIndex 
)

Builds an anemometer bound to the given ADC and channel index, with a zero peak wind speed.

Author
Eddie O'Hagan
Date
8/13/2026
QSFS01 windSensor(adc, 2);
Parameters
[in]analogToDigitalConverterThe ADC this sensor reads through.
[in]analogToDigitalConverterIndexThe ADC channel index this sensor reads from.

◆ ~QSFS01()

RumPi::QSFS01::~QSFS01 ( )
virtual

Destroys the sensor, turning it off first.

Author
Eddie O'Hagan
Date
8/13/2026
QSFS01* windSensor = new QSFS01();
delete windSensor;

Member Function Documentation

◆ CalculateWindSpeed()

double RumPi::QSFS01::CalculateWindSpeed ( ) const

Calculates the current wind speed (m/s) from the ADC's output voltage using the datasheet's 0.4V-2.0V linear range mapped onto 0 to the sensor's max wind speed.

Author
Eddie O'Hagan
Date
8/13/2026
double windSpeed = windSensor.CalculateWindSpeed();
Returns
The current wind speed, in m/s (0 if below the sensor's threshold or no ADC is wired).

◆ ConsumePeakWindSpeed()

double RumPi::QSFS01::ConsumePeakWindSpeed ( )

Returns the peak wind speed seen since the last call, then resets the peak for the next window.

Author
Eddie O'Hagan
Date
8/13/2026
double peak = windSensor.ConsumePeakWindSpeed();
Returns
The peak wind speed (m/s) since the last call (0.0 = calm).

◆ GetAnalogDigitalConverter()

IAnalogDigitalConverterComponent * RumPi::QSFS01::GetAnalogDigitalConverter ( ) const

Gets the ADC this sensor reads through.

Author
Eddie O'Hagan
Date
8/13/2026
IAnalogDigitalConverterComponent* adc = windSensor.GetAnalogDigitalConverter();
Returns
The ADC, or nullptr if none is set.

◆ GetAnalogToDigitalConverterPinIndex()

unsigned int RumPi::QSFS01::GetAnalogToDigitalConverterPinIndex ( ) const

Gets the ADC channel index this sensor reads from.

Author
Eddie O'Hagan
Date
8/13/2026
unsigned int index = windSensor.GetAnalogToDigitalConverterPinIndex();
Returns
The ADC channel index.

◆ ProcessRawValues()

void RumPi::QSFS01::ProcessRawValues ( )
overridevirtual

Samples the current wind speed and keeps the highest value seen since the last snapshot consumed the peak.

Author
Eddie O'Hagan
Date
8/13/2026
windSensor.ProcessRawValues();

Implements RumPi::BaseComponent.

◆ ReadRawAnalogValue()

int RumPi::QSFS01::ReadRawAnalogValue ( ) const

Reads the raw analog value from the ADC, or -1 if no ADC is wired.

Author
Eddie O'Hagan
Date
8/13/2026
int value = windSensor.ReadRawAnalogValue();
Returns
The raw analog value, or -1 if no ADC is set.

◆ SetAnalogDigitalConverter()

void RumPi::QSFS01::SetAnalogDigitalConverter ( IAnalogDigitalConverterComponent analogDigitalConverter)

Sets the ADC this sensor reads through.

Author
Eddie O'Hagan
Date
8/13/2026
windSensor.SetAnalogDigitalConverter(adc);
Parameters
[in]analogDigitalConverterThe ADC to set.

◆ SetAnalogToDigitalConverterPinIndex()

void RumPi::QSFS01::SetAnalogToDigitalConverterPinIndex ( unsigned int  pinIndex)

Sets the ADC channel index this sensor reads from.

Author
Eddie O'Hagan
Date
8/13/2026
windSensor.SetAnalogToDigitalConverterPinIndex(2);
Parameters
[in]pinIndexThe ADC channel index to set.

◆ ToString()

std::string RumPi::QSFS01::ToString ( ) const
overridevirtual

Serializes the anemometer's raw analog value and calculated wind speed to a string.

Author
Eddie O'Hagan
Date
8/13/2026
std::string data = windSensor.ToString();
Returns
A string describing the sensor's reading.

Implements RumPi::BaseComponent.

◆ TurnOff()

void RumPi::QSFS01::TurnOff ( )
overridevirtual

No-op: the anemometer holds no resources that need releasing when turned off.

Author
Eddie O'Hagan
Date
8/13/2026
windSensor.TurnOff();

Implements RumPi::BaseComponent.

◆ TurnOn()

void RumPi::QSFS01::TurnOn ( )
overridevirtual

No-op: the anemometer is passive and reads on demand, so there is nothing to turn on.

Author
Eddie O'Hagan
Date
8/13/2026
windSensor.TurnOn();

Implements RumPi::BaseComponent.

Member Data Documentation

◆ myAnalogToDigitalConverter

IAnalogDigitalConverterComponent* RumPi::QSFS01::myAnalogToDigitalConverter
protected

The ADC this sensor reads through.

◆ myAnalogToDigitalConverterPinIndex

unsigned int RumPi::QSFS01::myAnalogToDigitalConverterPinIndex
protected

The ADC channel index this sensor reads from.

◆ myPeakWindSpeed

double RumPi::QSFS01::myPeakWindSpeed
protected

Highest wind speed (m/s) seen since the last read.

ProcessRawValues raises it each sample so a gust between snapshots is not sampled away; the snapshot consumes it via ConsumePeakWindSpeed().


The documentation for this class was generated from the following files: