SD card sensor data logging sensor readings(bmp180,dht11,mq-125

I DONE A CODE only for sensor readings(totally 3 sensors)

here is the code:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

Adafruit_BMP085 bmp;

const int mq135Pin = A0;

void setup() {
Serial.begin(9600);
dht.begin();
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP180 sensor, check wiring!");
while (1);
}

Serial.println("Sensor Reading - BMP180, DHT11, and MQ-135:");
}

void loop() {
// Read DHT11 sensor data
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();

// Read BMP180 sensor data
float pressure = bmp.readPressure() / 100.0;

// Read MQ-135 sensor data
int mq135Value = analogRead(mq135Pin);

// Calculate gas resistance (you may need to calibrate this according to your MQ-135 datasheet)
float rs_gas = 10000.0 * ((1023.0 / (float)mq135Value) - 1.0);

// Print data to serial monitor
Serial.print("Temperature (C): "); Serial.print(temperature); Serial.print(" | ");
Serial.print("Humidity (%): "); Serial.print(humidity); Serial.print(" | ");
Serial.print("Pressure (hPa): "); Serial.print(pressure); Serial.print(" | ");
Serial.print("MQ-135 Value: "); Serial.print(mq135Value); Serial.print(" | ");
Serial.print("Gas Resistance (Ω): "); Serial.println(rs_gas);

// Wait for a few seconds before reading again
delay(5000);
}

i need data logging for it

Sorry I cannot answer your question I cannot read the code as posted, please follow the forum guidelines and post it appropriately. Also missing are links to technical information on the sensors and an annotated schematic, be sure to show all power sources.

sorry i was in a hurry

Sounds an interesting project.

What have you tried so far for the data logging part.

What Arduino board are you using?
What do you want to log the data to?
How frequently do you want to log the data?
Is your project going to be battery powered?

Being more specific will get you better answers / guidance.

Instead of typing above, you could have fixed the code in the opening post :wink:
Edit the post, select all code and click the <CODE/> button.
Next save your post.

1 Like

Being in a hurry makes you prone to mistooks. After a day it is not working and the code is in the wrong format. Read the forum guidelines.

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