I took the plunge and decided to “design” and create a small PCB intended to keep together neatly the bits I want on a couple of sensors.

Fritzing

Writing a book was, for me, a lot more work than designing a small printed circuit board (PCB), but even so, the design took a few hours to create, particularly since I wanted to squeeze everything as closely together as possible to save cost on the manufacturing. The book-writing gave me a lot more satisfaction, but I’ll admit to being tickled when I received a thin envelope with two very small PCBs in it.

PCB

I suppose most of you will snort at seeing that, as it’s basically just a holder for a few integrated parts and not a real board design, but that doesn’t bother me at all; snort as much as you like.

I created these using Fritzing and used their (not inexpensive) Fritzing Fab PCB factory to produce them. They’re located near Berlin, so I was hoping for quick turnaround which I got. The PCB has a Wemos-D1 ESP8266 on it with a DS18B20 digital temperature sensor and a digital Lux meter thing which flips when luminosity goes under or above a threshhold which is set on it. And the PCB works.

soldered

The firmware running on the Wemos-D1 mini is based on Homie because I’ve had very good experiences with it, and it’s rock stable.

There will probably be a second iteration of the Homie/LT PCB. For one, the big fat red LED will go away (yes, I was told it’d be idiotic, but I wanted blinkenlights!), and we’ll probably add a simple LDR instead of the digital light sensor as the latter is very tall and gives the whole thing a rather ungainly look.

homie-ota

Apropos Homie: I decided to create a small Python utility called homie-ota which comes with a really retro-style looking, vintage Web interface upon which you can see an inventory of Homie devices in your network, upload new firmware binary files and issue an OTA (Over the Air) request via MQTT to a device for it to come and get a new firmware. I’ve been laughed at for the look-and-feel of the Web pages, but Ben has nevertheless been very supportive and has provided a ton of features and patches.

homie-ota

Relay board

Another thing which is running Homie in the house is a small WiFi IoT Relay board which I had to try: it costs $6 including enclosure and postage & handling, and it switches two 220V outputs.

Electrodragon

Nathan Chantrell wrote an in-depth review about this and a second module while the Electrodragons were en-route to me. To cut a long story short, I don’t regret this purchase, and the devices appear to be safe enough for the load I’m running them on (a lightbulb or two).

OpenHAB

The small relay board I described above is well suited to be integrated into my OpenHAB installation which I do via MQTT of course. This items file picks up one of the relays and allows me to switch it:

Group homie "Homie"

String homie_name { mqtt="<[hippo:devices/dr03/$name:state:REGEX((.*))]" }
Switch homie_online { mqtt="<[hippo:devices/dr03/$online:state:JS(homie-tf.js)"}

Switch  homie_relay
	<selfSocket>
	(Relays) { 
	mqtt="<[hippo:devices/dr03/relay1/on:command:JS(homie-tf.js)]",
}

Switch homie_relay_setter {
	mqtt=">[hippo:devices/dr03/relay1/on/set:state:ON:true],
	      >[hippo:devices/dr03/relay1/on/set:state:OFF:false]"
}

String homie_fwname {
	mqtt="<[hippo:devices/dr03/$fwname:state:REGEX((.*))]"
}
String homie_fwversion { 
	mqtt="<[hippo:devices/dr03/$fwversion:state:REGEX((.*))]"
}

Number homie_signal {
	mqtt="<[hippo:devices/dr03/$signal:state:REGEX((.*))]"
}

String homie_fwname_fwversion

As it’s all MQTT-controlled, I can switch a relay either by pressing the switch in the OpenHAB UI or with an MQTT publish:

mosquitto_pub -t 'devices/dr03/relay1/on/set' -m true

openhab

It’s a huge bit of fun to play with these ESP8266 modules, and at their extremely low cost, there’s not much you can do wrong.

See also: Homie for Python.

automation and MQTT :: 02 May 2016 :: e-mail