Showing posts with label Home Automation. Show all posts
Showing posts with label Home Automation. Show all posts

Tuesday, 15 March 2016

12 Volt DC PIRs for Outdoor Use

I've wanted to automate the operation of some external lights in my home for a long time, and PIR motion sensors are a must. I already have several as part of an intruder alarm system, but they are not rated for outdoor use; electronics that is typically uses components with wider than normal operating temperatures (e.g. -40 to +85 degrees Celsius instead of 0 to +70), and conformal coating is often used to protect circuitry from moisture (condensation).

When I first looked for external PIRs (several years ago), I found that almost every one of them was designed to be powered by the mains, and to switch a mains load (a lamp). But I need to drive the inputs of a microprocessor based control system from the PIR, so I would prefer a contact closure (volt free) output. I did find one or two low voltage DC units, but they were horrendously expensive (nearly 100 GBP).

A more recent search turned up a much more reasonable solution:

12V DC Outdoor PIR Motion Sensor
12V DC Outdoor PIR Motion Sensor

This unit retails for under 25 GBP from Solar and Wind Power Systems. It is IP44 rated, runs from a 12 Volt (AC or DC) power supply and has a relay that can switch up to 10 Amps. It allows adjustments to on-time, range (sensitivity) and ambient light.

Note that the unit is supplied with a 4 way terminal block that is quite large (appropriate for 10 Amps). I swapped this for a smaller one. Also, the knock-outs molded into the ABS plastic housing are quite difficult to remove - I resorted to drilling them out.

Here's a video of a quick test of one. In this setup, the ambient light adjustment is at maximum (to allow daylight operation), the range/sensitivity is low, and the on-time is at a minimum - corresponding to about 5 seconds. The power supply is 12VDC, and the output is wired to ground the cathode of a blue LED - the anode is wired to 12V via a 470R resistor.



Notice that the unit's output remains on while the PIR is detecting motion, and stays on afterwards for 5 seconds.

I checked the range quickly in this setup, and detection worked reliably at 4 meters in daylight.

Tuesday, 8 March 2016

Arduino Real Time Clock

I needed an accurate real time clock for an Arduino based home automation project; many are I2C controlled and based on Maxim's DS3231 which is achieves an accuracy of about 1 minute per year (2ppm) through temperature compensation - a potentially useful side effect of this is that the part provides a temperature reading. Most boards also include an I2C EEPROM. I found a seller on eBay offering 3 units for under 5 GBP, including next day postage:

Real Time Clock and EEPROM board
Real Time Clock and EEPROM board

The board provides a header with 6 pins:
  • GND - ground
  • VCC - power (3.3V or 5V)
  • SCL - I2C clock
  • SDA - I2C data
  • SQW - programmable interrupt/square wave output
  • 32K - free running 32kHz clock output
There's a holder for a CR2032 coin cell on the reverse, to provide battery backup. Note that these are typically not included with the boards (there are international restrictions on shipping lithium batteries).

I hooked it up to my Arduino Mega 2560 with male-female flying leads: I wired GND and VCC to GND and 5V on the power header, SCL and SDA to their counterparts on the communication header, and the SQW output to the INT3 input.

I then wrote a quick program in to test the board (I prefer to code in C using Atmel's Studio for AVR microcontroller development, for more on this see here.) This used the nice, stable and simple I2C master driver written by Peter Fleury. Note that I ignored the board's EEPROM.

The program prints the current time, day, date and temperature once a second:

       
RTC test
time: 12:14.44   day: TUE   date: 08/03/2016   temperature: +24.00
time: 12:14.45   day: TUE   date: 08/03/2016   temperature: +24.00
time: 12:14.46   day: TUE   date: 08/03/2016   temperature: +24.00


The program uses the Arduino's USB serial port for console I/O, based on Mika Tuupola's recipe here. I use TeraTerm on a desktop Windows PC for this, connected to the Arduino's COM port at 115200 baud.

You can download a ZIP of the Atmel Studio 7 project from here.