NT-T02B/ZABR1 cheap Chinese wireless serial

I have been testing the NT-T02B transmitter and ZABR1 receiver, which are cheap Chinese wireless serial links available on eBay (search for 433 MHz Arduino). For mine, I paid $5.49 including postage. I did not bother to connect proper length antennas (18cm) so my reliable operation distance was short. The VirtualWire library is not up to Arduino 1.0, so I had to replace WProgram.h with Arduino.h in the library files in order to successfully compile.

I setup the transmitter to sequentially number the transmitted messages so that I could look for drops on the receive side. See attached screen capture.

Working sketches are below.

For the transmit end:

#include <VirtualWire.h>
#include <string.h>

// rf_tx.ino
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Original by: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
//

#undef int
#undef abs
#undef double
#undef float
#undef round

int count = 0;

void setup()
{
    Serial.begin(9600);	  // Debugging only
    Serial.println("Transmitter setup");

    // Initialise
    vw_set_tx_pin(12);    // Set tx pin (default is 12) 
    vw_setup(2000);	 // Bits per sec
}

void loop()
{
    //const char *msg = "hello world";
    char msg[VW_MAX_MESSAGE_LEN];
    char scount[VW_MAX_MESSAGE_LEN];
    
    memset(msg,0,VW_MAX_MESSAGE_LEN-1);
    strcat(msg,"Message ");
    itoa(count++, scount, 10);
    strcat(msg,scount);
    
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    Serial.println(msg);
    delay(200);
}

and for the receive end:

#include <VirtualWire.h>
// rf_rx.ino
//
// 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
// Original Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley


#undef int
#undef abs
#undef double
#undef float
#undef round

void setup()
{
    Serial.begin(9600);	// Debugging only
    Serial.println("Rx setup");

    // Initialise the IO and ISR
    vw_set_rx_pin(11);    // Set Rx pin (defaults to 11)
    vw_setup(2000);	 // 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;
    
    // Get the last message received (without byte count or FCS)
    // Copy at most *buflen bytes, set *buflen to the actual number copied
    // Return true if there is a message and the FCS is OK
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;

        buf[buflen] = 0;        // NULL terminate string received
        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Rx ");
        Serial.print(buflen, DEC);
        Serial.print(" ctrs - ");
        Serial.println((char *)buf);
        digitalWrite(13, false);
    }
}