ESP8266 + MQTT + OLED Display

Die Tage kam die Idee auf, aktuelle Benzinpreise über ein OLED-Display auszugeben.
Da im Lager noch ESP8266 + OLED Display waren, machte ich mich ans Werk.

Stückliste:

ESP8266 + MQTT + OLED Display
Dieses Video ansehen auf YouTube.
ESP8266 als Infotafel für Benzinpreise

Druck des Gehäuse im 3D-Drucker mit PLA:

Nun gehen wir ans programmieren

Wir installieren nun die Software auf den ESP8266. Download Software hier :
https://github.com/letscontrolit/ESPEasy/releases

Dann installieren wir den Benzinpreis Flow als Node in Node-Red :

[{"id":"f4356834.fa1b9","type":"http request","z":"3e94ac6b.14ec4c","name":"Bavaria Petrol - Munich","method":"GET","ret":"txt","url":"https://www.clever-tanken.de/tankstelle_details/33072","tls":"","x":390,"y":220,"wires":[["99c4504c.9752e8"]]},{"id":"dcc69e72.2d2b7","type":"inject","z":"3e94ac6b.14ec4c","name":"","topic":"tank1","payload":"","payloadType":"date","repeat":"","crontab":"*/30 6-22 * * *","once":false,"onceDelay":0.1,"x":130,"y":220,"wires":[["f4356834.fa1b9"]]},{"id":"99c4504c.9752e8","type":"html","z":"3e94ac6b.14ec4c","name":"","property":"payload","tag":"span","ret":"text","as":"single","x":630,"y":220,"wires":[["c82b6057.1d4178","f0488e18.7bbe28"]]},{"id":"f08d0285.7aed98","type":"http request","z":"3e94ac6b.14ec4c","name":"Jet Gasoline Station Munich ","method":"GET","ret":"txt","url":"https://www.clever-tanken.de/tankstelle_details/3525","tls":"","x":400,"y":300,"wires":[["99c4504c.9752e8"]]},{"id":"c82b6057.1d4178","type":"function","z":"3e94ac6b.14ec4c","name":"Parse Value","func":"msg.payload =  msg.payload[38];\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":180,"wires":[["19abc7a8.27acd","345c6c56.07a18c","a0f4e3b7.15172","2bc1949.1ea4cec"]]},{"id":"f0488e18.7bbe28","type":"function","z":"3e94ac6b.14ec4c","name":"Parse Value","func":"msg.payload =  msg.payload[25];\nreturn msg;","outputs":1,"noerr":0,"x":798,"y":343,"wires":[["718c3793.9f05b","da5e38a5.75422","24e7a44c.4f8adc"]]},{"id":"97ced692.21332","type":"inject","z":"3e94ac6b.14ec4c","name":"","topic":"tank2","payload":"","payloadType":"date","repeat":"","crontab":"*/30 6-22 * * *","once":false,"onceDelay":0.1,"x":130,"y":300,"wires":[["f08d0285.7aed98"]]},{"id":"19abc7a8.27acd","type":"debug","z":"3e94ac6b.14ec4c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":140,"wires":[]},{"id":"345c6c56.07a18c","type":"ui_chart","z":"3e94ac6b.14ec4c","name":"","group":"71098437.c4817c","order":16,"width":0,"height":0,"label":"Benzinpreis Super+","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1010,"y":180,"wires":[[],[]]},{"id":"a0f4e3b7.15172","type":"mqtt out","z":"3e94ac6b.14ec4c","name":"SuperPlus","topic":"/benzin/superplus","qos":"1","retain":"","broker":"ec5b75d5.c274e8","x":989,"y":220,"wires":[]},{"id":"2bc1949.1ea4cec","type":"mqtt out","z":"3e94ac6b.14ec4c","name":"SuperPlus ESP1","topic":"esp1","qos":"1","retain":"","broker":"ec5b75d5.c274e8","x":1032,"y":92,"wires":[]},{"id":"718c3793.9f05b","type":"ui_chart","z":"3e94ac6b.14ec4c","name":"","group":"71098437.c4817c","order":17,"width":0,"height":0,"label":"Benzinpreis E10","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"6","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":993,"y":344,"wires":[[],[]]},{"id":"da5e38a5.75422","type":"mqtt out","z":"3e94ac6b.14ec4c","name":"Super E10","topic":"/benzin/e10","qos":"1","retain":"","broker":"ec5b75d5.c274e8","x":987,"y":392,"wires":[]},{"id":"24e7a44c.4f8adc","type":"mqtt out","z":"3e94ac6b.14ec4c","name":"Super E10 ESP2","topic":"esp2","qos":"","retain":"","broker":"ec5b75d5.c274e8","x":1014,"y":444,"wires":[]},{"id":"71098437.c4817c","type":"ui_group","z":"","name":"Licht","tab":"8caaa69e.5cf878","order":1,"disp":true,"width":"6","collapse":false},{"id":"ec5b75d5.c274e8","type":"mqtt-broker","z":"","broker":"mqtt.unixweb.de","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8caaa69e.5cf878","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1}]
Node-Red Flow für Benzinpreise

Jetzt konfigurieren und verbinden wir den ESP8266 und das Display SSD1306

Verdrahtung NodeMCU/ESP8266 mit SSD1306 Display via I2C

Jetzt installieren und konfigurieren wir einen MQTT-Generic Import als neues Gerät:
Hinweis : Bei Name unbedingt „MQ“ + „MQTT Topic“ + „Value1, Value2“ nehmen sonst klappt das Beispiel nicht. Achte auf die exakte Groß- und Kleinschreibung, denn diese ist sehr wichtig.

Im Anschluss brauchen wir noch eine Anbindung an einen MQTT-Broker. Dazu nehmen wir den mqtt.unixweb.de als Broker. Später kannst Du auch Deinen eigenen nehmen.

Nun können wir alles einschalten, starten und wenn der NodeMCU eingeschaltet ist , drücken wir im Node-Red auf den Trigger „tank1:timestamp“, denn erst jetzt werden die aktuellen Daten an den MQTT-Broker gesendet und ich Echtzeit am NodeMCU/ESP8266 mit Display angezeigt.

Fertig ist die Anzeige mit dem OLED-Display

Falls es Fragen gibt einfach einen Kommentar hier hinterlassen

Viel Spaß und Erfolg mit dem kleinen Projekt.


Die mit Sternchen (*) gekennzeichneten Verweise sind sogenannte Provision-Links. Wenn du auf so einen Verweislink klickst und über diesen Link einkaufst, bekomme ich von deinem Einkauf eine Provision. Weiterführende Infos gibt es hier unter Punkt 8 in der Datenschutzerklärung  https://blog.unixweb.de/datenschutzerklaerung/

2 Kommentare

Kommentar hinterlassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.