TPH V2¶
Required items¶
- SODAQ SARA SFF
- SODAQ SARA SFF BASEBOARD
- TPH
I2C¶
Connect the TPH sensor to one of the two I2C connectors.
Libraries¶
Install the following libraries from the Arduino library manager:
- Adafruit Unified Sensor
- Adafruit BME280 Library
Arduino Code¶
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
void setup() {
SerialUSB.begin(9600);
SerialUSB.println(F("BME280 test"));
if (!bme.begin()) {
SerialUSB.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
SerialUSB.print("Temperature = ");
SerialUSB.print(bme.readTemperature());
SerialUSB.println(" *C");
SerialUSB.print("Pressure = ");
SerialUSB.print(bme.readPressure() / 100.0F);
SerialUSB.println(" hPa");
SerialUSB.print("Approx. Altitude = ");
SerialUSB.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
SerialUSB.println(" m");
SerialUSB.print("Humidity = ");
SerialUSB.print(bme.readHumidity());
SerialUSB.println(" %");
SerialUSB.println();
delay(2000);
}