Sunday, 23 December 2018

Home Automation: Using Arduino Uno & ESP8266(Blynk app)

 Hardware required:

    1>Arduino UNO(r3)
    2>ESP8266-01 wifi module
    3>4 channel relay
    4>Male to female jumper wires
    5>Adaptor(output:12V/1Amp) 
You could check out amazon or if you live near kolkata Chadni market is where you can get these for really cheap

Software required:

    1>Arduino IDE, Link:https://www.arduino.cc/en/Main/Software
    2>Blynk library for Arduino, Link:https://github.com/blynkkk/blynk-library/releases/tag/v0.5.4
    3>Project files provided
    4>Blynk App on Android/iOS, Link:https://play.google.com/store/apps/details?id=cc.blynk


Now,
Steps to make the project:
  1. make connections as in connect2.png
  2. power up using pc via usb
  3. open up arduino ide
  4. Load from File->Examples->Bare Minimum
  5. Verify and upload the file
  6. Open serial monitor
  7. Set NL&CR and baud rate to 115200(this is the default rate)
  8. Now give command ("AT") it should return ("OK") if you don't get anything check other baud rates or else you need to flash the firmware.
  9. Now give command ("AT+CWMODE=1) it set the chip in station mode(client)
  10. Give command("AT+UART_DEF=9600,8,1,0,0") it will change baud rate to 9600
  11. change baud ratee in serial monitor to 9600
  12. Now give command("AT+CWLAP") and see if your home wifi gets listed, if not then turn on your home wifi or try to move closer to your home wifi.
  13. We will try to connect to home wifi network.
  14. Give command ("AT+CWJAP="home_wifi","password") and it will return text if it gets connected, also you could check using your home wifi's page
  15. Let's disconnect, give command("AT+CWQAP") it should return ("OK"). Now , that our wifi module is working let us get into the work, make connections as in final.png
  16. Setup blynk app on your andriod/iOS device.
  17. Load the code provided making required changes as mentioned in comments to the arduino borad.(Change the blynk Auth token,wifi name/ssid,password with your own)
  18. Now that your code has been uploaded you can put the device with live circuits, but be careful not to hurt yourself, also you could power the arduino using an adapter.

Final Connections:




Project files download:


Here is github linkfor the project: https://github.com/SubrataSarkar32/home-automation

Saturday, 28 October 2017

Sara - A virtual assisstant made in python

Have you ever wondered about building your own virtual assistant? Off course who might have not, specifically something like Jarvis. Now you can too with Python and other languages with their rich libraries at your disposal.Here is my small glimpse of what can be done in Python. I have made my assistant(Sara) with very limited features to start off with. Features would be kept on adding and your help would be appreciated always as it is licensed under GPLv2. Also you can tinker around with it to make your own assistant styled according to you as it is under GPLv2.
Hope you like it.
It is available at https://github.com/SubrataSarkar32/sara
Here is a vedio below:

Tuesday, 11 April 2017

pdecrypt(Python:Simple Caesar Cipher)

Ever felt the need to encrypt text data. Now do it easily using pdencrypt(works on simple caesar cipher).This is a python program. After creating a file you would like to keep the python with you so that no one gets clue.Can be considered public domain work.You responsible for using the software properly You take liability of storing your own data and protecting it Programmer is not responsible for mistakes on part of user. If you have any suggestions feel free to coment.
Sorry small update for typo erors:
import string
name=raw_input('Enter file name: ')
def entangle(t):
    key=13
    lock=string.printable
    ret=''
    for wor in t:
        po=lock.find(wor)
        if po+key>=len(lock):
            po=((po+key)-(len(lock)-1))-1
        else:
            po+=key
        ret+=lock[po]
    return ret
def disentangle(t):
    key=13
    lock=string.printable
    ret=''
    for wor in t:
        po=lock.find(wor)
        if po-key<0:
            po=len(lock)+(po-key)
        else:
            po-=key
        ret+=lock[po]
    return ret

def read(name):
    file1=open(name,'r+')
    op=file1.readlines()
    for obj in op:
        obj=disentangle(obj)
        print obj
    file1.close()
def write(name):
    file1=open(name,'r+')
    t=raw_input('Enter ;')
    t=entangle(t)
    prev=file1.read()
    wr=prev+t+'\n'
    file1.close()
    file1=open(name,'w+')
    file1.write(wr)
    file1.close()
def main(name):
    file1=open(name,'r+')
    keyi=file1.readline()
    file1.close()
    key=raw_input('Enter your key: ')
    if key==disentangle(keyi[:-1]):
        while True:
            choi=raw_input('choice:')
            if choi=='1':
                read(name)
            elif choi=='2':
                write(name)
            elif choi=='3':
                break
            else:
                print 'invalid input'
                print 'program quitting'
                file1=open(name,'r+')
                prev=file1.read()
                wr=prev+'\n'
                file1.close()
                file1=open(entangle(name)+'.tri','w+')
                file1.write(wr)
                file1.close()
                file1=open(name,'w+')
                file1.write(name)
                file1.close()
    else:
        print 'Warning!! do not interfere encrypted txt'
        file1=open(name,'r+')
        prev=file1.read()
        wr=prev+'\n'+entangle('Warning!Someone tried to access your file')+'\n'
        file1.close()
def run():
    import os
    if os.path.isfile(name):
        main(name)
    else:
        file1=open(name,'w+')
        print 'This is important!!'
        print 'Your key is being set.'
        print 'You must remember this else your information stored is doomed'
        import random
        k=random.randint(10,len(string.printable)-1)
        print 'Your key is ',k
        stor=entangle(str(k))+'\n'
        file1.write(stor)
        file1.close()
        main(name)
run()

Saturday, 18 February 2017

Facebook+Python=Awesome

Do you like python? Do you use facebook?
If the answer is yes why not use facebook via python.
Below is the code to use facebook via python .This program has been inspired by http://www.geeksforgeeks.org/send-message-to-fb-friend-using-python
 Disclaimer of Warranties and Limitation of Liability.
a.Unless otherwise separately undertaken by the author, to the extent possible, the author offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b.The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Check out fbchat's policies before continuing.
# This code to be considered under GPLv3.Use it under your responsibility.
Code:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#Please use it carefully.Ensure loging out by using a browser
#Required dependencies:
#   requests
#   lxml
#   beautifulsoup4
#   fbchat
def main():
    '''main function: initiation of fbchat and login'''
    import fbchat
    from getpass import getpass
    username = str(raw_input("Username: "))
    client = fbchat.Client(username, getpass())
    '''
    #For sendig same message to specific number of clients
    no_of_friends = int(raw_input("Number of friends: "))
    for i in xrange(no_of_friends):
        name = str(raw_input("Name: "))
        friends = client.getUsers(name)  # return a list of names
        friend = friends[0]
        msg = str(raw_input("Message: "))
        ask = 'O'
        while ask.upper()!='Y' and ask.upper()!='N':
            ask = raw_input('Are you sure about sending this message to'+friend+'(Y/N):')
            if ask.upper()=='Y':
                sent = client.send(friend.uid, msg)
                if sent:
                    print("Message sent successfully!")
            elif ask.upper()=='N':
                print("Message was not sent .")'''
    def choicefrnd(friends):
        '''choose freind from list'''
        try:
             chno=input('Enter index of friend: ')
             friend = friends[chno-1]
             return friend
         except:
             print 'Please give index number as printed above from 1 to n'
             choicefrnd()
    def talk():
        '''talk with friends. Contains main loop and sub loops'''
        ch='y'
        while ch=='y':   
            name = str(raw_input("Name: "))
            friends = client.getUsers(name)  # return a list of names
            for i in xrange(len(friends)):
                print str(i+1)+str(friend[i])
            if len(friends)>=1:
                friend=choicefrnd(friends)
                msg = str(raw_input("Message: "))
                ask = 'O'
                while ask.upper()!='Q':
                   
                    ask = raw_input('Are you sure about sending this message to'+friend+'(Y/N):')
                    if ask.upper()=='Y':
                        sent = client.send(friend.uid, msg)
                        if sent:
                            print("Message sent successfully!")
                    elif ask.upper()=='N':
                        print("Message was not sent .")
                    elif ask.upper()=='Q':
                        break
                    else:
                        print 'Could not decipher your answer.'
                    print 'Press q to quit chatting this friend'
            else:
                pass           
        else:
            pass
        talk()
        client.logout()
main()

Sunday, 25 September 2016

Wednesday, 2 March 2016

AI in 2040