SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By dgaugler
#190612
This is my first post so please bear with me. I am working on my first Arduino project using an RF transmitter and receiver. I was not able to get my two Arduino's to communicate using Virtual Wire but I was able to get RadioHead to work. Well sort of.

The transmitter is working fine but the receiver is doing something odd. I get a message that the "init failed." but then I get a hexidecimal equivalent of what I sent ("Hello"). It will keep on receiving that HEX code, just like it should. The transmitter is a FS1000A and the receiver is it's pair.

Does anyone have any thoughts, or experienced anything similar?

Thanks,
Dave G.
By sterretje
#190614
Maybe post the code? And please use code tags.

My transmitter test code based on one of the examples that comes with the RH library
Code: Select all
// ask_transmitter.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to transmit messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) transmitter with an TX-C1 module
#include <RH_ASK.h>
//#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
// RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11


void setup()
{
  Serial.begin(9600);   // Debugging only
  if (!driver.init())
    Serial.println("init failed");

  pinMode(13, OUTPUT);
}

void loop()
{
  static unsigned long prevMillis = 0;
  unsigned long currMillis = millis();

  char msg[24];

  static int count;

  if (currMillis - prevMillis > 500)
  {
    prevMillis = currMillis;
    sprintf(msg, "%d", count++);

    driver.send((uint8_t *)msg, strlen(msg) + 1);
    driver.waitPacketSent();

    digitalWrite(13, !digitalRead(13));

    Serial.print("TX duration (ms): "); Serial.println(millis() - currMillis);
  }
}
And the receiver code
Code: Select all

// ask_receiver.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to receive messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) receiver with an Rx-B1 module
#include <RH_ASK.h>
//#include <SPI.h> // Not actualy used but needed to compile
RH_ASK driver;
// RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11
void setup()
{
  Serial.begin(9600); // Debugging only
  if (!driver.init())
    Serial.println("init failed");
}
void loop()
{
  static int lastCount = 0;
  static int dropCount = 0;

  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(buf);
  if (driver.recv(buf, &buflen)) // Non-blocking
  {
    int count = atoi((char*)buf);
    if (count != lastCount + 1)
    {
      dropCount++;
      Serial.print("Missed some beats. ");
      Serial.print("Last count: "); Serial.print(lastCount);
      Serial.print(". Rcvd count: "); Serial.print(count);
      Serial.print(". Drop count: "); Serial.println(dropCount);
    }
    lastCount = count;

    
    Serial.println((char*)buf);

    // Message with a good checksum received, dump it.
    //driver.printBuffer("Got:", buf, buflen);
  }
}
This code was used to test the reliability.

Note: I have never seen the error message that you get.
By jremington
#190617
Agreed, post the code, using code tags. However, it sounds like the setup is working fine. Since there is nothing to initialize in those simple transmitters, I can't imagine what the "init failed" message could mean.

VirtualWire should work fine as well, and is simpler and smaller.