#!/usr/bin/python #g the MCP3008 analog input channels and printing # them all out. # Author: Tony DiCola # License: Public Domain import datetime import time import Adafruit_DHT import os from python_speech_features import mfcc import scipy.io.wavfile as wav # Import SPI library (for hardware SPI) and MCP3008 library. import Adafruit_GPIO.SPI as SPI import Adafruit_MCP3008 import RPi.GPIO as gp def main(): gp.setmode(gp.BCM) os.environ['PYTHON_EGG_CACHE'] = '/home/pi/Desktop/divya/records' # Sensor should be set to Adafruit_DHT.DHT11, # Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302. sensor = Adafruit_DHT.DHT22 # Example using a Raspberry Pi with DHT sensor # connected to GPIO23. pin = 23 # Software SPI configuration: CLK = 11 MISO = 9 MOSI = 10 CS = 8 mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI) # Sensor should be set to Adafruit_DHT.DHT11, # Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302. sensor = Adafruit_DHT.DHT22 # Example using a Raspberry Pi with DHT sensor # connected to GPIO23. pin = 23 # Software SPI configuration: CLK = 11 MISO = 9 MOSI = 10 CS = 8 mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI) #print('Reading MCP3008 values, press Ctrl-C to quit...') # Print nice channel column headers. #print('| {0:>4} | {1:>4} |'.format(*range(2))) #print('-' * 17) # Main program loop. # Read all the ADC channel values in a list. i=0 while(1): #time.sleep(8) values=[0]*2 values[0] = mcp.read_adc(0) i=i+1; if(values[0]>10): values=[0]*2 values[0] = mcp.read_adc(0) #for i in range(1,8): # The read_adc function will get the value of the specified channel ($ # values[i] = mcp.read_adc(i) # Print the ADC values values[1]=mcp.read_adc(1) # print('| {0:>4} | {1:>4} |'.format(*values)) # print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} $ # Try to grab a sensor reading. Use the read_retry method which wi$ # to 15 times to get a sensor reading (waiting 2 seconds between ea$ humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) # Note that sometimes you won't get a reading and # the results will be null (because Linux can't # guarantee the timing of calls to read the sensor). # If this happens try again! # if humidity is not None and temperature is not None: # print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity)) # else: # print('Failed to get reading. Try again!') date=datetime.datetime.now().date() time1=datetime.datetime.now().time() par1=str(values[0]) par2=str(values[1]) par3=str(temperature) par4=str(humidity) os.system("arecord -D plughw:1 -d 11 -t wav mon.wav") (rate,sig) = wav.read("/home/pi/mon.wav") mfcc_feat = mfcc(sig,rate) print("date=")+str(date) print("time=")+str(time1) print("Light Intensity=")+str(par2) print("Temperature=")+str(temperature) print("Humidity=")+str(humidity) print("MFCC=") print(mfcc_feat) # break # time.sleep(30) if __name__ == "__main__": main()