Example #1
0
# Create the light sensor object using AI2 pin 2
light = grove.GroveLight(2)

# Instantiate a UV sensor on analog pin A3
uv = upmUV.GUVAS12D(3);
# analog voltage, usually 3.3 or 5.0
GUVAS12D_AREF = 5.0;
SAMPLES_PER_QUERY = 1024;

# Create the temperature sensor object using AIO pin 0
i2c_th = th02.TH02()

#
p = Phant(keys["publicKey"],
          'device', 'temp', 'humidity', 'light', "uv", "moisture",
          private_key=keys["privateKey"])

device = open("/factory/serial_number").read().strip('\n')

temp = i2c_th.getTemperature()
humid = i2c_th.getHumidity()
lux_val = light.value()
uv_val = uv.value(GUVAS12D_AREF, SAMPLES_PER_QUERY)
moisture_val = moisture.value()

myLcd.setCursor(1, 0)
try:
    p.log(device, temp, humid, lux_val, uv_val, moisture_val)
except requests.exceptions.ConnectionError as e:
    print("Connection error with data.sparkfun.com")
Example #2
0
#    time.sleep(2)
#    print str(vis)
#    SI1145.SI1145_RESET
#    time.sleep(2)
#    sensor = SI1145.SI1145() #"/dev/i2c-1")
#    time.sleep(2)
#    vis = sensor.readVisible()
##------------------------ above is to initialize the si1145 at the rpi--------------------


#------------------------- below are definations for the sensors in the column ---------------------------------
field_name=['tpf0','tp11','tp8d','tpa3','mo0','mo1','mo2','mo3','mo4','mo5','mo6','mo7',
    'mo8','mo9','mo10','mo11','mo12','mo13','mo14','mo15','su1','tp1','su2','tp2','su3','tp3','su4','tp4','tphr45','tphr47']
#http://stackoverflow.com/questions/3869487/how-do-i-create-a-dictionary-with-keys-from-a-list-and-values-defaulting-to-say
parsed_data=dict((el,0.0) for el in field_name)
pht_sensor = Phant(publicKey=public_daisy_sensors, fields=field_name ,privateKey=private_daisy_sensors,baseUrl=nectar_address)

# 'All,Tp,F0,20.44,Tp,11,20.06,Tp,8D,20.25,Tp,A3,20.62,Mo,0,247.00,Mo,1,70.15,Mo,2,69.20,Mo,3,65.90,Mo,4,69.95,Mo,5,75.00,Mo,6,66.00,Mo,7,60.80,Mo,8,69.60,Mo,9,40.35,Mo,10,190.90,Mo,11,86.60,SuTp,113DECAGON MPS-2 124,-3661.3,20.0,SuTp,213DECAGON MPS-2 124,-2251.4,20.0,SuTp,313DECAGON MPS-2 350,-6885.3,19.9,SuTp,413DECAGON MPS-2 136,-3487.4,20.3,Vis,260,IR,253,UV,0.02,AllDone\r\n'

#port_weather = '/dev/ttyACM0'
port_sensor  = 'USB VID:PID=2341:0042 '

##------------------------- below is to initialize sensor result connect to new arduino
#[port_weather_isopen, weather_fid]=serial_openlock.open_port(port_weather)
#while port_weather_isopen == False:
#    [port_weather_isopen, weather_fid]=serial_openlock.open_port(port_weather)
#    time.sleep(60)
#serial_openlock.initialize(weather_fid)
#weather_fid.write("Weather") 
#msg_weather = weather_fid.readline()
#port_weather_isopen=serial_openlock.close_port(weather_fid)
Example #3
0
#si1145_sleep_interval_seconds=10;
#while vis == 0:
#    print 'si1145 init failed'
#    time.sleep(2)
#    print str(vis)
#    SI1145.SI1145_RESET
#    time.sleep(2)
#    sensor = SI1145.SI1145() #"/dev/i2c-1")
#    time.sleep(2)
#    vis = sensor.readVisible()
##------------------------ above is to initialize the si1145 at the rpi--------------------


field_name_weather=['aet','batt','dlyrainmm','ir_down','ir_up','lt','mo_soil','p','pet','rainmm','rh','tc','temp_soil','uv_down','uv_up','vis_down','vis_up','wddir','wddiravg2m','wdgstdir','wdgstdir10m','wdgstkph','wdgstkph10m','wdspdkph','wdspdkphavg2m','tp_box_45','tp_box_47','rh_box_45','rh_box_47','ip']
parsed_data_weather=dict((el,0.0) for el in field_name_weather)
pht_weather = Phant(publicKey=public_daisy_weather, fields=field_name_weather ,privateKey=private_daisy_weather,baseUrl=nectar_address)
port_weather = 'USB VID:PID=0403:6015'
#------------------------- below are definations for the weather station ---------------------------------

##------------------------- below is to initialize sensor result connect to new arduino
#[port_weather_isopen, weather_fid]=serial_openlock.open_port(port_weather)
#while port_weather_isopen == False:
#    [port_weather_isopen, weather_fid]=serial_openlock.open_port(port_weather)
#    time.sleep(60)
#serial_openlock.initialize(weather_fid)
#weather_fid.write("Weather") 
#msg_weather = weather_fid.readline()
#port_weather_isopen=serial_openlock.close_port(weather_fid)


Example #4
0
with open('/home/pi/script/pass/private_scales_partha', 'r') as myfile:
    private_scales_partha = myfile.read().replace('\n', '')

with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address = myfile.read().replace('\n', '')

field_name_scales_partha = [
    'scale1', 'scale2', 'scale3', 'scale4', 'scale5', 'scale6',
    'temperature_1', 'humidity_1', 'temperature_1', 'humidity_1',
    'temperature_2', 'humidity_2', 'temperature_3', 'humidity_3',
    'temperature_4', 'humidity_4', 'temperature_5', 'humidity_5',
    'temperature_6', 'humidity_6', 'temperature_7', 'humidity_7'
]

pht_scales_partha = Phant(publicKey=public_scales_partha,
                          fields=field_name_scales_partha,
                          privateKey=private_scales_partha,
                          baseUrl=nectar_address)

scales_partha = dict((el, 0.0) for el in field_name_scales_partha)

#-------------------below are preparation for the sensor arduino -----------

