Пример #1
0
 def __init__(self, id=None):
     if not id:
         try:
             self._ds18b20_device = ds18b20.DS18B20()
         except Exception as err:
             msg = 'No DS18B20 devices discovered'
             raise DeviceError(msg)
     else:
         print ds18b20.DS18B20.get_available_sensors()
         try:
             self._ds18b20_device = ds18b20.DS18B20(id)
         except Exception as err:
             msg = 'DS18B20 ' + id + ' device not found'
             raise DeviceError(msg)
Пример #2
0
    def __init__(self):
        # self.__teapot = DigitalOutputDevice(PIN_TEAPOT, active_high=False)
        # self.__light = DigitalOutputDevice(PIN_LIGHT, active_high=False)
        # self.__amp = DigitalOutputDevice(PIN_AMP, active_high=False)

        self.__temp = ds18b20.DS18B20()
        self.__led = RGBLED(PIN_LED_R, PIN_LED_G, PIN_LED_B)
Пример #3
0
 def __init__(self):
     self.log = logging.getLogger('TEMP_T')
     self.bus = ds18b20.DS18B20()
     self.asyncIO = AsyncIO(self.QUEUE_CHECK_PERIOD, self.__onRead, None,
                            self.__onStart)
     # create translator between raw device name and human readable name
     self.names = {
         't' + str(i + 1): rawName
         for i, rawName in enumerate(self.bus.devices)
     }
Пример #4
0
def get_water_temp():
    instance = ds18b20.DS18B20(sensorInfoFile=SENSOR_INFO_FILE)
    return instance.read()
Пример #5
0
        value = complemento2(dato[0])*(16**2) + dato[1]
    elif medicion == 'FechaHora':
        pass
    elif medicion == 'Temperatura':
        pass
    return value

def complemento2(dato):
    number = dato
    if dato >> 7 == 1:
        number = -1 * (dato & 0x7F)
    return number

hora = [0x01,0x06,0x00,0x17,0x03,0x06,0x12,0x19]

sensor_aceleraciones = acelerometro.Acelerometro(0x1C)
clock = clock.Clock( hora )
temperatura = ds18b20.DS18B20()

tareas.append( Repetir(1, actualizar_mediciones) )
tareas.append( Repetir(.1, actualizar_valores))


for tarea in tareas:
    tarea.start()


App.mainloop()                      #corremos la App
    

Пример #6
0
 def __init__(self):
     self._sensor = ds18b20.DS18B20()
     self._tijd = 10
     self._gui()
#!/usr/bin/env python
# show status

import ds18b20

while True:
    tempDevice = ds18b20.DS18B20();

    print 'temp=', tempDevice.readTemp();
Пример #8
0
import sys
import time
import logging
import ds18b20

logger = logging.getLogger(__name__)

try:
    ds = ds18b20.DS18B20(sys.argv[1])
except Exception as e:
    logger.error(e)
    exit(1)

try:
    while True:
        try:
            temp = ds.read_temp()
            print(temp)
        except Exception as e:
            logger.error(e)
        time.sleep(1)
except KeyboardInterrupt:
    exit(0)
Пример #9
0
 def initialize_sensor(self):
     try:
         sensor = ds18b20.DS18B20()
         return sensor
     except Exception:
         raise NoDeviceDetected('Cannot detect DS18B20 device!')
                        default=8086,
                        help='InfluxDB port')
    parser.add_argument('--username',
                        action='store',
                        default='root',
                        help='InfluxDB username')
    parser.add_argument('--password',
                        action='store',
                        default='root',
                        help='InfluxDB password')
    parser.add_argument('--database',
                        action='store',
                        required=True,
                        help='InfluxDB database')
    parser.add_argument('--measurement',
                        action='store',
                        required=True,
                        help='Sensor measurement')
    parser.add_argument('--location',
                        action='store',
                        required=True,
                        help='Sensor location')

    args = parser.parse_args()
    print(args)

    tsen = ds18b20.DS18B20()
    temperature = tsen.read_temp()
    print(temperature)
    post_to_influxdb(args, temperature)