Wind turbine powered POV weather station... reading sht21...

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi freaks...

I've built a turbine using a stepper where the shaft is stationary and the body of the motor is attached to the blades.

The idea is that it will be displaying the humidity and temp using an 8 bit POV on one of the blades...

So far everything is working except for the SHT21...
I'm unfamiliar with TWI/I2C and testing it is a bit inconvenient ...
..unplug the battery used for programming, unplug programmer, plug in stepper, turn on fan, wait for spin up without loosing any fingers, etc...
I should have added at least a serial connection but was unaware at the time that the sht21 differed from the sht11...

So hopefully someone can take a look at this code I've attempted to port from an Arduino library using Peter Fleury's I2C lib...

uint16_t readSensor(uint8_t command)
{
  uint16_t result;

  i2c_start(0x40);   //begin
  i2c_write(command);             //send the pointer location
  _delay_ms(100);
  i2c_stop();         //end

 
  //Store the result
  result =  i2c_read (1); //(1) <<8 );
  result = result <<8;
  result += i2c_read (0);
  result &= ~0x0003;   // clear two low bits (status bits)
  return result;
}

So far it's not returning anything but 0...

I've posted the project on my site, there is the sch, pics and vid...
http://krazatchu.ca/?page_id=198

Thanks,
Michael

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This code should be a bit closer to correct...
But is still giving all zeros...

I'm sending 0xE5 for RH and 0xE3 for Temp...

Any ideas?

uint16_t readSensor(uint8_t command)
	{
	
	uint16_t result;
	uint16_t chksum;	

	i2c_start(0x80);  		// device address 0x40 and final bit 0 = write
	i2c_write(command);		// get rh and hold during measure 0xE5
	_delay_ms(100);
	i2c_stop();

	i2c_start_wait (0x81); 	// device address 0x40 and final bit 1 = read
	
	result =  i2c_read(1);	// read msb
	result = result <<8; 	// shift 8
 	result += i2c_read (1);	// read lsb
	result &= ~0x0003;   	// clear two low bits (status bits)
		
	chksum = i2c_read (0); 	// read check sum 
	
	return result;

	
	}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It works better when you don't forget to change the pin assignments after replacing i2cmaster.s ...

All is good now... Will post a vid once it's all up in the air...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you realise that SHTxx sensors don't use I²C or TWI compatible comms?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's not the SHT1x or SHT7x... It's the SHT2x ... It uses I2C...

See here, on the right where it says sensor output..
http://www.sensirion.com/en/01_humidity_sensors/00_humidity_sensors.htm

On page 11 in the datasheet it says something about backwards compatibility with the non-compliant SHT1x/SHT7x bus..
But it didn't function with working SHT11 code I have used before...

The code in the second post works a treat.
The calculation for T and RH I've copied from the SHT21 Arduino library...

Michael realizes

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah they have a variant that is I²C now. Cool.
Steve didn't realise!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

only thing left now is to put it on the same boards as the other sensors so you can easilly use it in a development environment....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As a follow up...

The project was completed some time ago...

There are pics and video on my website
http://krazatchu.ca/?page_id=198

Michael

Last Edited: Wed. Sep 1, 2010 - 12:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cool.
Must have some pretty high winds where you are!