Adafruit DPS310: an example that runs
Yes. You can use the Adafruit DPS310 library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Barometric pressure, DPS310). The example below, "The DPS310 simpletest: temperature and pressure", runs on the Arduino Uno R3.
Built in on Mokxi: #include <Adafruit_DPS310.h> and it builds, with nothing to install. Free, and no account needed.
What Adafruit DPS310 does
Pressure and temperature: begin_I2C(), configurePressure(), configureTemperature(), setMode(), the available checks and getEvents(). That is what Adafruit DPS310 covers. The sketch below uses it on the Arduino Uno: “The DPS310 simpletest: temperature and pressure”.
The Adafruit DPS310 library's interface, for the Infineon DPS310 barometric pressure and temperature sensor.
It reads Mokxi's dps310 part over I2C. The simpletest.
The calls follow release 1.1.6 of the library, so a sketch written here builds on a real board too. The example is the one Mokxi's own tests build and run, so what is printed here is what runs.
| Library Manager name | Adafruit DPS310 |
|---|---|
| Author | Adafruit |
| Include | #include <Adafruit_DPS310.h> |
| Boards | every board Mokxi compiles for but ATtiny85 |
| In the simulator | Simulated: it runs against the part the way it does on the bench. |
| Parts it drives | Barometric pressure, DPS310 |
Install it
It builds on every board Mokxi compiles for but ATtiny85.
In Mokxi it is built in: #include <Adafruit_DPS310.h> and the sketch compiles, with no download, no zip and no Library Manager.
On a real board, install "Adafruit DPS310" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit DPS310 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.1.6, so a sketch written here builds there too.
What to know in the simulator: Over I2C; begin_SPI() returns false.
- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi
The calls you will use
In the order a sketch meets them.
Adafruit_DPS310 dps
Makes dps, the Adafruit_DPS310 object the calls below are made on.
dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES)
Sets the pressure to the value you pass in.
dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES)
Sets the temperature to the value you pass in.
dps.getEvents(&temp_event, &pressure_event)
Returns the events as true or false. Arguments: temp event, pressure event.
Example: The DPS310 simpletest: temperature and pressure
On the Arduino Uno R3. It runs in the browser exactly as printed.
#include <Adafruit_DPS310.h>
Adafruit_DPS310 dps;
void setup() {
Serial.begin(115200);
Serial.println("DPS310");
if (!dps.begin_I2C()) {
Serial.println("Failed to find DPS");
while (1) yield();
}
Serial.println("DPS OK!");
dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES);
dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES);
}
void loop() {
sensors_event_t temp_event, pressure_event;
while (!dps.temperatureAvailable() || !dps.pressureAvailable()) {
return;
}
dps.getEvents(&temp_event, &pressure_event);
Serial.print(F("Temperature = "));
Serial.print(temp_event.temperature, 1);
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(pressure_event.pressure, 1);
Serial.println(" hPa");
Serial.println();
}Wiring
- Arduino Uno R3 A4 to Barometric pressure, DPS310 SDA
- Arduino Uno R3 A5 to Barometric pressure, DPS310 SCL
- Arduino Uno R3 5V to Barometric pressure, DPS310 VIN
- Arduino Uno R3 GND to Barometric pressure, DPS310 GND
Projects that use Adafruit DPS310
Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.
Keep going
Try Adafruit DPS310 without installing anything
Open the example, change the sketch, and keep your version in a free account.