Now for the actual hacking part...
Below is the RCSwitch output in Serial Monitor.
The attached pic is a "telegram" copy of the raw data.
Reed Switch Sensor - Basic Receive:
Received 5592405 / 24bit Protocol: 1
Reed Switch Sensor - Advanced Receive:
Decimal: 5592405 (24Bit) Binary: 010101010101010101010101 Tri-State: FFFFFFFFFFFFÀ PulseLength: 479
microseconds Protocol: 1
From the above I conclude the reed switch sensor has an id code : 5592405
My objective is to capture the id code (5592405) with my existing sketch (to be modified) whenever the reed switch sensor transmits.
This is a basic form of my existing receiver sketch which already works with a home-grown sensor.
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (email@example.com)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
char cid = "0000-0001_A01";
Serial.begin(9600); // Debugging only
Serial.println("setup"); //Prints "Setup" to the serial monitor
vw_set_rx_pin(A5); //Sets pin D12 as the RX Pin
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
for (i = 0; i < buflen; i++)
char c = (buf[i]);
// Serial.print(" ");
So the question is how to modify my sketch so-that it still works with my home-grown sensor but additionally can detect the reed switch sensor.
I know RCSwitch listens on an interrupt port I would need to use Pin 2 or Pin 3.
Broadly speaking I am assuming I would need to integrate parts of the RCSwitch sketch into my sketch.
In theory I know I could start with the RCswitch sketch as a base and modify it to extract the id code, then add the rest of my code that I need.
I will probably need to add an array of known sensor id codes, so the sketch only processes input from (my) specific sensors and not stray transmissions.
I would appreciate any suggestions of different/better approaches.