-1

I am currently running a project with 2 TinyDuinos and 2 TinyShields 433MHz Radio (SI4432) in order to pass 3 axes (x , y ,z) from one to the other from long distance.

I have tried

  • to concat the axes as one string and send the string,
  • to send an array like string axes = { x , y , z } to the receiver (of course the variables are already defined),
  • send only one string. In this case I have only the first 2 letters of the string. For example if the string was string first = "456" , I would get "45" on the receiver

The Radio shield's examples uses uint8_t type and arrays to send and receive the data, I have already tried to cast the string to char* and then to uint8_t and nothing different happens. Maybe I am missing something.

Below there are my code screen shots. I will put 2 links for the examples of the transmitter and the receiver I got some code from

Similar Project : https://tinycircuits.com/blogs/learn/121634375-football-play-calling-watch-tutorial

Radio Shield Page: https://tinycircuits.com/products/433mhz-long-range-radio-tinyshield

TinyDuino Main Shield : https://tinycircuits.com/collections/all/products/tinyduino-processor-board

Code Screenshots

Transmitter code

Receiver code

Output from Receiver

  • 3
    Please add the code in your question, don't use images/screenshots. This allows easier editing by others and more crucially helps the search engines. – MichaelT Oct 16 '18 at 0:21
0

For this kind of thing you need to craft a packet to contain your data. The best method is to use a struct.

struct coords {
    int x;
    int y;
    int z;
};

Then you can define a variable from it:

struct coords myCoords;

And set individual values:

myCoords.x = 23;
myCoords.y = 180;
myCoords.z = -3817;

Now you can cast it to whatever type you need for sending:

manager.sendtoWait((uint8_t *)&myCoords, sizeof(struct coords), SERVER_ADDRESS);

Receiving is done in much the same way:

struct coords recCoords;
uint8_t len = sizeof(struct coords);
uint8_t from;

if (manager.recvfromAck((uint8_t *)&recCoords, &len, &from)) {
    Serial.print("X = ");
    Serial.println(recCoords.x); 
    Serial.print("Y = ");
    Serial.println(recCoords.y); 
    Serial.print("Z = ");
    Serial.println(recCoords.z); 
}

In future please post your actual code, not pictures of your code. It makes it a real pain having to keep scrolling up and manually typing in bits of your code rather than being able to copy-and-paste a couple of lines.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.