Thursday, April 23, 2015

Pregnancy countdown device with Arduino

Once you or your spouse gets pregnant, thats all that matters in life. You immediately starts to count down to due date and you constantly want to know the current weight and length of the baby. And trust me; you do not wish to use a freakin iPhone app for that. You (and your baby) deserve a dedicated device for the job!

This is what you are waiting for

I hereby present my pregnancy countdown device. I built this a couple of years ago, and the baby whose due date was steadily counted down with this one is now a walking and babbling toddler. This is a simple weekend project that you can assemble with junk-box parts and an IKEA picture frame.

2 days and 22h to due date. You better pack the bag!

You are in week 40 and the baby is now 51.5 cm!

You are in week 40 and the baby is 3558 grams.

The device switches between due date countdown, baby length, baby weight and the current time (above) with 5 seconds on each.

The device is based on a Arduino UNO R3, a DS1302 real time clock and a 8-digit 7-segment display. The DS1302, and four buttons are soldered on a prototyping shield. The Arduino and the display are "glued" to the IKEA picture frame with sugru. I used an exacto knife to cut a hole in a 10x15cm picture and used an old 35mm film strip as a bezel for the 7 segment display diodes.

The buttons were initially for setting the due date, but I did not care to implement that in the software. Hardcoding is sufficient for this purpose (depending on how many kids you are planning of course).

The core of the code is basically to calculate the length and the weight of the baby given a specified due date. For any day the weight and the length can be interpolated from the tables below (showing weeks). The length (in cm) and weight (in grams) are average values for northern european babies. If all your meals are pure butter and coke during pregnancy (it can happen), you mileage may vary.