port_sensor = 'USB VID:PID=2341:0042 SNR=557363037393516030D1'
#port_sensor  = '/dev/ttyACM0'
port_scale1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.1:1.0-port0'
port_scale2 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.2:1.0-port0'
#port_scale3='/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-port0'
port_scale4 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.4.1:1.0-port0'
port_scale5 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.4.2:1.0-port0'
port_scale6 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.4.3:1.0-port0'
Example #5
0
import time
import numpy as np
import sys
from phant import Phant

import serial_openlock

field_name_area51 = [
    't_2896_begin', 't_2896_peak', 't_2896_end', 't_14_begin', 't_14_peak',
    't_14_end', 't_19_begin', 't_19_peak', 't_19_end', 'saltrh_2_t',
    'saltrh_2_rh', 'saltrh_11_t', 'saltrh_11_rh', 'mo_7', 'mo_8', 'mo_9',
    'mo_10', 'te', 'tas606', 'commercial', 'evap'
]

pht_area51 = Phant(publicKey='21mmonra90TYXlx9KL4J',
                   fields=field_name_area51,
                   privateKey='GZGGko8KJWtKaoAYNe5b')

parsed_data_area51 = dict((el, 0.0) for el in field_name_area51)

#-------------------below are preparation for the sensor arduino -----------
port_sensors = 'USB VID:PID=0403:6015 SNR=DN01JJDJ'
#'All,SucHeat,2896,Heating,21.81,21.81,21.94,22.00,22.12,22.25,22.31,22.44,22.50,22.62,22.69,22.75,22.81,22.94,22.94,23.00,23.06,23.12,23.19,23.25,23.31,Dsping,23.31,23.31,23.25,23.19,23.12,23.00,22.94,22.87,22.75,22.75,22.69,22.62,22.56,22.50,22.50,22.44,22.44,22.37,22.37,22.31,22.31,SucHeat,14,Heating,25.68,41.80,42.77,43.26,43.75,44.24,44.73,45.70,45.70,46.19,50.10,46.68,47.17,47.66,47.66,48.14,48.14,48.14,48.63,48.63,48.63,Dsping,32.03,31.05,30.57,30.08,30.08,29.59,29.10,29.10,28.61,28.61,28.12,28.12,27.64,27.64,27.64,27.64,27.64,27.15,27.15,27.15,27.15,SucHeat,19,Heating,26.17,38.38,38.38,38.87,38.87,39.36,40.33,40.33,40.82,41.31,41.31,41.80,41.80,42.29,42.29,42.77,43.26,43.26,43.75,43.75,44.24,Dsping,30.57,30.08,29.59,29.59,29.10,29.10,28.61,28.61,28.12,28.12,28.12,28.12,27.64,27.15,27.15,27.15,27.15,26.66,26.66,26.66,26.66,SaltRH,11,21.50,99.90,SaltRH,2,22.30,96.20,Mo,7,341.86,Mo,8,402.00,Mo,9,319.29,Mo,10,344.00,AllDone\r\n'
#'All,SucHeat,2896,Heating,21.81,21.87,21.94,22.06,22.19,22.31,22.37,22.50,22.56,22.69,22.75,22.81,22.87,22.94,23.06,23.06,23.12,23.19,23.25,23.25,23.31,Dsping,23.37,23.31,23.31,23.19,23.12,23.06,23.00,22.87,22.81,22.75,22.75,22.62,22.62,22.56,22.50,22.44,22.44,22.37,22.37,22.31,22.31,SucHeat,14,Heating,25.68,42.29,42.77,43.26,43.75,44.24,45.21,45.70,45.70,46.19,46.68,46.68,47.66,47.66,47.66,48.14,48.14,48.63,48.63,49.12,49.12,Dsping,31.54,31.05,30.57,30.57,30.08,29.59,29.59,29.10,28.61,28.61,28.12,28.12,28.12,27.64,27.64,27.64,27.15,27.15,27.64,27.15,27.15,SucHeat,19,Heating,25.20,38.38,38.38,38.38,39.36,39.36,39.84,40.33,40.82,40.82,41.31,41.80,41.80,42.29,42.77,42.77,43.26,43.26,43.75,43.75,44.24,Dsping,30.08,29.59,29.59,29.59,29.10,29.10,28.61,28.61,28.12,28.12,27.64,27.64,27.64,27.64,27.15,27.15,27.15,26.66,26.66,26.66,26.66,SaltRH,11,21.50,99.90,SaltRH,2,22.30,96.50,Mo,7,338.71,Mo,8,404.00,Mo,9,318.43,Mo,10,344.43,AllDone\r\n'

# makesure the salinity sensor are well initialized
serial_openlock.get_result_by_input(port=port_sensors, command="SoilSalinity")
time.sleep(3)
serial_openlock.get_result_by_input(port=port_sensors, command="SoilSalinity")
time.sleep(3)
Example #6
0
from gpiozero import Button
from phant import Phant
from upload_phant import upload_phant
import time
from time import sleep,localtime,strftime
import paho.mqtt.client as mqtt
import json

with open('/home/pi/pyduino/credential/salt_marsh_weather.json') as f:
        credential = json.load(f)

field_name=["salt_marsh_rain","salt_marsh_wind","tmp1","tmp2"]
salt_marsh_weather=dict((el,0.0) for el in field_name)

pht_salt_marsh_weather = Phant(publicKey=credential['public_salt_marsh_weather'],
                                       fields=field_name,
                                       privateKey=credential['private_salt_marsh_weather'],
                                       baseUrl=credential['nectar_address'])

class UQ_RainFall:
    '''
    UQ_RainFall class, set up a bucket pin with approprisate debouncing time (time required for
    a tipping duration to be register), name, volume of each tip and debug flag
    Requires to run config after initialisation to allow automatic counting
    '''
    def __init__(self, pin = 2, debounce = 0.05, name = "Bucket 1" , volume = 0.2794, debug = True):
        #base on the Button class of gpiozero, pull_up = True means the reading pin default state is
        #high, so connect one pin to GND and one pin to the reading pin
        self.sensor_pin = Button(pin, pull_up = True, bounce_time = debounce)
        self.name = name
        self.debug = debug
        self.count = 0
Example #7
0
public_pizo_pre = csv_tools.get_one_line(pyduino_credential_path +
                                         'public_pizo_pre')
private_pizo_pre = csv_tools.get_one_line(pyduino_credential_path +
                                          'private_pizo_pre')
nectar_address = csv_tools.get_one_line(pyduino_credential_path +
                                        'nectar_address')

