hello all this my first ever post, anyway i'm using a bme280 sensor in conjunction with an arduino uno and processing 3, i'm pretty new to arduino and i got my code of the internet. is there a way to calculate air density with an arduino (using temperature, pressure and humidity) i need to do it by this Friday :o so please help,
regards unigregs.
also the air density then must be outputted on processing
Is Google not working today?
Do a Google search for "calculate air density using temperature, pressure and humidity".
The first result tells you how.
Do another Google search for "arduino processing IDE tutorial". There are thousands of results including videos.
I agree with mikb55 (although not in such a sarcastic way), that this question:
unigregs:
is there a way to calculate air density with an arduino (using temperature, pressure and humidity)
.... should really be:
is there a way to calculate air density
with an arduino(using temperature, pressure and humidity)
The physics behind that which leads to the arithmetic, has nothing to do with Arduino.
So if you have the temperature, pressure and humidity, how would you do the calculation with a calculator? Figure that out first.
Then it's surely a trivial matter, assuming you already have the Arduino divining the temperature, pressure and humidity, to code one line of arithmetic that combines them into the density?
Then squirt that off to processing; it's a while since I used processing, but iirc from the Arduino it's just a serial print, and processing reads COMx?
sorry i should have made it more clear, I know there is plenty about calculating air density from temperature, pressure and humidity but i'm unsure as to how to write that in arduino code, like i said i'm a noob. when i looked it up i found heaps about rho_duino but nothing about how to calculate rho then print it over serial.
[line of arithmetic that combines them into the density? Then squirt that off to processing]
that was pretty much what i mean
i'm unsure as to how to write that in arduino code, like i said i'm a noob
You really need to learn a bit about the programming language C/C++. There are lots of excellent on-line tutorials.
That said, if you take the time to post the code (using code tags) that gives you believable values for temperature, pressure and humidity, and also to post the formula you intend to use for density, someone would probably be happy to take the few seconds needed to write the single block of code.
See the How to use this forum post for hints on getting the most from your time here.
attached is my arduino code as well as all the thing needed to run it. and heres a link to a website that explains rho How to Calculate Air Density | Sciencing.
is that helpful?
ArduinoApp.ino (980 Bytes)
BME280.cpp (7.78 KB)
BME280.h (2.95 KB)
DataTypes.h (372 Bytes)
I2C.cpp (1.46 KB)
I2C.h (249 Bytes)
Is that the very best you can do?
jremington:
Is that the very best you can do?
if you need more then let me know. i'm more than willing to help its due at 5pm tonight!
here's an updated version of code showing where the calculation needs to go.
you still need the attachments from the message above
ArduinoApp.ino (1.03 KB)
In the future, please consider starting to think about your homework assignments a bit earlier than the due date.
oh well
has anyone got an idea on how i could do it though?
Sure, learn how to use Arduino and the C/C++ programming language. Arduino comes with a bunch of simple tutorials that teach how the special features of a microcontroller are sensibly used.
After some reading and hands on effort, your project will seem pretty easy.
thanks
Forget the density thing and processing for a moment: have you got a sketch running where the sensor is correctly gathering its readings and displaying them for you on the serial monitor?
I don't have a bme, mines a bmp, but when I got it I just fired it up with the adafruit example and off it went. Have you done the same with a bme example?
Then let's just say, since I have a bmp not a bme and therefore no humidity reading, the calculation is to add twice the temperature to the pressure. (Nonsense calculation, of course, but hey, a calculation is a calculation.)
I added this to the example code:
//this part's made up, just to do something with the numbers:
float myJunkValue = event.pressure + 2 * temperature;
Serial.print("Junk (pressure + 2*temp): ");
Serial.print(myJunkValue);
Serial.println(" junkUnits");
And so my output in the serial monito:
Pressure: 830.41 hPa
Temperature: 23.90 C
Altitude: 1647.37 m
Junk (pressure + 2*temp): 878.21 junkUnits
Pressure: 830.43 hPa
Temperature: 23.80 C
Altitude: 1647.17 m
Junk (pressure + 2*temp): 878.03 junkUnits
You would do something similar, with the real calculation....
And then finally, this tutorial at sparkfun shows you how to write a simple sketch in processing to read the COM port and print it out. So the "hello world" they serial print from the Arduino would obviously be the data you want to see, such as the humidity.