If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I want to add BME280 to my Sprouter, but I have 3k2 free space, and I need at least 4k3 free, and a bit more, for some simple calc.
I have a Main-Menu with 23 items and 2-lines on a 2x16 LCD.
My thoughts are;
Replace 45k22 with 46k22 but thats not easy todo,
Or;
Replace 46 Print commands into,
MainMenu: ' Rotary Switch

Probably wrong but compile without using Print, then compile with Print and subtract one fro the other. I suspect that the Print command itself isn't that big, all the clever formatting is a different part of the compiler.

Hello, its great to see you using the ProtonBasic Forum. Support for the ProtonBasic compiler is provided by the community via this forum. The forum provided by and administered by Crownhill Associates.
Several forum members kindly offer their support by helping to moderate messages posted on the forum, this keeps them very busy ! From time to...

Do we want to delete old versions.
what if someone has old code that needs to be modified and recompiled?
Rewriting old code to generate source that will compile in the latest version could be an expensive process.
Time consuming and costly, Don't you think?

The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the smallest package on the market today, providing accurate distance measurement whatever the target reflectances unlike conventional technologies. It can measure absolute distances up to 2m, setting a new benchmark in ranging performance levels, opening the door...

MTH,
Write a small article to the Wiki please. Doing so this piece of great code will not get lost in the forum.

Re: BME280 Humidity/Pressure/Temperature code

Originally Posted by Les

Floating point is Floating point, regardless if it is a PIC16F887 or a PIC18F25K20 or an AVR etc....

The compiler's underlying asm code is better than 99% of all compilers out there. Both I2C and SPI do not require huge speeds and if the compiler uses too much RAM or flash code space within the device, it will inform the user with an error message.

I noticed in your code, you have huge expressions, with will eat up a lot of space within the flash, as it will with all devices and compilers, regardless. This is because a compiler must take the worst case scenario with each piece of the expression, which is also the highest use of both RAM and flash. This is a back throw of C, which is normally simply copy and pasted from PC applications, regardless of the fact that it is now running on a small microcontroller that does not have gigabytes of RAM. This will cause problems with both speed and size on any microcontroller. That's always been the problem with C and C++. Copy and pasting from a very large platform to a tiny platform causes so many issues, but most "programmers" simply do not understand the complexities anymore. Unfortunately, we live in a copy and paste world, without much actual learning going on anymore :-(

Bottom line, is that the compiler is very much capable of interfacing to the peripheral and calculating the expressions, but a 16F887 device is very tiny and very old now, so even when completed, it will not have a lot of room left for any other code inside it. That's also one of the big problems with the internet these days. The vast majority of information on it is many years old, so the general user is stuck with very old code on old devices. Always remember, on any microcontroller, always think low level, but write high level. This way you will get the most out of any device.

I don't have a BME peripheral, but if I did, I would create some simple code that would show you it working on 99% of all 14 and 18F PIC devices, as it is a simple interface, with straightforward maths behind it, even though it is actually far too much maths for a simple peripheral device that doesn't actually do a lot. :-) Bob Already showed that an interface to it is actually quite straightforward to do. Adapting Bob's code for a 14-bit core 16F887 devie requires approx 6K of flash memory, on a device that only has 8K of it. The RAM usage is approx 180 words from the device's 368 words available, so it will still fit. All that is required is a subroutine to do the Pow.

