Ejemplo n.º 1
0
def senddata():
    sht30Temperature, sht30Humidity = sht30.measure()
    print("Temperature: %6.3f" % sht30Temperature)
    client.celsiusWrite(sht30TempChannel, sht30Temperature)
    time.sleep(5)
    print("Relative humidity: %6.3f" % sht30Humidity + '%')
    client.humidityWrite(sht30HumidityChannel, sht30Humidity)
    time.sleep(5)
Ejemplo n.º 2
0
def senddata():
  sht30Temperature, sht30Humidity = sht30.getTempAndHumi(clockStretching=SHT3X.NO_CLOCK_STRETCH,repeatability=SHT3X.REP_S_HIGH)
  print("Temperature: %6.3f"%sht30Temperature)
  client.celsiusWrite(sht30TempChannel,sht30Temperature)
  client.celsiusWrite(sht30TempChannel+1,sht30Temperature)
  print("Relative humidity: %6.3f"%sht30Humidity + '%')
  client.humidityWrite(sht30HumidityChannel,sht30Humidity)
  client.humidityWrite(sht30HumidityChannel+1,sht30Humidity)  
Ejemplo n.º 3
0
def senddata():
    print("Measuring...")
    dht11.measure()
    temp = dht11.temperature()
    print("Temperature: %f °C" % temp)
    client.celsiusWrite(dht11TempChannel, temp)
    time.sleep(5)
    humidity = dht11.humidity()
    print("Relative humidity: %6.3f" % humidity + '%')
    client.humidityWrite(dht11HumidityChannel, humidity)
    time.sleep(5)
Ejemplo n.º 4
0
Archivo: mqtt.py Proyecto: ve2vax/misc
address = 0x76
bus = smbus2.SMBus(port)

bme280.load_calibration_params(bus, address)

# the sample method will take a single reading and return a
# compensated_reading object
data = bme280.sample(bus, address)

# the compensated_reading class has the following attributes
#print(data.id)
#print(data.timestamp)
#print(data.temperature)
#print(data.pressure)
#print(data.humidity)
vacuum = abs((data.pressure * 0.02953) - 29.53)
#print(vacuum)
temp = data.temperature

while True:
    client.loop()

    if (time.time() > timestamp + 10):
        data = bme280.sample(bus, address)
        vacuum = abs((data.pressure * 0.02953) - 29.53)
        temp = data.temperature
        client.celsiusWrite(1, temp)
        client.humidityWrite(2, data.humidity)
        client.vacuumWrite(3, vacuum)
        timestamp = time.time()
import cayenne.client
import time
import logging
import random

# Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
MQTT_USERNAME = "******"
MQTT_PASSWORD = "******"
MQTT_CLIENT_ID = "CAYENNE_CLIENT_ID"

tempChannel = 0
humchannel = 1

client = cayenne.client.CayenneMQTTClient()
client.begin(MQTT_USERNAME,
             MQTT_PASSWORD,
             MQTT_CLIENT_ID,
             loglevel=logging.INFO)
random.seed(5)

while True:
    client.loop()
    temp = 28.0 + random.getrandbits(8) / 50.
    print("Sending a temperature value of %f degrees C" % temp)
    hum = 30 + random.getrandbits(8) / 10.
    print("Sending a relative humidty value of %f %% " % hum)
    client.celsiusWrite(tempChannel, temp)
    time.sleep(2)
    client.humidityWrite(humchannel, hum)
    time.sleep(2)