mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
add DHT20 RP2040 example
This commit is contained in:
parent
070fe385a2
commit
84bc647931
28
libraries/DHT20/examples/DHT20_test_rp2040/.arduino-ci.yml
Normal file
28
libraries/DHT20/examples/DHT20_test_rp2040/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
@ -0,0 +1,82 @@
|
||||
//
|
||||
// FILE: DHT20_test_rp2040.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: Demo for DHT20 I2C humidity & temperature sensor
|
||||
//
|
||||
|
||||
// Always check datasheet - front view
|
||||
//
|
||||
// +--------------+
|
||||
// VDD ----| 1 |
|
||||
// SDA ----| 2 DHT20 |
|
||||
// GND ----| 3 |
|
||||
// SCL ----| 4 |
|
||||
// +--------------+
|
||||
|
||||
|
||||
#include "DHT20.h"
|
||||
|
||||
DHT20 DHT(&Wire); // or use 2nd I2C interface &Wire1
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DHT20 LIBRARY VERSION: ");
|
||||
Serial.println(DHT20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire1.setSDA(12); // select your pin numbers here
|
||||
Wire1.setSCL(13); // select your pin numbers here
|
||||
Wire1.begin();
|
||||
|
||||
delay(2000);
|
||||
|
||||
Serial.println("Type,\tStatus,\tHumidity (%),\tTemperature (C)");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// READ DATA
|
||||
Serial.print("DHT20, \t");
|
||||
int status = DHT.read();
|
||||
switch (status)
|
||||
{
|
||||
case DHT20_OK:
|
||||
Serial.print("OK,\t");
|
||||
break;
|
||||
case DHT20_ERROR_CHECKSUM:
|
||||
Serial.print("Checksum error,\t");
|
||||
break;
|
||||
case DHT20_ERROR_CONNECT:
|
||||
Serial.print("Connect error,\t");
|
||||
break;
|
||||
case DHT20_MISSING_BYTES:
|
||||
Serial.print("Missing bytes,\t");
|
||||
break;
|
||||
case DHT20_ERROR_BYTES_ALL_ZERO:
|
||||
Serial.print("All bytes read zero");
|
||||
break;
|
||||
case DHT20_ERROR_READ_TIMEOUT:
|
||||
Serial.print("Read time out");
|
||||
break;
|
||||
case DHT20_ERROR_LASTREAD:
|
||||
Serial.print("Error read too fast");
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown error,\t");
|
||||
break;
|
||||
}
|
||||
|
||||
// DISPLAY DATA, sensor has only one decimal.
|
||||
Serial.print(DHT.getHumidity(), 1);
|
||||
Serial.print(",\t");
|
||||
Serial.println(DHT.getTemperature(), 1);
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
Loading…
Reference in New Issue
Block a user