<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11458/i2c-interface-with-htu21d-using-nrf51822</link><description>HTU21D.rar hello there i am interfacing HTU21D with nrf51822. i am reading temperature and humidty from HTU21D. humidty register is E5. and temperature register is E3. now my problem is that when i am trying to read only humidity it gives me correct value</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Mar 2018 13:48:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11458/i2c-interface-with-htu21d-using-nrf51822" /><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/125363?ContentTypeID=1</link><pubDate>Wed, 21 Mar 2018 13:48:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05ab3eb5-c2d2-4e5a-8ab3-bb2303aa1700</guid><dc:creator>au</dc:creator><description>&lt;p&gt;I think for reading temperature with no hold the correct address is 0xF3 instead of 0xE3:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t trigger_temperature_no_hold_master = 0xF3; //Address to temperature reading with no hold of twi lines&lt;br /&gt;&lt;br /&gt;instead of:&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;uint8_t trigger_temperature_no_hold_master = 0xE3; //Address to temperature reading with no hold of twi lines &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43259?ContentTypeID=1</link><pubDate>Wed, 05 Oct 2016 12:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3490fc3e-167e-4cc2-90ba-9fcb0c86031e</guid><dc:creator>samchang</dc:creator><description>&lt;p&gt;Hello ,thanks for the examples. when I using in this example,the values (humidity or temperature)is correct initially in a small period of time (various about 3~10 minutes) after that ,the values might change to humidty -6, temperature -46 ,I wonder to kown there is the problem ?? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43257?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 15:16:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a06b722-c011-4387-a367-cc593bad1506</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i used my humidity function. now its working. thanks for your help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43258?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 15:13:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e12680e-6f64-4c37-8b1e-a50953a66591</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;what to write in main??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43255?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 15:10:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:668dcae0-2e71-4c1c-a9d4-e68112733a09</guid><dc:creator>Fredrik Sundt Brynhildsvoll</dc:creator><description>&lt;p&gt;Great, then we have one less problem.
I might have a solution. I have edited the code above a bit by adding a short delay after receiving the bytes from the humidity sensor. I have previously experienced that this is needed.
Could you try the above code? And can you add the code (from main) where you call these functions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43254?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 14:39:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cee4a09-b2dc-40e2-a80a-83009ccc827a</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;your temperature function is working. giving me 28 degree. but humidity function is not working&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43256?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 14:29:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d926276c-cc86-416b-882b-72903b0e4ca9</guid><dc:creator>Fredrik Sundt Brynhildsvoll</dc:creator><description>&lt;p&gt;Is the humidity and temperature changing or are they constant?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43253?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 14:19:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7ec64f3-5dca-4bb6-a4fd-c4017e965446</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;got humidty -6, temperature -46&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43252?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 14:18:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b89bcf54-871f-4ff1-9040-fa99f6aa4173</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;here i am also getting wrong humidity&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43251?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 14:05:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:472c9920-e09d-4fa9-b658-4b57ba7f729a</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;thanks. i tried it. but its not working for me&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43250?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2016 12:07:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e52fcd5a-b7ef-44f9-a421-cb3d32ea7aab</guid><dc:creator>Fredrik Sundt Brynhildsvoll</dc:creator><description>&lt;p&gt;Edit: Added a function that read the temperature.&lt;/p&gt;
&lt;p&gt;Is this question resolved?
I have actually implemented this sensor (HTU21D) in one of my projects, so I should be able to help.&lt;/p&gt;
&lt;p&gt;First of all: I would recommend you to use the function nrf_delay_ms() to delay the microcontroller. To use this you must include &amp;quot;nrf_delay.h&amp;quot;&lt;/p&gt;
&lt;p&gt;You are writing to the registers 0xE3 and 0xE5. As stated in the datasheet of HTU21D this is &amp;quot;hold master&amp;quot; mode.
When using a hold master mode the argument xfer_pending must be set to &amp;#39;true&amp;#39;:
nrf_drv_twi_tx(p_twi_master,slave_addr, &amp;amp;reg_addr,1,&lt;strong&gt;true&lt;/strong&gt;);&lt;/p&gt;
&lt;p&gt;I have rewritten your function for reading the humidity. I cannot test it right now, but I believe it should work.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void HTU21D_Humidity1(int *r) {
ret_code_t ret_code;
uint8_t htu21d_address = 0x40; //7 bit address of HTU21D
uint8_t trigger_humidiy_no_hold_master = 0xF5; //Address to humidity reading with no hold of twi lines
uint8_t returned_over_I2C[3] = {0,0,0}; //Array to hold data

ret_code = nrf_drv_twi_tx(p_twi_master, htu21d_address, &amp;amp;trigger_humidiy_no_hold_master, 1, true);//Writing 0xE5 to HTU21D tell the sensor to start humidity readings and hold the master
nrf_delay_ms(50);//Delay 50 ms, which is the maximum measurement time stated in datasheet
ret_code = nrf_drv_twi_rx(p_twi_master, htu21d_address, returned_over_I2C, 3, false); //Get raw humidity data
nrf_delay_ms(5);
//Calculate humidity
uint16_t rawHumidity = ((unsigned int) returned_over_I2C[0] &amp;lt;&amp;lt; 8) | (unsigned int) returned_over_I2C[1];
float tempRH = rawHumidity / (float)65536; //2^16 = 65536
float rh = -6 + (125 * tempRH); //From page 14 in datasheet
*r = (int)(rh); // this could be change to (int)(rh*10), then one decimal of the humidity data will be kept (but 34.5  = 345 ) 
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Function that read the temperature:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void HTU21D_Temperature1(float *r){
ret_code_t ret_code;
uint8_t htu21d_address = 0x40; //7 bit address of HTU21D
uint8_t trigger_temperature_no_hold_master = 0xE3; //Address to temperature reading with no hold of twi lines
uint8_t returned_over_I2C[3] = {0,0,0}; //Array to hold data

ret_code = nrf_drv_twi_tx(&amp;amp;p_twi_instance, htu21d_address, &amp;amp;trigger_temperature_no_hold_master, 1, true);//Writing 0xE3 to HTU21D tell the sensor to start temperature readings and hold the master
nrf_delay_ms(50);//Delay 50 ms, which is the maximum measurement time stated in datasheet
ret_code = nrf_drv_twi_rx(&amp;amp;p_twi_instance, htu21d_address, returned_over_I2C, 3, false); //Get raw temperature data
nrf_delay_ms(5);
uint16_t x = (returned_over_I2C[0]&amp;lt;&amp;lt;8) | returned_over_I2C[1];
float tempRH = x /(float) 65536; //2^16 = 65536
float rh = -46.85 + (175.72 * tempRH);
*r=rh;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43248?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2016 14:22:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d7053d2-f0ea-4c9b-8185-f734eaf136a2</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;yes but these are much and random delay. i will change it and update it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43247?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2016 14:06:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:484e55ac-3b4f-4fb4-a3ff-2429aabe695f</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;In &lt;code&gt;HTU21D_Temperature&lt;/code&gt; you have a two 200 second delays, &lt;code&gt;delay_ms(200000)&lt;/code&gt; and in &lt;code&gt;HTU21D_Humidity&lt;/code&gt; you have two 10 second delays, &lt;code&gt;delay_ms(10000)&lt;/code&gt;. Is that correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43246?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2016 13:55:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb425ec2-d4fc-4adf-8b44-e50b8db6d523</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;but i have not put delay in temperature function as per datasheet. may be this is reason. so first i should check this then i will tell you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43245?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2016 13:54:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a410af4e-8466-458e-96b4-dc9f4f1623e6</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;yes i am facing problem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43244?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2016 13:51:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3e499db-a5d3-4f8f-853e-a60c2103b5f1</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;So you get incorrect values if you call &lt;code&gt;HTU21D_Temperature()&lt;/code&gt; and &lt;code&gt;HTU21D_Humidity()&lt;/code&gt; back to back?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43243?ContentTypeID=1</link><pubDate>Sat, 23 Jan 2016 14:56:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd33a6db-6358-41af-ac81-ff3890b15d9b</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;anyone have solution??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43242?ContentTypeID=1</link><pubDate>Sat, 23 Jan 2016 04:55:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:266b8ff1-ea2d-410d-9165-1e8d7c44654b</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;it is working for other microcontroller. so i think problem is in code. can anyone suggest me??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43241?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 13:19:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f6ca2f6-9455-4093-9267-d3b0f117dde3</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i think i should use interrupt handler. like when one I2C read is completed then second I2C read will start&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43240?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 13:15:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04ecd1fb-9ac6-4631-a2ff-a3b3f2de72a1</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;how to check clock?? i have not DSO. I think there is problem in code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43239?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 13:12:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b19ddaca-827a-4410-986f-bf93059ad582</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;Sorry for misunderstanding. I mean if I were you I would check clock. So you check clock and may be try to match line with resistor or even small cap.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43238?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 13:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56a5964b-9e35-4e25-a68e-a02e9ad38f18</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;ok check it and tell me&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43237?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2016 08:10:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b725c6f6-447b-4b1c-a565-ba9e5e59427c</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;I&amp;#39;d check I2C clock line, can be noisy/ringing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43236?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2016 15:28:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:899dcb34-c854-4a7a-af1d-3d3388c48264</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;in BMP180 there is common register for temperature and pressure 0XF6. so i am facing same problem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C interface with HTU21D using nrf51822</title><link>https://devzone.nordicsemi.com/thread/43235?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2016 15:26:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c2cd47d-53e8-4a6e-947e-8e0e777f21e6</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;I am facing same problem in bmp180&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>