Coder Social home page Coder Social logo

Comments (13)

blueknight768 avatar blueknight768 commented on August 15, 2024

I forgot to mention but im not familiar with the U8G2 library and I have the 1306 screens. What reference should I use up here besides what you listed?

U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_Right(U8G2_R0, /* reset=*/U8X8_PIN_NONE);

I assume mine would look something like

U8G2_SH1306_128X64_NONAME_F_HW_I2C OLED_Right(U8G2_R0, /* reset=*/U8X8_PIN_NONE); ?

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

Okay I got it working but had to dig for the dht.h library (Lower case) as its not common or at least not anymore. After that I get output on the screens but the numbers are outputting wrong. So temp is interchanging (Flashing every second) between -1766.20 and 72.50. Humidity is doing the same between -999.00 and 38... Looks like maybe a formula issue?

from dht_22-temperature-humidty-oled-display.

Digital1O1 avatar Digital1O1 commented on August 15, 2024

Hey @blueknight768, first off, I appreciate you checking out this repo and I'm stoked to see that it could be used to help you and your dad with y'alls smoker!

I'm not sure where you're at geographic wise, but I'm currently in Texas and I'm just seeing all of this now and I hope you see this early enough to get your smoker project going

I saw that you had questions in multiple posts, so I"ll answer them sequentially.

The DHT library issue

So about you changing the dht.h to DHT.h

In the repo, I failed to mention that I was using Adafruit's DHT sensor library which I have a strong assumption is the reason why you got all of those compiler errors

image

I just read your last comment about how you dug up the dht.h library so I'm not sure how much help my last point would be for you.

Using a 1306 OLED display VS the 1106 OLED display

To be honest, I've only used 1306 displays when I first started out messing with microcontrollers like 5/6 years ago and have been using larger displays like 1106, or TFT screens since then.

But I do remember following tutorials like this.

https://www.instructables.com/OLED-I2C-DISPLAY-WITH-ARDUINO-Tutorial/

The Temp/Humidity values fluctuating

As far as the temp/humidity values changing so drastically, I'm honestly not 100% sure what could be the problem.

With the Uno I used for this project I had it running for several hours in my room just for fun and I never really experienced/seen the values jump that drastically.

Stupid question, but I have to ask for clarification

  • Are you using a DHT 22?
  • Are you supplying the sensor with 5, or 3.3 volts?
  • Is your nano supplying a constant 3.3/5 volts?
  • Do you experience the same thing with spare DHT22 sensors, if you have them lying around?

Things I would suggest right off the bat:

  • Replace the old get_Current_Readings() function with the new get_Current_Readings(). Upload the code, then open the serial monitor in the upper right-hand corner of the Arduino IDE. If the values are consistent, this eliminates the probability that there's something wrong with the calculations or whatever DHT sensor you're using

image

// Old
void get_Current_Readings()
{
int chk = DHT.read22(DHT22_PIN);
current_temp = DHT.temperature;
current_humditiy = DHT.humidity;
}

