 {
   if(cmd[0] == 1)
     Wire.write(val);
-  if(cmd[0] == 3 || cmd[0] == 7 || cmd[0] == 56)
+  if(cmd[0] == 3 || cmd[0] == 56)
     Wire.write(b, 3);
+  if(cmd[0] == 7)
+  {
+    Wire.write(ultrasonic_b, 3);
+    cmd[0] = 0;
+  }
   if(cmd[0] == 8 || cmd[0] == 20)
     Wire.write(b, 4);
   if(cmd[0] == 30) 
     Wire.write(b, 9);
-  if(cmd[0] == 40) 
+  if(cmd[0] == 40)
+  {
     Wire.write(dht_b, 9);
-  
+    cmd[0] = 0;
+  }
+
   if(cmd[0]==21)
   {
     Wire.write(b,21);     

    //Ultrasonic Read
    else if(cmd[0]==7)
    {
      pin=cmd[1];
      pinMode(pin, OUTPUT);
      digitalWrite(pin, LOW);
      delayMicroseconds(2);
      digitalWrite(pin, HIGH);
      delayMicroseconds(5);
      digitalWrite(pin,LOW);
      pinMode(pin,INPUT);
      dur = pulseIn(pin,HIGH);
      RangeCm = dur/29/2;
      b[1]=RangeCm/256;
      b[2]=RangeCm%256;
      //Serial.println(b[1]);
      //Serial.println(b[2]);
    }
    //Firmware version
    else if(cmd[0]==8)

int index=0;
int flag=0;
int i;
byte val=0,b[21],float_array[4],dht_b[21],ultrasonic_b[3];
unsigned char dta[21];
int length;
int aRead=0;
