Kilka dht22 na jednym module
-
soren
- Posts: 164
- Joined: Mon Jun 04, 2018 7:36 am
Cześć mam pytanko czy ktoś stworzył juz soft z kilkoma najlepiej z 5-6szt dht22 na jednym module najlepiej wemos?
-
klew
- Posts: 13908
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
- Has thanked: 134 times
- Been thanked: 137 times
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
Najlepsze suple dla Twojego domu 
-
klew
- Posts: 13908
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
- Has thanked: 134 times
- Been thanked: 137 times
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:
Code: Select all
// CHANNEL6 - DHT22 Sensor
new Supla::Sensor::DHT(DHTPIN, DHTTYPE);
Code: Select all
new Supla::Sensor::DHT(dht2pin, dht2type);
new Supla::Sensor::DHT(dht3pin, dht3type);
Najlepsze suple dla Twojego domu 
-
soren
- Posts: 164
- Joined: Mon Jun 04, 2018 7:36 am
To sie wgra tylko na arduino mega czy na wemosa też da radę?
-
Patryk
- Posts: 2944
- Joined: Mon Jan 07, 2019 7:51 pm
- Location: Rybnik
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.
-
elmaya
- Posts: 1485
- Joined: Wed Jun 27, 2018 5:48 pm
- Location: El Saucejo - Sevilla
przykład wemos 3 X DHT22
Code: Select all
/*
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();
}