Harvesting energy from WiFi and GSM networks?

By Confusion on Sunday 10 January 2010 21:21 - Comments (21)
Categories: Science, Technology, Views: 5.828

Source: Oh Gizmo, Engadget

At CES 2010, a company called RCA has presented a device called 'Airnergy', which is supposedly able to harvest energy from WiFi (and GSM) networks, for instance to charge your cellphone. Now this raises immediate suspicions: if that is possible, why aren't mobile devices powered by these networks in the first place? However, given the feeling that we are surrounded by a vast multitude of such networks, it still sounds remotely plausible. The only way to determine whether this makes sense, is to actually crunch the numbers:

My phone has a 0.9 Ah battery, at 3.7V. This means the battery holds 12kJ. With an uptime of 200 hours, this means a mobile phone consumes 17 mW on average.

A wireless accesspoint emits EM radiation in the order of of 100mW. If a device harvesting this power has an active area of 10x10cm and is, on average, located 1 meter from the accesspoint, it will pick up 0.01/(4*pi) * 100 = 0.08 mW, assuming the radiation is the same in all directions.

If the device in question can harvest 0.08 mW, it takes17/0.08 ~ 209 accesspoints and 200 hours to accumulate 12 kJ. My only conclusion can be that this product is completely bogus. Even at a conference, with perhaps 100 nearby cellphones as additional radiation sources, it wouldn't be useful.

This analysis grossly overestimates the power that could be harvested, as it assumes a 100% conversion of EM radiation into electricity and situates the accesspoints within one meter of the device. Is it a hoax? Is it fraud? Is it idiocy? Or is my calculation wrong?

I just started hating Java

By Confusion on Thursday 07 January 2010 15:42 - Comments (32)
Categories: Java, Python, Software engineering, Views: 6.362

A new year, a new hatred. I've just officially begun hating the language in which I do most of my work: Java. The tiresome verboseness finally got to me. Please compare with me:


Java:
1
2
3
4
5
6
7
8
9
10
11
12
    private static String joinObjectFields(final List<SomeObjectobjects
        final Character seperatorfinal SomeObject exclude) {

        String result = "";
        for (SomeObject objectobjects) {
            if (!object.equals(exclude)) {
                result += object.someField + seperator;
            }
        }
        // Strip last ; (and see edit3)
        return result.substring(0result.length() - 1);
    }



Python:
1
2
3
4
def joinObjectFields(objects, seperator, exclude):

  fields = [object.someField for object in objects if object != exclude]
  return seperator.join(fields)


To prevent "these pieces of code don't do the same thing", an alternate Java implementation, more like the Python one:

Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    private static String joinObjectFields(final List<SomeObjectobjects
        final Character seperatorfinal SomeObject exclude) {

        final String[] fields = new String[objects.size()];
        for (int i = 0i < fields.lengthi++) {
            if (!object.get(i).equals(exclude)) {
                fields[i] = object.someField;
            }
            else {
                fields[i] = "";
            }
        }
        return StringUtils.join(fields';');
    }

Doesn't get much better, even if you would initialize the array to contain "" in every field using a utility method.

For extra hatred, consider the necessary changes to the code to enable the same method to join the contents of a different object field.

Edit: A colleague noted that cloning the list and removing the 'exclude' would make matters slightly better.

Edit2: And before someone starts calling me a Python fanboy: you can also do this in a much shorter fashion in Scheme, Ruby, Perl, Scala, Lisp/Clojure, etc.

Edit3: And of course I stupidly forgot to check whether result.length() is actually > 0 in the first implementation.

Edit4: As JanDM rightly points out, I shouldn't use curly braces in Python :P.

Edit 5: This version in Java, posted by Markus in the comments, is far superior: I wasn't making any sense here: the code does a different thing.