Digital Dark Age is Real

February 2017 | Dios Kurniawan

Few days ago I realized that all my family video tapes stored in MiniDV format from the year 2002 to 2011 were simply unreadable. Not because they are defective, but because my MiniDV camcorder refuses to turn on – most likely because of its 15-year-old age. It is terrifying to see that suddenly I lost years of memory just because I do not have the hardware to play it back. Sure, I can always buy a new camcorder, but MiniDV is an obsolete video format and not many manufacturers still produce the hardware today.

Luckily I have transferred all videos to DVD discs, but the original raw uncompressed video – with higher quality than what’s stored in DVD’s MPEG-2 format – remains in those tapes, so I am left with a pile of video tapes which are as good as useless.

My video album in MiniDV tapes

This made me realize that the threat of “Digital Dark Age” was real. Digital Dark Age refers to a possible dystopian situation when our future generation cannot read our history records that we store in digital media. This can be compared to the first “Dark Age” in the mid ages after the fall of Roman Empire when most record of history on civilization was lost.

MiniDV is a relatively young digital format introduced in late 1990’s, but with the rise of flash storage technology, tape technology has slowly faded away from consumer electronics. Imagine your collection of memorable moments, photos, videos and documents you have amassed in the last 20 years in tapes would be unreadable if you don’t quickly migrate to the new technology. Digital Dark Age is looming over our lives.

Another example that digital dark age is upon us: In 1997, I published a book (see my book here), it was printed few thousands copies and they sold pretty well. Now, 20 years later, I still have the physical copy of my book, but I don’t have the digital copy anymore because the computer that I used to write the book in 1997 has gone forever.

Many digital formats have come to obsolescence and have finally extinct. Remember floppy disk? It used to be the most popular media to store computer files in 1980’s. Nobody uses it anymore, but there must be tons files are still stored in floppy disks which have not been migrated to a new storage media.

The same is true for CD-ROM, DVD, hard drive, USB flash disk, etc. Not one person in this world can guarantee that in 50-100 years time, someone will still own the device to read and extract the information.

My PATA hard disk, CD-ROM and Floppy Disks (remember them?)

Even if the files in the legacy digital media can be restored, there is still a big probability that we do not possess the software for reading the files in their original format. Those who were raised in 1980’s to early 1990’s most likely have used PCs to write documents using old word processing software which does not exist anymore. Remember Wordstar and Wordperfect? Can we open the files properly today?

JPEG format may be the de facto standard for storing digital pictures today, but who can guarantee that the algorithm to decompress JPEG images will still be known by the future generations in 100 or 200 years from now?

Cloud storage is also a vulnerability. We are accustomed to store our photos in Google Photos, Dropbox or Apple iCloud and think they will be safe there. Are we 100% sure that Google and Apple will still in business 100 years from now?

Large organizations are now relying on Big Data technology to store and process data in large amount. They put files in Hadoop File System with multiple different compression formats. How can we ensure that in 20 years the data will still be readable?

If we do not do something in controlling our way in storing digital data, we are risking the possibility that our grand children will never be able to read our records. History would be lost forever. I recommend that from now on, all of us make physical copies of our most important photos and documents to preserve them.

Our New Product: Petelur.ID

July 2016 | Dios Kurniawan

We have launched our new product, Petelur.ID, a non-commercial service promoted by the Food and Agricultural Organization (FAO). We launched the service at Jakarta Convention Center (JCC) yesterday.

Read the media coverage here.

Holiday Project: Simple IoT Experiment

September 2015 | Dios Kurniawan

Last Lebaran holiday in July was a good time for me to jump back into my programming hobby. Quiet days, no interruptions and no deadlines. It was really a good time to delve into coding. Well, programming is actually much more fun if it is only a hobby when you can choose what real-life problems you want to solve with your software, pick the language you like, and choose how to do it. This time, I got about a week worth of leisure time, and I decided to create a solution to one domestic problem: a refrigerator door sensor.

A remote sensor for refrigerator

Let’s be more clear with the requirement. The problem definition is: I want to know how many Magnum Mini ice cream packs are left in my fridge. Yes, ice cream. My daughter loves to eat Magnum Mini while the same is true for me. It creates some sort of competition situation, either she or myself would eat up the ice cream. Nothing more upsetting to me than seeing no more Magnum Mini is left in the fridge each time I got home from work. I wish I could have an app in my hands telling me if my ice cream supply falls short, so I could stop by at local groceries store on my way home to restock the ice cream. I was thinking about some kind of a camera that monitors the inside the freezer, or a counter device to see how many times the fridge door is opened each day, but I could not find such thing in local DIY shops. Enter Android smartphones.

My stockpile of Magnum Minis in the fridge

