I have been wondering how I can send 2 sets (or blocks or whatever) of data via one pair of 433Mhz Tx & Rx.
I have two sensors feeding a Nano in the garage. One outputs a signal of .5v-4.5v to the Nano ADC, whence it is Sent to the receiver in the house. The other sensor outputs a train of pulses to the Nano. I wanted that also sent via the 433. Two signals, one transmitter (didn't want to use two Tx/Rx).
I found that, in the RadioHead code in the sketches, if I use 'data', and 'Hata' on both ends, and two interrupts, I can send and receive them both via one pair.
Hopefully this will be useful to someone.
No sooner did I publish this than the outputs reversed on me. in troubleshooting mode.
Put the data into an array, or structure, or format it into a text string, and send that.
Because you didn't have any method of synchronization between the two channels that you created.
yes. that makes sense. but to get synchronization, don't i have to send something back to the transmitter ?
No, you just need to identify the source of each transmission with an ID. But you don't have to, if you pack them in the same transmission. Then they will always be in the same order.
i considered a text string, but from what i can see, there is a problem with data of varying lengths, and getting numbers back out at the receiving end may be difficult.
I have no idea how to send an array.
There are 1000's of examples online. I believe some examples with the library, too. Hundreds of posts in this forum also, so you could search here.
No, not at all. If you would take a moment to post a specific example of data items, we can show you a couple of lines of code that would handle the case.
Yes, the receive method reports the data length.
that ID sounds promising and simple. I read the radioHead ask guide and didn't see anything about ID. I did find :
/// Each message is transmitted as:
///
/// - 36 bit training preamble consisting of 0-1 bit pairs
/// - 12 bit start symbol 0xb38
/// - 1 byte of message length byte count (4 to 30), count includes byte count and FCS bytes
/// - n message bytes (uincluding 4 bytes of header), maximum n is RH_ASK_MAX_MESSAGE_LEN + 4 (64)
/// - 2 bytes FCS, sent low byte-hi byte
and
As discussed in the RFM documentation, ASK receivers
/// require a burst of training pulses to synchronize the transmitter and
/// receiver, and also requires good balance between 0s and 1s in the message
/// stream in order to maintain the DC balance of the message.
and lastly :
/// Constructor.
/// At present only one instance of RH_ASK per sketch is supported.
I thought I was more or less giving each an ID by using 'data' and 'Hata'. but I guess not.
Glad to. I will send both my sketches if you want.
one set of pulses is from the output of my Hantek O'scope at 1 kHz.
the other is pulses from my signal generator,varying from 396 hz to 12,000Hz.
But ultimately I will replace one of them with an ADC converted value of 0-1023.
That's because the payload protocol is your responsibility. The application code is up to you.
You don't need to concern yourself with the details of the radioHead packet structure. Just put some stuff in a buffer and send it. The receiving code gives you back that buffer, as well as its length.
e.g. TX:
int buf[4];
buf[0]=ID; //this packet ID
buf[1]=analogRead(A0);
buf[2]=counts;
buf[3]=whatever;
radio.send ( (uint8_t *)buf, sizeof(buf));
jrem -
thanks. i hope you don't mind if i go thru it line by line to make sure i understand it.
int buf [4] tells the number of elements in the buffer. it would be int buf[3] if the whatever was eliminated.
buf[0]= ID; I can give it any name i want ? like test1 ?
buf[1]= analogRead(A0); seems self explanatory.
buf[2]=counts; is this the name of the frequency count i get from my ISR ?
buf[3]=whatever; self explanatory.
radio.send ( (uint8_t *)buf, sizeof(buf)); says to send the objects in buffer test1 using uint8_t data type, size is test1 ?
is any of that right ?
It's all "whatever". The radio packet is just a transport mechanism. What data you send, and what you do with it, is up to you. So, of course, you can give it any names you want.
See that the mechanism is just a tool, and imagine how you would use it.
By declaring int buf[4] you are set aside space for 4 integers.
Thus everything you store has to fit into an integer data type, within the allowed range for integers. Characters are allowed, e.g.
buf[3]='A'; //set to ASCII code for character A.
In the following, the (uint8_t *) is a cast that satisfies RadioHead's expectation that you will be sending character data, of length sizeof(buf) bytes. What data are actually sent is irrelevant.
radio.send ( (uint8_t *)buf, sizeof(buf));
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.