@Hackscribble
I'm powering all of it through an USB port. Do you think that it may be caused by insufficient current?
@weedpharma
The code is as follow:
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <DHT.h>
#include <Adafruit_BMP085.h>
#include <Wire.h>
#include <SPI.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(8, 9, 10, 11, 12);
Adafruit_BMP085 bmp180;
DHT dht(3, DHT22);
void setup() {
Serial.begin(9600);
display.begin();
display.setContrast(48);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
dht.begin();
bmp180.begin();
display.setCursor(1,1); // sets cursor position
display.println("TEMP"); // print
display.setCursor(30,1);
display.println("--- C");
display.setCursor(1,12);
display.println("UMID");
display.setCursor(30,12);
display.println("--- %");
display.setCursor(1,23);
display.println("PRES");
display.setCursor(30,23);
display.println("------ mB");
}
void loop() {
float p = bmp180.readPressure()/100.0;
float t = dht.readTemperature();
float h = dht.readHumidity();
// if (isnan(h) || isnan(t)) {
// Serial.println("Failed to read from DHT sensor!");
// return;
// }
display.fillRect(29,1,24,10,0); //draws a white rectangle above the "---"'s done in void setup
display.setCursor(29,1); //sets cursor above the white rectangle
display.println(t,1); // prints the temperature with 1 decimal
display.fillRect(29,12,24,10,0);
display.setCursor(29,12);
display.println(h,1);
display.fillRect(29,23,42,10,0);
display.setCursor(29,23);
display.println(p,2);
display.display();
delay(2000);
// Serial.print("Humidity: ");
// Serial.print(h);
// Serial.print(" %\t");
// Serial.print("Temperature: ");
// Serial.print(t);
// Serial.print(" *C ");
// Serial.print("Pressure: ");
// Serial.print(p);
// Serial.println(" mb");
}
I used the commented serial-code-parts to see if it wasn't the display being buggy, but it isn't.
@Robin2
The 2 options that work (1 sensor + display) can be done by simply commenting the "other sensor" code parts.
When I try to run it all together I receive 0 / n.a.n on the humidity sensor.
I hope it's all clear. If any more information is needed, i'll be glad to give it.