Archive

Archive for February, 2016

Calculate Energy Usage using Current Sensor ACS712 30A

February 27th, 2016 No comments

                 This is a simply cheap solution to calculate Energy consumed by your gears..But still the accuracy i have not tested..Buy a
module as shown below with ACS712 and please make sure of the current rating according to your requirement.

             The module has one Vcc, one Gnd and one Vout pins so simply you connect the Vout pin to any Analog input of Arduino and power up the module from Arduino. But don’t forget to change the analog pin no in the provided sketch..

Sketch :
/*
Measuring KWh Current Using ACS712
*/
const int sensorIn = A3;
int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A Module


double SensorVoltage = 0;
double SensorVRMS = 0;
double AmpsRMS = 0;
float KWH=0;
uint32_t lastTime=0;

void setup(){
Serial.begin(9600);
}

void loop(){
lastTime=millis();
SensorVoltage = getSensorVoltageInput();
SensorVRMS = (SensorVoltage/2.0) *0.707;
AmpsRMS = (SensorVRMS * 1000)/mVperAmp;
Serial.print(AmpsRMS);
Serial.print("RMS Current ");
Serial.print("Energy ");
KWH=KWH+(((AmpsRMS*220*0.9)/3600)*(millis()-lastTime)); // Taken 220V RMS (Indian Scenario) and PF 0.9
Serial.print(millis());
Serial.print(" : ");
Serial.println(KWH);
}

float getSensorVoltageInput()
{
float result;

int readValue;
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here

uint32_t start_time = millis();
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the maximum sensor value*/
minValue = readValue;
}
}

// Subtract min from max
result = ((maxValue - minValue) * 5.0)/1024.0;

return result;
}

Categories: ACS712, Arduino, Current to Kwh, Energy, onitoring Tags:

Use TRIAC as Relay

February 25th, 2016 No comments
           Mostly we all use relays to control AC loads as they are widely available and cheaper.. But things becomes complicated as they are bulky and makes noise……everyone knows where i have placed my

relay…so what to do ??? you can say SSR right ? but i googled a lot and found out these are costlier so i thought of using TRIAC instead of Relay and after googling a bit i found it working….And that’s what i was looking for my Wi-Fi powerboard that i am working on…And it’s working all good…by the way i will post about that later…….

Circuit :

        Up there i have provided a schematic that i have used for my components . MOC3021 is a isolated TRIAC driver and is easily available in market…I have used a diode in the input to MOC3021 as it was becoming 0 volt always causing my ESP8266 module GPIO to false and that was not working to control…
*** Don’t use inductive load with this. That will require the usage of a snubber circuit. The modified schematic will look like below..

Categories: BT136, MOC3021, oksbwn, Relay, TRIAC Tags:

Making PCB at Home

February 24th, 2016 No comments

              By using the conventional APBS which are available in market ,making circuits becomes messy as you have to do all the connections using the wires and of-course it looks ugly.So to avoid that and get a beautiful circuit of your own at a cheaper cost i  am providing this article.

To make own PCB we need Copper cladded board,Hydrochloric acid,hydrogen peroxide,one driller,laser printer,Software to make the circuit design,magazine paper ,one press iron and water.I  have given where can you get all the materials.Now all the processes step by step..

Step-1
          First of plan the circuit you are looking for and roughly draw one schematic over a paper.Now by using any software for schematic design draw your schematic in your PC.You can get a lot of free schematic software with a little bit of googling.I have used DIY Layout cretor which is a freeware one.


Step-2
        Now take a printout of the designed schematic by using one laser printer over one glossy magazine paper.Donot use the inkjet printer as they donot have the toner.(Powder used in laser one).The picture should be inverted one.


Step-3
      Cut a desired piece of PCB and wash it cleanly with alcohol or spirit so that to avoid any oily substances over it .Put the printout over the PCB (print should face the copper side of PCB) and press it firmly by using a hot press iron so that not disturbing the paper position.Do this for nearly one minute. Let it to cool and now wash away the paper in water ,u will find the design to be printed over the board.

A piece of copper claded board available in market.Print of the schematic over one glossy magazine paper with one laser printer.(I have done with one marker)
Copy of the schematic over the copper board  by putting the print over the board and heating with one press iron.(I have drawn the schematic directly over the board and heated with the press iron by putting one paper over it)

Step -4
   This process is actually one chemical process.Take a plastic or fiber container.(metal container may get damaged due to the chemicals) and put 2 quantity of hydrogen peroxide and one quantity of hydrogen chloride.Put the board in the solution and leave it for sometime.

**Don’t use your naked hands, use gloves.

Hydrochloric acid available in any hardware store.Take one time of it e.g:100 ml.
Hydrogen peroxide which is available at any local medical shop.Take two times of that of HCl.e.g:200 ml
Put the board after the step-3 into the solution and wait for sometime.Don’t use any metal container.

