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");