Project tutorial
Magconn With Arduino Can Control Internal Environment!

Magconn With Arduino Can Control Internal Environment!

You can control internal environment with Magconn. Just combining Magconn module and Sensor. This system is easy and wireless control.

  • 610 views
  • 0 comments
  • 4 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Overview

This project is supported by the 1st Magconn Idea Competition. Until now, turning on and off the air conditioner, heater and etc. , you used different remote controls.

We were dissatisfied with this and thought it for better way. We wanted to control this wirelessly and also be compatible with other devices. So we decided to use Bluetooth. It is wireless and is the connection method supported by many devices(Laptop, SmartPhone, desktop and etc.) and is suitable for what we want.

Have you ever tried to replaces parts on breadboard?(even any circuits)

It will be simple if there are few wires, but if you have a lot of wires and a mix of other wires, it will be inconvenient and difficult to replace the parts. The Magconn Module is can resolve this problem. We connected DHT22(Temperature and Humidity Sensor) to the Magconn Module by soldering.

Step 1

Now you do not need to connect each line any more, just connect or disconnect modules.

And we connected Arduino and Sensors as follows.

We used two bluetooth modules(HC-06) to connect with serial communication with smart phones.

Please note that Arduino UNO's Digital 0,1 pins are reserved for hardware serial communication pins and should be uploaded while disconnected during Arduino Sketch.

Step 2

Now we've got it working.

Now it works.

Above video shows external power supply to Arduino and Bluetooth connection with PC and smartphone.

The 74LS138, a DEMUX IC, was used as a way to get the most out of the pins, and we controlled four LEDs according to the fine dust concentration.

The criteria for fine dust concentration were in accordance with the Korea Meteorological Agency standard. There is only one DHT22 sensor combined with the Magconn module because it is difficult to connect the limit and pin to the number of the module.

In the future, other sensors and communication modules can be combined with the Magconn module for proper use. Pairing with PC HC-06 is for serial communication between PC and Arduino. After that, serial communication is possible by connecting Bluetooth and corresponding HC-06 module to PC.

Step 3

HC-06, which is marked as Pairing with Android, connects your smartphone with Bluetooth. I used the Bluetooth Serial Controller application in Google Play Market.

Due to the lack of parts, you can simply read the data from the sensor and stop it, but if you have more pins and have other IRs, you can set more commands and set up more commands.

To summarize the behavior:

The temperature, humidity and fine dust concentration are automatically displayed on the LCD when power is first applied.

After that, when the signal is applied to the Bluetooth on the smartphone by the power control, the data communication is controlled by generating the interrupt. In this case, input 1 turns on the power and 0 turns on the power.

When the power is ON, 'POWER ON' is displayed on the LCD and environmental information is displayed on the LCD. Receives environmental information read from the sensor via serial communication.

When the power is OFF, 'POWER OFF' is displayed on the LCD. I do not receive environmental information.

The resistor connected to the LED is to limit the overcurrent to a 330 ohm resistor, and the resistor on the DHT22 sensor is a pullup resistor.

Overall control was with a smart phone, and data transmission and reception with a PC.

Code

Untitled fileArduino
#include <LiquidCrystal.h>
#include "DHT.h"
#include <SoftwareSerial.h>

#define DHTPIN 4        // DHT22 핀의 설정 Set DHT PIN
#define DHTTYPE DHT22   // DHT22 (AM2302) 센서종류 설정 
 
DHT dht(DHTPIN, DHTTYPE);

int dust_sensor = A0;   // 미세먼지 핀 번호 
int dust_A = 5;    // 74LS138 PIN1 (A)
int dust_B = 6;  // 74LS138 PIN2 (B)
float dust_value = 0;  // 센서에서 입력 받은 미세먼지 값 
float dustDensityug=0;  // ug/m^3 값을 계산

int sensor_led = 7;     // 미세먼지 센서 안에 있는 적외선 led 핀 번호
int sampling = 280;    // 적외선 led를 키고, 센서 값을 읽어 들여 미세먼지를 측정하는 샘플링 시간 
int waiting = 40;    
float stop_time = 9680;   // 센서를 구동하지 않는 시간 

int power=1;



LiquidCrystal lcd(8,9,10,11,12,13);

int blueTx=2;   //Tx (보내는핀 설정)at
int blueRx=3;   //Rx (받는핀 설정)
SoftwareSerial mySerial(blueTx, blueRx);  //시리얼 통신을 위한 객체선언
char controlsignal;
String myString=""; 

void Receive()
{ 
   while(mySerial.available())  //mySerial 값 존재시
  {
    char myChar = (char)mySerial.read();  //mySerial int형식의 값을 char형식으로 변환
    myString+=myChar;   //수신되는 문자열을 myString에 모두 붙임 (1바이트씩 전송되는 것을 모두 붙임)
    delay(5);           //수신 문자열 끊김 방지
  }
  
  if(!myString.equals(""))  //myString 값이 있다면
  {
      if(myString=="1")  //myString 값이 '1' 이라면
      {
        power=1;
        Serial.print("\nPOWER ON\n");
      } 
      else if(myString=="0")
      {
        power=0;
        Serial.print("POWER OFF\n");
      }
      
    myString="";  //myString 변수값 초기화
   
  }


}