Step -5
   Take the board out of the solution and wash it completely with water.Wash the board with alcohol to clean the black lines.And using the drill drill the holes in the PCB where u require according to your design.Now your PCB is ready for use.Rock with your own PCB.

Take the board out of the solution and wash it clearly with water and than remove the black lines with alcohol or spirit.A hand drill used for drilling ofthe holes for the components.Available at any hobby shop.U can also use machine drill.After completion of all the steps the circuit will look like this.
Categories: APB, Design, oksbwn, PCB, PCB at home Tags:

Screenshots of my SmartHome Android App..

February 24th, 2016 No comments

Guys here are some screenshots of the Android App used to control devices in my smart home that i am working on….

                                             

I have blurred some images for Privacy…..Please have your opinions on if any modification required…

Categories: My Smart Home, Uncategorized Tags:

Getting started with ESP8266-01

February 23rd, 2016 No comments
         

                 Wi-Fi…..Sounds good right….What if you can make your next project with Wi-Fi interface and with cheaper cost even if lower then ENC28J60 based Ethernet module…..I am sure you will be the happiest one….So how is that possible..? Ya you red right you can get Wifi at cheper price then ENC28J60 and that’s by using ESp8266 Wi_Fi modules.
               These modules are extremely cheaper and easy to use. In this post i will post about how to get started with ESp8266-01 modules.

Pin Diagram :

Connections :
  
        S1: Reset Switch
        J3: When you want to go into programming mode connect GND with GPIO0.
Working :
  Connect J2 with the serial converter from PC . Points to be must followed are :
      ** Must use a separate power supply. Donot use USB.
           Must use a 3.3 volt USB to RS232 converter like FTDI.
   
     Now connect the module with PC and use any serial Communication program and set with parameters 8N1 with baudrate 9600. Now reboot the module and you could see some garbage data getting printed on the console, don’t worry everything is fine.
  Now provide command   “AT + (Hit Enter or CR+LF)”  to check the communication.
     If everything works good the module will reply,
     AT
     OK
Happy tinkering….
 


Categories: ESP8266, oksbwn Tags:

3G Connectivity With Raspberry Pi using Huwaei E303 Dongle

February 16th, 2016 No comments
  Hi Guys. In this post we will see how to provide internet connectivity to Raspberry Pi using 3G USB dongle. This comes handy in many cases.The internet connection will be provided by a Huawei E303 USB 3g dongle on the vodafone network Odisha.



Setup
                            Power Source ——–>RPI—>(USB) 3g Dongle

         

  The USB port of the PI doesnot have enough power to provide to a 3G dongle so if you plug directly the dongle onto the Pi the Pi may behave unwantingly which can be avoided by using an externally powered USB hub. I Raspbian Wheezy on Raspberry Pi. Next is after connecting the dongle to the Pi is to check if that has been detected by Pi. To get a list of USB connected devices type :

   $ sudo lsusb

   The output of the above command will be something like this :

      
   Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
   Bus 001 Device 010: ID 12d1:1504Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

 I have higlighted the output that shows the detected USB dongle. Most of the USB dongle comes with partition hosting drivers. So their might be chance that the Pi detects the dongle as mass storage device. Don’t worry about that just install usbmodeswitch.To install, in the terminal window type:

   $ sudo apt-get install usb-modeswitch

The usbmodeswitch just helps to change the mode of the dongle from mass storage to modem.

Download and setup  UMTSKeeper and Sakis3g

UMTSKeeper

 UMTSkeeper is used to automatically reconnect the 3g dongle using the Sakis3g script should the connection drop, which actually happens quite a few times. Download and unpack UMTSkeeper by issuing the following commands from the terminal window:

$ sudo mkdir umtskeeper
$ cd umtskeeper
$ sudo wget "http://zool33.uni-graz.at/petz/umtskeeper/src/umtskeeper.tar.gz"
$ sudo tar -xzvf umtskeeper.tar.gz
$ sudo chmod +x umtskeeper

 The first command created a folder called ‘umtskeeper’ in the current directory you are in. To confirm what this directory is, type ‘pwd’. Make note of the output, as we will need the full path to automate UMTS keeper later. Now we will download Sakis3g into the same directory to keep things simple.

Sakis3g

 Sakis3g is a script used to make a 3g connection. You need to be able to provide a few details: your APN, the PIN for your sim card and your username and password if your provider requires them. This information can (hopefully) be found on your providers website or in the documentation that came with your simcard/dongle. If not, a search on google for ‘your provider APN settings’ should unearth them. The sakis-3g.org website has been down for some time. Fortunately somebody has uploaded a copy of the script to sourceforge. To download and unpack it, issue the following commands from the terminal window:

   $ sudo wget "http://downloads.sourceforge.net/project/vim-n4n0/sakis3g.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvim-n4n0%2Ffiles%2Fts=1363537696use_mirror=tene~t" -O sakis3g.tar.gz
$ sudo tar -xzvf sakis3g.tar.gz
$ sudo chmod +x sakis3g

