<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: simple PIR sensor library</title>
		<link>http://forums.leaflabs.com/topic.php?id=9937</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:21:37 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=9937" rel="self" type="application/rss+xml" />

		<item>
			<title>jake1981 on "simple PIR sensor library"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9937#post-21746</link>
			<pubDate>Thu, 20 Dec 2012 11:46:58 +0000</pubDate>
			<dc:creator>jake1981</dc:creator>
			<guid isPermaLink="false">21746@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Updates made - I also updated all my other libraries. Now licenses are mentioned.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jake1981 on "simple PIR sensor library"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9937#post-21737</link>
			<pubDate>Thu, 20 Dec 2012 00:20:15 +0000</pubDate>
			<dc:creator>jake1981</dc:creator>
			<guid isPermaLink="false">21737@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'll update the library when I've got some time. But let's get to the answers;&#60;/p&#62;
&#60;p&#62;What is my work based on? It is not based on that source, it's based on some other&#60;br /&#62;
source that I unfortunately cannot remember Where it located on the internet - but I chose&#60;br /&#62;
That one Because it was more informative than arduino pirsense doc. If I remember correctly,&#60;br /&#62;
It was on instructables.com&#60;/p&#62;
&#60;p&#62;My license will be updated to readme. It will be public domain.&#60;/p&#62;
&#60;p&#62;Yes, the device I used was the cheapest parallax type sensor I found from the ebay. Same sensors are sold also at electrodragon.com&#60;/p&#62;
&#60;p&#62;Idea in my library is to record if there has been movement, that's why I wrote it that way, as project I plan to use this doesn't necessarily need the value all the time, but on a request; it needs to know if there has been activity..&#60;/p&#62;
&#60;p&#62;And sorry about that digitalwrite low, I haven't readed all the docs and thought it couln't hurt. I'll add a ifdef arduino to that code..
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jake1981 on "simple PIR sensor library"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9937#post-21733</link>
			<pubDate>Wed, 19 Dec 2012 16:56:57 +0000</pubDate>
			<dc:creator>jake1981</dc:creator>
			<guid isPermaLink="false">21733@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks. Don't know if it speeds up a  anything, but shorter source is always good.. I'll fix this later..
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "simple PIR sensor library"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9937#post-21728</link>
			<pubDate>Wed, 19 Dec 2012 10:50:55 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">21728@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;jake1981 - I had a quick look at your library. &#60;/p&#62;
&#60;p&#62;IMHO it is good form to acknowledge the authors work that is used as a basis for new work.&#60;br /&#62;
I assume it is &#60;a href=&#34;http://playground.arduino.cc/Code/PIRsense&#34; rel=&#34;nofollow&#34;&#62;http://playground.arduino.cc/Code/PIRsense&#60;/a&#62;&#60;br /&#62;
IMHO you should also say what the copyright status of the code is.&#60;/p&#62;
&#60;p&#62;I think it would be helpful for you to say which PIR sensor you have tested the code with. It looks like you might used something like the Parallax PIR sensor (e.g. at &#60;a href=&#34;http://www.parallax.com/tabid/768/txtSearch/PIR+sensor/List/0/SortField/4/Default.aspx)&#34; rel=&#34;nofollow&#34;&#62;http://www.parallax.com/tabid/768/txtSearch/PIR+sensor/List/0/SortField/4/Default.aspx)&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Those are different from a 'raw' PIR sensor, (e.g. &#60;a href=&#34;http://uk.farnell.com/murata/ira-e712st3/pir-high-light-immunity/dp/1006207)&#34; rel=&#34;nofollow&#34;&#62;http://uk.farnell.com/murata/ira-e712st3/pir-high-light-immunity/dp/1006207)&#60;/a&#62; which need a signal amplifier. So being clear is helpful.&#60;/p&#62;
&#60;p&#62;How thoroughly do you understand the original code?&#60;br /&#62;
I ask because the code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;PIR::PIR(uint8 pin) {
  _pin = pin;
  pinMode(_pin, INPUT);
  digitalWrite(_pin, LOW);
  // ...&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;makes sense on an Arduino, but is a odd for an STM32. &#60;/p&#62;
&#60;p&#62;The statement &#60;code&#62;pinMode(_pin, INPUT);&#60;/code&#62; sets the pin to be an input.&#60;br /&#62;
So the statement &#60;code&#62;digitalWrite(_pin, LOW);&#60;/code&#62; is strange, without an explanation, because normally code wouldn't write to an input pin.&#60;/p&#62;
&#60;p&#62;However, on an Arduino (ATmega168/328), that sequence ensures the I/O ports pull-up resistor for that pin is off.&#60;br /&#62;
On Maple that &#60;code&#62;pinMode(_pin, INPUT);&#60;/code&#62; is sufficient, or you could say &#60;code&#62;pinMode(_pin, INPUT_FLOATING);&#60;/code&#62; (which is the same) if you wanted to be explicit about the pull-up/pull-down resistors.&#60;/p&#62;
&#60;p&#62;IMHO the logic of the PIR class is unnecessarily complicated.&#60;br /&#62;
It might be simpler to either have:&#60;br /&#62;
a) a function which blocks until the sensor calibration time has passed (probably not ideal as the Parallax data sheet says this could be 60 seconds, but workable), or&#60;br /&#62;
b) a function which itself returns true once the calibration time for the PIR has elapsed. For example, set the variable calibrationTime = millis() + actual calibration time in the constructor, then put the first-time calibration logic in a renamed&#60;code&#62;calibrating&#60;/code&#62; (is_calibrated?), and there is no need to call &#60;code&#62;updating&#60;/code&#62;. Just ask for the state of the PIR pin.&#60;/p&#62;
&#60;p&#62;It also isn't clear that the concept of waiting for a period of time is completely implemented in the PIR. It seems to be divided between the demo program and the PIR class. If the _state variable, and all methods that use it are removed from the PIR class, then the PIR class becomes simpler, and the demo program seems simple too. Or move all the logic into the PIR class, and have it solve that part f the use case.&#60;/p&#62;
&#60;p&#62;A small point. Code like this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;boolean PIR::calibrating(void) {
  if ( calibrationTime == 0 )
    return false;
  return true;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;May be simpler as:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;boolean PIR::calibrating(void) {
  return (calibrationTime != 0);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Just my $0.02. HTH
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jake1981 on "simple PIR sensor library"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9937#post-21715</link>
			<pubDate>Tue, 18 Dec 2012 17:11:45 +0000</pubDate>
			<dc:creator>jake1981</dc:creator>
			<guid isPermaLink="false">21715@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi. Again.&#60;/p&#62;
&#60;p&#62;I have written a simple PIR library for Maple. Handling PIRs is easy, with this library.. It is even easier..&#60;br /&#62;
Check the example for usage..&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/oskarirauta/PIR_sensor_library&#34; rel=&#34;nofollow&#34;&#62;https://github.com/oskarirauta/PIR_sensor_library&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
