Peter Ma
Published © GPL3+

Indoor Oxygen Reactor

Produce and maintain oxygen/Co2 levels in indoor environment through bio cells for Menopause and COVID19.

IntermediateShowcase (no instructions)20 hours2,719

Things used in this project

Hardware components

Arduino Due
Arduino Due
×1
Arduino Zero
×1
DFRobot ESP8266 Wifi Bee (Arduino Compatible)
×1
DFRobot Gravity IO Expansion Shield for Arduino V7.1
×1
DFRobot Immersible Pump & WaterTube
×1
DFRobot Gravity: Analog Infrared CO2 Sensor For Arduino (0~5000 ppm)
×1
DFRobot Gravity: Flexible 16x16 RGB LED Matrix
×1
DFRobot Gravity: I2C 16x2 Arduino LCD with RGB Backlight Display
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Indoor Oxygen Reactor Schema

Indoor Oxygen Reactor Schema

Code

Arduino code

Arduino
Arduino code
#include <Wire.h>
#include "rgb_lcd.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define PIN        4 // On Trinket or Gemma, suggest changing this to 1
#define NUMPIXELS  256 // Popular NeoPixel ring size
#include <WiFi.h>

char ssid[] = "yourwifi";     //  your network SSID (name)
char pass[] = "wifipassword";    // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
WiFiClient client;


Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

rgb_lcd lcd;

int sensorIn = A0;

void setup() {
  Serial.begin(115200);
  // Set the default voltage of the reference voltage
  analogReference(DEFAULT);
  lcd.begin(16, 2);

  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  pixels.clear(); // Set all pixel colors to 'off'
  
    // attempt to connect using WPA2 encryption:
  Serial.println("Attempting to connect to WPA network...");
  status = WiFi.begin(ssid, pass);

  // if you're not connected, stop here:
  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }
  // if you are connected, print out info about the connection:
  else {
    Serial.println("Connected to network");
    clearLights();
  }
  
}

void loop() {
  //Read voltage
  int sensorValue = analogRead(sensorIn);

  // The analog signal is converted to a voltage
  float voltage = sensorValue * (5000 / 1024.0);
  if (voltage == 0)
  {
    Serial.println("Fault");
  }
  else if (voltage < 400)
  {
    Serial.println("preheating");
  }
  else
  {
    int voltage_diference = voltage - 400;
    float concentration = voltage_diference * 50.0 / 16.0 + 500;
    // Print Voltage
    Serial.print("voltage:");
    Serial.print(voltage);
    Serial.println("mv");
    //Print CO2 concentration
    Serial.print(concentration);
    Serial.println("ppm");

    lcd.setCursor(0, 0);
    lcd.print("CO2 level");
    lcd.setCursor(0, 1);
    lcd.print(String(concentration) + " ppm   ");
    
    if(concentration > 1500)
    {
      lcd.setRGB(255, 0, 0);
      setupLights2();
    }
    else if(concentration > 1000)
    {
      lcd.setRGB(255, 255, 255);
      setupLights1();
    }
    else
    {
      lcd.setRGB(0, 0, 0);
      clearLights();
    }
    
    String tmp;
    tmp = String(concentrationpCount);
    if (client.connect(server, 3000)) {
        Serial.println("connected to server");
        // Make a HTTP request:
        client.println("GET /?CO2=" + concentration + " HTTP/1.1");
        client.println("Host: 192.168.1.12");
        client.println("Connection: close");
        client.println();
      }
      
  }
  delay(1000);
}

void clearLights()
{
  pixels.clear();
  pixels.show();   // Send the updated pixel colors to the hardware.
}

void setupLights1()
{

  for(int i = 0; i < 16; i++)
  {
    if(((i / 2) & 1) == 0) 
    {
      pixels.setPixelColor(16*i+7, pixels.Color(127, 0, 255));
    }
  }
  pixels.show();   // Send the updated pixel colors to the hardware.
}


void setupLights2()
{

  for(int i = 0; i < 16; i++)
  {
    if(((i / 2) & 1) == 0) 
    {
      pixels.setPixelColor(16*i+6, pixels.Color(127, 0, 255));
      pixels.setPixelColor(16*i+7, pixels.Color(127, 0, 255));
    }
  }
  pixels.show();   // Send the updated pixel colors to the hardware.
}

Credits

Peter Ma

Peter Ma

49 projects • 393 followers
Prototype Hacker, Hackathon Goer, World Traveler, Ecological balancer, integrationist, technologist, futurist.

Comments