Пример #1
0
def upm_temp():

  temp = upm.GroveTemp(1) # Analog Port A1
	upm_temp = temp.value()
	upm_fahr = upm_temp * 9.0/5.0 + 32.0;

	return upm_temp
Пример #2
0
def TemperatureRead(tem):
    global AC
    temp = grove.GroveTemp(0)
    celsius = temp.value()
    fahrenheit = celsius * 9.0 / 5.0 + 32.0
    oled_setTextXY(0, 0)
    oled_putString("Temp:" + str(celsius) + "C" + "," + str(int(fahrenheit)) +
                   "F")
    if automode:
        if celsius >= tem:
            AC = 1
            relay.write(1)
            if (switch == 0):
                rgb_led.setColorRGB(0, 0, 0, 25)
            else:
                rgb_led.setColorRGB(0, 150, 150, 255)
        else:
            relay.write(0)
            AC = 0
    if automode2:
        if celsius < tem:
            AC = 2
            relay2.write(1)
            if (switch == 0):
                rgb_led.setColorRGB(0, 25, 0, 0)
            else:
                rgb_led.setColorRGB(0, 255, 150, 150)
        else:
            relay2.write(0)
            AC = 0

    return celsius, fahrenheit
Пример #3
0
def readMeasures():

    tempSensor =  grove.GroveTemp(0)
    lightSensor = grove.GroveLight(0)
    global temperature
    global luminosity
    temperature = tempSensor.value()
    luminosity = lightSensor.value()
    def __init__(self):

        self.client = paho.Client()
        self.client.on_publish = self.on_publish
        self.client.connect("test.mosquitto.org", 1883, 60)

        self.button = grove.GroveButton(2)
        self.temp = grove.GroveTemp(0)
Пример #5
0
def readtemp():
    # Create the temperature sensor object using AIO pin 0
    temp = grove.GroveTemp(1)

    celsius = temp.value()
    fahrenheit = celsius * 9.0 / 5.0 + 32.0

    return (celsius, fahrenheit)
def publisher(client):
    time.sleep(2)
    print("Publisher task started")
    while True:
        temp = pyupm_grove.GroveTemp(1)
        print("Temperature = " + str(temp.value()))
        client.publish("temp882", str(temp.value()))
        time.sleep(5)
Пример #7
0
def temp_read(pin_obj):
    if device_type == DEVICE_TYPE_MRAA:
        return pyupm_grove.GroveTemp(pin_obj).value()

    elif device_type == DEVICE_TYPE_RPI:
        raise NotImplementedError

    elif device_type == DEVICE_TYPE_GPI:
        return grovepi.temp(pin_obj, '1.1')
Пример #8
0
    def __init__(self):
        # Grove Temperature sensor at Analog In 0, hardcoded for simplicity
        TEMP_SENSOR_PIN = 0
        # Grove Light Sensor at Analog In 1, hardcoded for simplicity
        LIGHT_SENSOR_PIN = 1

        self.temp_sensor = grove.GroveTemp(TEMP_SENSOR_PIN)
        self.light_sensor = grove.GroveLight(LIGHT_SENSOR_PIN)
        if not self.temp_sensor or not self.light_sensor:
            raise ValueError("Cannot initialize sensors")
Пример #9
0
def main():
  color_control = 0
  # Voltage to drive the display causes a shift in the thermistor reference.
  calibration_constant = 2
  print

  while True:
    
    # Create the temperature sensor object using AIO pin 0
    temp = grove.GroveTemp(0)
    temp = temp.value()    
    temp += calibration_constant 
    
    # Use Intel's iotkit-admin tool to send the temperature
    print "Sending temperature", temp, "degree Celsius..."
    
    # Change the color to indicate a new sample interval.
    if color_control % 2 == 0:
    	# RGB Cyan
        myLcd.setColor(0, 255, 255)
    else:
        # RGB Yellow
        myLcd.setColor(255, 255, 0)

    color_control += 1
    myLcd.setCursor(0,0)
    myLcd.write('Sending temp   ')
    myLcd.setCursor(1,1)
    myLcd.write('Sampled: '+  str(temp) + ' C')

    output = subprocess.check_output (["/usr/bin/iotkit-admin", "observation", "temperature", str(temp)])
    
    print output
 
    # Wait for one minute
    print "Waiting for one minute. Press CTRL+C to stop..."
    time.sleep(5)
    # Sample temperature setting every 1 seconds
    for count in range(54):
         setting = rotary()
         print "Temperature set for: ", setting, " Degrees Celsius"
         if setting < temp:
            relay.off()
            print relay.name(), 'is off'
	 else:
	    relay.on()
       	    print relay.name(), 'is on'

    # Delete the temperature sensor object
    del temp
  return 0;
