FYI: Interfacing Wireless Remote Control Sensor PT2262 / 2272 SC2272

Lately I have been experimenting with wireless sensors that use the PT2262/2272 integrated circuits. These chips are common in inexpensive, Chinese manufactured security alarm sensors, such as PIR Motion Detectors, door-open sensors, smoke alarms, keychain-fob remote controls, etc. Just seach eBay with "wireless alarm sensor My99" and you'll see a slew of what I am talking about.

I recently obtained, for about $7US e/w delivery, a 433MHz receiver e/w SC2272-T4 decoder and an associated keychain fob wireless remote control with four data buttons. I realize that the 2262/2272 protocol can be simulated in code (see the RC-SWITCH project) but I prefer that the protocol be in hardware so as to limit code-bloat, although I did test RC-SWITCH (see bottom of post). I don't really like that the SC2272-T4 in my unit is a toggle version. There are both Momentary and Latched versions of the same module, ironically, available under the same name - R06A

You can see a YouTube video of my experiment with the 2272 wireless receiver and keychain fob at YouTube-Link.

If you are interested in more of the technical details of the 2262/2272 chipset, read my blog post titled "Wireless Remote Control PT2272 for Arduino".

The same code can be used for any of the aforementioned 2262-based sensors.

The YouTube video polled the receiver's ports. The improved code below uses interrupts.

/*
** Test of R06A RF decoder e/w SC2272-T4
**
** This example uses a SainSmart I2C LCD2004 adapter for HD44780 LCD screens
**
** LCD2004 Address pins 0,1 & 2 are all permenantly tied high so the address 
** is fixed at 0x27
**
** Written for and tested with Arduino 1.0
** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal 
**
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
**
** NOTE: Tested on Arduino NANO whose I2C pins are A4==SDA, A5==SCL
**       INT0 is on D2
** Wiring for Nano: A4->SDA, A5->SCL
*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

// These pins are on the PCF8574 I/O expander for I2C-bus, not the nano
#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

#define  LED_OFF  0
#define  LED_ON  1

#define	PIN_D2_INT	0

// R06A defines - wired to Digital Arduino pins
// Wire the R06A per this assignment
#define R06A_VT 2    // used for INT0
#define R06A_D0 3
#define R06A_D1 4
#define R06A_D2 5
#define R06A_D3 6

int r06a_0, r06a_1, r06a_2, r06a_3 = 0; // storage for data states
int dirty = 0;	                        // interrupt has occurred flag

LiquidCrystal_I2C	lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

// Interrupt Service Routine attached to INT0 vector
void pinD2ISR()
{
    // Provide a visual clue of the interrupt
    digitalWrite(13, !digitalRead(13));  // Toggle LED on pin 13
    // Grab the data states
    r06a_0 = digitalRead(R06A_D0);      // Grab data for later consumption in loop()
    r06a_1 = digitalRead(R06A_D1);
    r06a_2 = digitalRead(R06A_D2);
    r06a_3 = digitalRead(R06A_D3);
    dirty = 1;				// flag interrupt occurance
}

void setup()
{
  lcd.begin (20,4);
  
// Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(LED_ON);
  
  lcd.home ();                   	// Home
  lcd.print("Test of R06A Decoder");	// Logo 1st line
  lcd.setCursor ( 0, 2 );        	// Go to the 3rd line
  lcd.print("DAT3 DAT2 DAT1 DAT0");
  
  attachInterrupt(PIN_D2_INT, pinD2ISR, RISING);	// Set D2 interrupt
  
  // setup the R06A decoder connections
  pinMode(R06A_D0, INPUT);
  pinMode(R06A_D1, INPUT);
  pinMode(R06A_D2, INPUT);
  pinMode(R06A_D3, INPUT);
}

void loop()
{
	if(dirty)
	{
		dirty = 0;		// clear interrupt occurance flag
		lcd.setCursor (15,3);     // go to LCD col 15 of line 4
		lcd.print(r06a_0 ? "HIGH": "LOW ");
		lcd.setCursor (10,3);     // go to LCD col 10 of line 4
		lcd.print(r06a_1 ? "HIGH": "LOW ");
		lcd.setCursor (5,3);      // go to LCD col 5 of line 4
		lcd.print(r06a_2 ? "HIGH": "LOW ");
		lcd.setCursor (0,3);      // go to LCD col 0 of line 4
		lcd.print(r06a_3 ? "HIGH": "LOW ");
	}
}

I did test the RC-SWITCH software using a plain 433MHz receiver. I compiled the test code “ReceiveDemo_Advanced.pde” and when I press the keychain-fob’s “A” key, the output is:

Decimal: 5227968 (24Bit) Binary: 010011111100010111000000 Tri-State: F01110FF1000 PulseLength: 451 microseconds Protocol: 1 (plus the raw data)

When I paste the raw data into Sui’s RC-SWITCH visualization tool at rc-switch raw data viewer the attached waveform in is the result. If you decode it you’ll see that it matches “F01110FF1000?. Pressing the “B” key yields “F01110FF0100?, the “C” key “F01110FF0010? and the “D” key “F01110FF0001?. You can clearly see that the least significant digits are the data field with the “D” key being the least significant. The address field is “F01110FF” which matches the solder pads on my key-chain fob used for the tests.