Page 1 of 1

Simple and sleek DIY sensor

Posted: Mon Dec 12, 2011 9:00 pm
by JohnieBraaf
Hi all,

I have been looking around here and there for the possibilities in motion sensing using RF sensors.

My search basically boiled down to, RFXCOM or other RF receiver combined with X10 or Visonic sensors.
However, I dislike the non-extensibility of these options. Especially when you also want to sense temperature etc.

I have found a good solution for the above described problem by using JeeNodes.

Part list:
- Enclosure with LITHIUM charger circuit €8
- Pir €3
- 2 x 3200 Ma LITHIUM batteries €8
- 1 x JeeNode €25
- 1-wire temp sensor €1
- 1 x temp humidity sensor €3

= 48 euro per sensor

You need an extra JeeNode or JeeLink linked to your server though.

You'll get a very easily chargable completely programmable sensor with motion and temp sensing.
There is also plenty of room and ports left to add, light intensity and humidity sensors.

Image
Image

Note that I still have to craft the temp and humidity sensor in.

A simple sketch (withouth ack's or double sending packages) would look like:

Code: Select all

#include <JeeLib.h>

Port pir (1);   
byte sendSize;
typedef struct {
  byte node;
  uint8_t pir_state;
} Payload;
Payload payload;

void setup() {
    Serial.begin(57600);
    Serial.print("\n[HomeSensor]");
    rf12_initialize(1, RF12_868MHZ, 33);
    payload.node = 1;
    pir.mode(INPUT);
}

void loop() { 
    // send only if state changes
    if (pir.digiRead() != payload.pir_state) {
        payload.pir_state = pir.digiRead();
  
        // print to serial
        Serial.print("\nPIR ");
        Serial.print(payload.pir_state ? "on " : "off");
        
        // send to server
        while (!rf12_canSend()) 
            rf12_recvDone();   
        rf12_sendStart(0, &payload, sizeof payload);
    }
}
And for the server / JeeLink this would be enough for a starter:

Code: Select all

#include <JeeLib.h>

MilliTimer sendTimer;

typedef struct {
  byte node;
  uint8_t pir_state;
} Payload;
Payload payload;

void setup () {
    Serial.begin(57600);
    Serial.println(57600);
    Serial.println("Send and Receive");
    rf12_initialize(1, RF12_868MHZ, 33);
}

void loop () {
    if (rf12_recvDone() && rf12_crc == 0) {
      const Payload* p = (const Payload*) rf12_data;
      Serial.println((word) p->node);
      Serial.print(":");
      Serial.print(p->pir_state);
    }
}
The only downside of this little thingy is the attachability.
I have ordered some velchro tape, which might be useful.

I'm curious if other people are also crafting similar multi purpose sensors.
And If so, what more are they sensing in addition to motion en temperature?

Best regards,

Jan

Re: Simple and sleek DIY sensor

Posted: Mon Dec 12, 2011 9:35 pm
by DJF3
Looking good! Thank you for sharing.

DJ

Re: Simple and sleek DIY sensor

Posted: Mon Dec 12, 2011 11:10 pm
by Digit
Nice work Jan!

I also use velcro tape ("klittenband"). I usually add a few drops of super glue, so the tape will always stay firmly attached to the sensor. Or staples, in case the velcro tape is used on a wooden surface. Works great.

I'm basically doing the same; 1-wire for temperature, PIR for motion and also measuring light with a LDR.
http://blog.hekkers.net/2011/09/11/a-ne ... ne-sensor/

I see you don't use low power techniques in your sensor sketch; what's your lifetime estimate of a full charge?

Re: Simple and sleek DIY sensor

Posted: Tue Dec 13, 2011 1:46 am
by JohnieBraaf
Thats a good question Robbert. I have some coding to do concerning requiring ack's as well as the WatchDogg power savings.
You're sensors have been of great inspiration to me. Interesting home automation you got going on there with all the sensor and balancing :)

I see you communicate by XBEE, which uses a quite different communication implementation.
How did you go about making sure the package arives at its destination? And how often do you experience collisions with all these JeeNodes?

For light sensing I was actually looking at the modern devices AmbiLight sensor.
http://shop.moderndevice.com/products/ambi-light-sensor
But it sure is more difficult to hide such a huge print when compared to the photocell.

Re: Simple and sleek DIY sensor

Posted: Tue Dec 13, 2011 1:12 pm
by wwolkers
Mind sharing where you found the enclosure?
Looks like a nice option for a resonable price!

Re: Simple and sleek DIY sensor

Posted: Tue Dec 13, 2011 8:42 pm
by JohnieBraaf
Hi, Wolkers, I found almost all parts on ebay, with mostly even free shipping... see:
http://www.ebay.nl/itm/ws/eBayISAPI.dll ... 029wt_1139
http://www.ebay.nl/itm/ws/eBayISAPI.dll ... 620wt_1163

When you use this enclosure, be sure to tap the power from the large USB port. In that way the protection against undercharging stays in tact.
I can make a closeup of the linkage if you want.

Re: Simple and sleek DIY sensor

Posted: Tue Dec 13, 2011 10:09 pm
by Digit
JohnieBraaf wrote: How did you go about making sure the package arives at its destination? And how often do you experience collisions with all these JeeNodes?
Not; XBee takes care of that. Collisions? What's that? :lol:
I have 12 XBees (including coordinator), of which 8 are used for sensors. I've never experienced missing packets - like for example missing a 'no motion'.
I think it's by far the best wireless I have here.

Re: Simple and sleek DIY sensor

Posted: Wed Dec 14, 2011 12:12 am
by JohnieBraaf
That is definitely a huge advantage of using XBEE modules. It's probably even a mesh network.
Well I guess I have to work my way around it using the parts I currently have.

I read an interesting topic over at JeeLabs about a guy who implemented a random delay resend.
The random delay kindof makes sure that no sensors are trying to resend (collide) at the same time (at least not twice).

Its a challange, but I like that ;)

Re: Simple and sleek DIY sensor

Posted: Tue Dec 27, 2011 2:30 pm
by JohnieBraaf
The sensor definitely needs some work on the powersavingsside... as my batteries ran out of spirit after 2 weeks.