Пример #10
0
def main():
    # Create the temperature sensor object using AIO pin 0
    temp = grove.GroveTemp(0)
    print temp.name()

    # Read the temperature ten times, printing both the Celsius and
    # equivalent Fahrenheit temperature, waiting one second between readings
    for i in range(0, 10):
        celsius = temp.value()
        fahrenheit = celsius * 9.0 / 5.0 + 32.0
        print "%d degrees Celsius, or %d degrees Fahrenheit" \
            % (celsius, fahrenheit)
        time.sleep(1)

    # Delete the temperature sensor object
    del temp
Пример #11
0
import pyupm_i2clcd as upm_lcd
import pyupm_grove, time, mraa
from datetime import datetime
from pytz import timezone
import pytz

CET = timezone('CET')
lcd = upm_lcd.Jhd1313m1(0, 0x3E, 0x62)
temp = pyupm_grove.GroveTemp(2)
light = mraa.Aio(0)
var = 25
oldtime = 'holder'
lcd.setColor(var,0,0)

while 1:
    newtime = datetime.strftime(datetime.now(tz=CET), '%Y-%m-%d %H:%M')
    if oldtime != newtime: 
        lcd.clear()
        if light.read() < 480 and light.read() > 200:
            if var > 50:
                var -= 5
                lcd.setColor(var,0,0)
            elif var < 50:
                var += 5
                lcd.setColor(var,0,0)
        elif light.read() < 180:
            if var > 25:
                var -= 5
                lcd.setColor(var,0,0)
        else:
            if var < 125:
 def get_actuator(self):
     return pyupm_grove.GroveTemp(self.pin)
Пример #13
0
import pyupm_grove
import time

temperature = pyupm_grove.GroveTemp(0)

while 1:
    print(temperature.value())
    time.sleep(1)
Пример #14
0
#!/usr/bin/python

import time, sys, signal, atexit, mraa, thread, threading, os
import pyupm_grove as grove
import pyupm_guvas12d as upmUV
import pyupm_grovemoisture as upmMoisture
import pyupm_stepmotor as mylib
import pyupm_servo as servo
from multiprocessing import Process

# IO Def
myIRProximity = mraa.Aio(5)  			#GP2Y0A on Analog pin 5
temp = grove.GroveTemp(0) 			#grove temperature on A0 
myMoisture = upmMoisture.GroveMoisture(1) 	#Moisture sensor on A1
light = grove.GroveLight(2) 			#Light sensor on A2
myUVSensor = upmUV.GUVAS12D(3) 			#UV sensor on A3
stepperX = mylib.StepMotor(2, 3) 		#StepMotorY object on pins 2 (dir) and 3 (step)
stepperY = mylib.StepMotor(4, 5)		#StepMotorX object on pins 4 (dir) and 5 (step)
waterpump = mraa.Gpio(10) 			#Water pump's Relay on GPIO 10
waterpump.dir(mraa.DIR_OUT)
waterpump.write(0)
gServo = servo.ES08A(6)                		#Servo object using D6
gServo.setAngle(50)
switchY = mraa.Gpio(7)    			#SwitchY for GPIO 7
switchY.dir(mraa.DIR_IN)
switchX = mraa.Gpio(8)				#SwitchX for GPIO 8
switchX.dir(mraa.DIR_IN)
EnableStepperX = mraa.Gpio(9)			#StepperMotorX Enable on GPIO 9
EnableStepperX.dir(mraa.DIR_OUT)
EnableStepperX.write(1)
EnableStepperY = mraa.Gpio(11)			#StepperMotorY Enable on GPIO 11
Пример #15
0
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import time, sys, signal, atexit
import pyupm_grove as grove
import pyupm_guvas12d as upmUV
import pyupm_grovemoisture as upmMoisture

# Create the light sensor object using AIO pin 0
light = grove.GroveLight(2)
# Instantiate a UV sensor on analog pin A0
myUVSensor = upmUV.GUVAS12D(3)
# Create the temperature sensor object using AIO pin 0
temp = grove.GroveTemp(0)
# Instantiate a Grove Moisture sensor on analog pin A0
myMoisture = upmMoisture.GroveMoisture(1)

# analog voltage, usually 3.3 or 5.0
GUVAS12D_AREF = 5.0
SAMPLES_PER_QUERY = 1024


## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
    raise SystemExit


# This function lets you run code on exit, including functions from myUVSensor
Пример #16
0
 def resetSensors(self, sensor_list):
     self.sensors = {}
     for requested_sensors in sensor_list:
         self.sensors[int(requested_sensors)] = grove.GroveTemp(
             int(requested_sensors))
Пример #17
0
# Pins used in your Grove kit. Adjust for your led, servo, and sensor.
LED_PIN = 8
TEMP_PIN = 0
SERVO_PIN = 5

# Minimum and maximum safe angle for the servo.
MIN_ANGLE = 30
MAX_ANGLE = 150

# Temperature threshold for the alarm in Celsius degrees.
MAX_TEMP = 28

