Allocate specific bit for my sensor data and word

#include <Wire.h>                     
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2,3);
int analogInput = A0;                         
const int sampleWindow = 50;          
unsigned int sample;

void setup(){
  BTserial.begin(9600);
  Serial.begin(9600);
  pinMode(analogInput, INPUT);                               
}

void loop(){
  
  unsigned long startMillis = millis();                    
  unsigned int PeaktoPeak = 0;                           
  unsigned int SignalMax = 0;
  unsigned int SignalMin = 675;

  while ( millis() - startMillis < sampleWindow ){

    sample = analogRead(analogInput);
    if (sample < 675) {

      if (sample > SignalMax){

        SignalMax = sample;                                
      }

      else if (sample < SignalMin){

        SignalMin = sample;                                
      }
    }
  }

  PeaktoPeak = SignalMax - SignalMin;                      
  float MeterValue = ( PeaktoPeak * 3.3 /675) * 10;   
  BTserial.println(MeterValue*10);
 delay(100);
}

Immediate guidance needed
Hi ,
i'm working dB meter project. I'm new to arduino programming , i like to know in which bit i'm getting sensor data from pin A0. and sending the sensor to bluetooth. I need to mention in which byte my sensor data available.
Kindly help me

Do you know what the code you posted does?

I don't see anywhere where you have 150 bytes or a sensor name.

Sorry, i just noted for example but actually i didnt know
in which byte i'm getting my sensor data. i need to find in which byte i'm getting my sensor value.

The code doesn't send the raw sensor data from A0 over bluetooth. I'm no audio expert but it looks like the code is performing some calculation on the peak to peak reading as sampled on A0 and sending the result over bluetooth.

Yes exactly, but my android developer asking me, in which byte you sending sound sensor output value over bluetooth, but i dont how to assign specific byte for sound value. i'm simply use this line BTserial.println(MeterValue);
to send data to apk.

.println() sends an ASCII string like "123.45". All the bytes/characters are data. They are followed by a newline character '\n'.

That bit of code is printing the value of MeterValue x 10 to your bluetooth module as plain ASCII text terminated with a CR & LF.

As an aside, is the code supposed to multiply the value by 10 twice?

yes because from MeterValue i just get float value of sensor like 0.23,0.45.. so i convert that value with multiple of 10 get dB value

I just need to know in which byte and which size of byte my sensor data stored

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