This was a quick project to add notifications for when I get real physical mail. This is something I’ve had on my mind since I made my first SMS doorbell notification system back in 2004 and I finally got around to it last month.
First of all I picked up a cheap internal letterbox flap and fixed that over the internal side of the letterbox opening. Then I took a microswitch that I had salvaged out of an old dot matrix printer some time ago and made a little right angle bracket from some perforated metal strip I had lying around. A few little adjustments to the microswitch actuation lever and I had it operating the switch as soon as the flap was moved even only slightly. It also operates it as it closes but that is easily taken care of in code to prevent duplicate notifcations and can also be used to detect if something is stuck part way through the letterbox instead of being pushed all the way through.
I last blogged about this in December 2013 when the second version of my ATmega328 & DS18B20 based temperature sensor, installed on 29 December 2011, had just reached the 2 year mark on the original set of batteries. That’s pretty good going and I’d have been happy with that but how long would it last until those Energizer batteries needed replacing? Well I found out in March of this year when it finally started to report erroneous readings, yes that is over 3 years on one set of AA batteries. To be honest, I did have a false alarm a few weeks prior when it started to transmit very irregularly but it recovered from that, presumably due to the increase in temperature affecting the battery capacity.
This is a small dev board I designed to make experimenting with and deploying the ESP8266 ESP-03 modules a bit easier. As well as breaking out all the pins to 2.54mm headers it has a position to fit either a DS18B20 temperature sensor or a DHT22 temperature/humidity sensor plus the required pull up resistor. It can be powered from 3.3V or 5V+* if the regulator is fitted and there is a footprint for a micro USB connector if required.
*The regulator I used is good for up to 18V but I don’t know how far you would be able to push it with only the small area of PCB that is used as a heatsink. I would imagine it will be OK to at least 9V.
A 3 way pin header allows a jumper to be moved to switch between normal running mode and flash programming mode. With the jumper in the RUN position GPIO0 is connected to the header marked 0 and in the PRG position GPIO0 is grounded. It needs to be powered up with the jumper in the PRG position to enable programming mode.
Like many people I have been playing with the Espressif ESP8266 WiFi modules over the last few months. I’ve had a couple of modules running for a while now, one connected to an Arduino pro mini clone with a 2×16 OLED display and one running directly on the ESP8266 using the NodeMcu Lua interpreter controlling a relay over an HTTP REST-like API.
One thing I was really hoping for was a native MQTT implementation as it is the protocol I use for my home automation and sensor network. Luckily tuanpm on the esp8266.com forums gave us a boxing day present in the form of a native MQTT client. MQTT on the ESP8266 means it will be easy to integrate input and output nodes in to my existing home automation and sensor network.
I got the idea for this after watching Dave’s teardown of the 1984 Sinclair flat screen pocket TV and thought it looked like a good candidate to make a cool retro style status display housing.
So soon after watching Dave’s teardown I headed off to eBay and picked one up, this one was non-functional to begin with (dead CRT) so I had no qualms about gutting it. With the guts and the fresnel lens removed you are left with a nice big space with a nice clear window for the screen.
This is part of a series of posts I am doing describing some of the things I have been doing as part of the revamp of my home automation system.
When I started on the home automation road in 2002 I began with a kit of 3 X10 modules and a CM12U PC interface which I controlled via the command line X10 application Heyu and some DIY scripts, shortly afterwards I switched to the Perl based MisterHouse package which I heavily customised over the years and continued to use until recently.
Many more X10 modules were added over time giving me control of most lights in the house as well as several appliances. X10 has always had a few issues though, the modules are fairly costly although the clones available these days have improved that somewhat but the biggest issue has always been that it is susceptible to noise or interference on the mains line causing things to not turn on/off when asked or to turn on/off erroneously. As more and more electrical devices have been added around the house and with nearly every wall socket having a 4, 6, 8 or more gang adapter plugged into it these problems have only got worse.
With this in mind I’ve been gradually adding more and more Home Easy modules to replace the X10 modules that were causing problems and have now switched almost exclusively to Home Easy. Unlike X10 these modules work via RF so don’t have the same communication problems and they are very cheap, 3 appliance modules can be had for around £20 with a remote control, less if you pick them up second hand on eBay and being controlled via 433MHz OOK signals they can easily be controlled using an Arduino etc.
Node-RED is currently taking the IoT world by storm, described as “A visual tool for wiring the Internet of Things” it is built on top of Node.js and is an open source project developed by IBM employees. It makes it easy to link various inputs and outputs adding simple or not so simple processing in between, just drop your various parts into a workspace and link them up. It also makes a great way to map MQTT topics to each other.
It comes with a whole host of input and output nodes, MQTT, http, websockets, serial, tcp/udp and it can read logs, write to files, call external programs, connect to databases etc. which make it possible to connect with just about anything you can think of. There is also built in support for services like email, Twitter, irc, Pushbullet and Twillio SMS.
To bring the data from my sensors into Node-RED I am using one of my Tiny328 boards running the Jeelib RF12demo sketch which is connected to a cheap FTDI adapter plugged directly into my server but this could just as easily be done with a JeeLink, a TinyTX or any Arduino compatible with an RFM12B radio. If using a Raspberry Pi then the RFM12Pi could also be used.
Back in November 2011 when I made my first ATmega328 based wireless temperature sensor node I did a rough calculation estimating that it would last 2 years or more on a couple of AA batteries. That first node was decommissioned after a few months but the second version, also based on an ATmega328 is still running and on the original set of batteries since 29 December 2011, exactly 2 years ago today.
That’s with an ATmega328P running at 16MHz with a RFM12B radio and DS18B20 temperature sensor powered from 2 x Energizer alkaline AA batteries (essentially the same as the new SMD Tiny328 nodes but built on stripboard) and is transmitting once a minute. The battery voltage is now down to 2.71V which is well out if spec for a 328 running at 16MHz but the datasheet specs seem to be very conservative and it is still ticking along fine. Previous tests showed that it should be good down to around 2.6V with the DS18B20, below that the sensor’s readings start to become erratic. Again, that’s a good margin less than the minimum of 3V stated in the data sheet.
Two plus years is inline with my original predictions but it is good to see it actually happen in the real world, particularly as this node started out on code that wasn’t quite as optimised for low power use and since I enabled ACKs at the end of August 2012 it makes quite a few retries (it is the furthest from the base station) so in reality it often sends more than once a minute.
Vic at Wicked Device kindly sent me one of their new WildFire Arduino compatible boards to try out. The WildFire uses the ATMega1284P microprocessor clocked at 16MHz and has an onboard Texas Instruments CC3000 WiFi module and a MicroSD card slot all on a board the same size as a standard Arduino Uno or Duemilanove.
Followers of this blog will know I’m a big fan of the ATMega1284P and it was what I used in my own OSWIN Arduino compatible board although that was with the huge 40 pin DIP version, the WildFire uses the 44 pin TQFP package making a much smaller board possible.
The ATMega1284P has quite a few advantages over the ATMega328 used in the Uno and Duemilanove, more RAM (16KB v 2KB), more Flash (128KB v 32KB) and more EEPROM (4KB v 1KB), things which really make a difference when doing web server type applications. There is also more I/O, on top of the usual array of pins found on the Uno/Duemilanove etc. the WildFire has 2 more analogue pins squeezed in next to the usual 6 and an extra 6 pin header provides 4 more digital pins as well as duplicates of the I2C pins and there is also a JTAG programming/debug header. You also gain a second UART on D2 and D3 and an extra interrupt that means two are still available for use (INT0 on D2 and INT1 on D3) even though INT2 on D8 is in use for the CC3000 IRQ. All the available pins on the WildFire are at a 5V logic level with a couple of buffer chips handling the high/low conversions to the 3V3 parts (CC3000 and uSD slot).
Some of the pins are used for communication with the built in peripherals, namely D4 for the uSD slot CS, D7 for the MAC chip data, D8, D9, D10 for the CC3000 and of course D11,D12,D13 are the SPI pins used for the uSD slot and CC3000. The WildFire library allows you to easily create an object to make sure these pins are initialised in a safe state.
Nick was kind enough to send me one of these little Ikea cupboard lights that he had the great idea of adding one of my TinyTX sensors to. These motion controlled LED lights are only £5 for two and are available in a range of colours, they are only 7.5 x 6.5 x 1.8 cm with 4 LEDs, a PIR detector and run from 3 x AAA batteries.
This is an excellent find and the size is spot on for the TinyTX, by removing the four LEDs (or just three of them) the TinyTX 2 or 3 will fit in nicely (with the ATtiny84 soldered directly to the board for a reduced profile) and the PIR control board will happily run on only two AAA batteries so we can bridge the third one leaving space for the antenna and maybe a sensor or two. It makes for a much neater and more compact occupancy sensor or room node than the Airwick iMotion Freshmatic that is commonly hacked for this purpose.