|
| 1 | +/* |
| 2 | + @file LPS22DF_Example.ino |
| 3 | + @author Giuseppe Roberti <giuseppe.roberti@ieee.org> |
| 4 | + @brief Example to use the LPS22DF 260-1260 hPa absolute digital |
| 5 | + output barometer |
| 6 | + ******************************************************************************* |
| 7 | + Copyright (c) 2022, STMicroelectronics |
| 8 | + All rights reserved. |
| 9 | + This software component is licensed by ST under BSD 3-Clause license, |
| 10 | + the "License"; You may not use this file except in compliance with the |
| 11 | + License. You may obtain a copy of the License at: |
| 12 | + opensource.org/licenses/BSD-3-Clause |
| 13 | + ******************************************************************************* |
| 14 | +*/ |
| 15 | + |
| 16 | +#include <LPS22DFSensor.h> |
| 17 | + |
| 18 | +LPS22DFSensor sensor (&Wire); |
| 19 | +float pressure, temperature; |
| 20 | + |
| 21 | +void setup() { |
| 22 | + pinMode(LED_BUILTIN, OUTPUT); |
| 23 | + Serial.begin(115200); |
| 24 | + Wire.begin(); |
| 25 | + sensor.begin(); |
| 26 | + sensor.Enable(); |
| 27 | +} |
| 28 | + |
| 29 | +void loop() { |
| 30 | + sensor.GetPressure(&pressure); |
| 31 | + sensor.GetTemperature(&temperature); |
| 32 | + |
| 33 | + Serial.print("Pressure[hPa]:"); |
| 34 | + Serial.print(pressure, 2); |
| 35 | + Serial.print(", Temperature[C]:"); |
| 36 | + Serial.println(temperature, 2); |
| 37 | + |
| 38 | + blink(LED_BUILTIN); |
| 39 | +} |
| 40 | + |
| 41 | +inline void blink(int pin) { |
| 42 | + digitalWrite(pin, HIGH); |
| 43 | + delay(25); |
| 44 | + digitalWrite(pin, LOW); |
| 45 | + delay(975); |
| 46 | +} |
0 commit comments