field_name = [
    'dp0', 'hum0', 'pre0', 'pre1', 'pre2', 'pre3', 'pre4', 'pretmp0',
    'pretmp1', 'pretmp2', 'pretmp3', 'pretmp4', 'timestamp', 'tmp0', 'tmp1',
    'tmp10', 'tmp11', 'tmp12', 'tmp2', 'tmp3', 'tmp4', 'tmp5', 'tmp6', 'tmp7',
    'tmp8', 'tmp9', 'volt0'
]
pizo_pre = dict((el, 0.0) for el in field_name)
pht_pizo_pre = Phant(publicKey=public_pizo_pre,
                     fields=field_name,
                     privateKey=private_pizo_pre,
                     baseUrl=nectar_address)

# whether the result will be displayed on the screen
screen_display = True

# whether save the result as a file
save_to_file = True

# the delimiter between files, it is prefered to use ',' which is standard for csv file
delimiter = ','

__author__ = 'chenming'

file_name_gelita_1 = pyduino_data_path + 'gelita_borehole'
fn_gelita = open(file_name_gelita_1, 'r')
Example #8
0
import sys
from phant import Phant
from twilio.rest import TwilioRestClient
from time import sleep

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = ""
auth_token = ""
client = TwilioRestClient(account_sid, auth_token)

p = Phant(public_key='q5JMKnDJKXCMnjbYr0lG', fields=['temp'], private_key='')

while (True):
    data = p.get()
    print("Latest Loudness Value is: {}".format(data[0]['temp']))
    if float(data[0]['temp']) > 1500:
        message = client.messages.create(
            body="Loudness: {0}\nD313 Room is making noise, please take action"
            .format(data[0]['temp']),
            to="+919650055244",  # Replace with your phone number
            from_="+12018905183")  # Replace with your Twilio number
        print(message.sid)
    sleep(15)
Example #9
0
    credential = json.load(f)

field_name = [
    'scale1', 'scale2', 'scale3', 'raw1', 'raw2', 'raw3', 'raw4', 'raw5',
    'raw6', 'ec1', 'ec2', 'ec3', 'ec4', 'ec5', 'ec6', 'dp1', 'dp2', 'dp3',
    'dp4', 'dp5', 'dp6', 'mo1', 'mo2', 'mo3', 'mo4', 'mo5', 'mo6',
    'sht33_temp_1', 'sht33_temp_2', 'sht33_temp_3', 'sht33_temp_4',
    'sht33_temp_5', 'sht33_temp_6', 'sht33_temp_7', 'sht33_humidity_1',
    'sht33_humidity_2', 'sht33_humidity_3', 'sht33_humidity_4',
    'sht33_humidity_5', 'sht33_humidity_6', 'sht33_humidity_7'
]

kathy_portbris_enclosure_1 = dict((el, 0.0) for el in field_name)
pht_kathy_portbris_enclosure_1 = Phant(
    publicKey=credential['public_kathy_portbris_enclosure_1'],
    fields=field_name,
    privateKey=credential['private_kathy_portbris_enclosure_1'],
    baseUrl=credential['nectar_address'])
try:
    client = mqtt.Client()
    client.username_pw_set(credential['access_token'])
    client.connect(credential['thingsboard_host'], 1883, 60)
    client.loop_start()
except Exception:
    print("Failed to connect to thingsboard")
    time.sleep(30)

try:
    while True:
        ard = serial.Serial(SERIAL_PORT, timeout=60)
        time.sleep(5)
Example #10
0
with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address = myfile.read().replace('\n', '')

#with open('/home/pi/script/pass/cmd_area51_taking_photo', 'r') as myfile:
#   cmd_area51_taking_photo=myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'mo0', 'mo1', 'mo2', 'mo3', 'tempa0', 'tempa1', 'tempa2', 'tempa3',
    'tempb0', 'tempb1', 'tempb2', 'tempb3', 'su0', 'su1', 'su2', 'su3',
    'scale1', 'tmp0', 'tmp1', 'tmp2', 'tmp3'
]
amphiroll_tank1 = dict((el, 0.0) for el in field_name)
pht_amphiroll_tank1 = Phant(publicKey=public_amphiroll_tank1,
                            fields=field_name,
                            privateKey=private_amphiroll_tank1,
                            baseUrl=nectar_address)

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'mo4', 'mo5', 'mo6', 'mo7', 'tempa4', 'tempa5', 'tempa6', 'tempa7',
    'tempb4', 'tempb5', 'tempb6', 'tempb7', 'su4', 'su5', 'su6', 'su7',
    'scale2', 'tmp4', 'tmp5', 'tmp6', 'tmp7'
]
amphiroll_tank2 = dict((el, 0.0) for el in field_name)
pht_amphiroll_tank2 = Phant(publicKey=public_amphiroll_tank2,
                            fields=field_name,
                            privateKey=private_amphiroll_tank2,
                            baseUrl=nectar_address)

#------------------------- below are definations for the sensors in the column ---------------------------------
Example #11
0
#!/usr/bin/python
import serial
import time
import numpy as np
import sys
from phant import Phant

# column for baoping
field_name = [
    'tp2', 'tp12', 'tp32', 'tp8a', 'tp21', 'tpe5', 'tp35', 'tpa3', 'tp4b',
    'tpc7', 'tp9f', 'mo0', 'mo1', 'mo2', 'mo3', 'mo4', 'mo5', 'mo6', 'mo7',
    'mo8', 'mo9', 'mo10', 'mo11', 'ht115rh', 'ht115t', 'ht119rh', 'ht119t',
    'scale'
]
pht = Phant(publicKey='8dojwRmX3jh0GDV99MlZ',
            fields=field_name,
            privateKey='pzNd8BXKPdHnAyYdda24')

#field_name=['Tp2','Tp12','Tp32','Tp8A','Tp21','TpE5','Tp35','TpA3','Tp4B','TpC7','Tp9F','Mo0',
#    'Mo1','Mo2','Mo3','Mo4','Mo5','Mo6','Mo7','Mo8','Mo9','Mo10','Mo11','ht1126rh','ht1126t','ht1127rh','ht1127t']

