Example Code for Arduino-Data Measurement
Last revision 2025/12/26
This article offers a comprehensive guide on measuring data using Arduino with a differential pressure sensor, including hardware and software setup, wiring instructions, and sample code for obtaining pressure and temperature values.
Hardware Preparation
- DFRduino UNO R3 (or similar) x 1
- LWLP Differential Pressure Sensor x1
- Wires
Software Preparation
- Arduino IDE
- Download and install the Differential Pressure Sensor Library. (About how to install the library?)
Wiring Diagram
In order to ensure the measurement resolution and the sensor life, please use the sensor in the clean air. Do not let water enter the nozzle of the sensor, or it will cause damage to the sensor.
Sample Code
/*!
* @file readData.ino
* @brief Read sensor pressure difference and temperature value
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [fengli]([email protected])
* @version V1.0
* @date 2020-05-14
* @get from https://www.dfrobot.com
* @url https://github.com/DFRobot/DFRobot_LWLP
*/
#include <DFRobot_LWLP.h>
/*!
* @brief Construct the function
* @param pWire IC bus pointer object and construction device, can both pass or not pass parameters, Wire in default.
* @param address Chip IIC address, addresses 0x0
*/
DFRobot_LWLP lwlp;
void setup() {
Serial.begin(9600);
//Init Chip
while (lwlp.begin() != 0) {
Serial.println("Failed to initialize the chip, please confirm the chip connection");
delay(1000);
}
}
void loop(void){
DFRobot_LWLP::sLwlp_t data;
//Get data of single measurement
data = lwlp.getData();
//Get data processed by the filter
//data = lwlp.getfilterData();
//Get temperature in unit centigrade degree
Serial.print("Temperature: ");
Serial.print(data.temperature);
Serial.println(" C");
Serial.print("Differential Pressure: ");
//Get pressure difference in unit pa
Serial.print(data.presure);
Serial.println(" pa");
delay(500);
}
Result
Was this article helpful?
