GY-63_MS5611/libraries/DHTNEW/examples/dhtnew_powerDown/dhtnew_powerDown.ino

85 lines
1.8 KiB
Arduino
Raw Normal View History

2020-11-27 05:10:47 -05:00
//
// FILE: dhtnew_powerDown.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DHTNEW library test sketch for Arduino
// URL: https://github.com/RobTillaart/DHTNew
2021-12-16 11:24:05 -05:00
2020-11-27 05:10:47 -05:00
// DHT PIN layout from left to right
// =================================
// FRONT : DESCRIPTION
// pin 1 : VCC
// pin 2 : DATA
// pin 3 : Not Connected
// pin 4 : GND
2021-12-16 11:24:05 -05:00
// to see the effect one must apply a voltmeter to the data pin of the sensor
2020-11-27 05:10:47 -05:00
// during the low power mode. Measuring during communication will disrupt the
// data transfer.
2021-11-18 03:48:40 -05:00
2020-11-27 05:10:47 -05:00
#include <dhtnew.h>
DHTNEW mySensor(16);
2021-11-18 03:48:40 -05:00
2020-11-27 05:10:47 -05:00
void setup()
{
2021-11-18 03:48:40 -05:00
while(!Serial); // MKR1010 needs this
2020-11-27 05:10:47 -05:00
Serial.begin(115200);
Serial.println("dhtnew_test.ino");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHTNEW_LIB_VERSION);
2021-11-18 03:48:40 -05:00
// MKR1010 needs this
// mySensor.setDisableIRQ(false);
2020-11-27 05:10:47 -05:00
Serial.println("\nstartup");
delay(2000);
Serial.println("read sensor with 2 second interval");
for (int i = 0; i < 3; i++)
{
int rv = mySensor.read();
if (rv != DHTLIB_OK)
{
Serial.println(rv); // will print -7 when measuring voltage
}
Serial.print(mySensor.getHumidity(), 1);
Serial.print(",\t");
Serial.println(mySensor.getTemperature(), 1);
delay(2000);
}
Serial.println("switch to low power (~ 5 seconds )");
Serial.println("measure voltage");
mySensor.powerDown();
delay(5000);
Serial.println("switch sensor on (and wait 2 seconds)");
mySensor.powerUp();
// wait for 2 seconds.
delay(2000);
Serial.println("read sensor with 2 second interval");
for (int i = 0; i < 3; i++)
{
mySensor.read();
Serial.print(mySensor.getHumidity(), 1);
Serial.print(",\t");
Serial.println(mySensor.getTemperature(), 1);
delay(2000);
}
Serial.println("\nDone...");
}
2021-11-18 03:48:40 -05:00
2020-11-27 05:10:47 -05:00
void loop()
{
}
2021-11-18 03:48:40 -05:00
// -- END OF FILE --