Guys, I manage to succesfully display the temperature and pressure on LCD. I have one final question, the pressure units that I get, are in pascal. How can I put them on bar? I know that 1 pascal = 0.00001 bar. Can I change the code in order have the pressure values in bar?
#include <Wire.h>
#include "Seeed_BMP280.h"
BMP280 bmp280;
#define analogPin A0 //the thermistor attach to
#define beta 3950 //the beta of the thermistor
#define resistance 10 //the value of the pull-up resistor
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
Serial.begin(9600);
if(!bmp280.init())
Serial.println("Device error!");
int status;
status = lcd.begin(LCD_COLS, LCD_ROWS);
if(status) // non zero status means it was unsuccesful
{
status = -status; // convert negative status value to positive number
// begin() failed so blink error code using the onboard LED if possible
hd44780::fatalError(status); // does not return
}
}
void loop() {
long a =1023 - analogRead(analogPin);
float sensor1 = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
float c = bmp280.getPressure();
Serial.print(sensor1);
Serial.print(", ");
Serial.println(c);
delay (500);
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.print(sensor1); // Print a centigrade temperature to the LCD.
lcd.setCursor(0, 1);
lcd.print("Press:");
lcd.print(c);
}
Guys, I am now with another problem. I connected now 3 sensors to the arduino mega, 2 thermistors and 1 barometer and I wanted to display the data in the same format than the previous one (value, value, value). I tried writing on the code Serial.print (", , ") but it didnt worked. Also I tried writing Serial.print (", ") one time between the sensor 1 and 2 and the other between the sensor 2 and 3 but it isnt working. Does anyone know what to do?
#include <Wire.h>
#include "Seeed_BMP280.h"
BMP280 bmp280;
#define analogPin A0 //the thermistor attach to
#define beta 3950 //the beta of the thermistor
#define resistance 10 //the value of the pull-up resistor
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
Serial.begin(9600);
if(!bmp280.init())
Serial.println("Device error!");
int status;
status = lcd.begin(LCD_COLS, LCD_ROWS);
if(status) // non zero status means it was unsuccesful
{
status = -status; // convert negative status value to positive number
// begin() failed so blink error code using the onboard LED if possible
hd44780::fatalError(status); // does not return
}
}
void loop() {
// sensor1 = thermistor number 1 ; sensor2 = thermistor number 2 ; sensor3 = barometer
long a =1023 - analogRead(analogPin);
float sensor1 = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
long d = 1023 - analogRead (A7);
float sensor2 = beta /(log((1025.0 * 10 / d - 10) / 10) + beta / 298.0) - 273.0;
float sensor3 = bmp280.getPressure();
Serial.print(sensor1);
Serial.print(", ");
Serial.println(sensor2);
Serial.print (", ");
Serial.println (sensor3);
delay (500);
lcd.setCursor(0, 0);
lcd.print("Temp1:");
lcd.print(sensor1);// Print a centigrade temperature to the LCD.
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Temp2:");
lcd.print(sensor2);
lcd.print (" C");
neiklot:
Because then you'll have a division by zero:
Yes that I understood gladly eheh :D. What I dont understood was why a could be equal to 10. I even dont know what a stands for ahah (I copied this equation for the temperature from another code on the internet)
wow thanks!!! It worked!! So what is the difference of putting Serial.println instead of Serial.print? the "ln" kind of finishes the line where the data is displayed, with the next values being displayed in the next paragraph?
So if the analog read of the thermistor gives 1013 the code will have some kind of error, right? Do you guys then think that I should change the code? Because that equation was really the best that I found to display the temperature in degrees celsius
brunopeniche:
the "ln" kind of finishes the line where the data is displayed, with the next values being displayed in the next paragraph?
Yes, and more "technically" it inserts a CR carriage return (to go back to the left) and a LF line feed (to click one line ahead) into the stream sent to the monitor.
Have a Google for the ascii table, and you will see character hex 0D, or decimal 13 is the CR and 0A or 10 is the LF.
neiklot:
Yes, and more "technically" it inserts a CR carriage return (to go back to the left) and a LF line feed (to click one line ahead) into the stream sent to the monitor.
Have a Google for the ascii table, and you will see character hex 0D, or decimal 13 is the CR and 0A or 10 is the LF.