The Arduino is really quite handy to have around. Right now we’ve got one reporting the temperature and humidity of a chicken incubater. It could also control the temperature, humidity, and egg rotation but we haven’t gone there yet. Even so it’s nice to get the measurements with the audible warning. Then you can always repurpose all this stuff to do something else once you are done incubating.

You just need (unvalidated list):

Add in a stepper motor, voltage switch, and some sort of fluid controller and you could do it all. Unglorious image of this – the OLED is very nice:

Here’s the relevant code – it of course plays the 1st 4 notes of Beethoven’s 5th as a warning (or at least an attempt at that not having found the true notes):

#include <Wire.h>
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include <Adafruit_Sensor.h>
#include "DHT.h"
#define OLED_DC 11
#define OLED_CS 12
#define OLED_CLK 10
#define OLED_MOSI 9
#define OLED_RESET 13

#define DHTTYPE DHT22   // DHT 22  (AM2302)
#define DHTPIN 2     // what pin we're connected to

#define speakerPin 4

// TONES  ==========================================
// Start by defining the relationship between 
//       note, period, &  frequency. 
#define  c     3830    // 261 Hz 
#define  d     3400    // 294 Hz 
#define  e     3038    // 329 Hz 
#define  f     2864    // 349 Hz 
#define  g     2550    // 392 Hz 
#define  a     2272    // 440 Hz 
#define  b     2028    // 493 Hz 
#define  C     1912    // 523 Hz 

//thermometer - humidity

float temp;
float humidity;

void setup() {


void loop() {
  display.clearDisplay();   // clears the screen and buffer

void getWeather() {
  //read DHT
  float humidity = dht.readHumidity();
  float t = dht.readTemperature();
  t = t * 9.0 / 5.0 + 32.0;
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(humidity)) {
    Serial.println("Failed to read from DHT");
  else {
    Serial.print("Humidity: "); 
    Serial.print(" %\t");
    Serial.print("Temperature: "); 
    Serial.println(" *C");


  delay(10000);   //10 seconds seems often enough

void updateDisplay(float h, float t) {
  display.print("Temp:  ");
  display.println(" F");
  display.println(" ");
  display.print("Humidity:  ");
  display.println(" ");

  // warnings
  if (t < 98.8 || t > 100) {
    display.println("CHECK TEMP!!!");
    display.println(" ");

  if (h < 50 || h > 70) {
    display.println("CHECK HUMIDITY!!!");

void playWarning() {
  tone(speakerPin, g);
  tone(speakerPin, g);
  tone(speakerPin, g);
  tone(speakerPin, C);


Here’s a quick python script to use the camera you can attach to a Raspberry Pi and take a picture whenever it detects motion. This is pretty cool, there are all sorts of silly things you can do if you can do motion detection. And to do it with the Raspberry Pi and attached camera is relatively inexpensive (less than $100) to boot! Next time someone knocks our mailbox down we’ll have ’em!

I started from the script here and modified it to just take one picture to both test whether anything changed as well as save the picture if something changed. Seems a bit better than the original taking two pictures – at least this doesn’t cause the Pi to freeze. That means the Pi have to scan a bit larger image for a change but skipping pixels seems to keep it under control. It also takes better pictures as takes some time (the -t 500 in the raspistill call) to calibrate the camera.

#!/usr/bin/env python

import StringIO
import subprocess
import os
import time
from datetime import datetime
from PIL import Image

# Motion detection settings:
# Threshold (how much a pixel has to change by to be marked as "changed")
# Sensitivity (how many changed pixels before capturing an image)
# ForceCapture (whether to force an image to be captured every forceCaptureTime seconds)
threshold = 10
sensitivity = 2000
forceCapture = True
forceCaptureTime = 60 * 60 # Once an hour

# File settings
saveWidth = 1280
saveHeight = 960
diskSpaceToReserve = 500 * 1024 * 1024 # Keep 500 mb free on disk

# Capture a small test image (for motion detection)
def captureTestImage():
    command = "raspistill -w %s -h %s -t 500 -e bmp -o -" % (1280, 960)
    imageData = StringIO.StringIO()
    imageData.write(subprocess.check_output(command, shell=True))
    im =
    buffer = im.load()
    return im, buffer

# Keep free space above given level
def keepDiskSpaceFree(bytesToReserve):
    if (getFreeSpace() < bytesToReserve):
        for filename in sorted(os.listdir(".")):
            if filename.startswith("capture") and filename.endswith(".jpg"):
                print "Deleted %s to avoid filling disk" % filename
                if (getFreeSpace() > bytesToReserve):

# Get available disk space
def getFreeSpace():
    st = os.statvfs(".")
    du = st.f_bavail * st.f_frsize
    return du

# Get first image
image1, buffer1 = captureTestImage()

# Reset last capture time
lastCapture = time.time()

while (True):
    # Get comparison image
    image2, buffer2 = captureTestImage()

    # Count changed pixels
    changedPixels = 0

    for x in xrange(0, 1280, 4):
        for y in xrange(0, 960, 4):
            # Just check green channel as it's the highest quality channel
            pixdiff = abs(buffer1[x,y][1] - buffer2[x,y][1])
            if pixdiff > threshold:
                changedPixels += 1

    # Check force capture
    if forceCapture:
        if time.time() - lastCapture > forceCaptureTime:
            changedPixels = sensitivity + 1

    # Save an image if pixels changed
    if changedPixels > sensitivity:
        lastCapture = time.time()
        timeN =
        print "Save jpg"
        filename = "capture-%04d%02d%02d-%02d%02d%02d.jpg" % (timeN.year, timeN.month,, timeN.hour, timeN.minute, timeN.second), "JPEG")
    # Swap comparison buffers
    image1 = image2
    buffer1 = buffer2
    print "Done waiting"

Fermi paradox

I had been thinking about the Fermi paradox the other day for no real reason but then XKCD had this comic:

That captures my opinion on it. The Fermi paradox is a bit too anthropocentic, assuming that other life would be like ours and not just happily swimming in oceans, not exploring the universe. Or being bigger than us or smaller or just other.

But then XKCD had this comic today which argues for the Fermi paradox. It is a bit concerning the temperature change estimates when viewed this way.

I suppose I did read this wrong the first time, it’s not as scary as I originally thought! My poor reading comprehension had us off the scale but we’re only at the question mark for now. I suppose in 100 years we’ll have it figured out, we’re good at figuring things out. So I’ll still scoff at the Fermi paradox.