Problem in receving the transmitted data using D6t thermal sensor and RF 433Mhz

Hello,

I am doing my project using Omron D6T thermal sensor. I need to transmit that data using wireless using RF433Mhz module. I working perfectly in wired form. I am using processing software to display it in visual. but now I am facing the problem in wireless. The transmitter part working perfectly. but i am getting error in receiver side. I am using 2 arduino uno boards.

The sensor will send 16 data with a reference temperature. I use processing to display it in a single pixel. In wireless transmitter transmits all 16 data perfectly. But in receiver i displays only one data as all 16 data, and I am getting 2 errors in processing. that is “null pointer exception” and “array index out of bound”.

I am fresh to arduino platform. Kindly help me. I will post all my code and data sheet.

// Transmitter code for RF

#include <VirtualWire.h>
#include <Wire.h>
#include <WireExt.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
#define D6T_addr 0x0A
#define D6T_cmd 0x4C
 
int rbuf[35];
float tdata[16];
float t_PTAT;


void setup()
{
  Wire.begin();  
  pinMode(17,OUTPUT);    // Power (VCC) for setting D17 (A3) pin
  digitalWrite(17,HIGH);
  pinMode(16,OUTPUT);    // Power (GND) for setting D16 (A2) pin
  digitalWrite(16,LOW);
  
    vw_set_ptt_inverted(true); // Required for RF Link module
    vw_setup(2000);                 // Bits per sec
    vw_set_tx_pin(3);                 
}

void loop()
{
  int a=value();
char b[4];
String str;
str = String(a);
str.toCharArray(b,4);
    const char *msg = b;       // this is your message to send

   vw_send((uint8_t *)msg, strlen(msg));
   vw_wait_tx();                                          // Wait for message to finish
   delay(200);
}

int value()
{
   int i;      
 
      Wire.beginTransmission(D6T_addr);
      Wire.write(D6T_cmd);
      Wire.endTransmission();
 
      if (WireExt.beginReception(D6T_addr) >= 0) 
      {
        i = 0;
        for (i = 0; i < 35; i++) {
          rbuf[i] = WireExt.get_byte();
        }
        WireExt.endReception();
 
        t_PTAT = (rbuf[0]+(rbuf[1]<<8));
        for (i = 0; i < 16; i++)
        {
          tdata[i]=(rbuf[(i*2+2)]+(rbuf[(i*2+3)]<<8));
          return tdata[i];
        }
      }
        
      }
// receiver code for RF

#include <VirtualWire.h>  // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
float tdata[16];
void setup()
{
    Serial.begin(9600);    

// Initialise the IO and ISR
    vw_set_ptt_inverted(true);    // Required for RX Link Module
    vw_setup(2000);                   // Bits per sec
    vw_set_rx_pin(8);           // We will be receiving on pin 23 (Mega) ie the RX pin from the module connects to this pin. 
    vw_rx_start();                      // Start the receiver 
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // check to see if anything has been received
    {
    int i,n=0,j=0;
     // Message with a good checksum received.
        
    for (i = 0; i < buflen; i++)
    {
      int z=0;
     z=buf[i]-48;
     n=n+(z*pow(10,2-i));   
        }
        while(j<16)
        {
          tdata[j]=n*0.1;
          j++;
        }
     }
  output_csv();   
}

void output_csv() {
  for (int i = 0; i < 16; i++) {
    Serial.print(tdata[i]);
    if (i < 15) {
      Serial.print("  ");
    } 
    else {
      Serial.println();
    }
  }
}
// processing output 

import processing.serial.*;
float[] tdata = new float[16]; 

// The serial port:
Serial myPort;
int count = 0;
color[] tcolor = {#40E000,#A0E0C0,#A0E0E0,#F0A000,#F0E000,#C0E0E0}; // Color table

 
void setup() {
 size(640,640);
  // List all the available serial ports:
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[0], 9600);
}
 
void draw() {
  while (myPort.available() > 0 && myPort.read()==10) {
    delay(2);
    String inByte = myPort.readStringUntil(10);
     tdata = float(split(inByte, ','));
     myPort.clear();
    println(tdata);for (int i = 0; i < 16; i++) { // Set the color for each area, to draw a square
      if (tdata[i] < 18) {
        fill(tcolor[0]);
      } else if (tdata[i] < 30) {
        fill(tcolor[1]);
      } else if (tdata[i] < 30.1) {
        fill(tcolor[2]);
      } else if (tdata[i] < 37.7) {
        fill(tcolor[3]);
      } else if (tdata[i] < 42.1) {
        fill(tcolor[4]);
      } else  {
        fill(tcolor[5]);
      }
      rect((i % 4)*160, (i / 4)*160, (i % 4)*160+160, (i / 4)*160+160);
      if (tdata[i]<5) {fill(255);} else {fill(0);}
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]),(i % 4)*160+80, (i / 4)*160+80);
    }
    
  }}

D6T01_ThermalIRSensorWhitepaper.pdf (652 KB)

thermal sensor wired.txt (1.77 KB)

processing output wired.txt (2.02 KB)

Hi there. I tried looking through your code but couldn't understand much of it. Perhaps some more comments would help.

However, I did notice something on the Processing side. The array out of bounds exception means that you are likely going too far.
What is the length of the String inByte? Could it be too big for tdata?

thanks for your reply. it is a totally i get 35 bits(PTAT, 32 DATA, EOF) in each transmission.