I just wrote about the 10-pack of GeekCreit Wireless IOT Modules – or as most of us know them – nodeMCU ESP8266 boards – at a very reasonable €23 for 10 – i.e. 2.30 each inc post. So what better to test them with than the freely-available tasmota-displays.bin and a nice OLED display.
But using the little 0.96″ displays is nothing new and though cheap they are a little on the small size. I was pleased therefore to note that Banggood stock a larger version at 1.3″ (I’ve no idea why we still use inches for the size of these). I’ve been using the SSD1306-based 0.96″ displays for years and you’ll find umpteen references to them in here.
The larger, white 1.3″ OLED displays however use a different chip – the SSH1106 – this particular version has the same resolution as the higher of the two smaller displays – i.e. 128*64
Having already tested one of my nodeMCU boards with the SSD1306 I was happy my hardware worked – and changed the Tasmota commands slightly to cater for the new display.
Disaster – and that’s why it has taken me a couple of weeks to write this article, planned originally for Christmas week. I wasted a lot of time on the Tasmota forums trying to find out why my new display – when presented with some text, would only show every other line of pixels. Antonio (Mr Shark) and I spent AGES trying to figure it out then he remembered he’d had a similar display and his worked.
The penny dropped… so I sent an email to Banggood who rapidly shipped off a pair of replacements. They turned up in deepest Spain this morning and here I am. They work, PERFECTLY – so it looks like, after all that, I simply had a duff display (looking now I can see a minor crack in the bottom left of the display which may have resulted in a disconnected internal wire) – nothing wrong with the Tasmota driver at all.
If you check the link in this article to the displays – note that for some reason Banggood show the GND and VCC positions to be the same as the SSD1306 displays – in FACT they are reversed (and marked accordingly) on the displays I have (i.e. vcc on the outside).
To drive these OLED displays, assuming for now you are working in the Tasmota webUI – is easy. But take note – the displays use 4 wires in total – 3v3,gND, SCL and SDA (i2c). The Tasmota (display version bin file) settings for this are easy – simply set GPIO4 (D2) to SDA in the webUI and GPIO5 (D1) to SCL using the “generic (18)” template. This as it happens is a choice, you don’t HAVE to use GPIO4 and 5, I just tried moving SCL to GPIO12 and it worked just as well.
Then wire the display to the ESP8266 board. (for reference these boards sit at i2c address 0x78 by default – that is how Tasmota knows the board is connected. In addition, a couple of commands are needed and these are non-volatile.
displaymode 0 displaymodel 7
There are a ton of commands and settings for displays and it all gets confusing very quickly – the ones I’ve given you above are all you need to get started. That should force a reset of the board and give you a blank screen on the display. Next you will want to send some text…again in this case in the console:
displaytext Hi how are you today
Of course it doesn’t stop there – you can set one of several fonts, clear the screen, change orientation and so much more as well as xy position the cursor but that gets confusing fast so I thought I’d get the basics out of the way – I got bogged down with all the commands through trying to do too much at once. Ok, got a working display?
How about clear screen and a little cursor positioning..
displaytext [z]Hi there[x0y8]how are you
“displaytext” supports commands in square brackets which can be used for control – for example [z] clears the screen, [x0y8] sets the cursor down and left etc. To go further – I direct you back to the massive Tasmota commands page (display section) for more. You have a small choice of fonts, can draw rectangles etc filled or un-filled and more.
If you were sending commands via MQTT, in this example to a device I’m calling “display1”, you might send the displaytext command as a topic – payload pair:
topic: cmnd/device1/displaytext payload: [z]Hi there[x0y8]how are you
Let’s ramp this up a bit by using 2 fonts (inline font setting), inline time (with seconds hence tS) and a horizontal line:
topic: cmnd/device1/displaytext payload: [zf1]HI THERE![x70tS][x0y12h128f0x0y18]how are you today?[x0y27]Lovely, thank you,[x0y36]What a nice day… topic: cmnd/device1/displaytext payload: [x0y45]Yes, it is.[x0y54]Warmer tomorrow.
Note the closing then opening brackets on the first payload – after time and before the xy setting – why? No idea but when I missed them out, the time showed up on line 2 in the smaller font – it’s a mystery).
There’s an important point here, these displays don’t last forever, so when I put a message up, sfter some time, maybe a couple of minutes depending on the job, I turn it off – this can be done with a POWER command or simply [z] to clear the display.
Until recently I was running the SSD1306 display on my home control Raspberry Pi, but now that I have this, I can combine the display and maybe a pair of SSD PSU control relays onto one nodeMCU board (I’m thinking power to the Pi and control of a pair of SSDs for cloning, all handled in Node-Red but that’s another article). Oh, another non-volatile command DISPLAYROTATE (0,1,2 or 3). Of course, it is up to you not to put too many characters on a line.
I’ll shortly expand this as I’m expecting more displays in the next week or so including colour LCD and OLED displays (the larger ones tend to use SPI hence more GPIOs).