Storing Data from BMP280

Hello and a good new year everbody,

I need some help with this apparently simple problem.
I own a BMP280 coming from a No-Name-Chinese company. It works pretty well, so I wanted to store some measured values for 20 minutes in the RAM and then connect the Arduino to a PC and read the values. Because the RAM of my Arduino Nano Every is not gigantic, I decided to truncate the numbers after the decimal point of the output of the bmp.readPressure() function. But- SURPRISE! The output was -as an example- not 123 but 123.00. I tried to save it then as an integer but it didnt worked.How to get rid of these numbers???

Hello burningsomepcbs

Scale the measured value as an integer, e.g. with 10.

1 Like

You can't do that. When you connect the Nano to the PC, it will reset the Nano and the data will be lost.

Look at using EEPROM to store the data. Store the data in binary format, not as strings.

But only if the power cut. But I provide nonstop power supply.

Are you sure about that?

Yep.Tried that before but got only false values.

Thanks a million. I have been working on this problem for 3 weeks (my own problem solving creativity is non-existent), now I have solved it. I will turn ahead to face the next problem😉.

Hello and a happy new year to all,

I am facing an endless series of problems right now. The idea is seemingly simple. You have a BMP280 and an Arduino Nano Every. The Arduino stores the print in its RAM and at the end I come and read the data from the serial port. But the point is the storage. The output of the bmp.readPressure() function returns only a float. So I decided to truncate the numbers after the decimal point and store only the Pascal number. But yeah, that's the problem. The Arduino just won't let go of those numbers. Even if you use trunc(), the output looks something like this: trunc(5.25)=5.00. And if you do it that way with (int), you get a ridiculous number, something like this: (int) 1005.56=3467. So yes, that is the point. How can I do a workaround?

You should store it in an int...

int a = round(reading);


Or:

int a = trunc(reading+0.5);

Or:

int a = int(reading+0.5);

100000 does not fit in int...

void loop() {
    pres=bmp.readPressure();
    Serial.println(pres);
    int preszwei=int(pres+0.5);  
    Serial.println(preszwei);
    delay(2000);
}

With this code following output is given:

BMP280 test// Test of serial port
101794.24//Actual pressure value for test reasons
-29278// False pressure value as an integer

:disappointed_relieved:

You know that if you maked it to an integer that would be just a value between 900 and 1100?

Wait...

Are you confusing Pa with hPa?

Lol your right

Yeah my fault.

Your two topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.