CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

data from BME/BMP temperature humidity pressure sensor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

data from BME/BMP temperature humidity pressure sensor
PostPosted: Tue Dec 04, 2018 9:19 am     Reply with quote

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 !
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 9:50 am     Reply with quote

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.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 9:57 am     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 10:05 am     Reply with quote

There is CCS 32 bit code here:

<https://www.ccsinfo.com/forum/viewtopic.php?p=213032>

Yes, you _will_ need voltage level conversion.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Tue Dec 04, 2018 10:21 am     Reply with quote

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-
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Tue Dec 04, 2018 10:23 am     Reply with quote

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-
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 1:22 pm     Reply with quote

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.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 06, 2018 4:05 am     Reply with quote

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);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Dec 06, 2018 4:55 am     Reply with quote

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.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 06, 2018 5:19 am     Reply with quote

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
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 06, 2018 6:40 am     Reply with quote

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
Monitair



Joined: 12 Mar 2012
Posts: 4

View user's profile Send private message

BMP280
PostPosted: Thu Aug 22, 2019 9:30 am     Reply with quote

Have you seen this. Very comprehensive.
https://simple-circuit.com/pic16f877a-bmp280-sensor-ccs-c/
I tried it and it worked straight out of the box.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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