Nearly all Android phones today are equipped with built-in accelerometers. This sensor is good for measuring the acceleration force that is applied to a device on all three physical axis (x, y, and z), including the force of gravity. Just like an aircraft, an Android device orientation is also defined by pitch, roll and azimuth. So why don’t we use this sensor for detecting door movements? Simply attach a cheap Android phone on the door and let it run to detect motion. All we need is an app that reads the accelerometer and sends the data over the internet thru Wi-Fi or 3G connection, basically turning an Android device into a remote sensor, or as some people prefer to call it : an M2M (machine-to-machine) sensor.

Device orientation variables for detecting open-close state

For this purpose, I wrote a simple Android app (I named “dSensor“) that reads the accelerometer sensor, detects movement and sends the event over the Wi-Fi to a remote server, which in turn will store the data. I do not intend to create anything overly complex because I understand a decent movement detection algorithm would need an in-depth study on digital signal processing theories. I would try to skip that and make the detection function as simple as it can. Simply detect changes in orientation and trigger the event to send data. Luckily, Android provides pretty complete library for accessing sensors under android.hardware.Sensor package.

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

Quite straight forward, detecting door’s open/closed position is achieved by implementing code in the onSensorChanged() event. The movement detection is implemented using accelerometer which in turn would trigger detection using magnetic field sensor, to determine if the door is opened or closed.

@Override public void onSensorChanged(SensorEvent event) { 
 if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER) { 
 //detect any slight movement to trigger door check 
 } 
 if(event.sensor.getType()==Sensor.TYPE_MAGNETIC_FIELD) { 
 //get azimuth, pitch & roll to check if door is open or closed 
 } 
}

After a couple days of coding, my first prototype app was ready to test. For this purpose I used my 4-year-old Samsung Galaxy Y which had been lying around unused at my house for quite a long time. This old smartphone is glued on the fridge’s door with its battery charger permanently attached, and continuously running the app in the foreground.

Android app to detect motion and send the data over Wi-Fi

The Android phone is attached to the fridge, acting as a sensor

Data from the device is transferred in JSON format via HTTP and is then stored in a database. Initially I chose MySQL, but later I moved to MongoDB (a NoSQL database) to take advantage of its scalability. I also created a simple web application to display the reports.

+---------------------+------------+----------+------------+
| time stamp          | azimuth    | pitch    | roll       |
+---------------------+------------+----------+------------+
| 2015-08-23 20:55:28 | 36.71875   | -25      | 11.5234375 |
| 2015-08-23 20:50:27 | 36.71875   | -25.7812 | 12.3046875 |
| 2015-08-23 20:45:26 | 35.9375    | -25      | 13.0859375 |
| 2015-08-23 20:40:25 | 39.84375   | -25      | 9.9609375  |
| 2015-08-23 20:35:24 | 39.84375   | -25      | 9.9609375  |
| 2015-08-23 20:30:23 | 39.84375   | -24.2187 | 9.9609375  |
| 2015-08-23 20:25:32 | 40.625     | -25      | 9.9609375  |
| 2015-08-23 20:20:21 | 39.84375   | -25      | 9.9609375  |
| 2015-08-23 20:15:20 | 39.84375   | -25      | 9.9609375  |
| 2015-08-23 20:10:18 | 35.9375    | -26.5625 | 8.3984375  |
| 2015-08-23 20:05:18 | 37.5       | -25      | 11.5234375 |
| 2015-08-23 20:00:16 | 37.5       | -25.7815 | 12.3046875 |
+---------------------+------------+----------+------------+

Now the analysis part. The raw data sent from the sensor tells me how many times the door is opened, but it cannot tell me how many ice cream packs are still in the fridge. The approach is to make an assumption that each time the door is opened, one Magnum Mini is taken out. I understand that my kids get home from school at around 3 PM, therefore any door opening event during the time until they get to sleep at around 10 PM can be assumed that my kids are extracting Magnum Minis from the fridge. Using simple if-then statements, each time the door is opened during this period, the number of ice cream counter is subtracted by one. Of course in reality it is not that simple as there may be other things inside the fridge, but at least that’s the closest approximation.

The application would require me to adjust the counter each time I restock my ice cream. Subsequently, the application will count how many ice cream has been consumed and will display the (estimated) remaining number in my fridge. Now, I can remotely view this information at my fingertips anywhere I have access to my web application. Pretty neat.

Web application shows how many times door has been opened during the day, and estimate how many remaining ice cream are still there

Not limited to refrigerators and ice cream, my sensor-on-a-phone solution can also be used on doors to detect theft, to count how many people entering a room, and many other uses. I am now working on modifying the code to detect motion and even vibration in my car. This demonstrates that a pretty versatile sensor can be had with a old, cheap hardware (under $30) which would otherwise become electronic waste.

Theft Detector

My simple project here highlights the vast opportunity to use Android devices for sensors, especially in light of the emergence of IoT (Internet of Things) trends. This is just a simple experiment, but the potential use case is limitless. There is nothing as exciting as starting a new project and seeing it evolve.