Kilka dht22 na jednym module
Na Arduino ide na nowej rozwijanej wersji biblioteki jest przykład z dwoma dht. Dodanie kolejnych, to jedna dodatkowa linia kodu na czujnik.
Biblioteką jest tu https://github.com/klew/arduino
Biblioteką jest tu https://github.com/klew/arduino
Widzimy się na Supla Offline Party vol. 2
Mała poprawka: tam był kiedyś przykład z dwoma DHT . Teraz widzę, że jest jeden.
Ale zmiana nadal jest prosta. Pod tymi liniami kodu:
dodaj:
pin i typ ustaw zgodnie z fizycznym podłączeniem.
Ale zmiana nadal jest prosta. Pod tymi liniami kodu:
Kod: Zaznacz cały
// CHANNEL6 - DHT22 Sensor
new Supla::Sensor::DHT(DHTPIN, DHTTYPE);
Kod: Zaznacz cały
new Supla::Sensor::DHT(dht2pin, dht2type);
new Supla::Sensor::DHT(dht3pin, dht3type);
Widzimy się na Supla Offline Party vol. 2
Nie twierdzę, że DHT22 to złe czujniki, ale zapoznaj się z tym:
viewtopic.php?f=8&t=5489
oraz:
viewtopic.php?f=26&t=5177
Osobiście wolę BME280.
viewtopic.php?f=8&t=5489
oraz:
viewtopic.php?f=26&t=5177
Osobiście wolę BME280.
przykład wemos 3 X DHT22
Kod: Zaznacz cały
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <SPI.h>
#include <SuplaDevice.h>
#include <supla/sensor/DHT.h>
// Choose proper network interface for your card:
// Arduino Mega with EthernetShield W5100:
//#include <supla/network/ethernet_shield.h>
// Ethernet MAC address
//uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
//Supla::EthernetShield ethernet(mac);
//
// Arduino Mega with ENC28J60:
// #include <supla/network/ENC28J60.h>
// Supla::ENC28J60 ethernet(mac);
//
// ESP8266 based board:
#include <supla/network/esp_wifi.h>
Supla::ESPWifi wifi("your_wifi_ssid", "your_wifi_password");
//
// ESP32 based board:
// #include <supla/network/esp32_wifi.h>
// Supla::ESP32Wifi wifi("your_wifi_ssid", "your_wifi_password");
/*
* This example requires DHT sensor library installed.
* https://github.com/adafruit/DHT-sensor-library
*/
#define DHT1PIN 14 // D5
#define DHT1TYPE DHT22
#define DHT2PIN 12 // D6
#define DHT2TYPE DHT22
#define DHT3PIN 13 // D7
#define DHT3TYPE DHT22
void setup() {
Serial.begin(115200);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
/*
* Having your device already registered at cloud.supla.org,
* you want to change CHANNEL sequence or remove any of them,
* then you must also remove the device itself from cloud.supla.org.
* Otherwise you will get "Channel conflict!" error.
*/
// CHANNEL6 - DHT22 Sensor
new Supla::Sensor::DHT(DHT1PIN, DHT1TYPE);
new Supla::Sensor::DHT(DHT2PIN, DHT2TYPE);
new Supla::Sensor::DHT(DHT3PIN, DHT3TYPE);
/*
* SuplaDevice Initialization.
* Server address, LocationID and LocationPassword are available at https://cloud.supla.org
* If you do not have an account, you can create it at https://cloud.supla.org/account/create
* SUPLA and SUPLA CLOUD are free of charge
*
*/
SuplaDevice.begin(GUID, // Global Unique Identifier
"svr1.supla.org", // SUPLA server address
"email@address", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();
}