View previous topic :: View next topic |
Author |
Message |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
data from BME/BMP temperature humidity pressure sensor |
Posted: Tue Dec 04, 2018 9:19 am |
|
|
Hello everybody
I'm trying to get work temperature humidity pressure sensor
BME/BMP... but no success...
It has SCL and SDA pins for communication
Is there any driver for PIC18F452 processor awailable ?
all the best for everybody ! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19365
|
|
Posted: Tue Dec 04, 2018 9:50 am |
|
|
I presume you mean something like a BMP-180/280?.
It is not hard to drive. What is difficulty is the maths needed to convert the reading into a temperature and pressure. The supplied maths for the 280 requires int64 variables, and these are only supported on the DSPIC's not on PIC18's.
Fortunately a poster here has written an int32 library for an older chip (the BMP-085), which is compatible with the BMP-180. This is as:
<http://www.ccsinfo.com/forum/viewtopic.php?t=23255&view=next>
However if you want to use the 280, then it will be a matter of writing your own int64 maths, or tracking down an int32 library online. There are many other processors that don't offer int64, so I'm sure routines will exist. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9172 Location: Greensville,Ontario
|
|
Posted: Tue Dec 04, 2018 9:57 am |
|
|
also
be careful about the sensor-PIC interface
That PIC is a 5 volt PIC, good down to 4.2 volts, while those sensors are 3 volt devices.
So, if you'll probably need logic level conversion of some kind. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19365
|
|
Posted: Tue Dec 04, 2018 10:05 am |
|
|
There is CCS 32 bit code here:
<https://www.ccsinfo.com/forum/viewtopic.php?p=213032>
Yes, you _will_ need voltage level conversion. |
|
![](templates/subSilver/images/spacer.gif) |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Dec 04, 2018 10:21 am |
|
|
Ttelmah wrote: | I presume you mean something like a BMP-180/280?.
It is not hard to drive. What is difficulty is the maths needed to convert the reading into a temperature and pressure. The supplied maths for the 280 requires int64 variables, and these are only supported on the DSPIC's not on PIC18's.
Fortunately a poster here has written an int32 library for an older chip (the BMP-085), which is compatible with the BMP-180. This is as:
<http://www.ccsinfo.com/forum/viewtopic.php?t=23255&view=next>
However if you want to use the 280, then it will be a matter of writing your own int64 maths, or tracking down an int32 library online. There are many other processors that don't offer int64, so I'm sure routines will exist. |
Thank you very much ... so I forgot to write must be BMP-280
I'm using module GYBMEP (BME/BMP280)
I think it works with +5V power supply though absolute maximum power supply voltage for PMB280 is +3.6V
all the best
-arto- |
|
![](templates/subSilver/images/spacer.gif) |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Dec 04, 2018 10:23 am |
|
|
temtronic wrote: | also
be careful about the sensor-PIC interface
That PIC is a 5 volt PIC, good down to 4.2 volts, while those sensors are 3 volt devices.
So, if you'll probably need logic level conversion of some kind. |
Thank you for your good notice !
I'm using module GYBMEP (BME/BMP280)
I think it works with +5V power supply though absolute maximum power supply voltage for PMB280 is +3.6V
hope so ...
all the best
-arto- |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19365
|
|
Posted: Tue Dec 04, 2018 1:22 pm |
|
|
You will need the pull-up resistors for the I2C bus, to be to 3.3v. Hopefully your board supports this?. You'll also need to set the I2C bus on the PIC to use SMBUS levels. |
|
![](templates/subSilver/images/spacer.gif) |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Thu Dec 06, 2018 4:05 am |
|
|
Ttelmah wrote: | You will need the pull-up resistors for the I2C bus, to be to 3.3v. Hopefully your board supports this?. You'll also need to set the I2C bus on the PIC to use SMBUS levels. |
Hello Ttelmah, and good independence day here from Finland ...
I gave up to use PIC processor for my BME/BMP GYBMEP module because I didn't get it work
because I'm loser and so dumb or lazy or both ...
instead I use Arduino uno compatible NERO board and made thinks work thanks to Arduino ready made header file Seeed_BME280.h ... as you can see it's very easy to get work...
thank you and all the best
-arto-
arduino code:
Code: |
#include "Seeed_BME280.h"
#include <Wire.h>
BME280 bme280;
void setup()
{
Serial.begin(9600);
if(!bme280.init()){
Serial.println("Device error!");
}
}
void loop()
{
float pressure;
//get and print temperatures
Serial.print("Temp: ");
Serial.print(bme280.getTemperature(),1);
Serial.println("C");//The unit for Celsius because original arduino don't support special symbols
//get and print atmospheric pressure data
Serial.print("Pressure: ");
pressure = bme280.getPressure();
//Serial.print(pressure /100);
Serial.print(pressure /100,0); //no decimals
Serial.println("hPa");
//get and print altitude data
Serial.print("Altitude: ");
Serial.print(bme280.calcAltitude(pressure),0);
Serial.println("m");
//get and print humidity data
Serial.print("Humidity: ");
Serial.print(bme280.getHumidity());
Serial.println("%");
delay(3000);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19365
|
|
Posted: Thu Dec 06, 2018 4:55 am |
|
|
The driver at the end of the thread I've already referred you to, is complete.
It solves the level translation by using the I2C in software mode.
The big problem is your module. If you have connected this to 5v, you have probably already killed it. Quote from this modules 'sales' sheet:
Quote: |
The module operates from 3.3V and is not 5V tolerant, so it is important to wire it correctly to 5V Arduinos using level shifters and 3.3V for power.
|
Note 'not 5v tolerant'....
It requires a 3.3v supply. |
|
![](templates/subSilver/images/spacer.gif) |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Thu Dec 06, 2018 5:19 am |
|
|
Ttelmah wrote: | The driver at the end of the thread I've already referred you to, is complete.
It solves the level translation by using the I2C in software mode.
The big problem is your module. If you have connected this to 5v, you have probably already killed it. Quote from this modules 'sales' sheet:
Quote: |
The module operates from 3.3V and is not 5V tolerant, so it is important to wire it correctly to 5V Arduinos using level shifters and 3.3V for power.
|
Note 'not 5v tolerant'....
It requires a 3.3v supply. |
Yes I understand what you mean ...
but in this moudule there is 3.3V regulator and level shifters ...
so I think it's ok for 5V power supply ...
look at link below if you wish ...
thank you
https://www.aliexpress.com/item/BME280-Digital-Sensor-Temperature-Humidity-Barometric-Pressure-Sensor-New/32665342978.html |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9172 Location: Greensville,Ontario
|
|
Posted: Thu Dec 06, 2018 6:40 am |
|
|
Yes, the 'module' you post does have the regulator and shifters needed to allow it to interface with 5 volt PICs.
So, that means it's a 'code' problem. Step #1 when adding any/every I2C device to a PIC is to use PCM P's 'I2C Scanner program loacted in the code library. This WILL confirm that the device is connected properly and a PIC can access it.Once this happens then cut the real program code.
One possibilty for failure is the address. PIC's typically use 8 bit addresses with embedded R/W bit while Ardunio use 7 bit + R/W.
Jay |
|
![](templates/subSilver/images/spacer.gif) |
Monitair
Joined: 12 Mar 2012 Posts: 4
|
|
![](templates/subSilver/images/spacer.gif) |
|