Tvout Displaying information coming from a nrf24l01+ temperature sensor.

Hello I'm still working on my temperature sensor i found some online tut to help me out i mange to display a lm35 temperature sensor over wireless using the nrf24l01+ modules one transmit one Receive it came up in serial monitor but when i found out i can display thing on the tv i merge the sketch with the Tvout and library that seems to work but i wanted to add a second one to the network and view 2 of them on the tv so i try to see if i can copy a second one in the receiver and for some reason it compiles but i can not get the second one to display i do not know what is wrong it's something with maybe addressing the nrf24 modules or node addresses i do not know can someone help me out i have listed below the sketch.

receiver

#include <TVout.h>
#include <fontALL.h>
#include "schematic.h"
#include "TVOlogo.h"


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(8, 10);
const byte rxAddr[6] = "00001";
const byte rxAddr2[6] = "00002";
TVout TV;

int zOff = 150;
int xOff = 0;
int yOff = 0;

int view_plane = 64;
float angle = PI/60;




void setup() {

   // Serial.begin(9600);
    TV.begin(NTSC,120,96);
       radio.begin();

     radio.openReadingPipe(0, rxAddr);
   radio.openReadingPipe(0, rxAddr2);
  radio.startListening();

 

 TV.clear_screen();


  
  }

void loop() {

 TV.select_font(font4x6);
  char text[32] = {0};
    radio.read(&text, sizeof(text));
    
     char text2[32] = {0};
    radio.read(&text2, sizeof(text2));
    
      TV.select_font(font6x8);
   // Serial.println(text);
//     TV.print(10,30,"                 ");
  // TV.print(10,30,"                   ");
  TV.print(5,20,"Sensor 1:");
  TV.print(5,30,(text)); 
    TV.print(5,50,"Sensor 2:");
    TV.print(5,60,(text2)); 
 
    delay(5000);
     TV.clear_screen();
  //  
}

transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

float temp;
int tempPin = 1;

RF24 radio(9, 10);

const byte rxAddr[6] = "00001";

void setup()
{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();
}

void loop()
{
  temp = analogRead(tempPin); // Read Sensor
  temp = temp * 0.48828125;  // Convert to Celcius

  char charVal[3+1+4];       // Float will be stored as chars here.
  String stringVal = "TMP="; // Initialize string that we'll append the float onto.
  dtostrf(temp, 8, 4, charVal); //8 is total width, 4 is precision; temp is copied onto charVal

  //convert chararray to string
  for(int i=0;i<sizeof(charVal);i++)
  {
    stringVal+=charVal[i];
  }

  stringVal+=" *C"; // Append what we want after the temperature
  Serial.println(stringVal.length()); // Confirm that the string is right before we send it to receiver.
  Serial.println(stringVal); // Confirm that the string is right before we send it to receiver.
  
  // Now convert string to char array for radio library
  char charArray[50];
  stringVal.toCharArray(charArray, sizeof(charArray));
  radio.write(&charArray, stringVal.length()); // Send to receiver

  for (int i=0; i<stringVal.length(); i++)
  {
    Serial.print(charArray[i]);
  }
  Serial.println();

  delay(1000);
}

transmitter 2

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

float temp;
int tempPin = 1;

RF24 radio(9, 10);

const byte rxAddr[6] = "00002";

void setup()
{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();
}

void loop()
{
  temp = analogRead(tempPin); // Read Sensor
  temp = temp * 0.48828125;  // Convert to Celcius

  char charVal[3+1+4];       // Float will be stored as chars here.
  String stringVal = "TMP="; // Initialize string that we'll append the float onto.
  dtostrf(temp, 8, 4, charVal); //8 is total width, 4 is precision; temp is copied onto charVal

  //convert chararray to string
  for(int i=0;i<sizeof(charVal);i++)
  {
    stringVal+=charVal[i];
  }

  stringVal+=" *C"; // Append what we want after the temperature
  Serial.println(stringVal.length()); // Confirm that the string is right before we send it to receiver.
  Serial.println(stringVal); // Confirm that the string is right before we send it to receiver.
  
  // Now convert string to char array for radio library
  char charArray[50];
  stringVal.toCharArray(charArray, sizeof(charArray));
  radio.write(&charArray, stringVal.length()); // Send to receiver

  for (int i=0; i<stringVal.length(); i++)
  {
    Serial.print(charArray[i]);
  }
  Serial.println();

  delay(1000);
}

Can someone please help me out to figure what is wrong and why i can not display a second sensor? thank you.

None of those sketches compile on my Uno. The problem (at least a problem) is that you define the addresses as a byte array and openReadigPipe and openWritingPipe take uninr64_t. Look at the examples for how to define the addresses. The sketches compile with the changes below.

//  replace const byte  rxAddf[] with
const uint64_t pipes[2] = {0xF0F0F0F0A8LL, 0xF0F0F0F0D2LL };

// in setup for receiver
    radio.openReadingPipe(1,pipes[0]);
    radio.openReadingPipe(2,pipes[1]);

//  in transmitter 1
const uint64_t pipe = {0xF0F0F0F0A8LL};

    //setup()
    radio.openWritingPipe(pipe);

//  in transmitter 2
const uint64_t pipe = {0xF0F0F0F0D2LL};

    //setup()
    radio.openWritingPipe(pipe);

it does compile if you have the nrf24 manaicbug library and the dht11 library. the addressing is for mesh networking.

I have a weather station with 1 receiver and 2 transmitters (much like your project) using that addressing and they communicate well. I recommended that code because I know that it works. If you know better, fine.

Honestly i don't know what works or don't works well. I do know it works with one sensor i had no problem with it but trying to setup a second sensor is when I'm having problems with it.

Hello groundfungus i change what you said in the addresses in the setup and all the new addresses are working but i can still only see 1 sensor not both. this is the changes i did.

Receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10);
const uint64_t pipes[2] = {0xF0F0F0F0A8LL, 0xF0F0F0F0D2LL };

int view_plane = 64;
float angle = PI/60;

void setup() {

    Serial.begin(9600);

       radio.begin();

    radio.openReadingPipe(1,pipes[0]);
    radio.openReadingPipe(2,pipes[1]);
  
  radio.startListening();

  }

void loop() {
  
  char text[32] = {0};
    radio.read(&text, sizeof(text));

   Serial.println(text);
 
    delay(1000);

}

Transmitter 1

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

float temp;
int tempPin = 1;

RF24 radio(9, 10);

const uint64_t pipe = {0xF0F0F0F0A8LL};

void setup()
{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(pipe);
  
  radio.stopListening();
}

void loop()
{
  temp = analogRead(tempPin); // Read Sensor
  temp = temp * 0.48828125;  // Convert to Celcius

  char charVal[3+1+4];       // Float will be stored as chars here.
  String stringVal = "TMP Sen 2) "; // Initialize string that we'll append the float onto.
  dtostrf(temp, 8, 4, charVal); //8 is total width, 4 is precision; temp is copied onto charVal

  //convert chararray to string
  for(int i=0;i<sizeof(charVal);i++)
  {
    stringVal+=charVal[i];
  }

  stringVal+=" *C"; // Append what we want after the temperature
  Serial.println(stringVal.length()); // Confirm that the string is right before we send it to receiver.
  Serial.println(stringVal); // Confirm that the string is right before we send it to receiver.
  
  // Now convert string to char array for radio library
  char charArray[50];
  stringVal.toCharArray(charArray, sizeof(charArray));
  radio.write(&charArray, stringVal.length()); // Send to receiver

  for (int i=0; i<stringVal.length(); i++)
  {
    Serial.print(charArray[i]);
  }
  Serial.println();

  delay(1000);
}

Transmitter 2

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

float temp;
int tempPin = 1;

RF24 radio(9, 10);

const uint64_t pipe = {0xF0F0F0F0D2LL};

void setup()
{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(pipe);
  
  radio.stopListening();
}

void loop()
{
  temp = analogRead(tempPin); // Read Sensor
  temp = temp * 0.48828125;  // Convert to Celcius

  char charVal[3+1+4];       // Float will be stored as chars here.
  String stringVal = "TMP Sen 2) "; // Initialize string that we'll append the float onto.
  dtostrf(temp, 8, 4, charVal); //8 is total width, 4 is precision; temp is copied onto charVal

  //convert chararray to string
  for(int i=0;i<sizeof(charVal);i++)
  {
    stringVal+=charVal[i];
  }

  stringVal+=" *C"; // Append what we want after the temperature
  Serial.println(stringVal.length()); // Confirm that the string is right before we send it to receiver.
  Serial.println(stringVal); // Confirm that the string is right before we send it to receiver.
  
  // Now convert string to char array for radio library
  char charArray[50];
  stringVal.toCharArray(charArray, sizeof(charArray));
  radio.write(&charArray, stringVal.length()); // Send to receiver

  for (int i=0; i<stringVal.length(); i++)
  {
    Serial.print(charArray[i]);
  }
  Serial.println();

  delay(1000);
}

I get no errors from it which is great thank you but how can i display both in the serial monitor?

If i take out the first address and just leave in the second address the second sensor shows up but if i put it back in the first address the first one shows up.

Update not sure why but in the serial monitor now I'm getting

TMP Sen 1) 21.9727 *C
TMP Sen 1) 21.9727 *C
TMP Sen 2) 20.6835 *C
TMP Sen 1) 21.9727 *C
TMP Sen 1) 22.4609 *C
TMP Sen 1) 21.8659 *C
TMP Sen 2) 21.9729 *C

Both sensors but it's not sensor 1 then sensor 2 it's showing sensor 1 more then sensor 2

I'm starting to see both now but i was wondering something they only show up when i touch the nrf24 modules why is that.? One other thing i have see today is that there is a Cap on the nrf24 module looks like between vcc and Ground why i that also needed?

The cap is there to smooth the power to the radio modules. I use a 10uf electrolytic. What is powering your radios?

i have ams1117 3.3v ldo what the uno boards use i bought some and put male header pins on them to make them breadboard friendly. i don't have any 10uf cap i do have some 4.7uf 35 caps they says jamicon on them. would they work? i see in the website they say between .1 to 10uf cap but there little yellow ones i only got these they are like a dark gray with a plus and minus on it.?

That is what I did for powering my radios (1117 with soldered headers). Try the 4.7uf, just make sure that the polarity is right (plus on cap to 1117 3.3 output and minus to ground).

I'm trying that now thank you i'll let you know what's going on.

So minus on the cap goes to ground correct? i never used caps only replaced 2 on a lcd monitor in my whole life.

minus to ground. Plus to the 3.3V output. The idea is that the cap stores energy and releases the energy, back, when the radio pulls bursts of current. This keeps the supply voltage more stable.

Just a quick update now when i added the caps and i look at the serial monitor for 1 and 2 this is what i get

TMP Sen 2) 120.1172 *C
TMP Sen 2) 120.1172 *C
TMP Sen 2) 119.6289 *C
TMP Sen 1) 171.8750 *C
TMP Sen 2) 119.1406 *C
TMP Sen 2) 119.1406 *C
TMP Sen 2) 120.6055 *C
TMP Sen 2) 120.6055 *C
TMP Sen 2) 119.1406 *C
TMP Sen 2) 120.6055 *C
TMP Sen 2) 120.1172 *C
TMP Sen 2) 119.6289 *C
TMP Sen 1) 172.3633 *C
TMP Sen 2) 118.6523 *C
TMP Sen 2) 119.1406 *C
TMP Sen 2) 118.6523 *C
TMP Sen 2) 120.1172 *C
TMP Sen 1) 171.8750 *C
TMP Sen 2) 118.6523 *C
TMP Sen 2) 120.1172 *C
TMP Sen 2) 119.1406 *C
TMP Sen 2) 119.1406 *C

once in a while it shows 1 but most of the time it shows 2. the numbers are wrong because disconnect the temperature sensors they are just getting raw values from the pin but at least it's somewhat coming up.

        radio.stopListening();
        radio.openWritingPipe(pipes[0]);  // or (pipe)
        Serial.print("sending >>>  ");
        Serial.print(sizeof(data));
        bool ok = radio.write( data, sizeof(data));
        radio.startListening();                           //   listen for ack
        if (ok) Serial.println("  ok...");
        else  Serial.println("   failed.\n\r");

This is my code for transmit (from examples). It is my understanding that you need to listen for the ack after sending. So you stop listening, open the pipe for send, send and then listen for ack. I left the prints in so you can see what is going on.

Well i can't serial print the transmitting side because I'm serial monitoring the receiver side and i only have one ftdi board.

It's been getting better. i put a delay on the transmit side of 3 seconds and one second delay on the receiving side so it been 2 then 1 then 2 then 1 sometimes it goes 1 then 2 then 1 then 2 or reverse.

this is the last comment from me on this post i think it looks a lot better once in a while i lose 2 for a split second or i lose 1 for a split second but then it comes back i wonder if need bigger caps maybe a 10uf cap is needed?

You don't seem to be checking in your receiver code if any radio data is available before reading & printing it. Also, how do you know what radio the data comes from. Does the available & read commands have extra parameters to determine what pipe you want to read?

Well I'm checking that each transmitter has a text before the numbers come in TMP Sen 1 and TMP Sen 2 transmitter 1 and transmitter 2if i disconnect transmitter 1 only transmitter 2 shows up says TMP Sen 2 and if i disconnect transmitter 2 only shows TMP Sen 1 transmitter 1. but i do understand some packets or data is getting lost in transit. but I'm going to put something also in the receiver side to tell me if it's transmitter one and two is available or failed yes I'm working on that now as well.