Grove Beginner Kit Project 8

The 0.96” screen says that the temperature is 0 °C in my house, and that there is no water vapor in the air. I think something’s wrong with my code.

Code:

#include <DHT.h>
#include <Arduino.h>
#include <U8x8lib.h>

#define DHTPIN 3
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); 

void setup(void) {
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
  u8x8.begin();
  u8x8.setPowerSave(0);
  u8x8.setFlipMode(1);
}

void loop(void) {
  float temp, humi;
  temp = dht.readTemperature();
  humi = dht.readHumidity();

  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.setCursor(0, 33);
  u8x8.print("Temp:");
  u8x8.print(temp);
  u8x8.print("C");
  u8x8.setCursor(0, 50);
  u8x8.print("Humidity");
  u8x8.print(humi);
  u8x8.print("%");
  u8x8.refreshDisplay();
  delay(200);
}

The manual is here.

The wiring “diagram” is in the manual.

As always, post your wiring diagram here.

The screen only displays what is sent to it. Do you have a DHT11? Not a DHT22?

  • The DHT needs 1 second to come up with the values, not 200ms.

  • Learn how to make non-blocking TIMERs, avoid delay(. . .)

To @xfpd :

  1. Wiring Diagram (green wires are the grove cables i would use if i broke the modules apart)

  2. I don’t know which one I have. It is a black case (rectangular prism, not the other one that slopes in at one side.

To @LarryD :

I followed the manual; I didn’t know it needed those. I’ll incorporate your suggestions, but what function do I use instead of delay?

  • Are you saying there are 50 lines on the display ?

i dont know anything about the display, i just followed the manual. All I know is that it has a 0.96 inch diagonal

  • I think you will find either 7 or 15 lines is the maximum. :thinking:
  • Look at your data sheet for the display.

But displaying the text isn’t the issue, the DHT not reporting is?

Your DHT should plugged into D3.

good luck.. ~q

  • We try to find all issues. :wink:

  • The DHT needs 1 second.

How do I incorporate the one second wait without delay?

ohh i forgot to put a cable


unsigned long previousMillis = 0;
const unsigned long interval = 1000;  // 1 second

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;

    //Code below runs every 1 second
    Serial.println("1 second passed");
  }

  // Other non-blocking code goes here.
}

the code you are using is straight out of the manual..

so either your dht is bad or just connected wrong..

if the diagram you posted is correct, then yes, it’s wrong and should be D3..

nice kit.. ~q

It still reads 0, and also the LED is on now? it was connected to d4, so how? :confounded_face: (I didn’t show it in the wiring diagram because the lesson isn’t even supposed to use it!)

from page 51..

Use Grove cable to connect the OLED to Seeeduino Lotus’s I2C interface (Note: I2C’s default
address is 0x78). Connect the Grove Temperature and Humidity Sensor to Seeeduino Lotus’s
digital signal interface D3.

~q

This is my code after I tried adding the waiting method you suggested

#include <DHT.h>
#include <Arduino.h>
#include <U8x8lib.h>

#define DHTPIN 3
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); 

unsigned long previousMillis = 0;
const unsigned long interval = 1000;

void setup(void) {
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
  u8x8.begin();
  u8x8.setPowerSave(0);
  u8x8.setFlipMode(1);
}

void loop(void) {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;

    float temp, humi;
  temp = dht.readTemperature();
  humi = dht.readHumidity();

  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.setCursor(0, 33);
  u8x8.print("Temp: ");
  u8x8.print(temp);
  u8x8.print("C");
  u8x8.setCursor(0, 50);
  u8x8.print("Humidity: ");
  u8x8.print(humi);
  u8x8.print("%");
  u8x8.refreshDisplay();

  }
}

Screen is connected to I2C and DHT is connected to P3 for me, idk what’s happening

There was something I didn’t say at the start: the temperature value keeps flashing between 0.00 and nan, but I recently discovered that turning the potentiometer all the way up makes the humidity value flash nan instead of the temperature value

u8g2/u8x8 use "pixel" lines (and columns), not character lines (and columns).