Sending Arrays with Manchester.h and RF433

I’m working on a project where I have a remote arduino sending 2 temperature values and humidity to a master arduino. The data needs to be in the form of t1.t1, HU, t2.t2 Unfortunately, the examples that come with the Manchester.h library show how an array is sent/received but don’t really give any examples on how to send the type of data I’m trying to send. My assumption is that I need to convert these numbers to a string and send the data as 72.34, 34, 74.34 (The numbers are just as an example). I need to be able to return this data to numbers I can actually use on the receiving end, and not just a string. Can someone, anyone, show me what code I would use to do this? I’m including the basic manchester.h array code. I just need someone to show me what code I need to add to make this work on the transmit and receiver end code. I’m seriously at the point of major frustration with this and have run out of options.

Transmit Code:

#include <Manchester.h>

/*

Manchester Transmitter example

In this example transmitter will send 10 bytes array per transmittion

try different speeds using this constants, your maximum possible speed will
depend on various factors like transmitter type, distance, microcontroller speed, …

MAN_300 0
MAN_600 1
MAN_1200 2
MAN_2400 3
MAN_4800 4
MAN_9600 5
MAN_19200 6
MAN_38400 7

*/

#define TX_PIN 5 //pin where your transmitter is connected
#define LED_PIN 13 //pin for blinking LED

uint8_t moo = 1; //last led status
uint8_t data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, moo);
man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
man.setupTransmit(TX_PIN, MAN_1200);
}

void loop() {
man.transmitArray(10, data);
moo = ++moo % 2;
digitalWrite(LED_PIN, moo);
}

Receive Code:

#include <Manchester.h>

/*

Manchester Transmitter example

In this example transmitter will send 10 bytes array per transmittion

try different speeds using this constants, your maximum possible speed will
depend on various factors like transmitter type, distance, microcontroller speed, …

MAN_300 0
MAN_600 1
MAN_1200 2
MAN_2400 3
MAN_4800 4
MAN_9600 5
MAN_19200 6
MAN_38400 7

*/

#define TX_PIN 5 //pin where your transmitter is connected
#define LED_PIN 13 //pin for blinking LED

uint8_t moo = 1; //last led status
uint8_t data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, moo);
man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
man.setupTransmit(TX_PIN, MAN_1200);
}

void loop() {
man.transmitArray(10, data);
moo = ++moo % 2;
digitalWrite(LED_PIN, moo);
}

I’m not sure that I understand it.

Do you have to use that Manchester library ? Or can you choose your own protocol ?

The Manchester code is good to transmit something. However, the VirtualWire or RadioHead is a lot better.
http://www.airspayce.com/mikem/arduino/VirtualWire/
http://www.airspayce.com/mikem/arduino/RadioHead/

I assume that “man.transmitArray(10, data);” transmits the array, using Manchester coding.
To receive something, there should be a function for receiving and decoding.

Are you using this ?

Do you use the newest version ?
There is an example to receive an array.

Which Arduino boards are you using ? and which transmitters and receivers ?

I think your main question is, how to transmit in the form of t1.t1, HU, t2.t2 (72.34, 34, 74.34).
Do you really have to transmit it like that ? Is that a string ?
It is easier to transmit a floating point as a binary variable.
When that is a string, the funtion to use is dtostrf().
The receiver can use atof().

I was actually able to get this project working using virtualwire, but the problem was that after an hour or so, the data would start getting corrupted and truncated so I determined I needed to use something else that had a checksum built in to make sure the data was actually being sent properly. In my tests with the manchester library, I was able to send data for days without any loss whatsoever. The values are being sent every 2-3 seconds and ultimately this data will be sent to the master unit from 3 other slave units grabbing temps and humidity.

I tried to use the radiohead libraries, but they didn't seem as straightforward to me to use?

The code I added to my post is literally everything that is included for examples regarding sending arrays via the manchester library. Even then, it's just blinking an LCD and doesn't really show me how to take the array and print it out into a useable format (preferably a float so I can actually do something with the data such as log temp differences etc.). Would it be possible for you to show me what code to use? I'm open to trying the radiohead code, I just couldn't figure out how to implement it.

These are the RF transmitters/receivers I'm using:

I'm really sorry if these are all dumb questions. I'm relatively new to the arduino platform and I've learned a lot so far, I'm just REALLY REALLY struggling with this last piece. You don't know how much it would mean to me if you could assist.

Don't be sorry, the questions are very valid.

Trust me, the latest VirtualWire is very good :slight_smile:
It will run for years without any problem.

RadioHead is not better than VirtualWire, it is a library that does it all, and includes the VirtualWire protocol.
Since you already had VirtualWire working, you could try that again.
But then we have to find the reason why the VirtualWire data got corrupted. There can be many reasons. For example something in the sketch. Did you actually get wrong data ? That is almost impossible, since VirtualWire has an checksum.
Data truncated ? That is also impossible with VirtualWire.
I'm guessing, that something was wrong with the sketch.

