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,
0,
0,
0,
0,
0,
0,
0,
1.6,
2.3,
3.1,
4.1,
5.4,
7.4,
8.7,
10.1,
11.6,
13,
14.2,
15.3,
16.4,
26.7,
27.8,
28.9,
30,
34.6,
35.6,
36.6,
37.6,
39.9,
41.1,
42.4,
43.7,
45,
46.2,
47.4,
48.6,
49.8,
50.7,
51.2,
51.7,
51.5,
51.3};

int weightTable[] = {0,
0,
0,
0,
0,
0,
0,
0,
1,
2,
4,
7,
14,
23,
43,
70,
100,
140,
190,
240,
300,
360,
430,
501,
600,
660,
760,
875,
1005,
1153,
1319,
1502,
1702,
1918,
2146,
2383,
2622,
2859,
3083,
3288,
3462,
3597,
3685,
3717,
3717,
3717,
3717};

No comments:

Post a Comment