Single Readings Sample

This application demonstrates temperature, humidity, pressure, altitude and gas resistance 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_Single_Readings 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>

// Global Variables
double meanSeaLevelPressureInBar = 1020.0;

// 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.
  double temperature = en.readTemperature();
  Serial.print("Temperature: ");
  Serial.println(temperature);

  // Read relative humidity.
  double humidity = en.readHumidity();
  Serial.print("Humidity: ");
  Serial.println(humidity);

  // Read pressure.
  double pressure = en.readPressure();
  Serial.print("Pressure: ");
  Serial.println(pressure);

  // Calculate altitude.
  double altitude = en.calcAltitude(meanSeaLevelPressureInBar);
  Serial.print("Altitude: ");
  Serial.println(altitude);

  // Read gas resistance.
  double gasResistance = en.readGasResistance();
  Serial.print("Gas Resistance: ");
  Serial.println(gasResistance);

  // 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
Altitude: 120.34
Gas Resistance: 121349.56

The application runs forever until you clear it from memory.

Last updated