parsed_data = {
    'tp2': 0.0,
    'tp12': 0.0,
    'tp32': 0.0,
    'tp8a': 0.0,
    'tp21': 0.0,
    'tpe5': 0.0,
    'tp35': 0.0,
    'tpa3': 0.0,
    'tp4b': 0.0,
Example #12
0
with open('/home/pi/script/pass/private_grange_5_luo2_wet', 'r') as myfile:
    private_grange_5_luo2_wet = myfile.read().replace('\n', '')

with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address = myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'mo0', 'mo1', 'mo2', 'mo3', 'mo4', 'mo5', 'mo6', 'mo7', 'su0', 'su1',
    'su2', 'su3', 'su4', 'su5', 'su6', 'su7', 'tmp0', 'tmp1', 'tmp2', 'tmp3',
    'tmp4', 'tmp5', 'tmp6', 'tmp7', 'dluo7', 'dlupe7', 'dlup7', 'wluo7',
    'wlupe7', 'wlup7'
]
grange_5_mo_su = dict((el, 0.0) for el in field_name)
pht_grange_5_mo_su = Phant(publicKey=public_grange_5_mo_su,
                           fields=field_name,
                           privateKey=private_grange_5_mo_su,
                           baseUrl=nectar_address)

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'dluo0', 'dlupe0', 'dlut0', 'dlup0', 'dluo1', 'dlupe1', 'dlut1', 'dlup1',
    'dluo2', 'dlupe2', 'dlut2', 'dlup2', 'dluo3', 'dlupe3', 'dlut3', 'dlup3',
    'dluo4', 'dlupe4', 'dlut4', 'dlup4', 'dluo5', 'dlupe5', 'dlut5', 'dlup5',
    'dluo6', 'dlupe6', 'dlut6', 'dlup6', 'rh', 'temp'
]
grange_5_luo2_dry = dict((el, 0.0) for el in field_name)
pht_grange_5_luo2_dry = Phant(publicKey=public_grange_5_luo2_dry,
                              fields=field_name,
                              privateKey=private_grange_5_luo2_dry,
                              baseUrl=nectar_address)
#!/usr/bin/env python3

from w1thermsensor import W1ThermSensor
from gpiozero import LightSensor
from phant import Phant
from time import sleep
from keys import PHANT_PUBLIC_KEY, PHANT_PRIVATE_KEY

tempSensor = W1ThermSensor()
lightSensor = LightSensor(18, charge_time_limit=0.05)

p = Phant(PHANT_PUBLIC_KEY, 'light', 'temp', 'location', private_key=PHANT_PRIVATE_KEY)

location = 'vs'

while True:

    temperature = tempSensor.get_temperature(W1ThermSensor.DEGREES_F)

    light = lightSensor.value

    print ('Light: %0.2f, Temperature %0.2f' % (light, temperature))

    try:
        p.log(light, temperature, location)
    except:
        print ('Error sending data to the server')

    sleep(10)
Example #14
0
#!/usr/bin/python
import serial
import time
import numpy as np
import sys
from phant import Phant

field_name = ['tas606', 'te', 'measure_local_time']

pht = Phant(publicKey='KJo3Nx8grJcMDpEWQOXg',
            fields=field_name,
            privateKey='vzVe5AZkyzcdvlKWG741')

parsed_data = {
    'tas606': 0.0,
    'te': 0.0,
    'measure_local_time': ''
}

### --------------------------input section ---------------------------
# the port arduino has been connected to. in windows, it is usually 'COM4, COM5' where
#   the number is subject to change. Just try 'devmgmt.msc' after pressing ctrl+r.
# In linux it is usually /dev/ttyUSB
#  below are the ls /dev/serial/by-id result:
#lrwxrwxrwx 1 root root 13 Feb  8 11:13 usb-FTDI_FT231X_USB_UART_DN01J0QE-if00-port0 -> ../../ttyUSB1
#lrwxrwxrwx 1 root root 13 Feb  8 11:13 usb-FTDI_FT231X_USB_UART_DN01JJDJ-if00-port0 -> ../../ttyUSB0
#lrwxrwxrwx 1 root root 13 Feb  8 11:13 usb-FTDI_USB__-__Serial-if00-port0 -> ../../ttyUSB2

#port = '/dev/ttyUSB1'  # USB1 is for all the EC 5 moisture sensors
port = '/dev/serial/by-id/usb-FTDI_FT231X_USB_UART_DN01J0QE-if00-port0'  # USB1 is for all the EC 5 moisture sensors
Example #15
0
import bme280
import time
from phant import Phant

p = Phant(publicKey='WGglMj2LaoCYmGynvnlQ',
          fields=['temperature', 'pressure', 'humidity'],
          privateKey='XR6X1MA9ZDurW0j8b8aR')

while True:
    temperature, pressure, humidity = bme280.readBME280All()
    temperature = round(temperature, 2)
    pressure = round(pressure, 2)
    humidity = round(humidity, 2)
    p.log(temperature, pressure, humidity)
    print temperature, pressure, humidity
    time.sleep(10)
Example #16
0
with open('/home/pi/script/pass/private_aster', 'r') as myfile:
    private_aster = myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name_aster = [
    'mo22', 'mo23', 'mo24', 'mo25', 'mo26', 'mo27', 'mo28', 'mo29', 'mo30',
    'mo31', 'temp1', 'temp2', 'temp3', 'temp4', 'temp5', 'temp6', 'temp7',
    'temp8', 'suction1', 'suction2', 'suction3', 'suction4', 'suction5',
    'suction6', 'suction7', 'suction8', 'evap1', 'ip', 'evap2', 'ip2'
]

#http://stackoverflow.com/questions/3869487/how-do-i-create-a-dictionary-with-keys-from-a-list-and-values-defaulting-to-say
parsed_data_aster = dict((el, 0.0) for el in field_name_aster)
pht_aster = Phant(publicKey=public_aster,
                  fields=field_name_aster,
                  privateKey=private_aster)
port_aster = 'USB VID:PID=2341:0042 SNR=5533'

#------------------------- above are definations for the sensors in the column ---------------------------------
#field_name_weather=['aet','batt','dlyrainmm','ir_down','ir_up','lt','mo_soil','p','pet','rainmm','rh','tc','temp_soil',
#    'uv_down','uv_up','vis_down','vis_up','wddir','wddiravg2m','wdgstdir','wdgstdir10m','wdgstkph','wdgstkph10m','wdspdkph','wdspdkphavg2m']
#parsed_data_weather=dict((el,0.0) for el in field_name_weather)
#pht_weather = Phant(publicKey='v0NOoW7RLRU3gYpAGdKW', fields=field_name_weather ,privateKey='aP9dMkmbzbiP2RkmJXNw')
#port_weather = 'USB VID:PID=2341:0042'
##------------------------- below are definations for the weather station ---------------------------------

