Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Silicon Labs Si7005 I2C odd behaviour

I2C Si7005

  • Please log in to reply
2 replies to this topic

#1 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 28 March 2015 - 12:06 AM

Hi all,

 

I have been working on a driver for the Silicon Labs Si7005 Digital I2C Humidity & Temperature Sensor and have been getting some odd behaviour.

 

I'm using a Seeedstudio Grove - Temperature & Humidity Sensor (Si7005 based I2C) which looked like a reasonable alternative to a Grove Temperature & Humidity Sensor Pro (DHT22 based bit bashed) which can be bit problematic on the Netduino platform.

 

I now have a working driver for the Si7005 but the first time I read from/write to the device it always fails, after that it always works as expected. (I had to get a working driver as I have 30+ of them for a project :))

 

Simplest possible example code below

 

......

using (I2CDevice device = new I2CDevice(new I2CDevice.Configuration(DeviceId, ClockRateKHz)))
         {
            // Read the device ID first time
            Debug.Print("First read always fails");
            byte[] writeBuffer1 = { REG_ID };
            byte[] readBuffer1 = new byte[1];
 
            // check that sensor connected
            I2CDevice.I2CTransaction[] action1 = new I2CDevice.I2CTransaction[] 
            { 
               I2CDevice.CreateWriteTransaction(writeBuffer1),
               I2CDevice.CreateReadTransaction(readBuffer1)
            };
 
            int length1 = device.Execute(action1, TransactionTimeoutMilliseconds);
            Debug.Print("Byte count " + length1.ToString());
            foreach (byte Byte in readBuffer1)
            {
              Debug.Print(Byte.ToString());
            }
 
 
            // Read the device ID a second time
            Debug.Print("Second read always works");
            byte[] writeBuffer2 = { REG_ID };
            byte[] readBuffer2 = new byte[1];
 
            I2CDevice.I2CTransaction[] action2 = new I2CDevice.I2CTransaction[] 
            { 
               I2CDevice.CreateWriteTransaction(writeBuffer2),
               I2CDevice.CreateReadTransaction(readBuffer2)
            };
 
            int length2 = device.Execute(action2, TransactionTimeoutMilliseconds);
            Debug.Print("Byte count " + length2.ToString());
            foreach (byte Byte in readBuffer2)
            {
               Debug.Print(Byte.ToString());
            }
      ...............
 
I have tried strobing the SDA line on startup with 
 
using (OutputPort i2cPort = new OutputPort(Pins.GPIO_PIN_SDA, true))
{
   i2cPort.Write(false);
}
 
But it made no difference. 
 
 
Does anyone have any suggestions/thoughts?
 
Thanks
 
@KiwiBryn
blog.devmobile.co.nz

 



#2 scardinale

scardinale

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationNew York, USA

Posted 29 March 2015 - 04:33 AM

Take a look at the GHI Gadgeteer driver for the SI70 at https://bitbucket.or...43.cs?at=master. You should be able to get it to work.



#3 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 29 March 2015 - 08:51 AM

Hi scardinale,

 

I had checked out the GHI Gadgeteer driver source but it is for a Si7020 which has different registers etc. to the Si7005.

 

With the 7005 you initiate a temperature\humidity measurement by writing to a register, then you poll the device until a flag in the status register is set, which indicates the result is ready to be read. 

 

The Gadgeteer code is also pretty relaxed about error checking etc. :-)

 

Thanks

 

@KiwiBryn
blog.devmobile.co.nz





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.