Thursday, April 23, 2015

Code for Gas booking python

Create a file called config.txt  and add following lines

phonenum: 9666261963
min_weight: 3
gas_agency: 9985203976


smartgasbooking.py

import serial
from random import randint
from time import sleep
from threading import Thread
import threading

resume=threading.Event()
 

def read_configfile():
    fin = open("config.txt","r")
    lines= tuple(fin)
    config = {}
    for line in lines:
       config[line.split(":")[0]]=line.split(":")[1]  
       fin.close()
    return config

config_arr=read_configfile()
   
def weight_read():
    global config_arr
    global resume
    while True :
     try:
        ser=serial.Serial('/dev/ttyAMA0',9600,timeout=1)  
        ser.flush()
        num=ser.inWaiting()
        if(num != 0):
            s=ser.read(num)
            print "weight",s
            weight= s.split(" Kg.")[0]
   #print weight
            if(float(weight) < 4):
                resume.clear()
                #call_number(config_arr["phonenum"])
                call_number("9666261963")                            
                print "calling"          
        ser.close()
     except:
        print "...."

def call_number(phnum):
   try:
    global resume
    ser = serial.Serial('/dev/ttyUSB0',9600,timeout=1)
    ser.flush()
    print "Calling ...",phnum
    cmd="ATD"+str(phnum)+";\r"
    ser.write(cmd)
    sleep(15)
    ser.write('ATH\r')
    ser.close()
   except:
    print "call_error"  
   resume.set()
 




try:
    resume.set()  
    wt_thread=Thread(target = weight_read);
    wt_thread.start()
    wt_thread.join()  
except:
    print " thread Error"
   

   

Interfacing Load cell with Raspberry Pi


Connectivity of  Load cell  to Load cell Amplifier for weighing scale

Input voltage - Excitation
Red wire  --------- Excitation input voltage (+)
Black wire -------- Excitation input Ground(-)

Output voltage - Signal
Green wire ------- Signal output (+)
White  wire ------ Signal output (-)
 
Load cell documentation :                   http://www.sunrom.com/p/load-cell-40-kg
Load cell  Amplifier documentation  : http://www.sunrom.com/p/load-cell-amplifier-for-weighing-scale-serial-output

Connectivity of Load cell Amplifier for weighing scale  to Raspberry Pi
 5V    ---------- pin 4 (5v)
GND  --------- pin 6 (GND)
 RXD --------- pin 8 (TXD)
 TXD --------- pin 10 (RXD)


Python code for weight reading

import serial
from random import randint
from time import sleep
from threading import Thread

def weight_read():
    global config_arr
    while True :
     try:
        ser=serial.Serial('/dev/ttyAMA0',9600,timeout=1)   
        ser.flush()
        num=ser.inWaiting()
        if(num != 0):
            s=ser.read(num)
            print s
            weight= s.split(" Kg.")[0]
        #print weight
            if(float(weight) < 4):
                #call_number(config_arr["phonenum"])
                print "calling"           
        ser.close()
     except:
        print "Weight read error"

try:
    wt_thread=Thread(target = weight_read);
    wt_thread.start()
    wt_thread.join()  
except:
    print " thread creation Error"






     


Friday, April 10, 2015

Interfacing SIM900A GSM Modem with Raspberry Pi

Interfacing SIM900A GSM Modem with Raspberry Pi
gsm_phone.py

import serial
import time
ser = serial.Serial('/dev/ttyUSB0',9600,timeout=1)
# 9600 is the default Baudrate for SIM900A modem
ser.flush()
ser.write('ATD9020XXXXXX;\r')
# AT command to call a number using GSM Modem
#ser.read(2)
# read 2 bytes of data from the serial port
time.sleep(10)
# wait for 10 seconds
ser.write('ATH\r')
# Hold the call
ser.close()
# close the serial port
connect RXD of USB2Serial to TXD of GSM Modem and TXD of Serial to RXD of GSM Modem. Also check if you can make a call to the modem and see whether a ring sound, so that network connection can be ensured.

You may use AT+CMGS=”phonenumber” for the sms

Saturday, March 7, 2015

Setting of ssh,rdp

As we don’t have a LCD monitor for connecting our pi board , so we decided to setup ssh , RDP.
As there are chances of ip changes so we have assigned a static ip for pi.

Static ip creation Steps :
  1. Open terminal and type sudo nano etc/network/interface
  2. change dhcp to static and enter following:
address:inet
netmask:mask
network:destination address
broadcast:bcast address
SSH :
  1. Use of putty in windows
  2. use of remmina in Linux
RDP :
  1. Use of Remote Desktop connection in windows
  2. Use remmina in Linux

Friday, March 6, 2015

Raspbian pi os installation

1)Downloaded image file of OS  link
2) Make the bootable copy of OS on MicroSD card.
3) setting of username , password

Thursday, February 26, 2015

Components used


  1. MQ6 LPG Gas Sensor  Rs 268 
  2. Mechanical platform with Load cell RS 1995
  3. Sim 900 gsm module and usb2 to serial RS232  Rs 1498
  4. Rasbery Pi Rs 3299    
  5. MicroSD Memory Card Rs 372
  6. Comfast wireless adapter Rs 299
  7. Ptron Hdmi cable Rs 195
  8. 6 in 1 electric soldering kit  Rs 285
  9. Digital multimeter Rs 164.34