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.