DistanceMeterAccurate offers an API to interact with an Ultrasonic Module to measure distances considering the current air temperature (due to the effect that the air temperature have in the sound speed in air).
More...
#include <DistanceMeterAccurate.h>
|
void | executeUpdateDistanceNonBlock () |
| Execute a non-block distance measurement.
|
|
bool | isUpdateDistanceNonBlockTimeout () |
| Verify if there is a non-block measuremenet on going that has already timeouted. More...
|
|
float | calculateDistance (IN float soundSpeedCmPerSec) |
| Calculates the distance to the object based on the sound speed in air using the last distance value measured! More...
|
|
float | executeUpdateDistanceBlock (IN float soundSpeed) |
| Execute a block distance measurement and calculates the distance based on the sound speed. More...
|
|
uint8_t | _triggerPin |
| Arduino pin used to trigger the echo wave emission.
|
|
uint8_t | _echoPin |
| Arduino pin that is set to LOW by when reflected echo wave arrives.
|
|
volatile bool | _isEchoing |
| Used to know if it is in a middle of a measurement.
|
|
volatile float | _distance |
| It contains a cached value of the last distance measured. More...
|
|
bool | _isInitialized |
| Used to know if the device API is initialized and ready to receive requests.
|
|
DistanceMeterAccurate offers an API to interact with an Ultrasonic Module to measure distances considering the current air temperature (due to the effect that the air temperature have in the sound speed in air).
It offers a the same of DistanceMeterNonBlock API plus a possibility to pass the updateDistance() and updateDistanceNonBlock() methods the current air temperature in order to minimize the distance calculation error. If you want know more about sound waves velocity dependency with temperature see https://en.wikipedia.org/wiki/Speed_of_sound.
- See also
- Limitation: This allows ONLY 2 instances of DistanceMeterAccurate per sketch!!
-
Limitation: The accuracy of the non-block method is much smaller because it uses interruption mechanism
-
Devices Supported: HC-SR03, HC-SR04, HC-SR05
-
Devices Tested: HC-SR04
◆ DistanceMeterAccurate() [1/2]
Easyuino::DistanceMeterAccurate::DistanceMeterAccurate |
( |
IN uint8_t |
triggerPin, |
|
|
IN uint8_t |
echoPin |
|
) |
| |
Constructor.
- Parameters
-
triggerPin | Arduino pin connected to the trigger pin of the Ultrasonic Module |
echoPin | Arduino pin connected to the echo pin of the Ultrasonic Module |
◆ DistanceMeterAccurate() [2/2]
Easyuino::DistanceMeterAccurate::DistanceMeterAccurate |
( |
IN uint8_t |
triggerEchoPin | ) |
|
Contructor used with Ultrasonic Modules that have only one pin for trigger and echo.
- Parameters
-
triggerEchoPin | Arduino pin connected to the trigger&echo pin of the Ultrasonic Module |
◆ getDistanceCentimeters()
float Easyuino::DistanceMeterAccurate::getDistanceCentimeters |
( |
| ) |
|
|
virtual |
Gets the last value that the API measured using the Ultrasonic Module.
- Returns
- distance (Centimeters) The most recent measurement the API have done
Reimplemented from Easyuino::DistanceMeter.
◆ updateDistance()
void Easyuino::DistanceMeterAccurate::updateDistance |
( |
IN float |
airTemperature = DEFAULT_AIR_TEMPERATURE_CELSIUS , |
|
|
IN TemperatureScale |
temperatureScale = CELSIUS |
|
) |
| |
Updates the distance of the Ultrasonic Module to the objects in a blocking way.
- Parameters
-
airTemperature | Air temperatures to be used when calculating the distance |
temperatureScale | The temperature scale that is being provided |
◆ updateDistanceNonBlock()
void Easyuino::DistanceMeterAccurate::updateDistanceNonBlock |
( |
IN float |
airTemperature = DEFAULT_AIR_TEMPERATURE_CELSIUS , |
|
|
IN TemperatureScale |
temperatureScale = CELSIUS |
|
) |
| |
Updates the distance of the Ultrasonic Module to the objects in a non-blocking way.
This means that the call to the method will return immediatly and in the "background" the distance measure will ocurr after a while. When the measurement is concluded and you call getDistanceCentimeters() or getDistanceInches() the new distance value will be returned. While the measurement is on going the distance will be from the last measurement.
- Parameters
-
airTemperature | Air temperatures to be used when calculating the distance |
temperatureScale | The temperature scale that is being provided |
The documentation for this class was generated from the following file: