NRF, TFT Data Write

OK here is what im trying to do.
I Have a SeeedStudio Tft Shield V1, NRF24 Radios Running on a Mega 2560 the other radio is trasmitting off a Micro.
the Tft is successfully running a simple touch Program just to turn and off leds. And is also Receiving streaming data .
I would like to convert it into a "Voltage" reading but im thinking i need to convert it to FLOAT.
Here is where it goes down hill . The TFT caon do eather String or Char Tft.drawString ,,Tft.drawChar

Ihave my Transmitter sending

char DATA[3];  // 2 element array holding DATA readings

void setup()   
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
}//--(end setup )---


void loop()   
{
  DATA[0] = analogRead(DATA_X);
  DATA[1] = analogRead(DATA_Y);
  DATA[2] = analogRead(DATA_Z);
  
  radio.write(DATA, sizeof(DATA));

and of course Receiver

 if ( radio.available() )
  {
  

    bool done = false;
   // while (!done)
    {
      // Fetch the data payload
      done = radio.read( DATA, sizeof(DATA) );
     
    //voltage = (DATA[0] * (14.7 / 1023.0));
    Tft.fillRectangle(0,200,240,20,BLACK);
    Tft.drawString(sensor3Char,2,200,2,WHITE);

With a COnvertion From

void getSensor(){  
  itoa(DATA[0], sensor3Char, 10);
  
  }

Its great i have the Raw numbers comming in , But it would be nice to see a "13.50 Volts "

Any Ideas?

I was thinking maybe Change what is being sent, But it only seems to want the format of

radio.write(DATA, sizeof(DATA));

Been at it a couple of days now ,, Need a Different prespective :slight_smile: Or different Web page to look at :slight_smile:

but im thinking i need to convert it to FLOAT.

What is "it" that you think you need to convert to a FLOAT? How do you propose to do that? What IS a FLOAT? C has a float data type.

I would like to convert it into a "Voltage" reading

There's that pronoun again that doesn't refer to anything.

The TFT caon do eather String or Char Tft.drawString ,,Tft.drawChar

You are challenging your spellchecker...

void getSensor(){  
  itoa(DATA[0], sensor3Char, 10);
  
  }

The name of this function does NOT illustrate what it actually does. DATA[0] is an int, with a range of valid values from -32768 to 32767. We'd be guessing how sensor3Char is defined, and whether this code makes any sense. I don't play guessing games.

Any Ideas?

Sure. You explain what you want converted to a float. You explain what difficulties you are having converting whatever that is to a float. You explain why you can't use dtostrf() to convert the float to a string. You explain why that string is then unusable.

Ok well lets try it this way . information is beeing displayed on the screen from the Transmitter. (0-1023)
i Would like it to display as a Value of 0-14.7 . And of course "DATA[0]" is the analogRead from the transmitter. But you have done enough code you already knew that :slight_smile: Is that more helpful ?

It seems to me that there is the need to convert DATA[0] to a float. The commented out code would do that, if it wasn't commented out. Then, there is the need to convert the float to a string. The dtostrf() function does that.

So, I guess I can't see what the problem is.

By the way, by convention, all capital letter names are reserved for constants. Constants, once initialized, never again appear on the left side of an equal sign.

OK that took a bit :slight_smile: I upgraded to 1.0.6 and messed up my librarys. Had to go back to 1.0.5 Just so i could work on this problem :slight_smile: .
OK As you said most of the stuff i had was correct but wasnt using it correctly so i changed it and added.
this is all ruff going to trim it down after this ,,,,,

static char outstr[15];

done = radio.read( data, sizeof(data) );

voltage = (data[0] * (14.7 / 1023.0));
dtostrf(voltage,6, 2, outstr);
Tft.fillRectangle(0,200,240,20,BLACK);
Tft.drawString(outstr ,2,200,2,WHITE);

IM guessing that is the direction you were trying to guide me in :slight_smile:

IM guessing that is the direction you were trying to guide me in

It is exactly what I expected you to come up with. I’m glad that you were able to do so, with just a few clues.

@ P:aulS +1

Doc