mirror of
https://github.com/adafruit/DHT-sensor-library.git
synced 2023-10-23 22:20:38 +03:00
d83378b1f1
Commit: c1a3b9e507
76 lines
13 KiB
HTML
76 lines
13 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.13"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>DHT sensor library: DHT.h Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">DHT sensor library
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.13 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">DHT.h</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="_d_h_t_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> </div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="preprocessor">#ifndef DHT_H</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#define DHT_H</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> </div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include "Arduino.h"</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> </div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="comment">/* Uncomment to enable printing out nice debug messages. */</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="comment">//#define DHT_DEBUG</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> </div><div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#afe84d42042833e4e334c977b93ff2407"> 26</a></span> <span class="preprocessor">#define DEBUG_PRINTER Serial </span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor"></span><span class="comment">/* Setup debug printing macros. */</span><span class="preprocessor"></span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="preprocessor">#ifdef DHT_DEBUG</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor"> #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor"> #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#else</span></div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#a88edd2aa4feabff4af21a997d5d8aa23"> 33</a></span> <span class="preprocessor"> #define DEBUG_PRINT(...) {} </span></div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#ae414eccb9fbdc7c0cc6edfc588a3aa34"> 34</a></span> <span class="preprocessor"> #define DEBUG_PRINTLN(...) {} </span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> </div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">/* Define types of sensors. */</span></div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#ac7ca444ad6788a4e3686a83bc036efb6"> 38</a></span> <span class="preprocessor">#define DHT11 11 </span></div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#a1574ee8a0bebaff3165f634e2717d4e7"> 39</a></span> <span class="preprocessor">#define DHT12 12 </span></div><div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#a1d34ec65a101891e5800d6e6a69fe528"> 40</a></span> <span class="preprocessor">#define DHT22 22 </span></div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#af718013a29c2115b00d7c77d2f28084b"> 41</a></span> <span class="preprocessor">#define DHT21 21 </span></div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="_d_h_t_8h.html#a3de32b1bf162072c5e2d695bea5bb296"> 42</a></span> <span class="preprocessor">#define AM2301 21 </span></div><div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="class_d_h_t.html"> 47</a></span> <span class="preprocessor">class DHT {</span></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <a class="code" href="class_d_h_t.html">DHT</a>(uint8_t pin, uint8_t type, uint8_t count=6);</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keywordtype">void</span> begin(uint8_t usec=55);</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="keywordtype">float</span> readTemperature(<span class="keywordtype">bool</span> S=<span class="keyword">false</span>, <span class="keywordtype">bool</span> force=<span class="keyword">false</span>);</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="keywordtype">float</span> convertCtoF(<span class="keywordtype">float</span>);</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="keywordtype">float</span> convertFtoC(<span class="keywordtype">float</span>);</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keywordtype">float</span> computeHeatIndex(<span class="keywordtype">bool</span> isFahrenheit=<span class="keyword">true</span>);</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="keywordtype">float</span> computeHeatIndex(<span class="keywordtype">float</span> temperature, <span class="keywordtype">float</span> percentHumidity, <span class="keywordtype">bool</span> isFahrenheit=<span class="keyword">true</span>);</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="keywordtype">float</span> readHumidity(<span class="keywordtype">bool</span> force=<span class="keyword">false</span>);</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keywordtype">bool</span> read(<span class="keywordtype">bool</span> force=<span class="keyword">false</span>);</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  uint8_t data[5];</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  uint8_t _pin, _type;</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="preprocessor"> #ifdef __AVR</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="comment">// Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask</span></div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <span class="comment">// for the digital pin connected to the DHT. Other platforms will use digitalRead.</span></div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  uint8_t _bit, _port;</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="preprocessor"> #endif</span></div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  uint32_t _lastreadtime, _maxcycles;</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  <span class="keywordtype">bool</span> _lastresult;</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  uint8_t pullTime; <span class="comment">// Time (in usec) to pull up data line before reading</span></div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> </div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  uint32_t expectPulse(<span class="keywordtype">bool</span> level);</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> };</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00078"></a><span class="lineno"><a class="line" href="class_interrupt_lock.html"> 78</a></span> <span class="keyword">class </span><a class="code" href="class_interrupt_lock.html">InterruptLock</a> {</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <a class="code" href="class_interrupt_lock.html">InterruptLock</a>() {</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span> <span class="preprocessor">#if !defined(ARDUINO_ARCH_NRF52) </span></div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  noInterrupts();</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  }</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  ~<a class="code" href="class_interrupt_lock.html">InterruptLock</a>() {</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span> <span class="preprocessor">#if !defined(ARDUINO_ARCH_NRF52) </span></div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  interrupts();</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  }</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span> };</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span> </div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span> <span class="preprocessor">#endif</span></div><div class="ttc" id="class_d_h_t_html"><div class="ttname"><a href="class_d_h_t.html">DHT</a></div><div class="ttdoc">Class that stores state and functions for DHT. </div><div class="ttdef"><b>Definition:</b> DHT.h:47</div></div>
|
|
<div class="ttc" id="class_interrupt_lock_html"><div class="ttname"><a href="class_interrupt_lock.html">InterruptLock</a></div><div class="ttdoc">Class that defines Interrupt Lock Avaiability. </div><div class="ttdef"><b>Definition:</b> DHT.h:78</div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.13
|
|
</small></address>
|
|
</body>
|
|
</html>
|