somy problem is i cant get readings from both at once,
if i unplug the pin for my two ds18b20 and omit the line
for request.temperature, then i get a reading from my dht22. if i unplug the wire for my dht22 i get a reading from my two ds18b20 when i re add the request line.
at the bottom of my code, i have the dht22 being read every 4 seconds so i tried to throw everything in there
at the start of the loop is my 4 floats and request temperature,
i know im horrible at explaing myself, hopefully the error is easy to see
p.s. the reason theres so much print.serial things at the bottom is to be prepared for when i have my
sd data logger thats on the way, i have it set up how i want, where it should print every 4 seconds, but the two
sensors are blocking eachother i think?
thanks for any help. i also had to cut out a bunch of code so i could post this, but it was unrelated anyways
/*Grow tent brain,
project started march 2018
people who helped along the way
arduino.cc
- odometer
-sherzaad
*/
#include <Button.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#include <dht_nonblocking.h>
#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal.h>
DS3231 rtc;
#include <OneWire.h>
#include <DallasTemperature.h>
//sensor input pins
static const int DHT_SENSOR_PIN = 12; //DHT22 pin number here
#define DHT_SENSOR_TYPE DHT_TYPE_22 //other pin infor for libraries
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );
#define ONE_WIRE_BUS 13 //Dallas pin number here
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress top = { 0x28, 0xFF, 0x38, 0x25, 0x63, 0x16, 0x04, 0x65 }; //Dallas device address (1/2)
DeviceAddress bottom = { 0x28, 0xFF, 0x5D, 0x10, 0x62, 0x16, 0x04, 0xC4 }; //Dallas device address (2/2)
//Neo pixel 8 strip leds
#define PIN 11 //pin number
#define NUMPIXELS 16 //number of leds in led strip
//colors
#define RED 250, 0, 0 //color 1
#define GREEN 0, 250, 0 //color 2
#define BLUE 0, 0, 250 //color 3
#define NOLIGHT 0, 0, 0 //no color/light
#define pixelbright 30
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
////////////////////////////////////////////////////////////////////////////////////////////////////////////Setup//////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
Wire.begin();
sensors.begin();
rtc.begin();
button1.begin();
button2.begin();
button3.begin();
button4.begin();
button5.begin();
button6.begin();
button7.begin();
button8.begin();
pixels.begin();
pixels.setBrightness(pixelbright);
rtc.adjust(DateTime(__DATE__, __TIME__));
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
}
//set pins (outputs)
pinMode(waterpump, OUTPUT);
pinMode(l1, OUTPUT);
pinMode(l2, OUTPUT);
pinMode(circulatepump, OUTPUT);
pinMode(circulatefan, OUTPUT);
pinMode(airstone, OUTPUT);
pinMode(exhaustlight, OUTPUT);
pinMode(exhausttent, OUTPUT);
pinMode(dfloat, INPUT);
}
//Set DHT22 nnblocking
static bool measure_environment( float *temperature, float *humidity )
{
static unsigned long measurement_timestamp = millis( );
/* Measure once every four seconds. */
if( millis( ) - measurement_timestamp > 4000ul )
{
if( dht_sensor.measure( temperature, humidity ) == true )
{
measurement_timestamp = millis( );
return( true );
}
}
return( false );
}
/////////////////////////////////////////////////////////////////////////////////////////Loop/////////////////////////////////////////////////////////////////////////
void loop() {
sensors.requestTemperatures(); // Send the command to get temperatures
float tempC1 = sensors.getTempC(top);
float tempC2 = sensors.getTempC(bottom);
float temperature;
float humidity;
//Neo pixel activity
//Red light means dump bucket is full
if (digitalRead(dfloat) == HIGH) {
pixels.setPixelColor(8, pixels.Color(RED));
pixels.show();
}
else {
pixels.setPixelColor(8, pixels.Color(NOLIGHT));
pixels.show();
}
//Blue light means plants are being watered
if (digitalRead(waterpump) == HIGH) {
pixels.setPixelColor(9, pixels.Color(BLUE));
pixels.show();
}
else {
pixels.setPixelColor(9, pixels.Color(NOLIGHT));
pixels.show();
}
//blue means resevior is being circulated
if (digitalRead(circulatepump) == HIGH) {
pixels.setPixelColor(10, pixels.Color(BLUE));
pixels.show();
}
else {
pixels.setPixelColor(10, pixels.Color(NOLIGHT));
pixels.show();
}
//Green light means lights are on
if (digitalRead(l2) == HIGH) {
pixels.setPixelColor(11, pixels.Color(GREEN));
pixels.show();
}
else {
pixels.setPixelColor(11, pixels.Color(NOLIGHT));
pixels.show();
}
//humidity
if (humidity > 60.){
pixels.setPixelColor(12, pixels.Color(BLUE));
}
if ((humidity < 59.99) && (humidity > 40)){
pixels.setPixelColor(12, pixels.Color(GREEN));
}
if (humidity < 39.99){
pixels.setPixelColor(12, pixels.Color(RED));
}
// side temp other
if (tempC1 > 26.) {
pixels.setPixelColor(13, pixels.Color(RED));
pixels.show();
}
if ((tempC1 < 25.99) && (tempC1 > 20.00)) {
pixels.setPixelColor(13, pixels.Color(GREEN));
pixels.show();
}
if (tempC1 < 19.99) {
pixels.setPixelColor(13, pixels.Color(BLUE));
pixels.show();
}
// side temp
if (tempC2 > 26.) {
pixels.setPixelColor(14, pixels.Color(RED));
pixels.show();
}
if ((tempC2 < 25.99) && (tempC1 > 20.00)) {
pixels.setPixelColor(14, pixels.Color(GREEN));
pixels.show();
}
if (tempC2 < 19.99) {
pixels.setPixelColor(14, pixels.Color(BLUE));
pixels.show();
}
pixels.setPixelColor(15, pixels.Color(30, 20, 100));
/*leave for Co2 upgrade
// Red means co2 is on
if (digitalRead( // ) == HIGH) {
pixels.setPixelColor(15, pixels.Color(GREEN));
pixels.show();
else {
pixels.setPixelColor(15, pixels.Color(NOLIGHT));
pixels.show();
}
}
*/
if ( measure_environment( &temperature, &humidity ) == true )
{
/* Measure temperature and humidity. If the functions returns
true, then a measurement is available. */
//Temp&humid
Serial.print( temperature, 1 );
Serial.println( " C, " );
Serial.print( humidity, 1 );
Serial.println( " % " );
Serial.println();
//time
DateTime now = rtc.now();
char buf[100];
strncpy(buf, "DD.MM.YYYY hh:mm:ss\0", 100);
Serial.println(now.format(buf));
Serial.println();
Serial.print(tempC1, 1);
Serial.println(" C, ");
Serial.print(tempC2, 1);
Serial.println(" C, ");
Serial.println();
if (digitalRead(dfloat) == HIGH){
Serial.println("Bucket Full!");
}
else{
Serial.println("bucket Good");
}
if (digitalRead(waterpump) == HIGH){
Serial.println("WaterPump Is On");
}
else{
Serial.println("WaterPump Is Off");
}
if (digitalRead(circulatepump) == HIGH){
Serial.println("Water Is Circulating");
}
else{
Serial.println("Water Is Still");
}
if (digitalRead(l1) == HIGH){
Serial.println("Light One Is On");
}
else{
Serial.println("Light One Is Off");
}
if (digitalRead(l2) == HIGH){
Serial.println("Light Two Is On");
}
else{
Serial.println("Light Two Is Off");
}
if (digitalRead(circulatefan) == HIGH){
Serial.println("Circulation Fans Are On");
}
else {Serial.println("Circulation Fans Are Off");
}
if (digitalRead(airstone) == HIGH){
Serial.println("Resevior Is Being Aerated");
}
else {Serial.println("Airstone Is Off");
}
if (digitalRead(exhaustlight) == HIGH){
Serial.println("Exhaust Fan Is On");
}
else {
Serial.println("Exhaust Fan Is Off");
}
if (digitalRead(exhausttent) == HIGH){
Serial.println("Tent Is Being Exhausted");
}
else {
Serial.println("Air Is Still"); // Co2 upgrade, will say Co2 is on, leave
}
Serial.println();
}
}