#include "DHT.h"
// Define the pins for the sensors
#define DHTPIN 14 // Pin connected to the DHT22
#define DHTTYPE DHT22 // Define the DHT type
const int soundPin = 34; // Analog sound sensor pin (simulated via potentiometer)
const int strainPin = 32; // Analog strain sensor pin (simulated via potentiometer)
// Create a DHT object
DHT dht(DHTPIN, DHTTYPE);
// Variables to store sensor values
float temperatureValue = 0;
int soundValue = 0;
int strainValue = 0;
void setup() {
// Initialize serial communication at 115200 baud
Serial.begin(115200);
// Initialize the DHT sensor
dht.begin();
// Print column headers for the graph in Serial Plotter
Serial.println("Time (ms)\tTemperature\tSound\tStrain");
// Setup analog input pins for potentiometers
pinMode(soundPin, INPUT);
pinMode(strainPin, INPUT);
}
void loop() {
// Read temperature from the DHT22 sensor
temperatureValue = dht.readTemperature();
// Read the values from potentiometers (sound and strain)
soundValue = analogRead(soundPin); // Simulated sound sensor data
strainValue = analogRead(strainPin); // Simulated strain data
// Convert analog reading (0-4095) to a readable value
float soundLevel = map(soundValue, 0, 4095, 0, 100); // Simulated sound level (0-100 dB)
float strainLevel = map(strainValue, 0, 4095, 0, 1000); // Simulated strain level (0-1000 arbitrary units)
// Print the values to the serial monitor
unsigned long currentTime = millis();
Serial.print(currentTime);
Serial.print("\t");
Serial.print(temperatureValue);
Serial.print("\t");
Serial.print(soundLevel);
Serial.print("\t");
Serial.println(strainLevel);
// Delay for a while (update rate)
delay(500); // Update every 500ms
}