Пример #1
0
            writer.printstring("LP " + str(float("%.2g" % gas_lpg)))
            writer.set_textpos(12, 0)
            writer.printstring("CO " + str(float("%.2g" % co)))
            writer.set_textpos(24, 0)
            writer.printstring("ME " + str(float("%.2g" % methane)))
            oled.show()
        print("Gas_LPG: " + str(float("%.2g" % gas_lpg)))
        print("CO: " + str(float("%.2g" % co)))
        print("Methane: " + str(float("%.2g" % methane)))
        try:
            client.publish(topic1, str(temp_only), qos=QOS)
            client.publish(topic2, str(humid_only), qos=QOS)
            if (bmx_present1 or bmx_present2):
                client.publish(topic3, str(press_only), qos=QOS)
            if (light_present1 or light_present2):
                client.publish(topic4, str(light), qos=QOS)
            client.publish(topic5, str(gas_lpg), qos=QOS)
            client.publish(topic6, str(co), qos=QOS)
            client.publish(topic7, str(methane), qos=QOS)
        except OSError:
            restart_and_reconnect()
        sleep(25)
        if (display_present1 or display_present2):
            oled.fill(0)
            oled.show()
        sleep(25)


if __name__ == "__main__":
    main(load_config())
Пример #2
0
from boot import load_config
import main_AHT20_SHT30_BMP280_1750_MQ9_DS1307

main_AHT20_SHT30_BMP280_1750_MQ9_DS1307.main(load_config())
Пример #3
0
        restart_and_reconnect()

    while True:
        mq = MQ()
        perc = mq.MQPercentage()
        gas_lpg = perc["GAS_LPG"]
        co = perc["CO"]
        methane = perc["SMOKE"]
        oled.fill(0)
        oled.show()
        oled.text("LP", 0, 0)
        oled.text(str(float("%.2g" % gas_lpg)), 24, 0)
        oled.text("CO", 0, 10)
        oled.text(str(float("%.2g" % co)), 24, 10)
        oled.text("ME", 0, 20)
        oled.text(str(float("%.2g" % methane)), 24, 20)
        oled.show()
        print(gas_lpg)
        print(co)
        print(methane)
        client.publish(topic4, str(gas_lpg))
        client.publish(topic5, str(co))
        client.publish(topic6, str(methane))
        sleep(10)


if __name__ == "__main__":
    config = load_config()
    client_id = hexlify(unique_id())
    mainloop(config)
Пример #4
0
from boot import load_config
import main_BME280

main_BME280.main(load_config())