Distance
List of Supported Sensors
| Sensor | Sensor Id |
|---|---|
HCSR04 | 7 |
note
Note the Sensor ID's of your chosen sensor, Sensor ID's needs to written into
config.yaml while configuring Shunya Interfaces.
Simple API
One API for all distance sensors.
- C/CPP
/* Add this line to your main function * to read data from the sensor */float distance = getCm();Advance API
Need more Advance features of the sensor, take a look at our Advance API's for sensor.
Advance API
- C/CPP
/* Add this line to your main function * to read data from the sensor */float distance = getCm7();Note
Advance API's are sensor specific, they are named: get<quantity> <sensor-id>.
For example:
getCm7() // get <Distance in Cm> <from sensor 7> (i.e HC-SR07)Using the wrong sensor id will cause the library to throw and error saying No
sensor found.