I’m using the SeeedStudio 2km 433 MHz RF module and I’ve been able to transmit data over my required distance (over 300 ft) including through 2 exterior walls plus interior walls). The sketches transfer 1 packet/second, but I’m able to achieve a rate of about 6/second without errors by changing the delays. For the purpose of my question, let’s stay with 1/second as originally written.
The two sketches I’m using are:
Receiver:
[code]/*
RX: 2Km RF Receiver Code from this article: http://www.seeedstudio.com/forum/viewtopic.php?f=4&t=309&p=767&hilit=pt2262#p767
RF–>arduino/seeeduino
VT–>pin3;
D0–>pin4;
D1–>pin5;
D2–>pin6;
D3–>pin7;
GND–>GND;
VDD–>5v.
*/
int data=0;
void setup()
{
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
attachInterrupt(1,RF_VT,RISING);
Serial.begin(9600);
}
void loop()
{
}
//=======================================
void RF_VT() // interrupt service function
{
data=(digitalRead(4)<<3)+(digitalRead(5)<<2)+(digitalRead(6)<<1)+(digitalRead(7)<<0);
Serial.print(“data=”);
Serial.println(data,DEC);
}[/code]
Transmitter:
[code]/*
TX: 2Km RF Transmitter Code from this article: http://www.seeedstudio.com/forum/viewtopic.php?f=4&t=309&p=767&hilit=pt2262#p767
RF–>arduino/seeeduino
D0–>pin4;
D1–>pin5;
D2–>pin6;
D3–>pin7;
GND–>GND;
VDD–>5v.
*/
void setup()
{
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
Serial.begin(9600);
}
void loop()
{
unsigned char i=0;
for(i=0;i<16;i++)
{
send_data(i);
Serial.print(“i=”);
Serial.println(i,DEC);
delay(500); // delay as short as 140 will work
send_data(0);
delay(500); // delay as short as 10 will work
}
}
//====================================
void send_data(unsigned char data)
{
digitalWrite(4,(data&0x01));
digitalWrite(5,(data&0x02));
digitalWrite(6,(data&0x04));
digitalWrite(7,(data&0x08));
}[/code]
The purpose of these sample sketches is to continuously transfer 4-bit packets starting at zero, going up to 15, then repeat.
When used this way, I reliably transfer packets for 2, 3, 4, …, 15, 2, 3, 4, …, 15 etc.
I believe I understand why ZERO doesn’t get transmitted. The code actually sends 0, 1, 0, 2, 0, 3, 0,4,… 0, 15, 0, 0, 0, 1 etc. and apparently the receiver module is looking for a transition from zero to something non-zero before firing an interrupt. So, OK.
But I do not receive ANY 1-packets. Seems like the transition from a packet of 4 zero bits (0000) to a packet of (0001) should be a transition and should work. But I never get this. Other packets with only 1 bit on (0010) (0100) and (1000) all come through fine.
Can anyone explain why the packet for “1” is always being lost? Thank you.