Thursday, April 23, 2015

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"






     


3 comments:

  1. hi can i get more specific instructions and photos as to how to connect the raspberry pi to both the amplifier and the load cell

    ReplyDelete
  2. I am using 5kg load cell. in my case "num" is always 0. any idea why it is ?

    ReplyDelete
  3. Thanks for sharing the valuable information about the weighbridge

    ReplyDelete