0

I bought this sensor:

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Weather/RHT03.pdf

and the output is "MaxDetect 1-wire bus", What does it mean and how to use it? I tried to connect it to the arduino and program it but it's not working properly, I receive data of 1 bit constantly. I guess my code is wrong. Do I need to use the Wire-1 library for arduino?

int SensorVccPin = 8; 
int datapin = 6;
int bitcheck1;
int bitcheck2;
int temp[16];
int humidity[16];
int sensorcheck[8];

void setup()
{
  pinMode(SensorVccPin, OUTPUT);  
    pinMode(datapin, INPUT);
    Serial.begin(9600); 
}

void loop()
{
    // This is the STEP #1
    digitalWrite(SensorVccPin, HIGH);  
  delay(5000); 

    digitalWrite(SensorVccPin, LOW);
     delay(15);


  digitalWrite(SensorVccPin, HIGH);  

  delayMicroseconds(30);   

  digitalWrite(SensorVccPin, LOW);  



while(digitalRead(datapin) == 0){

      delayMicroseconds(2);   }



   while(digitalRead(datapin) == HIGH)
{
delayMicroseconds(2);   }




  // STEP #2
  for (int i = 0; i<16; i++)
  {
    while(digitalRead(datapin) == LOW)
    {
      delayMicroseconds(2); }  

    delayMicroseconds(10);


  bitcheck1 = digitalRead(datapin);   // maybe store as an array
     delayMicroseconds(17);      // 50 sec pause  // 27us = 0 bit, 70us is 1 bit data
  delayMicroseconds(15); 
  bitcheck2 = digitalRead(datapin);

  if (bitcheck1==bitcheck2)
  {temp[i]=1;
  delayMicroseconds(28); 
  }
  else
  {temp[i]=0;

  }


    }

    for (int i = 0; i<16; i++)
  {
    while(digitalRead(datapin) == LOW)
    {
      delayMicroseconds(2); }  

    delayMicroseconds(10);


  bitcheck1 = digitalRead(datapin);   // maybe store as an array
     delayMicroseconds(17);      // 50 sec pause  // 27us = 0 bit, 70us is 1 bit data
  delayMicroseconds(15); 
  bitcheck2 = digitalRead(datapin);

  if (bitcheck1==bitcheck2)
  {humidity[i]=1;
  delayMicroseconds(28); 
  }
  else
  {humidity[i]=0;

  }


    }


    for (int i = 0; i<8; i++)
  {
    while(digitalRead(datapin) == LOW)
    {
      delayMicroseconds(2); }  

    delayMicroseconds(10);


  bitcheck1 = digitalRead(datapin);   // maybe store as an array
     delayMicroseconds(17);      // 50 sec pause  // 27us = 0 bit, 70us is 1 bit data
  delayMicroseconds(15); 
  bitcheck2 = digitalRead(datapin);

  if (bitcheck1==bitcheck2)
  {sensorcheck[i]=1;
  delayMicroseconds(28); 
  }
  else
  {sensorcheck[i]=0;

  }



  delayMicroseconds(80); 





  for(int i=0; i<16; i++)
  {
   Serial.print(temp[i]); 

  }
     Serial.print("  temp  "); 


  for(int i=0; i<16; i++)
  {
   Serial.print(humidity[i]); 

  }
       Serial.print("  hum  "); 

  for(int i=0; i<8; i++)
  {
   Serial.print(sensorcheck[i]); 

  }
       Serial.print(" check   "); 


    }



  }
EEstud
  • 309
  • 1
  • 3
  • 12
  • "it's not working properly" is not a very good problem description. What do you expect to happen? What actually happens? – David Schwartz Aug 08 '12 at 02:34
  • The sensor is using 1-Wire which I don't really know how to program. I tried writting a program to receive some bits from it but it always gives me 1- bits out of 40. – EEstud Aug 08 '12 at 02:57

2 Answers2

1

You should leave the VCC pin (pin 1) high the whole time. In fact, ideally, it should be connected to the power supply. It's the data pin (pin 2) that you should be pulling high and low to communicate with the sensor and it's the data pin that you should be reading. You will have to switch the data pin between input and output modes. Make sure you have a pull up resistor on the data pin because the sensor can only pull it low.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278
0

MaxDetect 1-wire bus is specially designed by MaxDetect Technology Co., Ltd. , it's different from Maxim/Dallas 1-wire bus, so it's incompatible with Dallas 1-wire bus.

You can take a look to this:

http://tienda.tdrobotica.co/download/RHT03_programa.pdf

Best regards.