This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I want to add few condition for data received via RX pin

Hi.. I am still new in using nrf product and understanding the example given via SDK.  For my project, I am trying to send continous data via BLE app UART to mobile phone. That data will be produced from my sensor which is BMD101 and connected to RX pin of nRF52832 board. My problem is that sensor data received is a continuous data, so I am trying to separate the data to a smaller packet so that the data that will be stored in the buffer will not full.

This is the example of the data that i will received from my sensor = "AAAA048002009EDFAAAA048002009EDGAAAA048002009EDFAAAA048002009EDG........"

So i am trying to make a condition like this :

 if(raw==0xAA){   //170 
         while (!mySerial.available()) {}          
         raw = mySerial.read();

   if(raw==0xAA){    //170
        while (!mySerial.available()) {}
        raw = mySerial.read();
        //DATA=4
   if(raw==0x04){  
        while (!mySerial.available()) {}
        raw = mySerial.read();
        //DATA=80
        
        while (!mySerial.available()) {}
        raw = mySerial.read();
        //DATA=2
        
        while (!mySerial.available()) {}
        raw = mySerial.read();
        data[0]=raw;
        
        while (!mySerial.available()) {}
        raw = mySerial.read();
        data[1]=raw;

        while (!mySerial.available()) {}
        check = mySerial.read();
  
    checksum= data[0]+data[1]+0x82;
    checksum &= 0xFF;
    checksum = ~checksum & 0xFF; 


    
raw = data[0]*256 + data[1];
    if (raw >= 32768){
        raw= raw - 65536;
     
    }
        if (checksum==check){
           //Serial.println(raw,DEC);//send to USB
           sensorDataVariable= raw;
           Serial.println(sensorDataVariable);
           delay(800);
    }
     

I am still new in using Keil and C, therefore i do not know where to put this coding. Hope that you can guide me in understanding the coding and which section i need to change to make this kind of condition. Thank you 

SDK used: 14.2

Board :nrf52832

Sensor : BMD101

Mobile phone :Huawei Nova 2i (nougot)

Parents Reply Children
No Data
Related