Witam dodałem czujnik dht22 ale aplikacji pokazuje mi 2 sztuki
w czym może byc problem ?
P.S macie pomysł jak zrobić czujnik temperatury który był by na dworzu ?
Musiał by być zasilany z akumulatora (bateri ) i łączyć sie z arduino bezprzewodowo
Code: Select all
#include <SPI.h>
#include <Ethernet.h>
#include <DHT.h>
#include <SuplaDevice.h>
/*
* SUPLA DEVICE - ARDUINO - ETHERNET SHIELD
* Author: Przemyslaw Zygmunt <[email protected]>
*
*/
#define DHTPIN 24
#define DHTTYPE DHT22
#define RED_PIN 44
#define GREEN_PIN 45
#define BLUE_PIN 46
#define BRIGHTNESS_PIN 7
#define COLOR_BRIGHTNESS_PIN 8
// Setup a DHT instance
DHT dht(DHTPIN, DHTTYPE);
// DS18B20 Sensor read implementation
void get_temperature_and_humidity(int channelNumber, double *temp, double *humidity) {
*temp = dht.readTemperature();
*humidity = dht.readHumidity();
if ( isnan(*temp) || isnan(*humidity) ) {
*temp = -275;
*humidity = -1;
}
}
unsigned char _red = 0;
unsigned char _green = 255;
unsigned char _blue = 0;
unsigned char _color_brightness = 0;
unsigned char _brightness = 0;
void get_rgbw_value(int channelNumber, unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *color_brightness, unsigned char *brightness) {
*brightness = _brightness;
*color_brightness= _color_brightness;
*red = _red;
*green = _green;
*blue = _blue;
}
void set_rgbw() {
analogWrite(BRIGHTNESS_PIN, (_brightness * 255) / 100);
analogWrite(COLOR_BRIGHTNESS_PIN, (_color_brightness * 255) / 100);
analogWrite(RED_PIN, _red);
analogWrite(GREEN_PIN, _green);
analogWrite(BLUE_PIN, _blue);
}
void set_rgbw_value(int channelNumber, unsigned char red, unsigned char green, unsigned char blue, unsigned char color_brightness, unsigned char brightness) {
_brightness = brightness;
_color_brightness= color_brightness;
_red = red;
_green = green;
_blue = blue;
set_rgbw();
}
void suplaDigitalWrite(int channelNumber, uint8_t pin, uint8_t val) {
digitalWrite(pin, val);
if ( pin == 3 )
digitalWrite(5, val);
}
void setup() {
SuplaDevice.setDigitalWriteFuncImpl(&suplaDigitalWrite);
Serial.begin(9600);
// Init DHT library
dht.begin();
// Set temperature/humidity callback
SuplaDevice.setTemperatureHumidityCallback(&get_temperature_and_humidity);
set_rgbw();
// Set RGBW callbacks
SuplaDevice.setRGBWCallbacks(&get_rgbw_value, &set_rgbw_value);
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0000000000000};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
// Ethernet MAC address
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
/*
* 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.
*/
// CHANNEL0 - RELAY
SuplaDevice.addRgbControllerAndDimmer();
SuplaDevice.addRollerShutterRelays(3, 5);
SuplaDevice.addRollerShutterRelays(27, 29, true);
SuplaDevice.addRollerShutterRelays(31, 33, true);
SuplaDevice.addRollerShutterRelays(35, 37, true);
SuplaDevice.addRollerShutterRelays(39, 41, true);
// CHANNEL4 - Opening sensor (Normal Open)
SuplaDevice.addSensorNO(A0); // A0 - Pin number where the sensor is connected
// Call SuplaDevice.addSensorNO(A0, true) with an extra "true" parameter
// to enable the internal pull-up resistor
// CHANNEL5 - Opening sensor (Normal Open)
SuplaDevice.addSensorNO(A1); // A1 - Pin number where the sensor is connected
// CHANNEL6 - DHT22 Sensor
// SuplaDevice.addDHT11();
// SuplaDevice.addAM2302();
SuplaDevice.addDHT22();
/*
* 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
mac, // Ethernet MAC address
"svr1.supla.org", // SUPLA server address
, // Location ID - TU WKLEJASZ SWÓJ ID
""); // Location Password - W NAWIASIE WKLEJASZ HASŁO
}
void loop() {
SuplaDevice.iterate();
}
You do not have the required permissions to view the files attached to this post.