You can do it yourself: Arduino ditigal thermometer

My arduino project

A digital thermometer

I have always liked electronics. I remember receiving different mechanical toy kits when I was a kid. I would make a car, a tank, a boat and all kind of different motorized projects. I would play for hours at a time with this kit. It was great but there was only an on/off switch.

During my teen years, I have been teaching robotics for children at our primary school with some lego mechanical kit. It was great because you could plug in sensors, motors and create a program that would check if a specific sensor was above a value and respond to it. My college final project was a full blown calculator. It was more like a full adder with three seven-segment display, but I like to think of it as a full calculator.

Since a few days ago, I have not touched electronics. I changed my mind after looking at the Arduino proposal. Arduino is a programmable and open source electronic board which includes a few input and output channels. It is low cost and easy to get started with. I bought an experimentation kit with an Arduino and a few of the base stuff you will want to play with in electronics: resistances, diodes, leds, transistors, sensors, motors, etc. It came with a few projects which I quickly completed.

I was wondering what I could do next and I came up with the digital thermometer project. Since my commercial digital thermometer is currently broken and my girlfriend likes to know what is the temperature in our house, I built a new one. You can see an picture of it in this post.

My initial kit did not include a display so I had to buy one. Also, the display had to be solder on pin headers so I bought a soldering iron. I never soldered before. I read the guide that came with my soldering iron, I tried a few times on a cardboard than set to complete my display. I was actually easier than I though. I managed to complete the soldering part with minor messes. The coding part was actually quite easy. There is a library to use the display with where you only need to pass the text to display. The remaining part was to read from the temperature sensor, compute the temperature from the voltage, plug in the wires and plug the power in.

If you like electronics and you are a total beginner in that field, Arduino is a nice platform to get started with. Have fun!

My reason hero

My reason hero is without a doubt Stefan Molyneux. Casting aside prejudices, myths and false beliefs, he explains philosophy the way it should be taught: with simple words.

In these dark times where violence is portrayed as the solution to most problems and where fairy tales are presented as truths, we need more people to reason with logic and to teach other to do so.

Bitcoin: a potentially disruptive currency

Coins

Coins by Joe Shlabotnik

In the past, I have described my tendency to like distributed and decentralized systems. Recently, I cam across this new virtual currency called Bitcoin.

Bitcoin is a peer-to-peer electronic currency. It cannot be controlled by anyone. I believe this is its main strength. Most currencies available and used today are controlled by a small group of people that can create money at will. With such a great power, it is bound to be abused. It is abused. This is why Bitcoin has the potential to be a disruptive innovation.

Bitcoin also have many other interesting properties. You can make anonymous transactions between two parties without any third party involved. There is a theoretical maximum amount of bitcoins available on the market. Anyone can currently generate new bitcoins with a computer, energy and some patience. In a sense, it simulates the hard currencies like gold and silver. No single person can control gold. You can trade gold anonymously. There is a physical maximum amount of gold available on the market. Anyone can dig up gold with a shovel, energy and some patience.

When I started using Bitcoin, I was wondering how I could get some coins to spend. I found a person who gives bitcoins for free. I generated a few bitcoins with my CPU/GPU. I am now considering buying and selling bitcoins on various open bitcoin exchange systems. There is already a good and wide community surrounding it.

One of Bitcoin’s current weakness is its popularity. A currency is strong only when it is used by many people to engage in trade. Bitcoin is accepted by only a few companies. It is also only asked for by a few people as a mean to pay for their labour. In order to promote it, I have decided to accept donations in bitcoins and only in bitcoins. If you like this blog post, other content or product I created, please consider donating a few bitcoins to: 1BBhiGu5xX1qSHbHPcnw5UB3hMo9DcCmav . I hope you will get interested by Bitcoin.

Keep your unoptimized source code

You got to keep them by juhansonin

You got to keep them by juhansonin

I had a quite interesting discussion with my coworker last week. We often have endless discussions about software development where he start by talking about how nice functional languages are and where it ends with how my knees hurt. It goes in all direction, but it is always interesting.

Back on the topic, at some point during our discussion, I told him how I think database schema architecture should work. I believe you should create your schema to be normalized from the start. BCNF is probably a good normal form. I believe you should at least target the third normal form or higher. Since the normal forms tends to make your database queries slower, if you have any performance problem you should follow these steps:

  1. Measure your queries’ performance.
  2. Find out which queries are your performance bottleneck.
  3. Denormalize tables that are part of those queries to gain performance if it applies.

In many cases, when you denormalize tables, you get a database schema which is less intuitive to understand and to work with. My key point in this is to keep your unoptimized normal form schema. You can have a separate branch in source control management system for your unoptimized schema and one for your optimized one. It is easy to do and it is inexpensive. You can also have a migration script which will take your unoptimized schema and transform it to the optimize form. This way you can keep developing in the reference world and have your production server run the optimized version simply by deploying your reference version plus the optimization migration script.

