Hello.
I have a project to sense emperature and humidity in some room.
I’m using Arduino Uno
Ethernet Shield v2
2 Temp & Humidity sensors: DHT22
1 temp & Humidity sensor: STH71
In the project, I read the parameters and send it to a Mysql database that I can read from a webpage.
I use to work only with the 2 DHT22 sensors and everything was OK for the las 3 weeks. Today I installed the STH71 and something funy hapend.
If I initialize the ethernet card using the command:
Ethernet.begin(mac, ip, myDns);
then the STH71 sensor doesn’t read at all. If I deactivate that line, then the sensor read perfect, the network work is disabled.
The code is as following:
#include <Sensirion.h>
#include <SPI.h>
#include <DHT.h>
#include <Ethernet2.h>
// PARA EL SENSOR SHT71
#define DATAPIN1 11
#define CLOCKPIN1 8
float temp3; //Stores humidity value
float hum3; //Stores temperature value
float dewpoint3; // Stores dewpoint value
Sensirion tempSensorSHT71_1 = Sensirion(DATAPIN1, CLOCKPIN1);
//*******************************************************************
//*******************************************************************
//*******************************************************************
//*******************************************************************
//Constants
#define DHTPIN1 2 // what pin we’re connected to
#define DHTPIN2 3 // what pin we’re connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht1(DHTPIN1, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
DHT dht2(DHTPIN2, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum1; //Stores humidity value
float temp1; //Stores temperature value
float hum2; //Stores humidity value
float temp2; //Stores temperature value
//*******************************************************************
//*******************************************************************
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac = { MY MAC ADDRESS };
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(192, 168, 1, 4);
// fill in your Domain Name Server address here:
IPAddress myDns(192, 168, 1, 1);
// initialize the library instance:
EthernetClient client;
char server = “www.MY WEB SERVER.com”;
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
// the “L” is needed to use long type numbers
void setup() {
// start serial port:
Serial.begin(9600);
// while (!Serial) {
// ; // wait for serial port to connect. Needed for Leonardo only
// }
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection using a fixed IP address and DNS server:
Ethernet.begin(mac, ip, myDns);
// print the Ethernet board/shield’s IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
//*******************************************************************
//*******************************************************************
dht1.begin();
dht2.begin();
//*******************************************************************
//*******************************************************************
Serial.println(“Starting up …”);
}
void loop() {
//*******************************************************************
//*******************************************************************
//Read data and store it to variables hum and temp
hum1 = dht1.readHumidity();
temp1= dht1.readTemperature();
Serial.print("Humidity1: “);
Serial.print(hum1);
Serial.print(” %, Temp1: “);
Serial.print(temp1);
Serial.print(” C, ");
temp1= (temp11.8)+32;
temp1=temp1-3; //calibrado por software
//Print temp and humidity values to serial monitor
Serial.print(“Temp1: “);
Serial.print(temp1);
Serial.println(” F”);
//******************************************************************
//*******************************************************************
hum2 = dht2.readHumidity();
temp2= dht2.readTemperature();
Serial.print("Humidity2: “);
Serial.print(hum2);
Serial.print(” %, Temp2: “);
Serial.print(temp2);
Serial.print(” C, ");
temp2= (temp21.8)+32;
temp2=temp2-3; //calibrado por software
//Print temp and humidity values to serial monitor
Serial.print(“Temp2: “);
Serial.print(temp2);
Serial.println(” F”);
//******************************************************************
//*******************************************************************
/*
tempSensorSHT71_1.measure(&temp3, &hum3, &dewpoint3);
Serial.print("Humidity3: “);
Serial.print(hum3);
Serial.print(” %, Temp3: “);
Serial.print(temp3);
Serial.print(” C, ");
Serial.print("Temp3: “);
temp3=(temp31.8)+32;
Serial.print(temp3);
Serial.println(" F");
/
//*****************************************************************
//*******************************************************************
Serial.println(” ********************************************************** ");
delay(2000); //Delay 2 sec.
// if there’s incoming data from the net connection.
// send it out the serial port. This is for debugging
// purposes only:
if (client.available()) {
char c = client.read();
Serial.write(c);
}
// if ten seconds have passed since your last connection,
// then connect again and send data:
if (millis() - lastConnectionTime > postingInterval) {
httpRequest1();
httpRequest2();
httpRequest3();
}
}
// this method makes a HTTP connection to the server:
void httpRequest1() {
//network data registers via webpage
}
// this method makes a HTTP connection to the server:
void httpRequest2() {
//network data registers via webpage
}
// this method makes a HTTP connection to the server:
void httpRequest3() {
//network data registers via webpage
}