Thursday, July 23, 2015

Low Frequencies and Solder Fumes

Somewhere inside UoC
Photo credit: Chathura Suduwella
Due to the nature of our research works, it's not enough just to sit in front of a computer and write programs that do certain things. Our work makes us to sniff solder fumes most of the times and sometimes it makes us to move out of the lab and walk all over the university. Last few weeks were so much stressful due to various challenging tasks we were facing. It's not easy but I think I learned so much interesting new things during these hard times. Among various things I was facing, two notable experiences are worth reporting for my future reference.

As a further step of our elephant infrasonic research, our guys wanted to do several field experiments within the university premises. It requires them to take the infrasonic emitter and detector equipment and move all over the university premises which is not as easy as it sounds. While moving we have to take data samples from the infrasonic detector at various places and we need to take note of the GPS coordinates of the particular location. Sometimes our infrasonic emitter stops functioning or gets stuck and sometimes our equipment runs out of battery power. Facing all those troubles, we have to keep moving all over. Joining with Chathura aiya, Poshitha and Waruna, I had a nice time in the field missing the lunch and a work day. Besides the troubles of experiments, we were happy about the outcomes of it.

First three units out of the production line :)
Second move is from the hardware side. Moving ahead of breadboards, we finally managed to
implement a much more usable wireless mote. It has extension headers to connect a USB ASP programmer board to reprogram the MCU without removing it from the mote as it was a very troublesome thing in our earlier version. First I tried everything on a breadboard and then started moving things into the permanent mote. Chathura aiya provided a great assistance in this effort and his confidence and ideas helped so much. Without his guidance, these little things will not be as beautiful and handy as they are at the moment. He exactly knows how to put things in the right position in order to make it smaller and look good.

A lot more interesting work is going on these days. I will try to write a brief note if I found anything worth telling to my future self. For the moment, this is it.

Sunday, July 19, 2015

Serial communication between Arduino and Android

I wanted to establish communication between an Arduino Uno board and an Android device for a project work. Initially I tried usb-serial-for-android library and reached to some level. I was able to read some amount of bytes from the Arduino board. However due to some reason, my Android device disconnects from the Arduno serial connection after a while. In order to try that, I followed the steps mentioned here. It's sad that I spent a whole day trying to make it work but finally failed. Perhaps this library actually works but due to some mistake I made, it's still not ready to work. Anyway, I'm leaving it to try later some other day if I find time.

It took me some time to realize that there are other libraries available to achieve the same thing. Since I ran out of time, I didn't get a chance to try them from scratch but I decided to try some sample apps they provide. These guys in Physicaloid provides an interesting library and sample projects which actually worked for me. Their PhysicaloidLibrary includes sample project in this place and some of those are in google play already.

I installed their USB Serial Monitor Lite app in google play into my Galaxy S3 device which runs Android 4.4.4. Then I installed following simple Arduino sketch into an Arduino Uno board. Connecting the two devices with the help of a USB OTG cable showed me that Arduino board responds to the messages from Android phone by blinking the LED at pin 13 and also by sending reply data.

static int counter = 0;
int led = 13;

void setup() {
        pinMode(led, OUTPUT);     

void loop() {
  digitalWrite(led, LOW);

  if (Serial.peek() != -1) {
          digitalWrite(led, HIGH);
        do {
                byte message = (byte);
                //Serial.print("Received: ");
                if(message == (byte) '1'){
                } else {
        } while (Serial.peek() != -1);     

I think I should look into the source code of this app which can be found here in order to adapt it into my work requirements.

Monday, July 6, 2015

Install GNURadio on Ubuntu 12.04 using install script

When using HackRF device, it is necessary to have GNURadio installed and running in our machine. Until today, what I used was a USB drive installed with a live linux image. This live linux image was pre-configured with GNURadio and other relevant tools. I have written a separate article about GNURadio based on this live linux image. This time, I'm installing GNURadio and relevant tools on my Ubuntu 12.04 system which will save me from requiring to restart the computer to go for a live linux image whenever I have to use HackRF.

Since the installation of GNURadio from source files is a big hassle, I found a wonderful installation script extremely helpful. GNURadio website has indicated it as a good way to install GNURadio and therefore, I decided to go with it. Here's the steps I followed to perform the installation using that script.

(1) Create a folder named 'src' somewhere in the home directory and move into it using terminal

mkdir src
cd src/

(2) Run the following command

wget && chmod a+x ./build-gnuradio && ./build-gnuradio

It takes a very long time to download source files and packages, compile them and configure all the necessary things.

(3) Add the following line to the ".bachrc" file in your home directory. This information was printed on the screen during the installation process of the previous step. That's why I followed it to set this path.

export PYTHONPATH=/usr/local/lib/python2.7/dist-packages

(4) Now plug-in HackRF device into a USB port and run following command.

sudo hackrf_info

An output much similar to the following should appear in the terminal then.

Found HackRF board 0:
Board ID Number: 2 (HackRF One)
Firmware Version: 2014.08.1
Part ID Number: 0xa000cb3c 0x00544f46
Serial Number: 0x00000000 0x00000000 0x14d463dc 0x2f6662e1

(5) Now we can start gnuradio companion (GRC) in order to try hackrf device using the following command.

sudo gnuradio-companion

That's it. After the GRC windowed showed up, we can start creating different flow graphs and run them with HackRF device.