<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[REXYGEN Community Forum / Reading a DHT11 sensor]]></title>
	<link rel="self" href="https://www.rexygen.com/oldforum/extern.php?action=feed&amp;tid=184&amp;type=atom"/>
	<link href="http://www.rexygen.com/oldforum/viewtopic.php?id=184"/>
	<updated>2017-03-15T08:38:21Z</updated>
	<generator>FluxBB</generator>
	<id>http://www.rexygen.com/oldforum/viewtopic.php?id=184</id>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1554#p1554"/>
		<content type="html"><![CDATA[<p>Hi Darren,</p><p>DHT sensors should work with Raspberry Pi. Try to contact Adafruit and explain them your issue. The problem is not on REX side since you are not able to run the external Python script.</p><p>Did you try to reinstall the library? Did you follow the installation guides here: <a href="https://github.com/adafruit/Adafruit_Python_DHT" rel="nofollow">https://github.com/adafruit/Adafruit_Python_DHT</a>?<br />Did you also run the DHT library setup command?</p><div class="codebox"><pre><code>sudo python setup.py install</code></pre></div><p>Regards, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2017-03-15T08:38:21Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1554#p1554</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1553#p1553"/>
		<content type="html"><![CDATA[<p>Currently using a RPI 1 , I think it is a B model. it has the 26 pin header.<br />I was looking at upgrading to RPI 3.</p><p>Would it be easier if I used a different sensor? perhaps one with I2c interface?</p>]]></content>
		<author>
			<name><![CDATA[darren.macleod@internode.on.net]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=53</uri>
		</author>
		<updated>2017-03-15T06:22:15Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1553#p1553</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1549#p1549"/>
		<content type="html"><![CDATA[<p>Hi Darren,</p><p>what Raspberry Pi version do you use? It seems that the Adafruit DHT library does not support Raspberry Pi 3 by default.<br />See the link: <a href="https://github.com/adafruit/Adafruit_Python_DHT/issues/60" rel="nofollow">https://github.com/adafruit/Adafruit_Py … /issues/60</a></p><p>Hope it will help.</p><p>Cheers, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2017-03-14T10:10:30Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1549#p1549</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1548#p1548"/>
		<content type="html"><![CDATA[<p>Hi Tomas,<br />I have tried to modify the script to work on DHT22 using GPIO25 as per below, and I am having issues.</p><br /><p>#!/usr/bin/python</p><p>import Adafruit_DHT<br />import socket<br />import struct<br />import time</p><br /><p>while True:<br />&#160; &#160; &#160; &#160; humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 25)<br />&#160; &#160; &#160; &#160; f_temp = open(&#039;/rex/rexcore/ramdisk/dht11_temp.txt&#039;, &#039;w&#039;)<br />&#160; &#160; &#160; &#160; f_temp.write(&#039;%.4f \n&#039; % (temperature))&#160; &#160;#writes temperature in specified txt file</p><p>&#160; &#160; &#160; &#160; f_humid = open(&#039;/rex/rexcore/ramdisk/dht11_humid.txt&#039;, &#039;w&#039;)<br />&#160; &#160; &#160; &#160; f_humid.write(&#039;%.4f \n&#039; % (humidity))&#160; &#160;#writes humidity in specified txt file<br />&#160; &#160; &#160; &#160; time.sleep(5)</p><br /><br /><br /><p>When I run this script as per line 6 of your earlier post I get the following:-</p><p>Traceback (most recent call last):<br />&#160; File &quot;dht22_read.py&quot;, line 10, in &lt;module&gt;<br />&#160; &#160; humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 25)<br />&#160; File &quot;/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py&quot;, line 94, in read_r&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;etry<br />&#160; &#160; humidity, temperature = read(sensor, pin, platform)<br />&#160; File &quot;/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py&quot;, line 80, in read<br />&#160; &#160; platform = get_platform()<br />&#160; File &quot;/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py&quot;, line 48, in get_pl&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;atform<br />&#160; &#160; from . import Raspberry_Pi<br />&#160; File &quot;/home/pi/Adafruit_Python_DHT/Adafruit_DHT/Raspberry_Pi.py&quot;, line 22, in&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;module&gt;<br />&#160; &#160; from . import Raspberry_Pi_Driver as driver<br />ImportError: cannot import name Raspberry_Pi_Driver</p><br /><br /><p>Any suggestions?<br />Thanks <br />Darren</p>]]></content>
		<author>
			<name><![CDATA[darren.macleod@internode.on.net]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=53</uri>
		</author>
		<updated>2017-03-14T08:35:49Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1548#p1548</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1488#p1488"/>
		<content type="html"><![CDATA[<p>Hi Chand,</p><p>good to hear that it is working now for you.</p><p>We don&#039;t have specificaly any I2C temperature sensor examples. However, please, investigate attached commpressed folder which contains updated library of various I2C examples. At least it can serve as a good starting point for your implementation.</p><p><a href="https://www.rexygen.com/oldforum/img/members/39/Rex_I2C_examples.zip" rel="nofollow">Rex_I2C_examples.zip</a></p><p>Cheers, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2017-02-15T07:36:39Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1488#p1488</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1485#p1485"/>
		<content type="html"><![CDATA[<p>That worked.&#160; Good to know about the default working folder change.</p><p>Do you have any I2C temperature sensor examples?&#160; specifically with the MCP9808 board?</p><p>Thanks again Tomas!</p>]]></content>
		<author>
			<name><![CDATA[chandc]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=90</uri>
		</author>
		<updated>2017-02-14T19:03:12Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1485#p1485</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1482#p1482"/>
		<content type="html"><![CDATA[<p>Hi Chand,</p><p>the problem you are facing is caused by security features introduced in Rex v2.50.1. Default working folder is now set to &quot;/rex/data&quot; and can be configured - look for &quot;data.path&quot; parameter in RexCore documentation - <a href="https://www.rexcontrols.com/media/2.50.1/doc/PDF/ENGLISH/RexCore_ENG.pdf#page=4" rel="nofollow">https://www.rexcontrols.com/media/2.50. … pdf#page=4</a></p><p>Try to enable the ramdisk inside /rex/data directory and accordingly change the SILO block fname parameters.</p><p>Hope the above is useful for you.</p><p>Regards, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2017-02-14T13:36:13Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1482#p1482</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=1479#p1479"/>
		<content type="html"><![CDATA[<p>Hi Tomas, </p><br /><p>I have installed v2.50 and am revisiting this example.&#160; I am able to see that temp and humidity values are updating in the ramdisk files; however, RexDraw &amp; RexView continue to read a 0 (zero) value.&#160; Could you please give me some tips on troubleshooting why RexDraw &amp; RexView might be unable to retrieve the values in the text files?</p><br /><p>Thanks in advance !</p>]]></content>
		<author>
			<name><![CDATA[chandc]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=90</uri>
		</author>
		<updated>2017-02-14T06:43:47Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=1479#p1479</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=813#p813"/>
		<content type="html"><![CDATA[<p>Hi Chand,</p><p>I&#039;m glad that you made it work <img src="http://www.rexygen.com/oldforum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><div class="quotebox"><cite>chandc wrote:</cite><blockquote><div><p>--&gt; What design factor guided you to select the ramdisk method?&#160; Would you advise using the ramdisk method for keeping a history of up to 10 measurements?</p></div></blockquote></div><p>Data exchange via files has one drawback - it writes the text files over and over again with certain period (every 5s in my example). Since SD card live is often affected by amount of write cycles we try to avoid damaging your SD card by writing the files into RAM memory. It can be used for that many measurements which can fit in your RAM memory (example uses only 10MB of RAM - it can be easily resized).</p><div class="quotebox"><cite>chandc wrote:</cite><blockquote><div><p>--&gt; The ramdisk files contain only a single value.&#160; Where is the trend data stored?&#160; Is it possible to configure trend data to be stored on another drive?</p></div></blockquote></div><p>Trend data are stored also in RAM memory in internal format. See <a href="https://www.rexcontrols.com/media/DOC/ENGLISH/BRef_ENG.pdf#page=265" rel="nofollow">documentation of TRND block</a> for more details. Pay attention to &quot;Function description&quot; paragraph about memory requirements.</p><p>Trend data will be stored in RAM memory - it can not be changed. However it is possible to use Archives which can be configured to be stored on another drive. Check out <a href="https://github.com/rexcontrols/REXexamples/tree/master/Function_blocks_Standard/ACD_Archiving" rel="nofollow">Archiving analog signals example</a> and <a href="https://www.rexcontrols.com/media/DOC/ENGLISH/BRef_ENG.pdf#page=257" rel="nofollow">Data archiving documentation</a> for more details.</p><div class="quotebox"><cite>chandc wrote:</cite><blockquote><div><p>Do you have a thermostat control type Rex sample project I might be able to take a look at?</p></div></blockquote></div><p>Yes, we do. See <a href="https://github.com/rexcontrols/REXexamples/tree/master/RaspberryPi_examples/SimpleThermostat" rel="nofollow">Simple Thermostat example</a> in our <a href="https://github.com/rexcontrols/REXexamples" rel="nofollow">GitHub repository</a>.</p><br /><p>If you require any further information, feel free to contact me.</p><p>Cheers, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2016-08-08T10:18:17Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=813#p813</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=812#p812"/>
		<content type="html"><![CDATA[<p>Hi Tomas, </p><br /><p>Thank you for clarifying.&#160; I am now able to see the temp &amp; humidity trends. </p><br /><p>Is the ramdisk method common for Pi based Rex control systems.&#160; A couple of follow up questions:<br />--&gt; What design factor guided you to select the ramdisk method?&#160; Would you advise using the ramdisk method for keeping a history of up to 10 measurements? <br />--&gt; The ramdisk files contain only a single value.&#160; Where is the trend data stored?&#160; Is it possible to configure trend data to be stored on another drive?</p><br /><p>Do you have a thermostat control type Rex sample project I might be able to take a look at?</p><br /><p>Thanks again Tomas!</p>]]></content>
		<author>
			<name><![CDATA[chandc]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=90</uri>
		</author>
		<updated>2016-08-08T00:12:54Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=812#p812</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=811#p811"/>
		<content type="html"><![CDATA[<p>Hi Chand,<br />you are completely right - the file you are looking for is &quot;dht11_read.py&quot;. Thank you for your notice. Will update my previous post.</p><p>Good luck with your project!</p><p>Cheers, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2016-08-06T21:08:23Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=811#p811</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=810#p810"/>
		<content type="html"><![CDATA[<p>Hi Tomas, </p><p>Step 5&#160; above references a dht11.py file.&#160; I see a dht11_read.py file in the DHT_sensor_reading.zip.&#160; Is that the py file you are describing or is it another?</p><p>Thank you,</p><p>Chand</p>]]></content>
		<author>
			<name><![CDATA[chandc]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=90</uri>
		</author>
		<updated>2016-08-06T20:46:21Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=810#p810</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=808#p808"/>
		<content type="html"><![CDATA[<p>Thank you very much for the excellent details Tomas!</p><p>I am on travel at the moment and will implement them asap this weekend.&#160; The level of detail you provided will jump start both the prototype and my understanding of Rex.</p><p>Regards,&#160; Chand</p>]]></content>
		<author>
			<name><![CDATA[chandc]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=90</uri>
		</author>
		<updated>2016-08-02T23:11:35Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=808#p808</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Re: Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=807#p807"/>
		<content type="html"><![CDATA[<p>Hello,</p><p>thank you for your interest in Rex control system. I presume that you are using Raspberry PI as target platform, am I right?</p><p>There are many possibilities how to read a DHT11 temperature / humidity sensor into REX. As you are starting with REX I would suggest using python script for reading the sensor values and storing them to text files on your target platform. REX will read the files using SILO blocks afterwards. The reason is that you don&#039;t need any advanced function blocks which require advanced licence.</p><p><strong>DHT - temperature and humidity sensor reading - <a href="https://www.rexygen.com/oldforum/img/members/39/DHT11_sensor_reading.zip" rel="nofollow">DHT11_sensor_reading.zip</a></strong></p><ol class="decimal"><li><p>Install <a href="https://github.com/adafruit/Adafruit_Python_DHT" rel="nofollow">Adafruit Python DHT Sensor Library</a></p></li><li><p>Connect the sensor to the Raspberry PI (e.g. according to the <a href="http://www.rototron.info/dht22-tutorial-for-raspberry-pi/" rel="nofollow">tutorial</a> to the GPIO4)</p></li><li><p>Try to run the DHT example to see if the sensor works well:<br />sudo /home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py 11 4<br />(= read DHT11 sensor connected to the GPIO4)</p></li><li><p>Prepare ramdisk for storing the text files in order to avoid damaging your SD card with excessive file writting:<br />Edit fstab: sudo nano /etc/fstab<br />Add the line: none&#160; &#160; &#160; /rex/rexcore/ramdisk&#160; &#160; &#160; &#160; tmpfs&#160; &#160; &#160; size=10M&#160; &#160; &#160; &#160; &#160; 0&#160; &#160; &#160; &#160; 0<br />Save and reboot.</p></li><li><p>Copy python script &quot;dht11_read.py&quot; to the Raspberry PI and make it executable:<br />sudo chmod +x dht11_read.py</p></li><li><p>Run the script. (you should see 2 new text files in folder /rex/rexcore/ramdisk)</p></li><li><p>Compile and download the Rex project to the target device using RexDraw.</p></li><li><p>Watch the trend with humidity and temperature using RexView.</p></li></ol><p>Note: the python script must be running all the time you want to read the sensor. You can for example use &quot;crontab&quot; with parameter &quot;@reboot&quot; to make the script running after reboot.</p><p>Hope that it will help you to start your prototype.</p><p>If you will need further information feel free to contact me.</p><p>Regards, Tomas</p>]]></content>
		<author>
			<name><![CDATA[tomáš čechura]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=39</uri>
		</author>
		<updated>2016-08-02T11:04:33Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=807#p807</id>
	</entry>
	<entry>
		<title type="html"><![CDATA[Reading a DHT11 sensor]]></title>
		<link rel="alternate" href="http://www.rexygen.com/oldforum/viewtopic.php?pid=806#p806"/>
		<content type="html"><![CDATA[<p>I am in the process of familiarizing myself with the Rex control system with the intention of using it as a basis for a product I am developing.</p><br /><p>For a prototype I am attempting to read a DHT11 temperature / humidity sensor.&#160; There are existing arduino libraries for reading the sensor and displaying it via serial monitor.</p><p>I am having some difficulty determining the best path for reading the DHT11 using Rex controls. The sensor has a single digital connection (<a href="http://www.candrian.gr/index.php/dht-11-one-wire-bus/" rel="nofollow">http://www.candrian.gr/index.php/dht-11-one-wire-bus/</a>).&#160; Would you suggest creating function blocks to access the sensor directly or is it possible to use Arduino libraries to read sensor data which could then be read via RexDuino.</p><p>Any advice / suggestions would be greatly appreciated in speeding up this prototype.</p>]]></content>
		<author>
			<name><![CDATA[contactform]]></name>
			<uri>http://www.rexygen.com/oldforum/profile.php?id=11</uri>
		</author>
		<updated>2016-07-31T20:44:17Z</updated>
		<id>http://www.rexygen.com/oldforum/viewtopic.php?pid=806#p806</id>
	</entry>
</feed>
