MQTT Broker "mosquito" startet automatisch und benötigt keine Konfiguration. apt install python3-pip apt install mosquitto apt install python3-w1thermsensor pip3 install paho-mqtt https://mosquitto.org/2011/08/mosquitto-on-openwrt/ https://webworxshop.com/2012/11/03/tiny-mqtt-broker-with-openwrt *MQTT Sensor Client in Python #!/usr/bin/env python3 # # read ds1822 sensor via Raspberrie Pi GPIO # and send via MQTT # import time import paho.mqtt.client as mqtt from w1thermsensor import W1ThermSensor def on_connect(client, userdata, flags, rc): print("Connected with result code " + str(rc)) client = mqtt.Client() client.on_connect = on_connect client.connect("localhost", 1883, 60) client.loop_start() sensor = W1ThermSensor() while True: time.sleep(15) ds_temp = sensor.get_temperature() client.publish("home/livingroom/temperature", ds_temp ) print (ds_temp) #!/usr/bin/env python3 # #bessere Variante ohne w1thermsensor # import os, sys, time import paho.mqtt.client as mqtt def on_connect(client, userdata, flags, rc): print("Connected with result code " + str(rc)) client = mqtt.Client() client.on_connect = on_connect client.connect("192.168.1.121", 1883, 60) client.loop_start() def aktuelleTemperatur(id): # 1-wire Slave Datei lesen file = open('/sys/bus/w1/devices/28-' + id + '/w1_slave') filecontent = file.read() file.close() # Temperaturwerte auslesen und konvertieren if ("YES" in filecontent): stringvalue = filecontent.split("\n")[1].split(" ")[9] temperature = float(stringvalue[2:]) / 1000 rueckgabewert = '%6.1f' % temperature else: #print("sensor not ready") rueckgabewert = False return(rueckgabewert) while True: temp1 = aktuelleTemperatur("0416a479b2ff") temp2 = aktuelleTemperatur("0516a488d7ff") if(temp1): client.publish("home/kitchen/temperature", temp1 ) if(temp2): client.publish("home/outdoor/temperature", temp2 ) #print ("kitchen temp1:",temp1) #print ("outside temp2:",temp2) time.sleep(10) *node red apt install nodered git su pi cd cd .node-red npm i node-red/node-red-dashboard npm install node-red-contrib-ds18b20 --save node-red-stop nohup node-red-start & http://SERVER:1880/ui node red functions: strip spaces var res = msg.payload.replace(/\s/g,''); var newMsg = {payload: res }; return (newMsg); 1234 -> 12.34 var res = msg.payload.substr(0, 2); var res2 = msg.payload.substr(2, 2); var newstring = res + "." + res2; var newMsg = {payload: newstring }; return (newMsg); add a pre-string to the value: var res = msg.payload; var newstring = "mode #" + res; var newMsg = {payload: newstring }; return (newMsg); *(shell) mosquitto-clients apt install mosquitto-clients mosquitto_sub -h localhost -v -t "#" mosquitto_pub -h mqtt -t "waschkaue/eingangshalle/000/uhr/actuators/set_pixel" -m "255 #200020" mosquitto_pub -h mqtt -t "huette/clubraum/000/redshift/actuators/set_pixel" -m "text ___c3RE___" mosquitto_pub -h mqtt -t "huette/clubraum/000/ws2812tonne/actuators/set_pixel" -m "255 #002222" mosquitto_pub -h mqtt -t "huette/clubraum/000/ws2812tonne/actuators/set_pixel" -m "mode #2a" mosquitto_pub -h mqtt -t "huette/clubraum/000/ws2812tonne/actuators/set_pixel" -m "speed #80" mosquitto_pub -h mqtt -t "huette/clubraum/000/ws2812tonne/actuators/set_pixel" -m "brightness #80" while true; do date +"text %H:%M:%S" | mosquitto_pub -h mqtt -t "huette/clubraum/000/redshift/actuators/set_pixel" -l echo "." done *Grafana (läuft auf huettenpi) http://docs.grafana.org/guides/getting_started/ https://grafana.com/ https://github.com/fg2it/grafana-on-raspberry http://air.imag.fr/index.php/Developing_IoT_Mashups_with_Docker,_MQTT,_Node-RED,_InfluxDB,_Grafana *InfluxDB (läuft sehr langsam auf derdicke) *Telegraf (füttert influxdb , läuft auf huettenpi) ftp://fileserver./pibackups/telegraf.conf http://electriceye.info/wordpress/?p=457 MQTT mit micropython auf ESP8266 https://www.hackster.io/fabian-affolter/esp8266-and-micropython-part-2-723014 https://github.com/micropython/micropython-lib/tree/master/umqtt.simple MQTT mit arduino auf ESP8266 Sketch->Biliotheken verwalten: nach MQTT suchen. Große Auswahl an libs! In diesem Beispiel: libraries\PubSubClient\src\PubSubClient http://s6z.de/cms/index.php/homeautomation-homecontrol/hardwareplattformen/esp8266/113-mqtt-basic-esp8266-mqtt-example https://www.clusterfsck.io/blog/mqtt-to-rrd-daemon/ https://markinbristol.wordpress.com/2015/09/20/setting-up-graphite-api-grafana-on-a-raspberry-pi/ RGBWW LED Dimmer: http://www.loxwiki.eu/pages/viewpage.action?pageId=13307747 http://www.schatenseite.de/2016/05/17/lichtsteuerung-mit-esp8266-und-mqtt/ /stat/huette/radar1 Steuerung Farben der Zechenuhr CAN ID: 120 MQTT Topic: waschkaue/eingangshalle/000/uhr/actuators/set_pixel Datentyp: pixelbin2ascii Byte 0: Nummer des Pixels (0...59), das neu gesetzt werden soll. Spezielle Pixelnummern siehe unten Byte 1: Rot Byte 2: Grün Byte 3: Blau Spezielle Pixelnummern: 255: Aus 254: Cheerlights 253: Rainbow 252: Fire 251: Colorblobs 250: Bubblesort 249: Speedmeter (Download) 248: alle Pixel gleiche Farbe
{}