Diana Khalipina
Published © GPL3+

Arduino-Based Determination of an Air Humidifier Efficiency

Using Arduino and the sensors I analysed how a small air humidifier can change the parameters of the room and influence health state.

BeginnerFull instructions provided2 hours2,726
Arduino-Based Determination of an Air Humidifier Efficiency

Things used in this project

Story

Read more

Schematics

Schematics for arduino board

Code

Code for arduino board

C/C++
#include <Wire.h>
#include <DHT.h>
#include <Adafruit_SGP30.h>
#include <OneWire.h>

DHT dht_8(8, DHT11);
Adafruit_SGP30 sgp30;
enum DS18B20_RCODES {
  READ_OK,
  NO_SENSOR_FOUND,
  INVALID_ADDRESS,
  INVALID_SENSOR
};
OneWire ds18b20_4(4);

void serial_setupConnection(int baudrate) {
  Serial.begin(baudrate);
  while (!Serial) {
    Serial.println("En attente de l'ouverture du port série...");
    delay(1000);
  }
  Serial.println("Port série activé. Baudrate: " + String(baudrate));
}

uint16_t sgp30_readCO2() {
  if (!sgp30.IAQmeasure()) {
    Serial.println("Measurement failed");
    return 0;
  }
  else return sgp30.eCO2;
}

byte ds18b20_measure(OneWire ds, float *temperature, byte reset_search) {
  byte data[9], addr[8];
  if (reset_search) ds.reset_search();
  if (!ds.search(addr)) return NO_SENSOR_FOUND;
  if (OneWire::crc8(addr, 7) != addr[7]) return INVALID_ADDRESS;
  if (addr[0] != 0x28) return INVALID_SENSOR;
  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);
  delay(800);
  ds.reset();
  ds.select(addr);
  ds.write(0xBE);
  for (byte i=0; i<9; i++) data[i] = ds.read();
  *temperature = (int16_t) ((data[1] << 8) | data[0]) * 0.0625;
  return READ_OK;
}

float ds18b20_readTemperature(OneWire ds) {
  float temp;
  if (ds18b20_measure(ds, &temp, true) != READ_OK) {
    Serial.println(F("Erreur de lecture du capteur."));
    return;
  }
  return temp;
}


void setup() {
  serial_setupConnection(9600);
  dht_8.begin();
  while (!sgp30.begin()) {
    Serial.println("En attente du capteur SGP30...");
    delay(1000);
  }
}

void loop() {
  Serial.print("@Graph:");
  Serial.print("Room temperature:");
  Serial.print(dht_8.readTemperature());
  Serial.print("|");
  Serial.print("Room humidity:");
  Serial.print(dht_8.readHumidity());
  Serial.print("|");
  Serial.print("Room CO2:");
  Serial.print(sgp30_readCO2());
  Serial.print("|");
  Serial.print("Body temperature:");
  Serial.print(ds18b20_readTemperature(ds18b20_4));
  Serial.print("|");
  Serial.print("\n");
  delay(50);
  delay(1000*30);
}

Credits

Diana Khalipina

Diana Khalipina

15 projects • 74 followers
I'm biomedical engineer and I create health kits to help everybody to take care of health in easy and cheap way

Comments