Ho un problema di ricezione con il ricevitore XF-FST a 433Mhz.
Visto che ho provato più Sketch con lo stesso risultato, per sicurezza vorrei escludere il programma testandolo.
Premetto che sul pin 11 il segnale dal ricevitore arriva in modo decente, ma nonostante questo non arriva in fondo dove dovrei leggere la scritta “Hello World” sul monitor seriale.
L’istruzione che dovrebbe leggere i dati ricevuti sono questi.
vw_set_rx_pin(11); // Arduino pin to connect the receiver data pin
vw_rx_start(); // Start the receiver
La domanda è: prima di queste, che istruzione devo mettere per ( sostituire ) il segnale ricevente dal
pin 11 e leggere sul monitor seriale “Hello World”
Se la scritta arriva in fondo elimino un problema e cerco prima.
Per correttezza metto il programma di ricezione e trasmissione completo.
Ringrazio anticipatamente
erosb
// Ricevitore
#include <VirtualWire.h>
void setup() {
Serial.begin(9600);
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_rx_pin(11); // Arduino pin to connect the receiver data pin
vw_rx_start(); // Start the receiver
}
void loop() {
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)){ // We check if we have received data
buf[buflen]='\0'; // Metto il terminatore di stringa
String msg = (char *)buf;
Serial.println(msg);
Serial.println();
}
}
// Trasmettitore
#include <VirtualWire.h>
void setup()
{
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_tx_pin(12) ; // Arduino pin to connect the transmit data pin
}
void loop()
{
const char *msg = "Hello World"; //Message to send:
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // We wait to finish sending the message
digitalWrite(13,HIGH);
delay(200);
digitalWrite(13,LOW);
}