When you think that the Manchester library is good enough for you, that's okay.

So you don't have to use the format you wrote about, you can just send what you want ?
I prefer to send the binary data.
There are a few possibilities.
You can use a structure, or glue the float just onto the buffer with a pointer, or use a union combining the structure with a buffer.
Does the next example make any sense ? If it is too complicated, we can always use a 'WriteAnything' library (but I forgot the name).

struct myDataStruct
{
  float temperature1;
  int humidity;
  float temperature2;
} myData;

// fill the struct
myData.temperature1 = 10.001;
myData.humidity = 60;
myData.temperature2 = 1234.0;

// transmit it
// I'm not sure about the (char *), I should look into that.
man.transmitArray( sizeof(myData), (char *) &myData);

// receive it
// Perhaps setting a pointer to the buffer is best.
myDataStruct *pmyData;
pmyData = (myDataStruct *) buffer;

// after receiving.
float t1 = pmyData->temperature1;

By the way, I don't use those receivers anymore, a coil is used for tuning (the square green block with red lacker). I only use receivers with a crystal now. But don't worry, they should work anyway.
Did you add a piece of wire to the antenna pin ?

Yes, one of the first things I did was add antennas to the transmitters/receivers. As I was testing, I’d just let my serial app run for a few days and wait to see if/when the data was corrupted. I was thinking (hoping?) that it was just the serial port being corrupted, but then I hooked the arduino up to an LCD that would display the data and it was becoming corrupted as well.

If you have any ideas for better radios/transmitters that would easier to use and that are inexpensive, obviously, I would be willing to try those. This problem with the data corruption is literally the last thing stopping me from finishing this product and putting it into production. I HATE HATE HATE asking for help…even though I know thats what these forums are for. haha. I just really like to figure stuff out on my own so I really get a firm grasp how it all works. The fact that I’m asking for help shows you how frustrated and defeated I’ve become!

Again, I REALLY appreciate any assistance you can give me. Its honestly a lifesaver. I’ve been working on this ONE problem for weeks now. :frowning:

There are too many unknown things for me.

I have now doubts about everything, hardware and software.
Do you use an official Arduino board ?
What about the rest of the hardware, the wiring, power supply ?

Can you do a test ? Use two Arduino boards, connect the transmitter and receiver to unused pins (not the serial port !), and use VirtualWire (the lastest one). Use the newest Arduino IDE (1.0.5 or 1.5.7). Show us the sketch, and a photo of the wiring, and it should run without any problem.

There are other 433MHz modules, but many are 3.3V.
When you bought the cheapest modules on Ebay, they work 9 out of 10 times. But I received such a transmitter 2 weeks ago with a missing resistor.

I have been reading this topic once more. It has "SRAM overflow" written all over it. Do you use buffers and many libraries, large display, old libraries, buffers on the stack, classes on the stack ?
You can try Arduino IDE 1.5.7, it will give an estimate for the flash and sram usage (but not for the variables on the stack).

I can actually send simple variables across the links using virtualwire. The data from the temperature sensors changes about every 1.5 seconds. I'm sending data every 2 seconds (just to make sure the sensors have time to pull data etc.) The ONLY issue happens when I'm sending data in arrays over a long period of time. If you have any examples using the radiohead library, absolutely let me know and I'll give it a whirl. I just couldn't figure it out the last time I looked at the radiohead stuff.

Sending data in arrays with VirtualWire is not the problem. I have VirtualWire with a number of bytes (I think about 16) and sending one byte or a number of bytes makes not difference for VirtualWire, it will work ofcourse. Some of my transmitters even run on a ATmega chip with internal clock, which is less accurate than a crystal.

I just can't believe that you are the only person in the world that has corrupted data and truncated data. It is most likely something in the sketch. It can be in the sender or in the receiver.
For example this is about bad data, but the problem was in the sketch: http://forum.arduino.cc/index.php?topic=212278.0

There is a function "vw_get_rx_bad()" to get the number of messages that didn't pass the checks in VirtualWire.

Peter_n:
Sending data in arrays with VirtualWire is not the problem. I have VirtualWire with a number of bytes (I think about 16) and sending one byte or a number of bytes makes not difference for VirtualWire, it will work ofcourse. Some of my transmitters even run on a ATmega chip with internal clock, which is less accurate than a crystal.

I just can't believe that you are the only person in the world that has corrupted data and truncated data. It is most likely something in the sketch. It can be in the sender or in the receiver.
For example this is about bad data, but the problem was in the sketch: http://forum.arduino.cc/index.php?topic=212278.0

There is a function "vw_get_rx_bad()" to get the number of messages that didn't pass the checks in VirtualWire.

Sorry to open up an "older" thread again, can you give me an example of sending/receiving more than one set of data please?
There is another thread that has an little example but it was just a quick write up that isn't easy to understand :confused:

Thank you,
Aaron.