Saturday, 5 November 2016


I wanted to send AGPS data to my UBLOX CAM-M8, so get a faster fix as the chip doesnt have a eeprom to save the data and not even a battery backup.
I understood that every chip needs to download a map of where all the satellites are in the space and then based on that information, the chip can triangulate the position.

The great information is that UBLOX provides a free access to the AGPS servies which you will need to provide a close location ( latitude and longitude) and then a file is generated.

To send this file, you will need to parse the data and send the message via Serial and because I couldnt find anywhere a sample code, I tried to code something which actually worked.

The real sending would be too check the ack message, but this worked fine for me.

Saturday, 7 November 2015

PN53x with Raspberry Pi and Python

Install libnfc on your raspberry pi by following Adafruit guide , make sure you are using the Serial pins and shorted the right pins on the board, check the version of the PN53x to short the right ones.

Install the library NFCPY which allows you to read and write through libnfc a nfc tag.

To decode a message:

To write a message

Saturday, 18 July 2015

[Arduino] Timestamp function

Arduino don't have the function which convert hhmmss and ddmmyy to unix timestamp and because I was looking to combine my data to one universal time, I did't find a method to achieve that.

I came across to the library TIME which is a good library but because I had to optimise my code and have the sketch as small as possible ( developing for Arduino pro mini ), I extracted the necessary function  and variables to generate timestamp.
The file is available on my github here and this is how you can use the function:

From the date:01.06.2015 and time 20:10:00 you will have call the function like this:

and it will return a long number which is unix timestamp.

Saturday, 13 December 2014

Remove Passphrase from SSH Key

Most of the time you create a ssh key for your GIT or SSH login and you wished the system wouldn't ask the password each time, and here there is a solution to it.

openssl rsa -in private_key_with_pass_phrase -out private_key_without_pass_phrase
WARNING: a pass phrase is an added layer of security in case you loose control of your private key. Think carefully about removing the password.

Just replace the old key with the new one and you solved your problem.

Sunday, 26 October 2014

J/Box2D first steps

I came across to use JBox2D and I didnt know anything about how a physical engine works, so I am writing some helpful tips here.

Scale and dimensions

Firstable you have to keep on your mind that Box2D works with meters, so forget pixel or dpi, you will need to use some functions to convert these measurements to something that the engine can understand.
In general people use a scale, because the engine works in a world of 100x100 meters, so its better to have it as small as possible. The common scale is 30.

Here a simple way to convert pixel to Box2D dimensions:

Create a simple ball

Let's start with the second step, you have to define all properties of the object, if its a ball, it has to have  round shape and be elastic.

So you have to define the body definition, if the object will be static or dynamic  and set the position in the world:

The position might be tricky to understand, but here is a simple solution:
When you want to draw something in a canvas, you draw something from position (X,Y), so if you want to draw something at the top left corner, you will choose (0,0).
So in this thinking you would put new Vec2(0,0) in this case, but this will be WRONG because in Box2D everything works in another way, you have to tell the position of the centre of the object.

If you object is  10x10 and you want to position to the top left corner, you position will be (5,5).

To continue the body creation, you have to tell the world that this object exists in the engine, so you have to call the method "createBody"

Then tell at the body, what kind of shape your object will be:

In this case we create a CircleShape, because its a ball. In other case you have to use PolygonShape to create a special shape or a simple square.

Another tricky to understand how to create a PolygonShape for a square is the follow:

You have to use "setAsBox", and the dimension that you put inside must to be half of the width and half of the height, because the BodyDefinition has the position of the centre of the object.

Last thing to complete the creation of the ball in the world is the Fixture Definition:

You can change the density, that is the weight of the object, the friction between objects and the restitution that is the elasticity. Play with some values and you will find out what better works with your project.


Joints are parts that connects two body parts, there are different ones.
There is a joint to simulate a rope connection, an elastic connection, a rotation connection, etc...
You can find more information around in the web, it is very simple to use them but tricky to find the right values or anchor points.

Friday, 4 October 2013

Concatenate a String with a Float

I came up with a very simple and difficult problem with my little Arduino, I couldn't concat a string and a float number, after a few hours on Google I found out the solution:

Helpful link:

Lightwave RF Arduino

I had some spare time ( and money ) and I decided to make my little flat a beginning of automate house.
I did some research how to control my lights from an Arduino, even knowing that I could replace the normal switch with a relay. This wasnt enough because I wanted to keep the manual system and to be controlled from an Arduino, so after few hours I came up with LightWaveRF system that has been "hacked" and it is possible to be controlled from an Arduino.

Their products are working with a simple RF protocol at 434 mhz, and they give you the possibility to control it from your smartphone, remote controller and a webpage.
Some people understood how the protocol works and they just write a simple library to interact with Arduino.
There are various adapter: Light switch, Power socket, Light, Sensor PIR, etc.. and if you get a remote controller and a RF receiver, you can reproduce the same signal from your code.

I was using this library to find out what ID and what kind of signals the remote controller was sending to the light switch. After a few minutes on the result and few website, I understood how to reproduce the same behaviour with a single click.
I suggest to use the Decode example to get your ID and to understand what kind of signal your are sending. If you have a multi channels remote, you have to be careful on which command and which channel.

Here an example to turn on my light:

Here a little description what message it sends:

When you got the ID, Channel and which command to send, you re ready to send your first message to your device.
Use the SEND example as based and create your custom message, replace it on the turnOn function and then compile. When the terminal is ready, you should be able to send "1" and whatever you decided to do, it will do it.
Be careful! If something is not working, just try with simple command like ON and OFF, after that move on dimming and mood ones.