View previous topic :: View next topic |
Author |
Message |
Jody
Joined: 08 Sep 2006 Posts: 182
|
BME280.c driver how to |
Posted: Tue Sep 11, 2018 2:30 am |
|
|
Hello,
I am trying to communicate with this device (BME280) with the driver provided from CCS.ver.5.080.
Have some questions. There is a debug defined in this driver. How can I let that part send it's info to my RS232 stream ?
And (or better) is there someone who has used this driver before ? A short example would be very nice.
Best regards,
Jody |
|
|
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Tue Sep 11, 2018 4:14 am |
|
|
Code: |
long long Tempie;
unsigned long long Drukkie;
unsigned long long Hummie;
mode = bme280_init();
bme280_set_mode(BM280_MODE_NORMAL);
mode = bme280_ok();
fprintf(LORA,"BME280 OK = %Ld\n\r",mode);
mode = bme280_get_humidity(&Tempie, &Drukkie, &Hummie);
fprintf(LORA,"BME280 Temp = %Ld Drukkie = %Ld Hummie = %Ld \n\r",Tempie, Drukkie, Hummie);
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Sep 11, 2018 5:14 am |
|
|
You need to look at 'streams' in the CCS manual.
If you press F11 when your project is open, the manual comes alive, simple 'search' for 'stream'. CCS has examples in there.
It's as simple as adding one more option to the #use RS232(....).
jay |
|
|
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Wed Sep 12, 2018 12:43 am |
|
|
Yes I know... but when I use the driver for the BME280 in the code there they use:
Code: | debug_bme280(debug_putc, "VER_OK "); |
this part I can't get to my LORA or other stream...
So I am doing something wrong...
The driver is functioning by the way!!!
Greetings,
Jody |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Wed Sep 12, 2018 5:41 am |
|
|
hmm, OK I don't have that driver as my compiler is, well, kind ,old....
But based upon what I've seen in the past 2 decades...
It appears the driver has a function called 'debug_bme280' where they pass (send ) "ver_OK" to another function called 'debug_putc' which I assume goes to a serial port,probably a PC though it could just as easily be a serial LCD module. I'm assuming that this serial port is different from the 'main' one as it is for debugging,so visual confirmation that 'stuff is being done'.. It could be a SW xmit only serial pin...
CCS does tend to make drivers 'universal', trying to please everyone and since it's 'all there', you should be able to customize it as required. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 12, 2018 12:21 pm |
|
|
Jody wrote: | Yes I know... but when I use the driver for the BME280 in the code there they use:
Code: | debug_bme280(debug_putc, "VER_OK "); |
this part I can't get to my LORA or other stream...
So I am doing something wrong...
The driver is functioning by the way!!!
Greetings,
Jody |
You need to create your own debug_putc() routine. This is the most
simple way to do it. This will write a character to your stream LORA:
Code: |
void debug_putc(int8 c)
{
fputc(c, LORA);
}
|
|
|
|
jaka
Joined: 04 May 2014 Posts: 36 Location: Finland
|
|
Posted: Wed Sep 12, 2018 12:50 pm |
|
|
I have used the CCS provided bme280 driver for quite some time and it is working well. However recently I noticed that the oversampling and filter settings were not working correctly. I found that the config register address is incorrect. It is 0xF4 in the driver but it should be 0xF5. It is located on row 417 of the bme280.c. I have reported this to CCS so it will probably get fixed in next update.
Another tip if using PIC16F series chips, you will probably get out of ROM error. This can be fixed by adding a #separate directive before int32 _bme280_compensate_H_int32 function. This forces the compiler to realize this function as separate, not inline, and allows the code to fit in the memory segments. |
|
|
|