Project Idea RF Transmitter

Hi guys, I've got an idea for a project, well, it's a component really that could be used in variouse projects but anyway here's the thing.

I recently had mice in the house. I vought some traps and caught a few in the attic. I had to place the traps in really hard to get to places and so I thought wouldn't it be good to have some electronics on each trap and have that send my iPhone a notification telling me when the trap had been sprung.

With this in mind i thought I'd hollow out the wooden base of the trap and fit a cheap RF transmitter, an ATTiny45 and a circuit that could power on the tiny when the trap was sprung so that it could send out an identifier byte to a "server" arduino.

So the limiting factors are, it has to be small enough to fit in the hollowed out base of a mouse trap, say, a 'little nipper', it has to have no wires connecting to big old batteries etc and it has to be powered completely off until it is 'soft' turned on, a pin turned high on power up holds it on until its done the transmition then goes low to power it down.

I found a circuit to handle the soft power on etc and I've build it. The problem is that I thought I'd use a couple of CR2032 coin cells to power the thing but I'm finding these are not man enough.

This little project could be really useful for an awful lot of applications, an identifiable transmitter that is always powered off until mechanically triggered, then sends its ID, then powers down again.

Does anyone know the best and easiest way to do this, I feel that using a micro is probably over kill being as I simply want to power up, send a byte then power down. It doesn't really even need to be a byte, just a uniquely identifiable signal will do but there may be many 'clients' so each would need to send a different 'ID' signal.

Interesting project. Have you already selected a transmitter / receiver? Do you have any datasheets? What are the power requirements of the modules you intend to use?

I could see switching the circuit on being easy enough when the trap is triggered. Have you solved for killing power after transmission is complete?

Is it really necessary to kill power? I mean, once the trap has been triggered, you have to go up there anyway to reset it and get the mouse out... What's the big deal with shutting it down? What if you went into low power mode instead? According to a brief glance at the datasheet, it looks the ATiny54 only draws .1 microamps in "low power" mode. I'm thinking maybe once it's switched on, it broadcasts the ID then goes into low power mode. Maybe charge a capacitor before going into lower power mode, and have the capacitor drain slowly through a resistor. Set an interrupt on the input from the capacitor so that the interrupt triggers the micro to "wake up" when the state of the input changes from the discharging capacitor. Re-transmit again and repeat. That way you keep re-transmitting the "trapped" condition periodically, which is probably better anyway. Case in point - I have a lot of 940Mhz home automation tech in my house, and periodically stuff gets jammed by my stupid 900Mhz -ish video baby monitor or some noise gets picked up from something in my neighbor's house. Repeatedly transmitting the trapped signal after a delay could help get the message across.

You'll want to start here:

http://www.airspayce.com/mikem/arduino/VirtualWire/

This library wraps up VirtualWire to make it much simpler to implement:

http://www.billporter.info/2011/05/30/easytransfer-arduino-library/

With respect to powering down the transmitter you could just feed it current through a digital pin; set the pin high/low to turn it on/off. These things use very little power so the ~20ma possible with a digital pin is plenty. I'm sure you can find plenty of info on how to sleep the ATTiny as well.

Hey, I really want to power down the thing because I want the battery to last a long time, my door bell calls its bell using a remote button with a CR2032 and my car alarm central locking does too so I would like to also, it just means power is not being drained and I can set and forget it.

Ok, so for the soft power circuit I thought of using this

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-off

I see what your saying about re-transmitting the signal and aslo about resetting manually but I thought that I’d like to design this so that it could be dropped on other projects too, like my front door bell, where the space and power constraints would also apply as my door bell is RF and uses a self contained CR2032 battery (I wonder how they do that)

And here are a couple of pics of the setup I have already, I have an ATTiny45 using one of those cheap chinese RF transmitter/receiver pairs. I originaly used VirtualWire when i coded it to use two arduino pro minis but that lib didn’t shoe horn into a tiny so I wrote my own(ish) code to do the sending utilizing something of a Manchester encoding algorythm, this was my starting point for that :

The Transmitter

The Reciever

And here is the test code, it sends a transmition every ten seconds, I know I’ve not encorperated the soft on off yet but this code is just trialling sending and receiving using the tiny chip. I will probably use something like prowl and avvisio (http://avvisoapp.com/) to send the push notification ultimately.

ATTiny45 transmitter code

#define tx_pin 1
const char ID = '1';

void setup(){
  pinMode(tx_pin, OUTPUT);
}

void loop(){
  sendData(ID);
  delay(10000);
}

void sendData(byte input)
{
  int i;
  
  //start by sending a pre-amble for 10 miliseconds
  unsigned long t = millis();
  
  while((millis() - t) < 10)
  {
    digitalWrite(tx_pin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(tx_pin, LOW);
    delayMicroseconds(1000);
  } 
  
  digitalWrite(tx_pin, HIGH);
  delayMicroseconds(3000);
  digitalWrite(tx_pin, LOW);
  delayMicroseconds(500);
  
    for(i=0;i<8;i++)
    {
      if(bitRead(input, i) == 1)
        digitalWrite(tx_pin, HIGH);
      else
        digitalWrite(tx_pin, LOW);
      delayMicroseconds(500);
      
      if(bitRead(input, i) == 1)
        digitalWrite(tx_pin, LOW);
      else
        digitalWrite(tx_pin, HIGH);
      delayMicroseconds(500);
    }
  
  digitalWrite(tx_pin, LOW);
}

Any Arduino receiver code

#define rx_pin 3
byte data_in;

void setup(){
  pinMode(rx_pin, INPUT);
  Serial.begin(9600);
}

void loop(){
  data_in = 0x00;
  //start by checking for a 10 miliseconds high
  unsigned long t = millis();

  while((millis() - t) < 10)
    if(digitalRead(rx_pin) == LOW)
      return;
  
  while(1)
    if(digitalRead(rx_pin) == LOW)
    {
      delayMicroseconds(8000);
      for(i=0;i<8;i++)
      {
        if(digitalRead(rx_pin) == HIGH)
          bitWrite(data_in, i, 1);
        else
          bitWrite(data_in, i, 0);
           
        delayMicroseconds(8000);
       }
       
       if(data_in != 0x00)
         Serial.print(data_in, BIN);
       break;
     }
}

This is the tx/rx data

Receiver
Operating voltage : DC 5V
Quiescent Current : 4mA
Receiving frequency : 433MHZ
Receiver sensitivity : -103DBm
Size : 30 x 12 x 7mm
Working temperature : -20°C ~ +70°C

Transmitter
Launch distance : 20-200 meters (different voltage, different results)
Operating voltage : 3-12V
Transfer rate : 4KB / S
Transmitting power : 10mW
Transmitting frequency : 433MHZ
working current : 20-28mA
Standby current : 0mA
Output power : 16dBm (40mW)
Transfer rate : <10Kbps
Working temperature : -10°C +70°C
Size : 19×19×8mm
Pinout from left ? right : (DATA; VCC; GND)