# whether the result will be displayed on the screen
screen_display = True

# whether save the result as a file
Example #17
0
with open('/home/pi/script/pass/public_scales_kathy', 'r') as myfile:
    public_scales_kathy = myfile.read().replace('\n', '')

with open('/home/pi/script/pass/private_scales_kathy', 'r') as myfile:
    private_scales_kathy = myfile.read().replace('\n', '')

with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address = myfile.read().replace('\n', '')

#------------------------- below are definations for the scales ---------------------------------
field_name = ['scale1', 'scale2', 'scale3']

scales_kathy = dict((el, 0.0) for el in field_name)
pht_scales_kathy = Phant(publicKey=public_scales_kathy,
                         fields=field_name,
                         privateKey=private_scales_kathy,
                         baseUrl=nectar_address)

#port_sensor  = 'USB VID:PID=2341:0042 SNR=557363037393516030D1'
port_scale1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0'
port_scale2 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0-port0'

scale1 = serial.Serial(port_scale1, timeout=20)
scale2 = serial.Serial(port_scale2, timeout=20)
#scale3 = serial.Serial(port_scale3,timeout=20)

scale1.write('IP\n\r')
scale2.write('IP\n\r')
#scale3.write('IP\n\r')

time.sleep(2)
Example #18
0
with open('/home/pi/script/pass/public_bougainvillea', 'r') as myfile:
    public_bougainvillea=myfile.read().replace('\n', '')

with open('/home/pi/script/pass/private_bougainvillea', 'r') as myfile:
    private_bougainvillea=myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name_bougainvillea=['mo0','mo1','mo2','mo3','mo4','mo5','mo6','mo7','mo8','mo9',
    'temp1','temp2','temp3','temp4','temp5','temp6','temp7','temp8','suction1',
    'suction2','suction3','suction4','suction5','suction6','suction7','suction8','evap1','ip','evap2','ip2']


#http://stackoverflow.com/questions/3869487/how-do-i-create-a-dictionary-with-keys-from-a-list-and-values-defaulting-to-say
parsed_data_bougainvillea=dict((el,0.0) for el in field_name_bougainvillea)
pht_bougainvillea = Phant(publicKey=public_bougainvillea, fields=field_name_bougainvillea ,privateKey=private_bougainvillea)
port_bougainvillea = 'USB VID:PID=2a03:0057 SNR=5563'



# whether the result will be displayed on the screen
screen_display=True

# whether save the result as a file 
save_to_file=True

# the Filename of the csv file for storing file
file_name= 'column_bougainvillea.csv'

#sleep_time_seconds=20*60  # this ends up with 49 min interval
sleep_time_seconds=30*60  # this ends up with 49 min interval
Example #19
0
# How seldom to upload the sensor data, if LOGGING is on
COUNT_INTERVAL = FREQUENCY_SECONDS / MEASUREMENT_INTERVAL

# Create sensor instance with default I2C bus (On Raspberry Pi either 0 or
# 1 based on the revision, on Beaglebone Black default to 1).
bmp = BMP085.BMP085(mode=BMP085.BMP085_HIGHRES, address=0x77)

# Initialize a LED display
#segment = SevenSegment(address=0x70)
segment = SevenSegment(address=0x71)
print segment

# Read in Phant config
json_keys_file2 = 'data.crookster.org.json'
p2 = Phant(jsonPath=json_keys_file2)

print 'Logging sensor measurements taken every {2} seconds to "{0}" every {1} seconds.'.format(
    p2.title, FREQUENCY_SECONDS, MEASUREMENT_INTERVAL)
print p2
print 'Press Ctrl-C to quit.'

while True:

    error_tables = {}

    try:

        # Attempt to get sensor readings.
        temp = bmp.read_temperature()
        pressure = bmp.read_pressure()
Example #20
0
    private_kathy_tensiometer=myfile.read().replace('\n', '')

with open('/home/pi/script/pass/access_token', 'r') as myfile:
    access_token=myfile.read().replace('\n', '')
#
with open('/home/pi/script/pass/thingsboard_host', 'r') as myfile:
    thingsboard_host=myfile.read().replace('\n', '')

with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address=myfile.read().replace('\n', '')



field_name=['pressure1','pressure2','temp1_tensiometer','temp2_tensiometer','temp1_humsensor','temp2_humsensor','temp3_humsensor','temp4_humsensor','temp5_humsensor','temp6_humsensor','humidity1','humidity2','humidity3','humidity4','humidity5','humidity6','dhthum','dhttemp','scale1','scale2','scale3']
kathy_tensiometer=dict((el,0.0) for el in field_name)
pht_sensor = Phant(publicKey=public_kathy_tensiometer, fields=field_name ,privateKey=private_kathy_tensiometer,baseUrl=nectar_address)


#port_sensor  = 'USB VID:PID=2341:0042 SNR=55639303035351A04171'
#port_sensor = '/dev/ttyACM0'  # remember when using device at /dev/folder rather than USB VID:PID, serial_openlock needs to have match_existing=False
#port_sensor0 = '/dev/ttyUSB0' # port for serial connection 
#port_sensor1 = '/dev/ttyUSB4'
port_sensor0 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0'
port_sensor1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0'
port_sensor2  = '/dev/ttyACM0'
port_scale1='/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5.2:1.0-port0'
port_scale2='/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5.3:1.0-port0'
port_scale3='/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5.4:1.0-port0'

scale1 = serial.Serial(port_scale1,timeout=20)
scale2 = serial.Serial(port_scale2,timeout=20)
Example #21
0
#!/usr/bin/python
import serial
import time
import numpy as np
import sys
from phant import Phant

# 

field_name=['suht_28e5_begin','suht_28e5_peak','suht_28e5_end','suht_2847_begin','suht_2847_peak','suht_2847_end',
    'saltrh_2_tp','saltrh_2_rh','saltrh_3_tp','saltrh_3_rh','mo_7','mo_8','mo_9','mo_10']

pht = Phant(publicKey='9J2rX3QZ94s5RJ9LjrbN', 
    fields=field_name ,privateKey='xz6exl8ypjCAvaK6W4PB')

parsed_data={'suht_28e5_begin':0.0,
    'suht_28e5_peak':0.0,
    'suht_28e5_end':0.0,
    'suht_2847_begin':0.0,
    'suht_2847_peak':0.0,
    'suht_2847_end':0.0,
    'saltrh_2_tp':0.0,
    'saltrh_2_rh':0.0,
    'saltrh_3_tp':0.0,
    'saltrh_3_rh':0.0,
    'mo_7':0.0,
    'mo_8':0.0,
    'mo_9':0.0,
    'mo_10':0.0};

