I managed to use an Wemos D1-mini and its OLED shield to create a mini-display for temperature, with (almost) no line of code.
Configuration is done once, and displayed information is entirely sent through MQTT.
Here’s a little tutorial:
- Flash the D1 mini with Tasmota with tasmota-display.bin build
- Perform the basic Tasmota setup (wifi, MQTT, …)
- Connect the OLED shield on the D1 mini
- Set the I2C pins :
- Web interface / Configuration / Configure Module
- D2 GPIO4 : I2C SDA
- D1 GPIO5 : I2C SCL
- Check the OLED shield is detected :
22:11:45 CMD: i2cscan
22:11:45 MQT: stat/esp01/RESULT = {"I2CScan":"Device(s) found at 0x3c"}
- Configure the display settings through display commands :
DisplayModel 2
(SSD1306 ie OLED Shield)DisplayWidth 64
DisplayHeight 48
DisplayMode 0
- Optionally
DisplayRotate
2 to display upside down
- Finally, type use the
Display
command to check your display settings :
{"Model":2,"Width":64,"Height":48,"Mode":0,"Dimmer":15,"Size":1,"Font":1,"Rotate":2,"Refresh":2,"Cols":[16,8],"Rows":2}}
- Optionally “Configure timers” to turn display on/off on fixed times
The device is now ready to receive MQTT “display commands”.
I created the following rule :
rule "esp01publishtemp"
when
Item HueSensor1Temperature received update
then
val mqttActions = getActions("mqtt","mqtt:broker:mosquitto-nas")
val esp01Temp = String.format("%2.1f",(newState as DecimalType).floatValue)
logInfo("esp01.rules", "esp01publishtemp : newState=" + newState + " ,esp01Temp="+esp01Temp)
mqttActions.publishMQTT("cmnd/esp01/displaytext","[Ozf1]Exterieur:[c1l2f2s2p-4]"+esp01Temp)
end
Explanations : When HueSensor1Temperature item is updated (no matter if it’s MQTT based or not) :
- Format the payload with 1 decimal
- Format the display :
- [0zf1] : Turn the display on (0), clear it (z) and select font 1
- Display the text for the first line (“Outside” in french here)
- [c1l2f2s2p-4] : On column 1 (c1) and line 2 (l2), select font 2 (f2), scale factor 2 (s2) and pad 4 characters to the right (p-4)
- Display the value
- Send the MQTT payload to the moquitto-nas broker
At first, nothing will be displayed until the first MQTT update.
This page list all display possibilities with tasmota.
Enjoy !