|
|
View previous topic :: View next topic |
Author |
Message |
pekka1234
Joined: 28 May 2017 Posts: 83
|
|
Posted: Wed Sep 13, 2023 11:54 am |
|
|
OK,
Now it is connected to ground
Pekka |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
BME280 error |
Posted: Thu Sep 14, 2023 3:20 am |
|
|
Thelmah
I try to find BMP280.c library, but find only BMP180.c library.
It has no humidity.
Them I found Simpe-circuit.com a right BMP280_lib.c library, but it has not a humidity.
I have a 5.092 ccs compiler
Pekka |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Sep 14, 2023 5:54 am |
|
|
curious and just trying to help narrow down where the problem is...
OK, you say you can communicate with the device, so can you read and display the temperature properly ? If so then it's only the 'humidity' section that doesn't work.
Can you read the 'humidity' registers then YOU 'do the math' to get the humidity ? Do you get a good number ? If so then the 'math' that converts the raw humidity data into a 'reading' is wrong.
Bosch does have sample code ( I just downloaded it) , so perhaps you can look at how they read,convert,display 'humidity' and modify your CCS driver to do what they do.
BTW when I went to Bosch site, that chip is not recommended for new products, they now have the 390............. |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
|
Posted: Thu Sep 14, 2023 6:22 am |
|
|
Temtronic,
Nice that you have found a solution.
Yes, I can read temperature and air pressure very nicely ,but not a humidity.
I also have a LDR resistor for the light and other NTC resistor for the other temperature.
Can you sen me this Bosch humidity or the whole program?
oh3gdo@gmail.com
Pekka |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Sep 14, 2023 7:13 am |
|
|
Your compiler comes with the BME280.c driver.
This does work.
I suspect you are simply not understanding how you have to set it up.
The point is that is enables the I2C driver itself, using the pins defined
by PIN_BME280_SCL and PIN_BME280_SDA. It sets the baud rate
defined by BME280_I2C_BAUD, and the address defined by
BME280_I2C_ADDRESS You just set these as your hardware requires and
then load the driver (these must be set first). You then have to call
bme280_init which initialises the driver and the chip.
The default values except for the baud rate should match your system.
Read the text in the driver. The comments explain how it has to be used.
Now the 180, and 280 are fairly compatible with each other the 280 supports
using the 180 driver. The difference to the E, is this adds the humidity
part to the sensor.
The Bosch code is _in_ the CCS driver. Again if you read it you will see it
says:
Quote: |
// THIS FUNCTION MOSTLY WRITTEN BY BOSCH, PROVIDED IN THEIR DATASHEETS.
// Returns humidity in %RH as unsigned 32 bit integer in Q22.10 format (22 integer and 10 fractional bits).
// Output value of "47445" represents 47445/1024 = 46.333 %RH
|
Understand this being in Q22.10 format. So 1024 times the actual
humidity 'value' in percentage.
What value do you get from the humidity code when you run it?.
Just as an integer?. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Sep 14, 2023 7:25 am |
|
|
I realise what you are doing wrong.
You are putting the sensor into forced mode.
Read the data sheet....
If you select forced mode, the sensor has to be _re forced_ for every
reading.
This is why you were getting a single value OK. It reads once, and then
goes to sleep.
You have to send another SENSOR_MODE_FORCED before you can do
another reading.
This is a case of not reading what the selection you are using means/
implies. |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
|
Posted: Thu Sep 14, 2023 8:02 am |
|
|
Ttelmah
Please tell me what a library I am using.
When I use BMP289_lib.c everything works as normal.
I can read the temperature and the pressure, but not humidity.
There are not SENSOR_MODE_FORCED
===
When I use BME280.c lib
Nothing works and there are not SENSOR_MODE_FORCED
==
When I am using BMP180.c library, Nothing works and there are no SENSOR_MODE_FORCED
==
Please tell what library you using, so that I can find the solution.
Thank you
Pekka |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Sep 14, 2023 10:46 am |
|
|
Your post on Mon Sep 11, 2023 12:30 pm, shows you using the CCS BME280.c
driver, with the comment that the first reading works, then returns zeros.
This is the correct driver, and is working. But at the start of your main
you select SENSOR_MODE_FORCED, which is why you are only getting the
first reading..... |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
|
Posted: Thu Sep 14, 2023 11:15 am |
|
|
OK
Try once more.
Hopefully I understand it now better.
Regards Pekka |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
BME280 error |
Posted: Fri Sep 15, 2023 2:35 am |
|
|
Ttelmah
I got the results, but they were just same, after 10 s delays.
I can convert then to real value dividing them bu 6418, 5480 and 3000, but this is not right.
Here are results:
Probyte BME280 sender 15-Sep-23
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
Then I try to heat the device by my respiratory and started the device again
I got a little air pressure change
Probyte BME280 sender 15-Sep-23
#TT15+147701.76,5480368.65,147806.10$
But not in the temperature or humidity.
An here is the code
#include <18F2620.h>
#DEVICE ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOMCLR //Master Clear pin not enabled
#FUSES NOWRT
#use delay(internal = 8MHz)
#use rs232(baud=9600, parity=N, UART1, errors, bits=8, BRGH1OK) // RS232 settings
#use I2C(MASTER, I2C1, FAST = 400000)
#define LEDON output_high(PIN_C5); //the red LED
#include "BMe280.c"
signed int32 pTemp;
unsigned int32 pPress;
unsigned int32 pHum;
void main()
{
int8 ok ;
delay_ms(100); // wait 0.1 second
printf("\rProbyte BME280 sender %s\r", __DATE__ );
bme280_init();
bme280_set_mode( BM280_MODE_FORCED);
while(TRUE)
{
printf("#TT15"); // # starts the sentence
bme280_get_humidity(&pTemp, &pPress, &pHum);
if(pTemp < 0)
{
pTemp = abs(pTemp); // abs: absolute value
printf("-%02Lu.%02Lu,", pTemp/ 100,pTemp% 100);
}
else {
printf("+%02Lu.%02Lu,", pTemp/100, pTemp % 100);
}
printf( "%04Lu.%02Lu,", pPress/100, pPress % 100);
printf( "%02Lu.%02Lu$\r", pHum / 1024, ((pHum* 100)/1024) % 100);
delay_ms(10000); // wait 10 seconds
}
}
// end of code.¯
Pekka |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Fri Sep 15, 2023 4:30 am |
|
|
I'm not surprised.
You are ignoring what you have already been told multiple times on how to
use the BME driver:
Code: |
//#use I2C(MASTER, I2C1, FAST = 400000)
//get rid of this- the driver loads it's own I2C stream
#define LEDON output_high(PIN_C5); //the red LED
//Specify the baud rate with the setting for the driver:
#define BME280_I2C_BAUD 400000
//Then load the driver
#include "BMe280.c"
|
|
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
BME280 error |
Posted: Fri Sep 15, 2023 5:11 am |
|
|
Thelmah
Nice that you look my problem
Here is my code :
===
#use delay(internal = 8MHz)
#use rs232(baud=9600, parity=N, UART1, errors, bits=8, BRGH1OK) // RS232 settings
//#use I2C(MASTER, I2C1, FAST = 400000) // This was my original define
//#use I2C(MASTER, I2C1, FAST = 100000) // then I try a slower
#define BME280_I2C_BAUD 400000 // Then I tried your define again
#define LEDON output_high(PIN_C5); //red led LED
#include "BMe280.c"
Here are first result
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
// I try to start again
Probyte BME280 sender 15-Sep-23
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
#TT15+147701.76,5480369.93,147806.10$
Pekka |
|
|
pekka1234
Joined: 28 May 2017 Posts: 83
|
BME280 error |
Posted: Sun Sep 24, 2023 3:09 am |
|
|
Thelmah,
I found that my sensor doesn't work in humidity.
So, I used DHT22 sensor a a humidity sensor.
Now everything works well.
Thank you for help
http://remotesmart.wikidot.com/weather
Pekka |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Sep 24, 2023 7:33 am |
|
|
Sounds as if it is a BMP, not a BME..... |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|