Example #22
0
#!/usr/bin/python

import sys
import os
import Adafruit_DHT
#import xively
from phant import Phant
from numerous import Numerous


phant_id = os.environ["PHANT_ID"]
phant_key = os.environ["PHANT_KEY"]
p = Phant(phant_id, 'humidity', 'tempc', 'tempf', private_key=phant_key)

# Numerous variables, sourced from external script
n_key = os.environ["NUMEROUS_KEY"]
n_humidity1 = os.environ["NUMEROUS_HUMIDITY1"]
n_temp_f1 = os.environ["NUMEROUS_TEMP_F1"]

mynumerous = Numerous(apiKey=n_key)
h1 = mynumerous.metric(n_humidity1)
tf1 = mynumerous.metric(n_temp_f1)

# Parse command line parameters.
sensor_args = { '11': Adafruit_DHT.DHT11,
				'22': Adafruit_DHT.DHT22,
				'2302': Adafruit_DHT.AM2302 }
if len(sys.argv) == 3 and sys.argv[1] in sensor_args:
	sensor = sensor_args[sys.argv[1]]
	pin = sys.argv[2]
else:
Example #23
0
#
#with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
#    nectar_address=myfile.read().replace('\n', '')

with open('/home/pi/pyduino/credential/scale_habib.json') as f:
    credential = json.load(f)  #,object_pairs_hook=collections.OrderedDict)

#------------------------- below are definations for the scales ---------------------------------
field_name = [
    'scale1', 'scale2', 'scale3', 'scale4', 'scale5', 'scale6', 'pressure1',
    'pressure2', 'temperature1', 'temperature2'
]

scales_habib = dict((el, 0.0) for el in field_name)
pht_scales_habib = Phant(publicKey=credential['public_scales_habib'],
                         fields=field_name,
                         privateKey=credential['private_scales_habib'],
                         baseUrl=credential['nectar_address'])

#port_sensor  = 'USB VID:PID=2341:0042 SNR=557363037393516030D1'
port_scale1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4.1.4:1.0-port0'
port_scale2 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4.1.3:1.0-port0'
port_scale3 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4.1.2:1.0-port0'
port_scale4 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4.4:1.0-port0'
port_scale5 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4.3:1.0-port0'
port_scale6 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4.2:1.0-port0'
port_sensor1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0'
port_sensor2 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0'

scale1 = serial.Serial(port_scale1,
                       baudrate=2400,
                       bytesize=7,
Example #24
0
    'mo7': 0.0,
    'mo8': 0.0,
    'mo9': 0.0,
    'mo10': 0.0,
    'mo11': 0.0,
    'su1': 0.0,
    'tp1': 0.0,
    'su2': 0.0,
    'tp2': 0.0,
    'su3': 0.0,
    'tp3': 0.0,
    'su4': 0.0,
    'tp4': 0.0
}
pht = Phant(publicKey='RMxqjA6nRXfbm01raooM',
            fields=field_name,
            privateKey='lzEpXb5dxRhYAbG6177V')
#    fields=['TpF0','Tp11','Tp8D','TpA3','Mo0','Mo1','Mo2','Mo3','Mo4','Mo5','Mo6','Mo7',
#    'Mo8','Mo9','Mo10','Mo11','Su1','Tp1','Su2','Tp2','Su3','Tp3','Su4','Tp4']

#TpF0,Tp11,Tp8D,TpA3,Mo0,Mo1,Mo2,Mo3,Mo4,Mo5,Mo6,Mo7,Mo8,Mo9,Mo10,Mo11,Su1,Tp1,Su2,Tp2,Su3,Tp3,Su4,Tp4,

#Soil,Tp,F0,25.62,Tp,11,25.81,Tp,8D,25.75,Tp,A3,26.56,Mo,0,423.45,Mo,1,220.70,Mo,2,224.00,Mo,3,224.70,Mo,4,227.00,Mo,5,226.10,Mo,6,204.35,Mo,7,200.00,Mo,8,213.00,Mo,9,207.00,Mo,10,240.05,Mo,11,325.55,SuTp,113DECAGON MPS-2 124,-4.6,26.5,SuTp,213DECAGON MPS-2 124,-4.7,26.6,SuTp,313DECAGON MPS-2 350,-9.7,26.4,SuTp,413DECAGON MPS-2 136,-10.0,26.8,
# this script reads off from arduino on the go.
# it is currently confirmed that arduino behaves similarly as all the scale sensors
# 1. having internal buffers
# 2. Being able to use simple serial interface to communicate with
# currently it is decided to use the time in raspberry pi/PC to record the time that
#    data collected by arduino for two reasons:
# 1. it is not known how much arduino time will be derivated over time.
# 2. raspberry pi has internet connected and so has time well syncronized.
Example #25
0
#    vis = sensor.readVisible()
###------------------------ above is to initialize the si1145 at the rpi--------------------


#------------------------- below are definations for the sensors in the column ---------------------------------
field_name_sensor=['mo0','mo1','mo2','mo3','mo4','mo5','mo6','mo7','mo8','mo9',
    'mo10','mo11','mo12','mo13','mo14','mo15',
    't26_begin','t26_peak','te2_begin','te2_peak','t45_begin','t45_peak',
    't57_begin','t57_peak','tfb_begin','tfb_peak','t7b_begin','t7b_peak','ip','evap']


