Weather Station - No Pressure reading on LCD ?

ukhelibob.

The answer to question #2 is, if i knew the variable and where to put it, i might not be on this forum asking what a lot of you are probably calling a stupid question, i am obviously taking a long time to learn stuff.

Is a Variable a declaration? where in the sketch should it be placed ?

Regards

Ray

I have used a Test sketch to check out the BMP180 sensor, the sensor is ok, it shows very accurate readings on the Serial Monitor screen.

Can you post this code?

A variable is a thing that you declare then it can hold values. If you're still using the code from your original post then you have declared:

float pres; //Stores pressure value.

Your comment says that it stores the pressure value. But, as I said several days ago, you never put any value into it. You need to read the pressure from the BMP180 into that variable and then you need to display it.

I'm sure the test sketch that you have for the BMP180 reads a pressure value and probably puts it into a variable. It should be quite easy to get that part of the code into your program. Or if you just post the test sketch maybe someone else will do the work for you.

Steve

@OP

If you have problem to trace the directory for the test sketch of your sensor, you please follow this path to open an example from the IDE. Post this sketch as your 'test sketch of BM180', which we will moderate for you.

IDE --->Examples ---> Sparkfun BM180 ---> SFE_BM180_example ---> right click and then 'copy and paste inline with code tags(</>).

Compare what you do with humidity

float hum;  //Stores humidity value

later

  hum = dht.readHumidity();

later still

  lcd.setCursor(0, 1); // First column, Second row
  lcd.print("Humidity : ");
  lcd.print(hum);
  lcd.print(" %");

Now compare that with what you do with pressure

float pres; //Stores pressure value.

later

  lcd.setCursor(0, 2); // First column, Second row
  lcd.print("Press. :");
  lcd.setCursor(16, 2);  //Seventeenth column, Second row
  lcd.print("mbar");

So where did you read the pressure from the sensor and where did you print the pres variable ?

Hi all.

I am still plugging along.

//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp = dht.readTemperature();

if this above action calls for Humidity and Temperature, what do i write, if anything, this seems to me to be the missing information, if i write pres = sfebmp180readPressure(); i get the error (smfbmp180 was not declared in this scope"

Post your code as it is now, and post the exact error message you are seeing.

if i write pres = sfebmp180readPressure();

Based on

 hum = dht.readHumidity();
  temp = dht.readTemperature();

Why would you write what you did ?

UKHeliBob:
Based on

 hum = dht.readHumidity();

temp = dht.readTemperature();




Why would you write what you did ?

Because the DHT11 doesn't read pressure?

AWOL:
Because the DHT11 doesn't read pressure?

Ah !

That certainly would be a factor, but the suggested function

sfebmp180readPressure();

does not even have the same format as

dht.readTemperature();

nor is there a sfebmp180 object in the code, but I guess that is where we came in.

Hi all.

Here is my latest attempt at a sketch, sorry i should have mentioned, i am using a BMP180 to measure Air Pressure, the DHT22 to measure Temperature & Humidity. The sketch also includes other instructions such as the UV sensor, i am sure they make no difference to the way the sketch runs.

I do not get an error when running this sketch, but at line - lcd.setCursor(16,2); instead of printing a pressure, the LCD reads - Press. : 0.00 mbar

//Libraries

#include <SFE_BMP180.h>
#include <DHT.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);  // Set the LCD address to 0x27 for a 20 chars and a 4 line display

SFE_BMP180 pressure;
#define ALTITUDE 122.5 // Altitude in meters

//Constants

#define DHTPIN 4  // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino

//Variables

int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value
float pres; //Stores pressure value


void setup(){
  
  dht.begin();
  
 // Reading Welcome Screen
  lcd.init();   // initialize the LCD
  lcd.backlight();
  lcd.begin(20, 4);
  lcd.setCursor(3,0);
  lcd.print("** WELCOME **");
  lcd.setCursor(0,1);
  lcd.print("GRESLEY WEATHER NOW");
  lcd.setCursor(2,2);
  lcd.print("Reading Sensors");
  lcd.setCursor(2,3);
  lcd.print("Collecting Data");
  dht.begin();

  delay(5000);
}

void loop() {
  
  //Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp = dht.readTemperature();
                          
  // Reading Temperature.
  lcd.clear();
  lcd.setCursor(3,0);
  lcd.print("Temp. :");
  lcd.setCursor(11,0);
  lcd.print(temp);
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("C");

  //Reading Humidity.
  lcd.setCursor(0,1);
  lcd.print("Humidity : ");
  lcd.print(hum);
  lcd.print(" %");

  
  // Reading Air Pressure.
  lcd.setCursor(0,2);
  lcd.print("Press. : ");
  lcd.setCursor(11,2);
  lcd.print(pres);
  lcd.setCursor(16,2);
  lcd.print("mbar");

  // Reading UV Index Level.
  lcd.setCursor(0,3);
  lcd.print("UV Level : ");

  delay(10000); //Delay 2 sec.

}

SFE_BMP180 pressure; You never seem to do anything with this object.

Presumably, the test sketch did.

You should look at that.

You're still missing this in setup():

  if (pressure.begin())
    Serial.println("BMP180 init success");
  else
  {
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail\n\n");
    while(1); // Pause forever.
  }

You HAVE to call the classes begin() function before it will wake up and go to work.

Hi AWOL.

I have removed "SFE_BMP180 pressure;" from the sketch, you are right it does nothing.

Hi outsider.

"You HAVE to call the classes begin() function before it will wake up and go to work."

What do i call the begin function? bmp.begin(); sfe_bmp180.begin(); or something else, does the function go underneath the dht.begin(): function ?

gresleyman:
Hi AWOL.

I have removed "SFE_BMP180 pressure;" from the sketch, you are right it does nothing.

No, that's not what I wrote - I wrote that you don't do anything with it.

gresleyman:
I have removed "SFE_BMP180 pressure;" from the sketch, you are right it does nothing.

You misunderstood. You still need this line to create the object called "pressure". AWOL was just saying there's still more to do.

"You HAVE to call the classes begin() function before it will wake up and go to work."

This is what AWOL was getting at. Check how the sample code does it but I think you'll need a statement something like pressure.begin() before you start to use the sensor.

Keep going. You'll get there! :slight_smile:

AWOL:
SFE_BMP180 pressure; You never seem to do anything with this object.

Presumably, the test sketch did.

You should look at that.

gresleyman:
Hi AWOL.

I have removed "SFE_BMP180 pressure;" from the sketch, you are right it does nothing.

@OP

We think that you are required to read a short lecture and work accordingly in order to understand what 'code lines' you need to place at the top of setup(){} function, within setup(){} function, within loop(){} function, and at the beneath of loop(){} function for reading pressure signal from your BMP180 Sensor and show it on the Serial Monitor/LCD Monitor.

If you interested in the above proposal, let there be your consent in the reply post.

Hi OP

I am open to any suggestions.

Ray

Hi All.

I have uploaded this sketch from the Internet for a Sparkfun BMP180 sensor, my sensor works great with it, and is very accurate when compared with my local air port readings. My problem is it is written for the Serial Monitor, so my question is "How do i change the sketch, and what do i change to get it to display on my i2c LCD 20,4 ?

With Hindsight i should have asked this question first.

gresleyman:
Hi OP

I am open to any suggestions.

Ray

You are the OP