# ========= * SETTING UP GPIOS * ========= #
led = pyupm_grove.GroveLed(LED_PIN)
servo = pyupm_servo.ES08A(SERVO_PIN)
temp_sensor = pyupm_grove.GroveTemp(TEMP_PIN)

led_flag = False

# ========= * PROJECT FUNCTIONS * ======== #


# ------------ Temperature sensor -------- #
def temperatureFunction():
    """
        Read temperature, triggers the alarm, and adjusts servo's angle.
    """

    # Read temperature and trigger alarm if necessary
    global led_flag
    temp = getTemperature()
Пример #18
0
import pyupm_grove

import lightbulb

# This is custom user configuration
TEMP_SENSOR_A_PIN = 0
LIGHT_SENSOR_A_PIN = 3
lightbulb.sensors.register(pyupm_grove.GroveTemp(TEMP_SENSOR_A_PIN))
lightbulb.sensors.register(pyupm_grove.GroveLight(LIGHT_SENSOR_A_PIN))

# Launch Flask
lightbulb.app.run(host='0.0.0.0', debug=True)
Пример #19
0
import pyupm_grove as g
from time import sleep

if __name__ == '__main__':

   temp = g.GroveTemp(0)

   while True:

        #print "%d" %light.raw_value() 
        print "Celsius: %d" %temp.value() 
        sleep(1.5)

Пример #20
0
def TemperatureRead():
    temp = grove.GroveTemp(0)
    celsius = temp.value()
    fahrenheit = celsius * 9.0 / 5.0 + 32.0
    return celsius, fahrenheit
Пример #21
0
 def __init__(self, analog_pin):
     self.temperature_sensor = upmGrove.GroveTemp(analog_pin)
     self.temperature_celsius = 0.0
     self.temperature_fahrenheit = 0.0
Пример #22
0
import pyupm_i2clcd as lcd
import pyupm_buzzer as upmBuzzer
import time

RED_LED_PIN = 2
GREEN_LED_PIN = 3
BLUE_LED_PIN = 4
TEMP_PIN = 0
BUZZER_PIN = 5

# led init
ledPins = {"R": mraa.Gpio(RED_LED_PIN), "G": mraa.Gpio(GREEN_LED_PIN), "B": mraa.Gpio(BLUE_LED_PIN)}
[ledPin.dir(mraa.DIR_OUT) for key, ledPin in ledPins.items()]

# temp init
temp = grove.GroveTemp(TEMP_PIN)

# lcd init
lcdDisplay = lcd.Jhd1313m1(0, 0x3E, 0x62)
lcdDisplay.clear()

# buzzer init
buzzer = upmBuzzer.Buzzer(5)
buzzer.stopSound()
notes = [0, 10, 10, 30, 40, 70, 100, 130, 180, 220, 270, 300, 310, 290, 220, 130, 560, 210, 500, 500, 500, 500]
global playing_request
global stop_request
playing_request = False
stop_request = False

 def getTemp(self):
     temp = pyupm_grove.GroveTemp(int(self.port))
     tempVal = float(temp.value())
     self.info["temp"] = str(tempVal)
     return self.info
Пример #24
0
# Author: Brendan Le Foll <*****@*****.**>
# Copyright (c) 2014 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import pyupm_grove as grove

x = grove.GroveTemp(0)
print x.value()
Пример #25
0
import pyupm_grove
import time

TEMP_PIN = 2

temp = pyupm_grove.GroveTemp(TEMP_PIN)



Пример #26
0
import json
import sys

__author__ = 'talbarda'
import random
import uuid
from src.sensor.http_client import http_client
from src.utilities.utils import get_conf, get_current_time
import time
import mraa
import pyupm_grove as grove
import math

INTERVAL = get_conf().get_conf_value(
    full_name="sensor.update_seconds_interval", val_type=float, def_val=1)
temperature_sensor = grove.GroveTemp(0)
pressure_sensor = mraa.Aio(2)
light = mraa.Gpio(2)
light.dir(mraa.DIR_OUT)
light_value = 0
light.write(light_value)


def change_light(val):
    global light_value
    if light_value != val:
        light_value = val
        light.write(val)


def collect_data():
Пример #27
0
#!/usr/bin/python

import time

import pyupm_grove as grove
import pyupm_i2clcd as lcd

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters

light = grove.GroveLight(1)
temperature = grove.GroveTemp(0)
display = lcd.Jhd1313m1(0, 0x3E, 0x62)


def functionLight(bot, update):
    luxes = light.value()
    bot.sendMessage(update.message.chat_id, text='Light ' + str(luxes))


def functionTemperature(bot, update):
    degrees = temperature.value()
    bot.sendMessage(update.message.chat_id, text='Temperature ' + str(degrees))


def functionEcho(bot, update):
    bot.sendMessage(update.message.chat_id, text=update.message.text)


if __name__ == '__main__':

    updater = Updater("209701132:AAEBn3_8ZBN-Lk8l8kRnkLKegmjA-S5iPeQ")