One Shot TPH Sample

This application demonstrates temperature, pressure, and humidity reading functions of the module. It uses Arduino IDE's Serial Monitor to display sensor readings.

To run the example:

  1. Open the IoT_Node_Environmental_One_Shot_TPH sketch from the examples menu.

  2. Select Turta IoT Node from Tools > Board menu.

  3. Select your device's COM port from Tools > Port menu.

  4. Open Serial Monitor from Tools > Serial Monitor.

  5. Select 115.200 baud from the Serial Monitor's status bar.

  6. Upload the code to your device.

Sample Code

#include <Turta_Environmental_Module.h>

// Create Environmental Sensor instance.
Turta_Environmental_Module en;

void setup() {
  // Initialize Environmental Sensor.
  en.begin();

  // Configure serial port.
  Serial.begin(115200);
  delay(200);
}

void loop() {
  // Read temperature, pressure, and humidity in one shot. 
  double temperature, pressure, humidity;
  en.readTPH(temperature, pressure, humidity);

  // Print temperature.
  Serial.print("Temperature: ");
  Serial.println(temperature);

  // Print relative humidity.
  Serial.print("Humidity: ");
  Serial.println(humidity);

  // Print pressure.
  Serial.print("Pressure: ");
  Serial.println(pressure);

  // Print an empty line.
  Serial.println("");

  // Delay 5000ms = 5 seconds.
  delay(5000);
}

Result

After the application is uploaded to the device, it writes current readings to the Serial Monitor every five seconds. The example output should be like this:

Temperature: 25.26
Humidity: 57.37
Pressure: 1009.65

The application runs forever until you clear it from memory.

Last updated