<p dir="ltr">Good point, Pete. This would certainly not be preferred if high accuracy is desired. But for a quick and dirty option, this may suffice. Perhaps if you included some kind of sampling and averaging, it would be a little bit better.<br></p>
<p dir="ltr">-Sent from my phone</p>
<div class="gmail_quote">On Aug 27, 2015 10:57 PM, "Pete Soper via TriEmbed" <<a href="mailto:triembed@triembed.org">triembed@triembed.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    One thing to keep in mind with this and nearly everything else on a
    Raspberry Pi is that your program can be preempted at any time.
    Literally in the middle of one of the Python statements control may
    be yanked away and given to another process, then passed back to
    finish that statement an indeterminate time later. Between device
    interrupts and processor scheduling ("time slicing") with background
    daemons, there is a blizzard of program interruption going on more
    or less randomly. Depending on the system load (or just plain
    chance) you may see this never or a lot or anything in between. So
    don't be surprised if the simple code from the Adafruit tutorial
    below puts out some very funky numbers occasionally (i.e. they're
    completely crazy with respect to what you know the sensor should be
    reporting). There are ways to make the code immune to these kinds of
    errors, but it adds complexity. A relatively accurate time reckoning
    scheme for Python on Linux is in "answer 54" <a href="http://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do-in-python?rq=1" target="_blank">on
      this page</a>. I just confirmed this works fine on my regular
    Linux system and think it ought to work just as well on an RPI. One
    way to reject bogosity is to toss a number that represents an
    impossible change in sensor readings. That is, if you know the
    sensor can't be reporting a room temperature of 70 degrees one
    moment and 90 degrees the next, you can toss the 90 degree reading.
    But this adds complexity and it won't be long before you want to use
    an ADC chip. :-)<br>
    <br>
    And concidentally, tonight at Splatspace Geoff Tattersfield
    facilitated a session about using an MCP3008 ADC chip with a
    Raspberry Pi using the SPI bus. Folks went through <a href="https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi" target="_blank">this
      Adafruit tutorial</a>.<br>
    <br>
    -Pete<br>
     <br>
    <div>On 08/27/2015 09:32 PM, dan via
      TriEmbed wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">I love it! And a very nice write-up too :) I'm
        definitely a fan of using the lights to show different kinds of
        information (weather, time, scores, etc.) I really like your
        weather display. Maybe you could have chasing blue lights when
        it's going to rain, hehe.
        <div><br>
        </div>
        <div>As a hardware nerd, I especially like the photoresistor RC
          timing trick. I'd have never thought of that, but it makes
          perfect sense. I'll have to keep that in mind for other
          projects :)
          <div><br>
          </div>
          <div>For those curious, the adafruit article Chip linked to
            explains how you can read restive sensors (like a photocell)
            using a Raspberry Pi's GPIO pins without needing an external
            Analog-to-Digital converter module. For simple sensors, this
            would be a great way to interface them to the Pi on the
            cheap.</div>
        </div>
        <div><br>
        </div>
        <div><a href="https://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi/how-it-works" target="_blank">https://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi/how-it-works</a><br>
        </div>
        <div><br>
        </div>
        <div>Thanks very much for sharing! Please keep us up to date
          if/when you make any changes/additions!</div>
        <div><br>
        </div>
        <div>-Dan</div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Aug 27, 2015 at 7:24 PM,
          Charles McClelland via TriEmbed <span dir="ltr"><<a href="mailto:triembed@triembed.org" target="_blank">triembed@triembed.org</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div style="word-wrap:break-word">
              <div>All,</div>
              <div><br>
              </div>
              From the last meeting, <a href="https://www.hackster.io/chipmc/awesome-led-entertainment-center" target="_blank">here</a> is the documentation for my
              Entertainment Center LED Geek makeover.  Comments and
              suggestions are welcome but please be kind as this is my
              first time programming in Python.
              <div><br>
              </div>
              <div>Thanks,</div>
              <div><br>
              </div>
              <div>Chip</div>
              <div><br>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Triangle, NC Embedded Computing mailing list<br>
            <a href="mailto:TriEmbed@triembed.org" target="_blank">TriEmbed@triembed.org</a><br>
            <a href="http://mail.triembed.org/mailman/listinfo/triembed_triembed.org" rel="noreferrer" target="_blank">http://mail.triembed.org/mailman/listinfo/triembed_triembed.org</a><br>
            TriEmbed web site: <a href="http://TriEmbed.org" rel="noreferrer" target="_blank">http://TriEmbed.org</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
Triangle, NC Embedded Computing mailing list
<a href="mailto:TriEmbed@triembed.org" target="_blank">TriEmbed@triembed.org</a>
<a href="http://mail.triembed.org/mailman/listinfo/triembed_triembed.org" target="_blank">http://mail.triembed.org/mailman/listinfo/triembed_triembed.org</a>
TriEmbed web site: <a href="http://TriEmbed.org" target="_blank">http://TriEmbed.org</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
Triangle, NC Embedded Computing mailing list<br>
<a href="mailto:TriEmbed@triembed.org">TriEmbed@triembed.org</a><br>
<a href="http://mail.triembed.org/mailman/listinfo/triembed_triembed.org" rel="noreferrer" target="_blank">http://mail.triembed.org/mailman/listinfo/triembed_triembed.org</a><br>
TriEmbed web site: <a href="http://TriEmbed.org" rel="noreferrer" target="_blank">http://TriEmbed.org</a><br>
<br></blockquote></div>