Simple Sensors Arduino library 1.0.0
A library for all the Simple Sensors by Soldered Electronics, regular and easyC versions.
Loading...
Searching...
No Matches
simpleSensor Class Reference

#include <Simple-Sensor-SOLDERED.h>

Inherits EasyC.

Inherited by simpleFireSensor, simpleLightSensor, simpleRainSensor, and simpleSoilSensor.

Public Member Functions

 simpleSensor ()
 easyC constructor for the Simple Sensors.
 
 simpleSensor (uint8_t _analogPin, uint8_t _digitalPin)
 Native constructor for the Simple Sensors.
 
uint16_t getRawReading ()
 Get the raw reading of the sensor.
 
float getResistance ()
 Calculate resistance which the sensor is measuring.
 
float getValue ()
 Get the value of the sensor as a percentage.
 
void setRawThreshold (uint16_t _thresh)
 Set the raw value of the threshold. Only for easyC.
 
uint16_t getRawThreshold ()
 Get the raw value of the threshold.
 
void setThreshold (float _thresh)
 Set the threshold as a percentage. Only for easyC.
 
float getThreshold ()
 Get the percentage value of the threshold, only for easyC.
 
void invertLED (bool _invert)
 Invert the LED on the breakout board.
 
void calibrate (float _highPercentage)
 Calibrate the high percentage value of the reading.
 
uint8_t getDigitalPin ()
 Get the location of D0 on the native board.
 
- Public Member Functions inherited from EasyC
 EasyC ()
 Main constructor for easyC version.
 
void begin ()
 Initializes sensors on native or easyC on default address.
 
void begin (uint8_t _address)
 Initializes sensors on supplied i2c address.
 
int sendAddress (char regAddr)
 Private function to send a single byte to sensor.
 
int readData (char a[], int n)
 Private function to read n bytes over i2c.
 
int readRegister (char regAddr, char a[], size_t n)
 Private function to send over i2c and then read n bytes.
 
int sendData (const uint8_t *a, int n)
 Private function to write n bytes over i2c.
 

Protected Member Functions

void initializeNative ()
 Overloaded function for virtual in base class to initialize sensor specific.
 

Private Attributes

uint8_t analogPin
 
uint8_t digitalPin
 
uint8_t rawReadData
 
uint16_t rawThreshold
 
float treshold
 
uint8_t adcWidthInBits
 
float adcMaxVoltage
 
float highPercentage = 100.0
 

Additional Inherited Members

- Public Attributes inherited from EasyC
int native = 0
 
bool beginDone = 0
 
int err
 
char address
 
const char defaultAddress = 0x30
 

Constructor & Destructor Documentation

◆ simpleSensor() [1/2]

simpleSensor::simpleSensor ( )

easyC constructor for the Simple Sensors.

◆ simpleSensor() [2/2]

simpleSensor::simpleSensor ( uint8_t _analogPin,
uint8_t _digitalPin )

Native constructor for the Simple Sensors.

Parameters
uint8_t_analogPin, the pin connected to A0
uint8_t_digitalPin, the pin connected to D0

Member Function Documentation

◆ calibrate()

void simpleSensor::calibrate ( float _highPercentage)

Calibrate the high percentage value of the reading.

Note
To calibrate, do a test run and read the getValue measurement when your sensor should read the highest possible value.

Then, pass that value to this function.

Parameters
float_highPercentage: the percentage which we want to represent 100%
Returns
None

◆ getDigitalPin()

uint8_t simpleSensor::getDigitalPin ( )

Get the location of D0 on the native board.

Note
This is so functions from inherited classes can access the pin.
Returns
uint8_t pin location of the digital pin D0.

◆ getRawReading()

uint16_t simpleSensor::getRawReading ( )

Get the raw reading of the sensor.

Returns
uint16_t of the raw analog read

◆ getRawThreshold()

uint16_t simpleSensor::getRawThreshold ( )

Get the raw value of the threshold.

Returns
uint16_t value of the set threshold

◆ getResistance()

float simpleSensor::getResistance ( )

Calculate resistance which the sensor is measuring.

Returns
float value of the resistance

◆ getThreshold()

float simpleSensor::getThreshold ( )

Get the percentage value of the threshold, only for easyC.

Returns
float value of the set threshold

◆ getValue()

float simpleSensor::getValue ( )

Get the value of the sensor as a percentage.

Returns
float percentage of the sensor reading

◆ initializeNative()

void simpleSensor::initializeNative ( )
protectedvirtual

Overloaded function for virtual in base class to initialize sensor specific.

Implements EasyC.

◆ invertLED()

void simpleSensor::invertLED ( bool _invert)

Invert the LED on the breakout board.

Parameters
boolledSetting: -True makes the LED turn off when the threshold is reached -False will have the LED turn on only when the threshold is reached

◆ setRawThreshold()

void simpleSensor::setRawThreshold ( uint16_t _thresh)

Set the raw value of the threshold. Only for easyC.

Parameters
uint16_t_thresh, threshold to set
Returns
none

◆ setThreshold()

void simpleSensor::setThreshold ( float _thresh)

Set the threshold as a percentage. Only for easyC.

Parameters
float_thresh, threshold to set, as a percentage
Returns
none

Member Data Documentation

◆ adcMaxVoltage

float simpleSensor::adcMaxVoltage
private

◆ adcWidthInBits

uint8_t simpleSensor::adcWidthInBits
private

◆ analogPin

uint8_t simpleSensor::analogPin
private

◆ digitalPin

uint8_t simpleSensor::digitalPin
private

◆ highPercentage

float simpleSensor::highPercentage = 100.0
private

◆ rawReadData

uint8_t simpleSensor::rawReadData
private

◆ rawThreshold

uint16_t simpleSensor::rawThreshold
private

◆ treshold

float simpleSensor::treshold
private

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