FHEM: Battery powered Home Automation remote display using small OLED and MQTT

This is the successor of my MQTT remote display. It is battery driven and can so be placed where you want.

The main component is a Pololu U1V11F3, a step up/down converter with 3V3 output and an Enable input pin. Unfortunately the Enable pin is already clamped to Vin via a 100K resistor. For me I had to remove the small SMD resistor to have the circuit powered off normally. The R6/100K is located directly to the Enable in Input connectors of the Pololu board.

The Enable pin is then connected to GND via an 1M resistor to ground. Do not leave the Enable pin floating, it will sense a finger tip already and switch to on/off by accident.

Then I added a momentary switch and a 47K resistor between Vin (the battery Plus) and the Enable pin. If the switch is pressed, the converter starts and gives 3V3 on it’s Output pin. This powers the ESP12 and the OLED display. But only as long as you press the switch. So I added a Diode from GPIO14 of the ESP-12 to the Enable pin.

In the code, GPIO14 is set as output and immediately set to high. This will enable the converter even when the switch is released.

After some code cycles, the GPIO14 output is set to low and the power of the converter is shut down.

The converter will not drain the battery in shutdown mode. But you need to press and hold the switch 2 or 3 seconds until the code powers the Enable pin.

FHEM: Home Automation remote display using small OLED and MQTT

I wanted to have a small display with some essential Home Automation data. So I buy an 1.3″ OLED display with I2C interface and started to look for some existing code for an ESP8266. The display should be feed using WiFi and be portable, so I can place it where needed.

I started with ESPeasy, as there is already support for multiple pages with text lines. Unfortunately the code is written to show sensor data of directly connected sensor only. No option to publish free text or data from a Home Automation system. The ESPeasy code will save the text to flash memory on every change when using the Web GUI. The flash memory would wear out after some month with my use case.

Finally I decided to start my own code. First I had to find out that the OLED display is not an SD1306 but a SH1106 one. Although some people state that these are more or less the same, the SD1306 libraries did not work for me. Then I found https://github.com/ThingPulse/esp8266-oled-ssd1306 which works well for me.

Starting with SSD1306UiDemo.ino I added WiFi and MQTT libaries and code.

My code will show 6 lines of text on two frames (3 lines each). The frames will change every 5 seconds. The content of the text lines is published by a FHEM server. As there was no easy way to integrate the display using a MQTT_DEVICE definition in FHEM, I wrote my own perl mqttmsg sub function and used the FHEM notify definition to publish changes to the display.

a small video

Continue reading ‘FHEM: Home Automation remote display using small OLED and MQTT’ »

Electronics: Modify Cree like Motorcycle LED Fog Projector Light

U5, U3 U7 Cree LED light with 3000lm and 30W?

There are various cheap High Power LED motorcyle LED lights out there, all coming with different circuits but all with 3 Modes: High Beam, Low Beam and Strobe Light.

A friend baught some of these LED Lights and asked me to remove the Strobe and Low Beam. Unfortunately, non of the existing posts had the same circuit board inside. During my research and tests I blew one the pair. I hoped to get a known circuit driven Light by buying another pair with Devil Eye, a blue Angel LED circle which is specified with 12-80V.

Continue reading ‘Electronics: Modify Cree like Motorcycle LED Fog Projector Light’ »

Android: Print PDF to Thermal Portable Wireless Printer

Recently I got the request to write an application that prints a PDF file on a portable Thermal printer.

Normally that does not make sense, as the protable printers come with 2, 3, 4 or 5 inch paper width only. But the PDF files are created for 3 inch paper and os this Receipt printing makes sense.

The idea was to render the PDF to a bitmap and then print the bitmap to the printer. These printers do not support PDF or Postscript, they come with special Printer Language support as called ZPL, ESP/P, CPCL or others. So we need to create a Bitmap of the PDF first and then print the Bitmap.

I started using the Android Google PDFRenderer but this fails with two issues: the bitmaps created are always transparent and print with black background where white has to be; the text was not rendered as the Fonts did not render.

Among others I found PDFbox and after fixing a small issue with scaling of bitmaps the solution works very well.

The CPCL_Sample code and application can load a PDF file. This is then converted to a scaled bitmap which can then be printed to a CPCL compatible printer. The CPCL performance is very different and printing on a Zebra takes about a minute for a 3 by 4 inch sized bitmap.

The code has to use a lot of intents and background tasks as most processing takes some time. The bitmap is created by an IntentService. The Sewoo SDK prints the bitmap first to a queue buffer and there is no control or feedback about the status of the print job. So it hopefully prints after some time.

By replacing the print SDK you should be able to print the bitmap of the rendered PDF to any Bitmap-Printing capable printer.

Be warned: there are Printers that are compatible with a Printer Language like CPCL but may not support Bitmap printing.

Source code and apk at github.