get_val()
Description
Gets value of requested sensor.
Syntax
get_val(sensor_ID);
Parameters
Variable | Input |
|---|---|
| is any sensor from list of sensors: Link to Sensor list. |
Returns
Returns sensor value.
Function call example
Setting value example
new PDP;
main(){
PDP = get_val(Sensor_SignalPDPActive); //You can set value of a variable same as sensor value
while(1){
if(get_val(Sensor_SignalIN4) == 0){ //You can also use sensor reading directly
doSomething();
}
Delay(100);
}
}
Notes and Warnings
In case of 64 bit sensor, to read all information it is necessary to read least significant byte and most significant byte and store them at separate variables:
Function call example
Get 64 bit value example
main(){
Ibutton_low = get_val(Sensor_Ibutton_ID, Bit64_low);
Ibutton_high = get_val(Sensor_Ibutton_ID, Bit64_high);
while(1){
Delay(100);
}
}In case of float sensor, to read correctly information it is necessary to convert value to float after reading sensor.
Function call example
Get 64 bit value example
new Float: temp;
main(){
temp = Float: get_val(Sensor_Temperature);
while(1){
Delay(100);
}
}Used in Examples
Accelerometer example
BIT64 example
Geozone example
Ibutton ID example
Output example
Reset cause example
SMS example
Socket v2 example
Time example