How can i send more than 255 (byte)?

RF24 radio(6, 7);
struct MyData {
byte h; // byte = o to 255
byte t; // word = 0 to 655
};
MyData data;

Hi,
very little information for any suggestions, but try:
byte h; // byte = o to 255
word t; // word = 0 to 655

RV mineirin

Do you mean more than 255 bytes, or an integer value too large to fit in a single byte?

// Transmitter Side

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

const uint64_t pipeOut = 0xE8E8F0F0E1LL;
//const byte address[6] = "00002";

RF24 radio(6, 7);
struct MyData {
byte h; // byte = o to 255
byte t; // word = 0 to 655
};
MyData data;

void setup() //========================================
{
Serial.begin(115200);

radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openWritingPipe(pipeOut);

Serial.println("Transmitter");
}
void loop() //------------------------------------------
{
data.h = 250;
data.t = 155;
if (isnan(data.h) || isnan(data.t)){
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
;
Serial.print("Humidity: ");
Serial.print(data.h);
Serial.print(" ");
Serial.print("Temperature: ");
Serial.println(data.t);

radio.write(&data, sizeof(MyData));
delay(500);
}

//========================================================================

//Receiver Side

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

#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

const uint64_t pipeIn = 0xE8E8F0F0E1LL;
//const byte address[6] = "00002";

RF24 radio(6, 7);
struct MyData {
byte h;
byte t;
};
MyData data;

void setup() //=======================================
{
Serial.begin(115200);

lcd.begin(16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.clear();

radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openReadingPipe(1, pipeIn);
radio.startListening();
Serial.println("Receiver ");
}
void recvData() //======================================
{
if ( radio.available() ) {
radio.read(&data, sizeof(MyData));
}
}
void loop()
{
recvData();

Serial.print("Humidity: ");
Serial.print(data.h);
Serial.print(" ");
Serial.print("Temperature: ");
Serial.println(data.t);

// lcd.clare();
lcd.setCursor(0,0);
lcd.print("Humidity:");
lcd.print(data.h);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print("Temperature:");
lcd.print(data.t);
lcd.print(" C");
delay(500);
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.