#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Define the pins and types for the sensors
#define DHTPIN 4 // GPIO pin for DHT22
#define DHTTYPE DHT22 // DHT22 sensor type
#define DS18B20_PIN 5 // GPIO pin for DS18B20
#define NTC_PIN 34 // Analog pin for NTC sensor
// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);
// Setup for DS18B20 sensor
OneWire oneWire(DS18B20_PIN);
DallasTemperature ds18b20(&oneWire);
// Initialize the LCD (address 0x27 for I2C)
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
// Start communication with sensors and LCD
dht.begin();
ds18b20.begin();
lcd.init();
lcd.backlight();
// Display the initial message
lcd.setCursor(0, 0);
lcd.print("Cubesat Monitoring");
lcd.setCursor(0, 1);
lcd.print("Status");
lcd.setCursor(0, 2);
lcd.print("By Vince Julian Day");
delay(2000); // Display message for 2 seconds
// Display Area Scanning with growing dots
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Area Scanning");
for (int i = 0; i < 4; i++) {
lcd.setCursor(15, 0);
lcd.print(".");
delay(500); // Pause for 500 milliseconds
}
// Clear dots for the next round
lcd.setCursor(15, 0);
lcd.print(" "); // Clear the dots
}
void loop() {
// Read temperature and humidity from DHT22
float humidity = dht.readHumidity();
float dhtTemperature = dht.readTemperature();
// Read temperature from DS18B20
ds18b20.requestTemperatures();
float ds18b20Temperature = ds18b20.getTempCByIndex(0);
// Read temperature from NTC analog sensor (Assuming a simple conversion)
int ntcValue = analogRead(NTC_PIN);
float ntcTemperature = ntcValue * (3.3 / 4095.0) * 100; // Adjust based on your sensor characteristics
// Clear the LCD
lcd.clear();
// Display temperature from DHT22
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(dhtTemperature);
lcd.print("C");
// Display humidity from DHT22
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
// Display temperature from NTC sensor
lcd.setCursor(0, 2);
lcd.print("NTC: ");
lcd.print(ntcTemperature);
lcd.print("C");
// Wait before refreshing
delay(2000);
}