433MHz RadioHead Packet size

Hello Guys & Girls,

I am currently trying a proof of concept, the long and short of it is I need to get a message through in a very small time frame, the smaller the better. roughly 25-50ms. I know this is possible in theory so I am trying to get the real world test sorted.

I am using Arduino Unos and some 433mhz transmitter and reciveers from amazon

They are very cheap and may be no good for what I am trying to do, at the moment I am trying to see if the issue is maybe down to the code rather than the hardware. I have been using the RadioHead library to send the packets, see code below;

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;

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

void loop()
{
const char *msg = 1;
driver.send((uint8_t *)msg, strlen(msg));
// driver.waitPacketSent();
delay (0);
}

I am not as familiar with C as other languages so this is very much copy and paste commando. All I need is a simple true or false value and it does not need to be encrypted or secure in anyway for this application the key is speed.

When I send the packet above it seems to be a set length i.e. I cant get a smaller packet with 1 that i get with Hello World for instance.

Any advice as to other library or ways in with RadioHead library to send a very small packet ideally 1 byte for testing. or could it be a hardware limitation. I have FPGAs available but if I can avoid breaking out MatLab I will.

Thanks :slight_smile:

When I send the packet above it seems to be a set length i.e. I cant get a smaller packet with 1 that i get with Hello World for instance.

I can't imagine how you arrived at that conclusion, since the second argument is the size of the packet.

Of course, you are sending garbage, but that is a different issue.

You should NOT be using a pointer. The first argument is the array of data to send. If you HAVE an array somewhere, you could (uselessly) create a pointer to point to it, and give that to the function. But, you must have an array somewhere. 1 is not an array. Pointing to 1 is meaningless.

PaulS:
I can't imagine how you arrived at that conclusion, since the second argument is the size of the packet.

Of course, you are sending garbage, but that is a different issue.

You should NOT be using a pointer. The first argument is the array of data to send. If you HAVE an array somewhere, you could (uselessly) create a pointer to point to it, and give that to the function. But, you must have an array somewhere. 1 is not an array. Pointing to 1 is meaningless.

Hey thanks for the reply.

As I said I don't know this language very well. Which part is dictating the length of the packet?

And the 1 value was just to denote that I want a simple true or false the packets I have actually been sending simple words like "hello", "help" etc. the 1 was just a place holder.

the 1 was just a place holder.

There is a huge difference between

  const char *msg = "hello";

and

  const char *msg = 1;

In the first case, the compiler will allocate space to hold the literal, and msg will point to that space.

In the second case, msg will point to memory location 1. You have NO idea what data is at that location, and you most likely have no way of changing the value at that location.

   const char msg[] = "hello";
   const char msg[] = 1;

will define different size arrays with KNOWN contents.

Which part is dictating the length of the packet?

driver.send((uint8_t *)msg, strlen(msg));
But, since msg is NOT a string, it makes no sense to pass it to a function that expects a string, because you have no idea what value you get back from making a meaningless function call.

Go back to the example that came with the RadioHead library, and start over trying to adapt it.