#'All,Mo,0,482.00,Mo,1,330.00,Mo,2,305.86,Mo,3,617.29,Mo,4,327.57,Mo,5,859.86,Mo,6,650.71,Mo,7,341.00,Mo,8,368.00,Mo,9,322.86,Mo,10,484.14,Mo,11,380.43,Mo,12,701.43,Mo,13,578.86,Mo,14,695.86,Mo,15,13.00,Vis,260.43,IR,252.71,UV,2.14,Vis,260.57,IR,253.00,UV,2.00,SucHeat,E2,Heating,15.94,15.94,15.88,15.94,16.00,16.12,16.25,16.37,16.56,16.62,16.81,16.94,17.06,17.25,17.25,Dsping,17.31,17.31,17.31,17.25,17.19,17.12,17.06,17.00,16.94,16.94,16.87,SucHeat,26,Heating,13.94,13.94,13.81,13.88,13.94,14.06,14.19,14.31,14.44,14.56,14.69,14.81,14.94,15.13,15.19,Dsping,15.25,15.25,15.25,15.25,15.19,15.13,15.06,15.00,14.94,14.94,14.88,SucHeat,7B,Heating,19.25,19.25,19.19,19.25,19.31,19.37,19.50,19.62,19.75,19.81,19.94,20.06,20.19,20.31,20.31,Dsping,20.37,20.44,20.37,20.37,20.31,20.25,20.25,20.19,20.12,20.12,20.06,SucHeat,FB,Heating,18.06,18.06,18.00,18.06,18.12,18.31,18.50,18.69,18.81,19.00,19.19,19.31,19.44,19.62,19.75,Dsping,19.75,19.75,19.69,19.62,19.56,19.50,19.37,19.31,19.25,19.19,19.12,SucHeat,45,Heating,16.25,16.25,-0.25,-0.25,-0.25,-0.25,-0.06,-0.25,-0.25,-0.25,-0.25,-0.06,-0.25,17.75,17.81,Dsping,17.87,17.87,17.87,17.81,17.75,17.69,17.62,17.50,17.44,17.37,17.31,SucHeat,57,Heating,17.37,17.37,-0.25,-0.25,-0.25,-0.25,-0.25,-0.25,-0.25,-0.25,-0.25,-0.25,-0.25,18.62,18.69,Dsping,18.75,18.81,18.75,18.69,18.69,18.62,18.50,18.44,18.44,18.37,18.31,SaltRH,6,16.00,38.10,16.00,39.10,SaltRH,7,16.70,34.10,16.70,35.10,AllDone\r\n'

#http://stackoverflow.com/questions/3869487/how-do-i-create-a-dictionary-with-keys-from-a-list-and-values-defaulting-to-say
parsed_data_sensor=dict((el,0.0) for el in field_name_sensor)
pht_sensor = Phant(publicKey=public_camellia_sensors, fields=field_name_sensor ,privateKey=private_camellia_sensors,baseUrl=nectar_address)
port_sensor  = 'USB VID:PID=2341:0010 SNR=55639313533351318031'


# whether the result will be displayed on the screen
screen_display=True

# whether save the result as a file 
save_to_file=True

# the Filename of the csv file for storing file
file_name= 'column_camellias_sensor_nectar.csv'

#sleep_time_seconds=20*60  # this ends up with 49 min interval
sleep_time_seconds=10*60  # this ends up with 49 min interval
Example #26
0
# this script records scale readings from adam gfk 600
import serial
import time
import numpy as np
import sys
from phant import Phant
ser = serial.Serial('/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0')

no_of_readings=60000  # totally how many readings will be done
sleep_time_seconds=300 # the interval of neighbouring reading


field_name=['commercial','nvl','ohaus','measure_local_time'];

pht = Phant(publicKey='7Jlzv3bb9vhZ4LLd9Waj', 
    fields=field_name ,privateKey='mz4rqWGGoqHjeYYaB9Nn')

parsed_data={'commercial':0.0,'nvl':0.0,'ohaus':0.0,'measure_local_time':''};


# the Filename of the csv file for storing file
file_name= 'rs232_ohaus_nvl20000_phant.csv'

save_to_file=True
screen_display=True
#temp=["" for x in range(no_of_readings)]
#reading_scale=["" for x in range(no_of_readings)]
#reading_time =["" for x in range(no_of_readings)]

__author__ = 'chenming'
Example #27
0
    public_grange_b_luo2=myfile.read().replace('\n', '')

with open('/home/pi/script/pass/private_grange_b_luo2', 'r') as myfile:
    private_grange_b_luo2=myfile.read().replace('\n', '')
with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address=myfile.read().replace('\n', '')

#time.sleep(10*60)

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name=['mo0','mo1','mo2','mo3','mo4','mo5','mo6','mo7',
    'su0','su1','su2','su3','su4','su5','su6','su7',
    'tmp0','tmp1','tmp2','tmp3','tmp4','tmp5','tmp6','tmp7',
    's2','s3','s4','s5','s6','s7']
parsed_data=dict((el,0.0) for el in field_name)
pht_sensor = Phant(publicKey=public_grange_b_moisture_suction, fields=field_name ,privateKey=private_grange_b_moisture_suction,baseUrl=nectar_address)



#------------------------- below are definations for the sensors in the column ---------------------------------
field_name=['dtp0','dtp1','dtp3','dtp5','dtp6','dtp7',
            'dox0','dox1','dox3','dox5','dox6','dox7',
            'drh0','drh1','drh3','drh5','drh6','drh7',
            'wtp0','wtp1','wtp2','wtp3','wtp4','wtp7',
            'wox0','wox1','wox2','wox3','wox4','wox7']
ele_o2=dict((el,0.0) for el in field_name)
pht_ele_o2 = Phant(publicKey=public_grange_b_electrochem_o2, fields=field_name ,privateKey=private_grange_b_electrochem_o2,baseUrl=nectar_address)



#------------------------- below are definations for the sensors in the column ---------------------------------
Example #28
0
    cmd_area51_taking_photo_basin = myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'moa1', 'moa2', 'moa3', 'mob1', 'mob2', 'mob3', 'moc1', 'moc2', 'moc3',
    'sua1', 'sua2', 'sua3', 'sub1', 'sub2', 'sub3', 'suc1', 'suc2', 'suc3',
    'tempa1_a', 'tempa2_a', 'tempa3_a', 'tempb1_a', 'tempb2_a', 'tempb3_a',
    'tempa1_b', 'tempa2_b', 'tempa3_b', 'tempb1_b', 'tempb2_b', 'tempb3_b',
    'tempc1_a', 'tempc2_a', 'tempc3_a', 'tempc1_b', 'tempc2_b', 'tempc3_b',
    'temp_dht22', 'tmp1', 'tmp2', 'tmp3', 'tmp4', 'tmp5', 'tmp6', 'tmp7',
    'tmp8', 'hum_dht22', 'scale1', 'scale2', 'scale3'
]
basin_test_wenqiang_mo_su = dict((el, 0.0) for el in field_name)
pht_basin_test_wenqiang_mo_su = Phant(
    publicKey=credential['public_basin_test_wenqiang_mo_su'],
    fields=field_name,
    privateKey=credential['private_basin_test_wenqiang_mo_su'],
    baseUrl=credential['nectar_address'])