double lengthTable[] = {0,

int weightTable[] = {0,

Wednesday, April 22, 2015

10 Great Audio Books for Makers and Geeks

Disclaimer: The DIYcrap blog is meant to be exclusively about crap that I am making. This post is going to be one rare exception to that rule.

I am a sucker for inspirational and geeky audio books. Although there are tons of excellent non-ficion books on paper or as e-books, not all of them are that good when transferred to audio. Some audiobooks are, however, really good and can make a boring commute become the most inspirational time of your day. This is a non-prioritized list of some of the best audio books about making, geeking, nerding (whatever) that I have heard during the last two years.  They are all positive, refreshing and inspirational, and explains why new inventions in technology make the world progress towards a better place. These books are perfect if you are fed up with all the negative news stories telling you the world is going to hell and that we are soon going to die from the melting polar ice, hunger or terrorism.

Enough said. Lets begin with the list, emphasizing again that the list is not prioritized.

1: The Second Machine Age: 

Work, Progress, and Prosperity in a Time of Brilliant Technologies

Written by: Erik BrynjolfssonAndrew McAfee
Length: 8 hrs and 49 mins
Published: 2014

The book explains how digital technology dictates changes in the economy. The authors give many examples on different technologies that contributes to this change, such as robotics, 3D-printing, artificial intelligence and autonomous vehicles. The thesis of the book is very good, but on the negative side, the book is very similar to "The race against the machine" written by the same authors. If you have read (or listened) to the previous book, you can skip this. If you have not read the first book, you should choose "The second Machine age" as it is more updated.

2: Stuff Matters: 

Exploring the Marvelous Materials That Shape Our Man-Made World

Written by: Mark Miodownik
Length: 6 hrs and 34 mins
Published: 2014

This book is all about materials science. The author goes into detail about the history behind some key materials and the impact they have in our everyday lifes. Materials such as glass, steel, plastic and chocolate are explained with lots of humour and with interesting stories. If you have forgotten absolutely everything from your chemistry classes this book can reboot your interest in that direction. 

3: The Innovators: 

How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution

Written by: Walter Isaacson
Length: 17 hrs and 28 mins
Published: 2014

This book describes the fascinating history of the computer and electronics age. Among the heroes whose lifes and work are described are Ada Lovelace, Charles Babbage, Grace Hopper, Howard Aiken, Steve Wozniak, Steve Jobs and Bill Gates. It is obvious already in the first pages that Walter Isaacson does not like the romantic illusion of a lone inventor often described in biographies. He rather advocates that collaboration between different people is the main driver behind innovation. Overall, the book is really great, it is well written, and it goes through the whole history of information technology.

4: iWoz: 

How I Invented the Personal Computer and Had Fun Along the Way

Written by: Steve Wozniak, Gina Smith
Length: 9 hrs and 12 mins
Published: 2007

The books is told by Steve Wozniak about Steve Wozniak. In fact, the whole book is about Wozniak. Wozniak, Wozniak, Wozniak. As you probably can tell, there is a lot of bragging self-centered Wozniak in there, but who cares? Wozniak is an electronic genius, and he knows it. Although the book is badly edited, there are lots of interesting stories in here.

Walter Isaacson claims in Innovators (above) that Steve Jobs and Steve Wozniak were equally important in making Apple a big success. It might be true from a business point of view, but Wozniaks romantic story of creating a working computer sitting on his own is of no doubt the more interesting story of the two (at least from a geeky point of view).

5: Abundance: 

The Future Is Better Than You Think

Length: 10 hrs and 22 mins
Published: 2012

This book advocates that mankind could not only be causing all problems we face on earth, but we can also do something about these problems. Thanks to recent developments within digital technology, material technology and so on, we can actually improve the life of all people with water purification, diagnostic apps, new means of food production, renewable energy etc. If you are tired of all negative news stories telling you the earth is going to hell, this book will bring the optimist out in you.

6: The Long Tail: 

Why the Future of Business Is Selling Less of More

Written by: Chris Anderson
Length: 8 hrs and 1 min
Published: 2006

This book is already a classic. You can read more about Chris Andersons concept on his web-page, and he explains it like this: "The theory of the Long Tail is that our culture and economy is increasingly shifting away from a focus on a relatively small number of "hits" (mainstream products and markets) at the head of the demand curve and toward a huge number of niches in the tail."

Most of Chris Andersons predictions in this book has already come true, and it might seem somewhat outdated. However, the main thesis still holds, and it is well written, and highly recommended.

7: Automate This: 

How Algorithms Came to Rule Our World

Written by: Christopher Steiner
Length: 7 hrs and 41 mins 
Published: 2012

Although the statement that algorithms "came to rule our world" is very exaggerated, the book has some interesting stories. Most of the use of algorithms described in the book is from Wall street, and there is no doubt that algorithmic trading has changed the way Wall street and that part of the economy is working (or not working). I would not use this book to teach people about algorithms. Novices might even be scared to believe that algorithms are, in fact, taking over the world. But as pure entertainment, this book is recommended.

8: Makers: 

The New Industrial Revolution

    Another book of Chris Anderson made it on my list! This book is about how 3D-printers, laser cutters, digital fabrication, Kickstarter, Arduino and the new DIY/Maker-movement is altering how businesses are created and run, and how the digital age also influences the production of physical stuff (i.e., bits and atoms). 

    Anderson believes that we face a new industrial revolution, and that the new tools and production processes can offer a way for USA and Europe to incource production of physical objects from China. He might or might not be true about this thesis. It does not matter for me. The book is full of optimism about the future and it just makes me want to make stuff right away.

    9: What If?: 
    Serious Scientific Answers to Absurd Hypothetical Questions

Written by: Randall Munroe
Length: 6 hrs and 36 mins
Published: 2014

This book is full of humor and hard facts. It provides answers to questions like "What is the farthest one human being has ever been from every other living person? Were they lonely?", and "What if you tried to hit a baseball pitched at 90 percent the speed of light?", or  "How fast can you hit a speed bump while driving and live?" and " If there was a robot apocalypse, how long would humanity last?". If you have ever read (and understood) Randall Munroe’s iconic webcomic, this book is for you. The book makes you proud that you enjoyed physics and chemistry classes all those years ago while the other kids hated them.

10: Bold: 

How to Go Big, Make Bank, and Better the World

Written by: Peter H. Diamandis, Steven Kotler
Length: 9 hrs and 6 mins 
Published: 2015

This book is written by the same authors that wrote Abundance in 2012. It is sort of an update of this book and sort of isn't. It is mainly a motivational book for business people wanting to understand exponential technology. For an inventor or engineer, it can be quite irritating reading a book that constantly talks about going big, bold and make a billion-dollar company.  Unfortunately, most of the stories and examples in the book are well-known and does not bring anything new to the table.

The book is narrated by one of the authors, Steven Kotler. A very bad idea. Although the book is very optimistic in its style, the narration seems very monotone, negative and depressive. It is as if he is just about to jump off a cliff. Why am I even bothering to recommend this book? Well, it is about creating businesses that changes the the world, it is optimistic, and makes me want to be an entrepreneur.

Tuesday, April 14, 2015

Script for downloading all Popular Electronics magazines

The great page has got loads and loads of old radio and electronics magaizines for download. Among these are the venerable Popular Electronics magazine which was published between October 1954 and October 1982. These old magazines are really great, not only for historic reasons and for fun, but there are also lots of electronic circuits, loadspeaker designs, and more in there that you can still build directly from the articles or you can use them as inspiration for new projects.

The most famous issue is probably the January 1975 issue presenting the Altair 8800 computer kit. Now you can build your own based on the original instructions :-)

I have made a simple Python script that downloads all the 337 isssues of the Popular Electronic magazine. The script is based on a script from Peter B. Mark that downloads all 73 ham radio magazines from (btw, a highly recommended magazine).

Using the script, I can read through all the editions on my iPad even when I am offline, for example when I am waiting for my flight on an airport with nothing else to do and no WiFi.

Disclaimer: The whole bunch of magazines will occupy about 3.5GB of disk space. Furthermore, the naming of the directories on americanradiohistory is not concise, so the script might seem a bit crappy. But it works! Feature: If you exit the script while it runs, it will not download previously downloaded magazines when you restart. Good luck.

Download pdfs of Popular Electronics Magazine

import os
import urllib2
import urllib

END_YEAR = 1982
OUTPUT_DIR = "PopularElectronics"

MISSING = ('PopularElectronics/Pop-1954-01.pdf', 'PopularElectronics/Pop-1954-02.pdf', 'PopularElectronics/Pop-1954-03.pdf', 'PopularElectronics/Pop-1954-04.pdf', 'PopularElectronics/Pop-1954-05.pdf', 'PopularElectronics/Pop-1954-06.pdf', 'PopularElectronics/Pop-1954-07.pdf', 'PopularElectronics/Pop-1954-08.pdf', 'PopularElectronics/Pop-1954-09.pdf')

def main():
    if not os.path.exists(OUTPUT_DIR):

def downloadPopMag(prefix):
    for year in range(START_YEAR, END_YEAR + 1):
        for month in range(1,13):
            fileName = "%s/Pop-%d-%02d.pdf" % (OUTPUT_DIR, year, month)
            if not os.path.exists(fileName) and fileName not in MISSING:
urlyear = year - 1900
tenyear = urlyear - (urlyear % 10)
strtenyear = str(tenyear) + "s"                
if(urlyear > 69):
urlyear = year

editionString = "%s-%d-%02d" % (prefix, year, month)

url = "" % (strtenyear, urlyear, editionString)
                print("Downloading: %s..." % url)
                print("To: %s" % fileName)
                try: pdfData = urllib2.urlopen(url).read()
except urllib2.HTTPError as e:
# Probably wrong prefix. Try with the other prefix later
print e.code
                outFile = open(fileName, "wb")
                print("Skipping: %s" % fileName)

if __name__ == "__main__":