void setup(){
  Serial.begin(9600);   // 시리얼 모니터 시작, 속도는 9600
  
  mySerial.begin(9600); //블루투스 시리얼 개방
  
  pinMode(sensor_led,OUTPUT); // 미세먼지 적외선 led를 출력으로 설정

  pinMode(dust_A, OUTPUT);     
  pinMode(dust_B, OUTPUT);   // 74LS138 PIN 출력 설정

  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);

  attachInterrupt(0, Receive, CHANGE);
 
  dht.begin();

  lcd.clear();
  lcd.setCursor(5,0);
  lcd.print("POWER");
  lcd.setCursor(6,1);
  lcd.print("O N");
  delay(2000);
}

void loop(){
  if(power==1)
  {
  digitalWrite(sensor_led, LOW);    // LED 켜기
  delayMicroseconds(sampling);   // 샘플링해주는 시간. 

  dust_value = analogRead(dust_sensor); // 센서 값 읽어오기
  
  delayMicroseconds(waiting);  // 너무 많은 데이터 입력을 피해주기 위해 잠시 멈춰주는 시간. 

  digitalWrite(sensor_led, HIGH); // LED 끄기
  delayMicroseconds(stop_time);   // LED 끄고 대기  

  dustDensityug = (0.17 * (dust_value * (5.0 / 1024)) - 0.1) * 1000;    // 미세먼지 값 계산
  Serial.print("\nDust Density [ug/m3]: ");            // 시리얼 모니터에 미세먼지 값 출력
  Serial.print(dustDensityug);
  
  if(dustDensityug <= 30.0){       // 대기 중 미세먼지가 좋음 일 때 초록색 출력
     digitalWrite(dust_A, LOW);
     digitalWrite(dust_B, LOW);
     Serial.print("   ");
     Serial.println("Green");
  }else if(30.0 < dustDensityug && dustDensityug <= 80.0){      // 대기 중 미세먼지가 보통 일 때 노란색 출력
     digitalWrite(dust_A, HIGH);
     digitalWrite(dust_B, LOW);
     Serial.print("   ");
     Serial.println("Yellow");    
  }else if (80.0 < dustDensityug && dustDensityug <= 150.0){    // 대기 중 미세먼지가 나쁨 일 때 주황색 출력
     digitalWrite(dust_A, LOW);
     digitalWrite(dust_B, HIGH);
     Serial.print("   ");
     Serial.println("Orange");        
  }else{                                                     // 대기 중 미세먼지가 매우 나쁨 일 때 빨간색 출력
     digitalWrite(dust_A, HIGH);
     digitalWrite(dust_B, HIGH);    
     Serial.print("   ");
     Serial.println("Red");
  }
  
  float h = dht.readHumidity();    //온습도센서
  float t = dht.readTemperature();
 
  if (isnan(t) || isnan(h)) {
    //값 읽기 실패시 시리얼 모니터 출력
    Serial.println("Failed to read from DHT");
  } 
  else 
  {
    //온도, 습도 표시 시리얼 모니터 출력
    Serial.print("Humidity: "); 
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: "); 
    Serial.print(t);
    Serial.println(" *C\n");
  }
 
  lcd.clear();                 //LCD에 화면 띄움
  lcd.setCursor(0,0);
  lcd.print(" ");
  lcd.print(t);
  lcd.print("'C");
  lcd.setCursor(9,0);
  lcd.print(h);
  lcd.print("%");\
  lcd.setCursor(1,1);
  lcd.print(dustDensityug);
  lcd.print("ug/m3");

  delay(2000);
  }

  if(power==0) // mystring이 '0'일때 (off)
  {

    lcd.clear();
    lcd.setCursor(5,0);
    lcd.print("POWER");
    lcd.setCursor(6,1);
    lcd.print("OFF");
    delay(2000);
  }
}

Schematics

Fritzing Image
Kakaotalk 20180126 015151260 fsg2r3guty
dht_0U3SalhNsT.zip

Comments

Similar projects you might like

Factory/Warehouse/Control Shed/ Environment Monitoring

Project tutorial by Muhammad Afzal

  • 2,679 views
  • 0 comments
  • 11 respects

Arduino Humidifier Control

Project tutorial by Arduino “having11” Guy

  • 10,143 views
  • 6 comments
  • 11 respects

The Environment Cube! Know the Land Beneath You using Sigfox

Project tutorial by Dhairya Parikh

  • 3,452 views
  • 0 comments
  • 6 respects

Arduino Control AC Water Heater temperature

Project tutorial by Mohannad Rawashdeh

  • 14,385 views
  • 0 comments
  • 10 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 11,981 views
  • 6 comments
  • 34 respects

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 11,114 views
  • 5 comments
  • 16 respects
Add projectSign up / Login