Why would you want to do this? Here are a few good arguments:

  • It is always good to have a clean reference for some optimized part of your application. References are often much easier to read, understand and change than their optimized counter part. Just being able to understand some part faster can have a tremendous impact on your performance.
  • Bottlenecks change over time. After multiple updates on your application, you might discover that your bottleneck is changing. Having the clean reference in a separate branch makes it easier to go back to it, evaluate again the new bottleneck and optimize only the new bottlenecks.
  • Technology change over time. You might wake up one day to find out the new version of your DBMS optimize itself on the fly without your intervention for your previous slow queries.

This also applies to code. Optimized code is often harder to read, understand and maintain. A good example of this is unladen-swallow. It is a faster implementation of the Python language by Google. In this same spirit, their long-term plan is:

[...] to make Python fast enough to start moving performance-important types and functions from C back to Python.

Google understands the value of easy to read and easy to modify code. It is time we put more effort into that goal. Having your reference unoptimized code easily accessible is a good start to get there.

H.264: A dent in Firefox’s progress

Firefox is showing his teeth by Ben Fredericson

Firefox is showing his teeth by Ben Fredericson

Firefox’s progress has been quite steady since its’ first releases. I remember downloading one of the first alpha version to try it out. It was rough but it was on a good track.

Today, Firefox has a lot of competition for the top spot. Opera, Google Chrome, Safari and even the upcoming Internet Explorer 9 are coming to bite back. However, I believe the biggest challenge Firefox will have to overcome is H.264.

H.264 is a highly popular video codec. It was created in collaboration with the MPEG group. It fits into the long saga of video on the web and HTML5 which itself fits into another long story about the evolution of the HTML standards and the evolution of the web.

To put it in context, a group of people interested in the evolution of the web decided to propose a new version of HTML, the base language on which web pages are built on. They called it HTML5. One of the goals of this group was to introduce standard facilities for video on the web. An open way to put video on the web without having to rely on external proprietary plugins like Flash. After specifying an HTML tag to fulfil this goal, they discussed which video codec would be needed to play those videos. After a long and much passionate discussion, the group came to the conclusion that it would be better not to make any video codec mandatory for any browser. Just like there is no mandatory image format that a browser must support in the web standards, there would be no one for video too.

Left in the hands of those who build browsers, two groups quickly emerged in the political video codec movement: those in support for an open, free and without licensing fees video codec and those in support for an already well established but proprietary with licensing fees video codec. Firefox and Opera sided with the open group while Safari and recently Internet Explorer sided with the proprietary group. Ogg Theora is currently the open group video codec and H.264 is the proprietary video codec. Google Chrome did not choose a group and implemented both video codecs.

There are many difficulties that Firefox will go through if it does not implement H.264. The proprietary video codec is rapidly gaining traction, momentum and popularity. Many high profile video web sites are currently using it with their Flash video player. It is simply natural for them to keep using it with HTML5. Many video experts say that it is superior to the Ogg Theora alternative. There is already a widespread of hardware decoding components for H.264 making your iPhone battery last way longer when viewing H.264 videos.

Even with these difficulties, I believe it would be a bad move for Firefox to introduce H.264. It would be a dent in the open web standards by establishing a proprietary component as a norm on the web. It would be a first step towards a less open web space with all the consequences that could follow.

If Firefox does not implement H.264, that might not stop others to put H.264 in Firefox. Recently, Canonical, the Ubuntu parent’s company, has been offering OEM the option to license H.264 with their new computers that come with Ubuntu pre-installed. This could theoretically means that an OEM could sell you Ubuntu with a modified version of Firefox with H.264 in it while being 100% legal. A few days ago, a new project called Wild Fox was created with the intention of offering a modified version of Firefox that includes H.264 for all those countries where the H.264 patents are not enforceable which exclude USA and South Korea.

A wild card in this video codec battle is VP8. It is a video codec that Google obtains by acquiring the On2 Technologies company. Google is suppose to announce the open-sourcing of the VP8 codec at their Google I/O conference either tomorrow or thursday. VP8 should be superior to Ogg Theora. It would counter the weakness argument given by those who choose H.264 over Ogg Theora for its’ image quality and performance.

Let’s hope Firefox can go through these H.264 related problems and prosper like it did in the recent years.

Updates: Google confirmed today the open sourcing of VP8 along with another project called WebM to create a video container for the web. This is some great news. Mozilla and Opera joined the WebM project and are already working on it.

Stop caring too much about how your site looks

The perfect woman by Jeremy Levine

The perfect woman by Jeremy Levine

I know many people who want their website to looks exactly the same across all browsers. They want absolute consistency like mad people think they can walk on water. These people should stop caring too much about it because, mainly, it is impossible.

Since I started this blog, I have been looking how it looks like on different browsers and platforms. I have noticed the font is a bit smaller on a default Ubuntu installation. It does not display that well on the BlackBerry browser. Do I care? Not much.

I could work a little to make it display nicely on the BlackBerry but it would not be worth it. I do not have any visitor on my website using the BlackBerry browser. I have a few iPhone browser visit, somewhere around seven visitors in the last year. Even if I had that much BlackBerry, I do not think it would be worth it anyway. BlackBerry is more associated with the businessman type of person. They are not the kind of people who would read my blog anyway.

Different operating system are using different font rendering engine. Different browsers are using different default margin values. Managing absolute consistency is a a great walk into hell. Do not go over there. Instead, focus on what people want: easy access to content. Focus on what is technically feasible: degrade gracefully.