Hi All,
I’m a new one on this forum, so I hope I will do everything as I should. I’m also fresh with Arduino, so I will be asking a lot of basic questions.
I set up an Arduino Mega with Ethernet Shield.
The Arduino Mega is: https://si.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=386&urlRequestType=Base&partNumber=2830990&storeId=10175
and the Ethernet Shield is: https://www.amazon.de/gp/product/B009N826DY/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1
Power supply is 5V over the USB port.
For displaying the graphs I’m using the Blynk App.
I have connected 4x digital temperature sensors DS18B20 with 4.7k pull up resistors and 2x DTH22 digital temperature and humidity sensors at first with no pull up resistor, later I have added the 4.7k pull up resistors to the DTH22 also.
The issues I’m having are following:
- after powering up the unit it all works fine for about 1 - 6 hours
- after that I stop getting results from one of the DTH22 sensors (both temperature and humidity at the same time.
- about half an hour later, I stop getting the results from the second DTH22 sensor also
- and some time after that (few hour) the unit is down from Blynk also, so it seems as the Network Shield would go down and the only solution is to reset the unit.
So far I set the fixed IP address, that works fine and I hope to get sistem stability, so the network shield will not go down. I will hawe to wait and see if it solves issue no 4, from my list above.
Now I’m working on solving the issue with DHT22 sensors. I see the stability of readings from DHT22 is wery well known issue. After a lot of research, I find Rob Tillaart library for DHT sensors, and as I understand it should solve the stability issue. If I set the DTH22 sensor just with serial print it works fine, the program is the following:
#include <dht.h>
dht DHT_1;
dht DHT_2;
#define DHT22_PIN1 8
#define DHT22_PIN2 9
void setup()
{
Serial.begin(9600);
}
void loop()
{
{
// READ - DHT 1
int chk = DHT_1.read22(DHT22_PIN1);
// DISPLAY - DHT 1
Serial.print(DHT_1.humidity, 1);
Serial.println(DHT_1.temperature, 1);
}
{
// READ - DHT 2
int chk = DHT_2.read22(DHT22_PIN2);
// DISPLAY - DHT 2
Serial.print(DHT_2.humidity, 1);
Serial.println(DHT_2.temperature, 1);
}
delay(2000);
}
However if I try to add this part to my program and use it with Blynk ,together with other sensors, I don’t manage to do it. Below is the program I managed to put together, however it is not working, so I would really be gratefull for some guidance
//==== Kniznice ===================================================
//#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#include <dht.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
char auth[] = "xxx";
SimpleTimer timer;
//==== Nastavitve fiksnega IP naslova ==============================
byte mac[] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX };
IPAddress ip(192, 168, 99, 11);
IPAddress dns_ip(8, 8, 8, 8);
IPAddress gw_ip(192, 168, 99, 1);
IPAddress mask(255, 255, 255, 0);
//****************************************************************
//**** NASTAVITEV PARAMETROV *************************************
//****************************************************************
//==== Network shield ============================================
#define W5100_CS 10
#define SDCARD_CS 4
//==== DHT Senzorji ==============================================
dht DHT_1;
dht DHT_2;
#define DHT22_PIN1 7
#define DHT22_PIN2 8
//==== Temperaturni senzorji =====================================
#define ONE_WIRE_BUS1 2
#define ONE_WIRE_BUS2 3
#define ONE_WIRE_BUS3 5
#define ONE_WIRE_BUS4 6
OneWire oneWire1(ONE_WIRE_BUS1);
OneWire oneWire2(ONE_WIRE_BUS2);
OneWire oneWire3(ONE_WIRE_BUS3);
OneWire oneWire4(ONE_WIRE_BUS4);
DallasTemperature sensor1(&oneWire1);
DallasTemperature sensor2(&oneWire2);
DallasTemperature sensor3(&oneWire3);
DallasTemperature sensor4(&oneWire4);
//==== Timerji ====================================================
BlynkTimer timer1;
BlynkTimer timer2;
BlynkTimer timer3;
//==== Temperaturni senzorji ======================================
void temp_senzorji()
{
Blynk.virtualWrite(V5, sensor1.getTempCByIndex(0));
Blynk.virtualWrite(V6, sensor2.getTempCByIndex(0));
Blynk.virtualWrite(V7, sensor3.getTempCByIndex(0));
Blynk.virtualWrite(V8, sensor4.getTempCByIndex(0));
sensor1.requestTemperatures();
sensor2.requestTemperatures();
sensor3.requestTemperatures();
sensor4.requestTemperatures();
}
//==== DHT Senzorji ===============================================
void dht_senzor_1()
{
int chk = DHT_1.read22(DHT22_PIN1);
float h1 = DHT_1.humidity;
float t1 = DHT_1.temperature;
Blynk.virtualWrite(V2, h1);
Blynk.virtualWrite(V1, t1);
}
void dht_senzor_2()
{
int chk = DHT_2.read22(DHT22_PIN2);
float h2 = DHT_2.humidity;
float t2 = DHT_2.temperature;
Blynk.virtualWrite(V4, h2);
Blynk.virtualWrite(V3, t2);
}
//==== Nastavitev zagona programa ==================================
void setup()
{
//==== Nastavitev zagona ===========================================
Serial.begin(9600);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH);
//==== Registracija na Blynk strežnika =============================
//Registracija na Blynk strežnik s fiksnim IP naslovom
Blynk.begin(auth, "cloud.blynk.cc", 8442, ip, dns_ip, gw_ip, mask, mac);
//Registracija na Blynk strežnik z dinamičnim IP naslovom
//Blynk.begin(auth);
//==== Branje senzorjev ============================================
sensor1.begin();
sensor2.begin();
sensor3.begin();
sensor4.begin();
timer1.setInterval(2000L, temp_senzorji);
/*
DHT_1.begin();
timer2.setInterval(2000L, dht_senzor_1);
DHT_2.begin();
timer3.setInterval(2000L, dht_senzor_2);
*/
}
void loop()
{
Blynk.run();
timer1.run();
timer2.run();
timer3.run();
}