Hi Les
Firstly my comment "it must be something to do with the compiler" is in no way a criticism of Proton Basic. Ignoring the differences between I2C and SPI in the code supplied by Bob Marshall, it doesn't work with a 16f887.
The part that doesn't work is what I call equations and I'm assuming these are what you refer to as Expressions, I'm not a mathematician or an expert programmer so my use of terminology my not be absolutely correct. As stated by Bosch the BME280 is designed for use in mobile phones and the code they supply in the data sheet appears to C. Expressions/Equations are so complex that unless you are a mathematician, Cut and Paste is the only option. The Humidity version in Bob's code is (I think) for 64 bit floating point, I've changed this for the slightly simpler 32 bit version. The other 2 compilers I tried can't handle this in one bite so it had to be broken down. Beacause of the masses of parenthesis, this was not an easy task. The 2 compilers mentioned don't even have the level of variables offered by Proton and they don't work 100% with this MC. Since there was an example of the code for Proton, I decided to try.
So back to my comment about the compiler, all I meant was, there is something happening between the compiler and the MC that prevents the experssion/equation being completed. The "weak link" seems to be the 16f887.
The BME works perfectly on an Arduino but that of course is C/C++ & M328P so not easy to convert to PIC
You might ask why I'm using 16f887? Because I have some and I'm familiar with them. I've spent a lot of time trying to get this to work and have come to the conclusion it isn't worth any more effort. Either get an 18f or learn how to program the Arduino for my needs. I'm not keen on the Arduino because I prefer to develop my own code (regardless of how good or bad, it is a hobby). So unless I want to learn C/C++ which I don't, it will be cut and paste + a bit of tinkering to make the bits work together.

I've only been using Proton for a few weeks and once I'd got over the differences between IDEs, I was very impressed by the programming tools and options

Re: BME280 Humidity/Pressure/Temperature code

Hi Superdat,
I am no mathematician but this is how I think the complex lines for humidity can be broken down, unfortunately I do not have a device and the ones I have ordered I have now been told are BMP280.
It compiles so hopefully I have got it right, it could probably be broken down even more/better but it should be a start.
Hopefully it is commented enough.

Re: BME280 Humidity/Pressure/Temperature code

Over a year or so, they can be worth a hundred pounds or so, because up to 30 free devices can be ordered every month.

I have signed up and placed my first sample order (I hope). It seems you can order 2 devices per order and place 3 orders in a month (those numbers are for Ireland YMMV). Not sure what happens after that. Even at that its 6 free devices so give it a spin.

BTW the signup response was real quick so I guess it's automated with a email address blacklist.

Re: BME280 Humidity/Pressure/Temperature code

Always make sure you increase the amount of devices in each sample and update the cart George. Otherwise, it defaults to a single device per sample. It ranges from up to 3 devices per sample to 5 devices per sample, and you can have 6 samples.

New samples can be ordered every 28 days.

Over a year that is a lot of absolutely free devices, with some of the devices costing up to £7 or more. That's where I get all of my dsPIC devices because they are actually quite expensive units unfortunately. Microchip seem to be increasing the price of the devices they eventually want to dump :-(

Re: BME280 Humidity/Pressure/Temperature code

I forgot to say. It's called "Manage Cart" to increase the amount of devices per sample. Then don't forget to update cart or they won't be altered. Then go to the checkout to confirm the samples.

You will receive emails very soon afterwards to confirm your sample order, then a couple of days later, you will receive an email saying they are in transit.

I've gotten samples from all the semiconductor manufacturers for many years now, without any business emails. I eventually had to dump a huge box full of them when we moved back up north, unfortunately.

One of the best is maxim. They have some wonderful devices and a lot are available for sampling. Many years ago, all of the devices were available for sampling from maxim and linear and Texas etc... However, they seem to be clamping down somewhat, but some are still available. Also go to the more obscure semiconductor manufacturers, create a sign in, and try for samples. Over time, you'll get hundreds of devices from LEDs, MOSFETS, transistors, cases, to the more complex chips like accelerometers etc...

I got a load of FRAM chips a few years ago, even though I wouldn't even think of using them in a project because they are so expensive, but I wanted to see if I could interface with them etc...

Re: BME280 Humidity/Pressure/Temperature code

Hi Les,
Thanks for reminding me of this, I used to get them and then they said that it had changed for Europe and you had to request them from the local distributor.
I have just tried and it seems to work for me again.