// New
void get_Current_Readings()
{
int chk = DHT.read22(DHT22_PIN);
current_temp = DHT.temperature;
current_humditiy = DHT.humidity;
Serial.print("Temp : "); (Serial.print(current_temp); Serial.print(" ");
Serial.print("Humidity : "); (Serial.println(current_humditiy);
}

  • I do have a strong assumption that the values are jumping is due to the U8G2 library instead of the Adafruit libraries that support the 1306. I say that due to the fact that I ran the same code/set-up for several hours in my room and never experienced the values jump that wide before, but regardless, give the instructable tutorial I linked earlier a shot and let me know how that goes and I'll do my best to help you out considering the fact that I don't have any more 1306 OLED displays.

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

Hey thank you for the reply! I appreciate it. Well I settled for a single screen version as I needed it done today but things kind of went down hill lol. Everything was working perfect up until it got mounted to the smoker case. I didn't pull any wires out as they were hot glued in place but WHATEVER happened killed the entire board. I had a TP4056 that was supplying power to the Arduino and screen, as well as DHT22 and everything went crazy after it was flipped on (Granted I tested it at home at least 10 times). Screen wouldn't come on all the time, when it would the temp readings were not being detected ect... Long story short I looked like a idiot with my new contraption. Found out later after taking it home my charger board was outputting something like 9 Volts -_-. Now im building another one with a spare ardunino and 0.96" screen. I did order some of the 1.3" ones as I like them more.

Thank you for the new code that helps a lot! I was thinking if possible to make a wemos D1 mini weatehr station like on this page but could I somehow also output the data to a screen AND over wifi?

https://hackaday.io/project/165061-solar-powered-wifi-weather-station-v20

from dht_22-temperature-humidty-oled-display.

Digital1O1 avatar Digital1O1 commented on August 15, 2024

Damn, I'm sorry to hear that....

But I just wanted to share with you that any of the Arduino boards (Since they're all based on the ATMega328) can handle/ be supplied 7-12 volts, so the output voltage to the TP4056 supplying the 9 volts is plenty since the Arduino boards have a voltage regulator on them that can "Knock" down the incoming voltage to the "right" amount the ATMEga328 needs.

Here's a link to the tech/spec sheet if you're curious: https://store.arduino.cc/usa/arduino-nano

image

As far as using the Wemos D1 board, you can totally use this code as a strong foundation!

However, the pinouts are different since you're going from using the ATMega chip(s) on the Arduino board, to whatever chip the ESPRESSIF "family" uses since they're the most prolifically used WiFi chip used in WiFi development boards.

Outputting the data from the DHT to both the OLED screen and via WiFi using either Blynk or Thinkspeak is very doable and very well documented since there are 32098430983498 tutorials out there.

I hope the best of luck to you!

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

Okay awesome to know! Thanks again for the info. I was curious why does the VIN pin also supply power? If the board is connected via USB the VIN gives power out I mentally would have assumed its diode isolated. I addition as far as the small screens go do you usually give them 3.3v or 5v?

Regards

from dht_22-temperature-humidty-oled-display.

Digital1O1 avatar Digital1O1 commented on August 15, 2024

I want to say that the VIN pin "Takes" in power from an outside source like a 4 pack of AA batteries.

When the board is connected via USB, the only pins that output power from the Arduino boards are the 3.3/5 volt pins.

I'm also not sure if there's a diode that prevents current from flowing back into the board, but it something that you can look up considering the fact that the Arduino boards are open-sourced.

The 1106 OLED displays that I've used I supply with 5 volts.

The majority of OLED displays that I've seen usually run on 5 volts, but it's best to check the datasheet before plugging it into anything.

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

Okay So I just got the ssd1106 screens and here is still the same issue. I'm trying to upload a video to show you.

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

https://youtu.be/f8JVFszxrp4

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

In addition here is my code.

#include <Arduino.h>
#include "U8g2lib.h"
#include <Wire.h> //Library for I2C interface
#include <dht.h>

U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_Right(U8G2_R0, /* reset=/U8X8_PIN_NONE);
U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_Left(U8G2_R0, /
reset=*/U8X8_PIN_NONE);

dht DHT;
#define DHT22_PIN A2

float current_humditiy, new_humidity, current_temp, new_temp = 0;
char temp_buffer[20], humidity_buffer[20];

void get_Current_Readings()
{
int chk = DHT.read22(DHT22_PIN);
current_temp = DHT.temperature;
current_humditiy = DHT.humidity;
}

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

OLED_Right.setI2CAddress(0x3C * 2);
OLED_Left.setI2CAddress(0x3D * 2);

OLED_Right.begin();
OLED_Left.begin();

OLED_Right.setFont(u8g_font_7x13);
OLED_Left.setFont(u8g_font_7x13);

}

void loop()
{
get_Current_Readings();
if ((new_temp != current_temp) && (new_humidity != current_humditiy))
{
new_temp = current_temp;
new_humidity = current_humditiy;
OLED_Right.drawStr(15, 10, "===== Temp =====");
dtostrf((new_temp * 1.8) + 32, 5, 2, temp_buffer);
OLED_Right.drawStr(40, 40, temp_buffer);
OLED_Right.sendBuffer(); // transfer internal memory to the display
OLED_Right.clearBuffer(); // clear the internal memory

    OLED_Left.drawStr(10, 10, "=== Humidity ===");
    dtostrf(new_humidity, 5, 2, humidity_buffer); 
    OLED_Left.drawStr(40, 40, humidity_buffer);
    OLED_Left.sendBuffer();  // transfer internal memory to the display
    OLED_Left.clearBuffer(); // clear the internal memory
}
else
{
    delay(100);
}

}

Well your code I should say.

If I try to use your new edit you listed here

// New
void get_Current_Readings()
{
int chk = DHT.read22(DHT22_PIN);
current_temp = DHT.temperature;
current_humditiy = DHT.humidity;
Serial.print("Temp : "); (Serial.print(current_temp); Serial.print(" ");
Serial.print("Humidity : "); (Serial.println(current_humditiy);
}

I get this error:

image

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

I think there is still a library discrepancy im trying to figure out. I deleted all my DHT libraries and redownloaded the single one you listed earlier in the message from adfruit. So the original code needs to be changed to not list "dht.h" but "DHT.h" which is the new file name. After I do that I get a error here with the old code and latest library.

image

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

So close I just really want to get this project out of the way its driving me crazy as its supposed to be simple lol. Thanks again for any help you have!

from dht_22-temperature-humidty-oled-display.

blueknight768 avatar blueknight768 commented on August 15, 2024

Okay so for anyone else having problems with this code and what not it all came down to library issues. I will list the specific libraries used and my code. To recap this seems to be skipped over many times. Basically there are a number of various different versions of the "dht.h" library and yes thats "dht.h" NOT the new "DHT.h" it seems to me many people never re-updated their libraries so they must still have the old one installed in their libraries folder and not know it. essentially listed in this thread

https://arduino.stackexchange.com/questions/44898/dht-h-library-not-being-imported

You have this download link https://github.com/RobTillaart/Arduino/archive/master.zip

Download it and extract it. Inside you want to grab the folder here

C:\Users\yourusername\Documents\Arduino\Arduino-master\libraries\DHTlib
NOT
C:\Users\Blue_\Documents\Arduino\Arduino-master\libraries\DHTstable

Then copy the entire DHTlib library and paste it into your libraries folder. This fixed my numbers from jumping around all over the place and what not. Here is my code with my preferred text sizing and format.

#include <Arduino.h>
#include "U8g2lib.h"
#include <Wire.h> //Library for I2C interface
#include <dht.h>

U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_Right(U8G2_R0, /* reset=/U8X8_PIN_NONE);
U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_Left(U8G2_R0, /
reset=*/U8X8_PIN_NONE);

dht DHT;
#define DHT22_PIN A2

float current_humditiy, new_humidity, current_temp, new_temp = 0;
char temp_buffer[20], humidity_buffer[20];

void get_Current_Readings()
{
int chk = DHT.read22(DHT22_PIN);
current_temp = DHT.temperature;
current_humditiy = DHT.humidity;
}

void setup()
{
Serial.begin(115200);

OLED_Right.setI2CAddress(0x3C * 2);
OLED_Left.setI2CAddress(0x3D * 2);

OLED_Right.begin();
OLED_Left.begin();

}

void loop()
{
get_Current_Readings();
if ((new_temp != current_temp) && (new_humidity != current_humditiy))
{
new_temp = current_temp;
new_humidity = current_humditiy;
OLED_Right.setFont(u8g_font_courB14r);
OLED_Right.drawStr(47, 12, "Temp");
OLED_Right.setFont(u8g_font_courB24r);
dtostrf((new_temp * 1.8) + 32, 5, 2, temp_buffer);
OLED_Right.drawStr(0, 50, temp_buffer);
OLED_Right.drawStr(105, 50, "F");
OLED_Right.sendBuffer(); // transfer internal memory to the display
OLED_Right.clearBuffer(); // clear the internal memory

    OLED_Left.setFont(u8g_font_courB14r);
    OLED_Left.drawStr(28, 12, "Humidity");
    OLED_Left.setFont(u8g_font_courB24r);
    dtostrf(new_humidity, 5, 2, humidity_buffer); 
    OLED_Left.drawStr(0, 50, humidity_buffer);
    OLED_Right.drawStr(105, 50, "%");
    OLED_Left.sendBuffer();  // transfer internal memory to the display
    OLED_Left.clearBuffer(); // clear the internal memory
}
else
{
    delay(100);
}

}

from dht_22-temperature-humidty-oled-display.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.