Links

Temp RH Sample

This application demonstrates temperature and humidity reading functions of the module. It uses Arduino IDE's Serial Monitor to display sensor readings.
To run the example:
  1. 1.
    Open the IoT_Node_TempRH sketch from the examples menu.
  2. 2.
    Select Turta IoT Node from the Tools > Board menu.
  3. 3.
    Select your device's COM port from Tools > Port menu.
  4. 4.
    Open Serial Monitor from Tools > Serial Monitor.
  5. 5.
    Select 115.200 baud from the Serial Monitor's status bar.
  6. 6.
    Upload the code to your device.

Sample Code

IoT_Node_TempRH.ino
#include <Turta_TempRH_Module.h>
// Create Temperature & RH Sensor instance.
Turta_TempRH_Module th;
void setup() {
// Initialize Temperature & RH Sensor.
th.begin();
// Configure serial port.
Serial.begin(115200);
delay(200);
}
void loop() {
// Read temperature.
double temperature = th.readTemperature();
Serial.print("Temperature: ");
Serial.println(temperature);
// Read relative humidity.
double humidity = th.readHumidity();
Serial.print("Humidity: ");
Serial.println(humidity);
// Print an empty line.
Serial.println("");
// Delay 1000ms = 1 seconds.
delay(1000);
}

Result

After the application is uploaded to the device, it writes current readings to the Serial Monitor each second. The example output should be like this:
Temperature: 24.04
Humidity: 63.67
Temperature: 24.07
Humidity: 63.65
Temperature: 24.09
Humidity: 63.63
The application runs forever until you clear it from memory.
Last modified 3yr ago