#pht_basin_test_wenqiang_mo_su= Phant(publicKey=public_basin_test_wenqiang_mo_su, fields=field_name ,privateKey=private_basin_test_wenqiang_mo_su,baseUrl=nectar_address)

#------------------------- below are definations for the sensors in the column ---------------------------------
#field_name=['tmp3','tmp4','tmp5','tmp6','tmp7','tmp8','tmp9','tmp10',
#            'hum3','hum4','hum5','hum6','hum7','hum8','hum9','hum10',
#            'scale1','scale2']
#basin_test_wenqiang_scale=dict((el,0.0) for el in field_name)
#pht_basin_test_wenqiang_scale = Phant(publicKey=public_basin_test_wenqiang_mo_su_scale, fields=field_name ,privateKey=private_basin_test_wenqiang_mo_su_scale,baseUrl=nectar_address)

port_sensor = 'USB VID:PID=2341:0042 SNR=8573531303335131F052'
port_scale1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.1.1:1.0-port0'
port_scale2 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.1.2:1.0-port0'
port_scale3 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.2:1.0-port0'
Example #29
0
#	'B_Cam' : ['cstemp1', 'csec1', 'csdp1'],
#	'C_Cam' : ['cstemp2', 'csec2', 'csdp2'],
#	'D_Cam' : ['cstemp3', 'csec3', 'csdp3'],
#	'E_Cam' : ['cstemp4', 'csec4', 'csdp4'],
#
#}
#
#sensor_name = #strip and split to get the name
#name_field = look_up.get(sensor_name) #list of strings for certain sensor_name
#temp_filed = name_field[0]
#ec_field = name_field[1]
#dp_filed = name_file[2]


wwl1=dict((el,0.0) for el in field_name)
pht_sensor = Phant(publicKey=credential["public_wwl1"], fields=field_name ,privateKey=credential["private_wwl1"],baseUrl=credential["nectar_address"])

port_sensor  = '/dev/ttyS0'

# whether the result will be displayed on the screen
screen_display=True

# whether save the result as a file 
save_to_file=True

# the Filename of the csv file for storing file
file_name= 'wwl1.csv'

sleep_time_seconds=60*60
#sleep_time_seconds=1*10
Example #30
0
with open('/home/pi/script/pass/private_qal_sali_gs3_p', 'r') as myfile:
    private_qal_sali_gs3_p = myfile.read().replace('\n', '')

with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address = myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'mo0', 'mo1', 'mo2', 'mo3', 'mo4', 'mo5', 'mo6', 'mo7', 'mo8', 'mo9',
    'su0', 'su1', 'su2', 'su3', 'su4', 'su5', 'su6', 'su7', 'su8', 'su9',
    'tmp0', 'tmp1', 'tmp2', 'tmp3', 'tmp4', 'tmp5', 'tmp6', 'tmp7', 'tmp8',
    'tmp9'
]
qal_mo_su = dict((el, 0.0) for el in field_name)
pht_sensor = Phant(publicKey=public_qal_moisture_suction,
                   fields=field_name,
                   privateKey=private_qal_moisture_suction,
                   baseUrl=nectar_address)

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'tmp0', 'tmp1', 'tmp2', 'hum0', 'hum1', 'hum2', 'dp0', 'dp1', 'ec0', 'ec1',
    'gstmp0', 'gstemp1', 'pre0', 'pre1', 'pretmp0', 'pretmp1', 'dhttmp0',
    'dhthum0', 'volt0', 'tmp4', 'tmp5', 'tmp6', 'tmp7', 'tmp8', 'tmp9',
    'tmp10', 'tmp11', 'tmp12'
]
qal_sali_gs3_p = dict((el, 0.0) for el in field_name)
pht_qal_sali_gs3_p = Phant(publicKey=public_qal_sali_gs3_p,
                           fields=field_name,
                           privateKey=private_qal_sali_gs3_p,
                           baseUrl=nectar_address)
Example #31
0
with open('/home/pi/script/pass/nectar_address', 'r') as myfile:
    nectar_address = myfile.read().replace('\n', '')

with open('/home/pi/script/pass/cmd_area51_taking_photo', 'r') as myfile:
    cmd_area51_taking_photo = myfile.read().replace('\n', '')

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'mo0', 'mo1', 'mo2', 'mo3', 'mo4', 'mo5', 'su0', 'su1', 'su2', 'su3',
    'su4', 'su5', 'tempa0', 'tempb0', 'tempa1', 'tempb1', 'tempa2', 'tempb2',
    'tempa3', 'tempb3', 'tempa4', 'tempb4', 'tempa5', 'tempb5', 'hum0', 'hum1',
    'hum2', 'tmp0', 'tmp1', 'tmp2'
]
bacteria_mo_su_sali = dict((el, 0.0) for el in field_name)
pht_bacteria_mo_su_sali = Phant(publicKey=public_bacteria_mo_su_sali,
                                fields=field_name,
                                privateKey=private_bacteria_mo_su_sali,
                                baseUrl=nectar_address)

#------------------------- below are definations for the sensors in the column ---------------------------------
field_name = [
    'tmp3', 'tmp4', 'tmp5', 'tmp6', 'tmp7', 'tmp8', 'tmp9', 'tmp10', 'hum3',
    'hum4', 'hum5', 'hum6', 'hum7', 'hum8', 'hum9', 'hum10', 'scale1', 'scale2'
]
bacteria_sali_scale = dict((el, 0.0) for el in field_name)
pht_bacteria_sali_scale = Phant(publicKey=public_bacteria_sali_scale,
                                fields=field_name,
                                privateKey=private_bacteria_sali_scale,
                                baseUrl=nectar_address)

port_sensor = 'USB VID:PID=2341:0042 SNR=557363037393516030D1'
port_scale1 = '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.2.1.1:1.0-port0'
Example #32
0
import sys
from phant import Phant
from twilio.rest import TwilioRestClient
from time import sleep
 
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = ""
auth_token  = ""
client = TwilioRestClient(account_sid, auth_token)

p = Phant(public_key='q5JMKnDJKXCMnjbYr0lG', fields=['temp'], private_key='')

while(True):
	data = p.get()
	print("Latest Loudness Value is: {}".format(data[0]['temp']))
	if float(data[0]['temp']) > 1500:
		message = client.messages.create(body="Loudness: {0}\nD313 Room is making noise, please take action".format(data[0]['temp']),
		    to="+919650055244",    # Replace with your phone number
		    from_="+12018905183") # Replace with your Twilio number
		print (message.sid)
	sleep(15)