Before going further, you should attempt to make a 3g connection using the sakis3g script alone, proving everything you’ve done up till now works. Sakis3g has an interactive mode, which will prompt you for information regarding your 3g connection. In the terminal window, type:

    $ ./sakis3g --interactive

and follow the prompts on screen. If you have no APN user or password, enter ‘0’. Once a connection has been made, make sure you can browse the internet, or issue a ping from the terminal window:

   $ ping  www.google.com

Now test UMTSkeeper. The command at first may look a bit confusing (the details are for my connection):

$ ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' APN='CUSTOM_APN' CUSTOM_APN='www'  SIM_PIN='1234' APN_USER='' APN_PASS=''" --sakisswitches "--sudo  --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat  'no'

Breaking it down a little, these are the areas that you will need to change:

USBMODEM: The Device ID we found using the lsusb command earlier

CUSTOM_APN, APN_USER, APN_PASS, SIM_PIN: Information about your sim card and your providers data network.

A full breakdown of the paramaters can be found on the UMTSKeeper site..

Once you are satisfied UMTSKeeper is working in harmony with Sakis3g, we can edit /etc/rc.local so that it starts when the operating system boots. In the terminal window, type:

 $ sudo nano /etc/rc.local

and add the following single line, edited to show your path to the umtsfolder you found with the ‘pwd’ command earlier:

 Path_to_umtskeeper_folder/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506'  APN='CUSTOM_APN' CUSTOM_APN='www' SIM_PIN='1234' APN_USER=''  APN_PASS=''" --sakisswitches "--sudo --console" --devicename  'Huawei' --log --silent --monthstart 8 --nat 'no' 

Exit, saving changes and reboot to enjoy uninterrupted 3G internet connection.

$ chromium -kiosk  //Install Gogle Chrome

RFID With Arduino

February 8th, 2016 No comments
    Hello visitors….. Its been a hard time working with my home automation system..And this week I was working with access control system. The end goal was to allow only the authorised user to use my home automation system as well as my system can keep track of the users in and out activity. It now knows exactly i am inside or not or one of my friend is inside. For that i have used RFID Reader as well as Mobile App access token……

    Today with this post i will share how to Interface EM18 RFID reader with Arduino. EM18 is really simple to Interface.
**I have used softwareSerial Lib of Arduino to use GPIO 2 as UART Rx Pin

Schematic:
     

Code: 
   


#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);
char dataBuffer[12];
int dataCounter=0;
void setup()
{
Serial.begin(57600);
Serial.println("Scan RFID Tag!");

// set the data rate for the NewSoftSerial port
mySerial.begin(9600);
}

void loop() // run over and over again
{

while (mySerial.available()) {
dataBuffer[dataCounter]=(char)mySerial.read();
dataCounter++;
}
if(dataCounter==12){
String data(dataBuffer);
Serial.println(data);
dataCounter=0;
}
Serial.println("Again");
delay(2000);
}

PIR Sensor with Arduino

February 5th, 2016 No comments

                           PIR sensors are really simple and easy to use as well as cheap motion detection sensor. The feature that it is easy to interface with any microcontroller makes it widely usable. Here i am providing a simple Arduino sketch to interface it with Arduino.

Circuit Diagram :

** Pin 8 of Arduino is connected to the OUT pin of the sensor.


Sketch :


#define timeToCaliberate 30
#define timeToDetectMotionBetween 5000

long unsigned int lastMotionTime;
long unsigned int motionInTime;
boolean lastMotionFinished = true;
boolean lastMotionDetected;

int inputPIRPin = 8; //the digital pin connected to the PIR sensor's output
int LED = 13;

//SETUP
void setup(){
Serial.begin(9600);
pinMode(inputPIRPin, INPUT);
pinMode(LED, OUTPUT);
digitalWrite(inputPIRPin, LOW);

Serial.println("Providing some time to sensor for caliberation.");
while(millis()/1000 < timeToCaliberate){
Serial.print("-");
delay(1000);
}
Serial.println("Caliberation Finished. Your PIR Sensor is now Online");
delay(50);
}

////////////////////////////
//LOOP
void loop(){
if(digitalRead(inputPIRPin) == HIGH){
digitalWrite(LED, HIGH);
if(lastMotionFinished){
lastMotionFinished = false;
Serial.println("Motion Detected");
motionInTime= millis();
delay(50);
}
lastMotionDetected = true;
}

if(digitalRead(inputPIRPin) == LOW){
if(lastMotionDetected){
lastMotionTime = millis();
lastMotionDetected = false;
}
if(!lastMotionFinished && millis() - lastMotionTime > timeToDetectMotionBetween){
lastMotionFinished = true;
Serial.print("Movement was for ");
Serial.print((millis()-motionInTime)/1000);
Serial.println(" second.");
motionInTime=0;
delay(50);
digitalWrite(LED, LOW);
}
}
}


All file are available on my git repository also. Checkout: here