RF 433mHZ modules not working
hi everyone,
i have 2 arduinos (one arduino nano connected pc, , arduino pro mini receive data through rf)
i bought pair of transmitter/receiver 433mhz, , i'm using virtualwire libraries. models are:
i'm sending data hyperterminal arduino nano, , lights led when receives string "ocho" (ok).
the problem can't make transmision work!! attach code of rx , tx, , 2 photos of protoboards arduinos. hope can help! suspect of antennas, tried different lenghts (18 cm, 30 cm, eg), i'm using small wires, maybe problem? or using jumper wires can make them not work @ all? (i tried bringing them close , nothing..)
the receiver should light ledrx when vw_get_message(buf, &buflen) true, never happens.
i tried not setting: vw_set_ptt_inverted(true); , nothing
mariana
i have 2 arduinos (one arduino nano connected pc, , arduino pro mini receive data through rf)
i bought pair of transmitter/receiver 433mhz, , i'm using virtualwire libraries. models are:
- receiver: rx-xd 5v
- transmitter: xd-fst (fs1000a)
i'm sending data hyperterminal arduino nano, , lights led when receives string "ocho" (ok).
the problem can't make transmision work!! attach code of rx , tx, , 2 photos of protoboards arduinos. hope can help! suspect of antennas, tried different lenghts (18 cm, 30 cm, eg), i'm using small wires, maybe problem? or using jumper wires can make them not work @ all? (i tried bringing them close , nothing..)
code: [select]
// rx:
#include <virtualwire.h>
int pos = 0;
int ledocho=3;
int ledrx=5;
int ledgrabok=10;
int patarx=8;
void setup()
{
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_set_rx_pin(patarx);
vw_rx_start();
pinmode(ledocho, output);
pinmode(ledrx,output);
pinmode(ledgrabok,output);
}
void loop()
{
byte buf[vw_max_message_len];
byte buflen = vw_max_message_len;
int i;
string numeropedido="";
digitalwrite(ledgrabok,high);
// enters if receives data:
if( vw_get_message(buf, &buflen) )
{
digitalwrite(ledrx,high);
for (i = 0; < buflen; i++)
{
if ((char)buf[i]=='.'){ break; }
numeropedido= numeropedido +(char)buf[i];
}
if (numeropedido=="ocho"){ digitalwrite(ledocho,high); }
else{digitalwrite( ledocho,low); }
numeropedido="";
digitalwrite(ledrx,low);
}
}code: [select]
// tx
#include <virtualwire.h>
// variables globales
char cad[100];
int i=0;
string cadena="";
int ledocho=2;
int patatx=6;
int answer=0;
int ledtx=10;
void setup()
{
vw_set_ptt_inverted(true);
vw_set_tx_pin(patatx);
serial.begin(9600); // abre el puerto serie 9600 bps
vw_setup(2000); // abre el puerto rf 2000 bps
pinmode(ledocho, output);
pinmode(ledtx,output);
serial.print("finalice con \".\" cada envio de datos.");
}
void loop()
{
// indica cuantos caracteres hay en el buffer:
if( serial.available() > 0)
{
cad[i] = serial.read();
serial.print(char(cad[i] ));
cadena = cadena + cad[i];
i++;
}
if( cad[i-1] == '.')
{
cad[i] = '\0';
i=0;
if (cadena == "ocho."){
digitalwrite(ledocho, high);
}
else{
digitalwrite(ledocho,low);
}
cadena = "";
answer=vw_send((byte *)cad, strlen(cad));
digitalwrite(ledtx,answer);
answer=0;
vw_wait_tx();
delay(200);
}
}
the receiver should light ledrx when vw_get_message(buf, &buflen) true, never happens.
i tried not setting: vw_set_ptt_inverted(true); , nothing
mariana
code: [select]
cad[i] = serial.read();
serial.print(char(cad[i] ));
cadena = cadena + cad[i];
this looks pretty stupid. use string (not preferred) or string (preferred) store data, not both.
the serial port on receiver doing what? why not being used debugging?
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > RF 433mHZ modules not working
arduino
Comments
Post a Comment