Miss data with VirtualWire sometimes.

Hello.
I'm trying to make a monitor device for my central pellet-based heater so I don't need to go in the stairs always to see if it's working or not.

The devices are in 2 pieces:

  1. the transmitter with 4-5 inputs and transmitt these data to ..
  2. the reciever where I can see on a display (on living floor) if its ok, which state it's in and if it's any faults.

I have done this so far just to test the transmitter/reciever:

A transmitter which sending strings like:
A 1
A 2
A 3
and so on.. It's counting.

And on the reciever (which is connected to PC to monitor the input)

Everything is almost ok, sometimes I don't get a number, it jumps over one.
2 or 3 numbers of 100 numbers can be missing.

A log for some of the numbers just to clarify what I mean:
(Here the number 'A 3880' is missing.)

Got: A 3877
Got: A 3878
Got: A 3879
Got: A 3881
Got: A 3882
Got: A 3883
Got: A 3884

Using: RX433N and TX433N devices. (the TX433N has 12v in it)
I'm using VirtualWire lib.
Baudrate is set to 500bps in VirtualWire.

The transmitter code (The example code from VirtualWire):

// transmitter.pde
//
// 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
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <stdio.h>
#include <VirtualWire.h>

int x;
char buffer[10];
    
void setup()
{
    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(500);       // Bits per sec
}

void loop()
{
    sprintf(buffer,"A %i",x);
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)buffer, strlen(buffer));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(1000);
    x++;
    if (x > 9999) x=0;
}

And the receiver code:

// receiver.pde
//
// 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
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

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

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(500);       // Bits per sec
    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[10]; // VW_MAX_MESSAGE_LEN
    uint8_t buflen = 10; // VW_MAX_MESSAGE_LEN
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      int i;
        digitalWrite(13, true); // Flash a light to show received good message
      // Message with a good checksum received, dump it.
      Serial.print("Got: ");
      
      for (i = 0; i < buflen; i++)
      {
          Serial.print(buf[i],BYTE);
      }
      Serial.println("");
        digitalWrite(13, false);
    }
}

Any suggestion?

Or maybe someone know a better way to transmit data wireless?

Seems to be a power problem when using USB as powersource.

With USB I got 4.7 V and the receiver want 4.5 to 5.5 V.
Several missed data, around 4-7 missed of 100 transmitts.

With extern powersource from an 7.5V AC/DC adapter I got 5.01 V on board and almost no missed data, maybe 1 of 300 transmitts.
:slight_smile:

So I will try later with about 5.2 V and try again.

Update: Fixed the antenna from being about 60cm to about 20 cm, and it seems to be better. 1 missed data of 788 transmitts. :smiley: