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
Raw data:
14860,448,1444,1360,504,440,1460,1356,508,132,2252,52,212,36,220,68,196,68,396,112,836,492,448,1456
,1388,516,424,1756,24,592,172,4008,116,4036,52,4092,484,1424,1400,520,452,1448,1388,520,100,24,1540
,1008,40,
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.
// receiver.pde
//
// 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 (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#include <VirtualWire.h>
int count;
char cid[] = "0000-0001_A01";
void setup()
{
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
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
// Serial.print("0000-0001");
Serial.print(cid);
Serial.print(".");
for (i = 0; i < buflen; i++)
{
char c = (buf[i]);
Serial.print(c);
// Serial.print(" ");
}
Serial.print(" ");
count++;
Serial.print(count);
Serial.println("");
digitalWrite(13, false);
}
}
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.