Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Wednesday, March 7, 2018

Arduino relay, control 220v devices code and hardware(circuit diagram)

At the first part of the video (Part-A), I will explain each line of the small code.
At the second part of the video (Part-B) I will build the hardware.

I  build a solution to power on a water pump(or other 220v devices) when there is water overflow.
You can do it to power on other AC (220V) appliances such as Lights, TVs, etc.


Part-A (Code explanation).

Video link for Part-A below this line:
https://youtu.be/mQLTWnA4ZHI


Download code here: Download link
or copy the code unter this line:


#define relay1 4             //Defines pin 4
#define relay2 7             //Defines pin 7         
#define sensor 2          //Define sensor pin 2 (input pin)
#define alwaysHigh 10     //gives 5v to the sensor
//#define ledPin 8 

int sensorState=0;    //keeps the reading of sensor pin 2 (high or low)
int flag=0;     // Takes values 0 or 1. When the sensorState changes.

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);

    //pinMode(ledPin, OUTPUT);  // Set the LED pin as output
    pinMode(sensor, INPUT);     // Set the Sensor pin as input
 
    pinMode(relay1, OUTPUT);     
    pinMode(relay2, OUTPUT);
    pinMode (alwaysHigh, OUTPUT);   //5V sourch, gives power to sensor
 
 
    digitalWrite(relay1, !(LOW));  //OFF
    digitalWrite(relay2, !(LOW));  //OFF
    digitalWrite(alwaysHigh, HIGH); //ON

    Serial.println("Relay-1 is OFF");
    Serial.println ("Relay-2 is OFF");
    Serial.print("\n");
}


void loop() {
    sensorState= digitalRead(sensor);
    //Serial.println(sensorState);
    if (sensorState == HIGH) {               // check if the sensor is in water(short circuit)
      digitalWrite(relay1, !(HIGH));                  // turns Relay1 ON
      digitalWrite(relay2, !(HIGH));                  // turns Relay2 ON
      if (flag==0){
        flag=1;
        Serial.println("relays are now ON");
      }
    }
    else{
      digitalWrite(relay1, !(LOW));             // turns Relay1 OFF                       
      digitalWrite(relay2, !(LOW));             // turns Relay2 OFF
      if (flag==1){
        flag=0;
        Serial.println("relays are now OFF");
      }
    }
} //loop end bracket


Part-B (Hardware)


Video link for Part-B below this line:
https://youtu.be/mimGR6aEHNA




Wednesday, March 16, 2016

SIM800L EVB - Arduino Nano Diagram - Alarm system

This is a cellular based alarm system. 

Basic specifications:
Once the magnetic reed sensor recognise intrusion, the alarm system sends sms or makes a call to a predifined cellphone number

The alarm system could be deactivated through a phonecall.
If you make a call to the alarm's cellphone-number, the alarm systen being inactive for five minutes and then return to an active status.
If you send an sms to the alarm system that contains the text / character 's'  (without:  '   ').
The system responds with the current alarm status (active/inactive)


More Details: 
This is the connection diagram of an arduino nano with the sim800 evb (gsm - gprs) module.
Requirements:
1 x Mini usb cable to give power to arduino nano
2 x 10k resistor
1 lx ed
1 x arduino nano microcontroller
1 x sim800l evb gsm/gprs module
1 x 3.7v li-ion battery
1 x step up controller
1 x magnet reed sensor


Download Code:
Click Here

Saturday, January 16, 2016

Arduino HC-06 bluetooth pc-button (schema and arduino code here)

The following project gives you the ability to switch on your desktop computer over bluetooth.

The way this thing works is:  You send a command over bluetooth (by pressing a key on your phone) and the electromagnet(attached on the arduino nano) connects two cables (that are acting as a switch).

The following circuitry support 5V and 12V electromagnets with the usage of PN222A transistor as shown 

It is necessary to connect those two cables direct on the mainboard of your pc (where the power button connector is  placed)

Another alternative could be a relay switch, but in this case I used an electromagnet.
 




Video on Youtube   --> https://youtu.be/ChciUi8SHEA





Arduino Code under this line:


//  voulios.blogspot.com (Technology Blog)
//  Chrysovalantis Eleftheriadis

int button = 8;  
int state;        //State '1' activates power-on button, state '0' deactivates it.
int flag=0;       //makes sure that the serial only prints once the state


void setup() {
    pinMode (button, OUTPUT);
    Serial.begin(9600);
}

void loop() {
    //if some date is sent, reads it and saves in state
    if(Serial.available() > 0){    
      state = Serial.read();
      Serial.println(state);  
      flag=0;
    }  
   
    if (state == '0') {   
        digitalWrite(button, LOW);
        if(flag == 0){
          Serial.println("Button is deactivated");
          flag=1;
        }
    }

    //Receives '1' from serial and activates the power button for 3 secs
    else if (state == '1') {
        digitalWrite(button, HIGH);     //activates the button
        delay(3000);                    //for three seconds
        state='0';                      //sets the state to '0' (for the next loop)
        if(flag == 0){
          Serial.println("Power Button has been pressed for 3 seconds");
          flag=1;
        }
    }
          

}