Sunday 30 November 2014

IoTogether Hackaton 2014: IoT loving with the LoveTotem


 IoTogether was a competition event for 7-8 co-located teams in Trento and Barcelona. Remote teams will be composed by participants from both sides who will be asked to interact via Future Internet videoconferencing tool provided by the SPECIFI project.

Sponsors: SPECIFI, COMPOSE and VISIONAIR.
Partnership: CREATE-NET, MuSe, BCNLab, I2CAT and the City of Barcelona.
***

The idea was as freaky as it could get, is a lot funnier to start explaining our team concept from the prototyping stage up to the final application...

At the Barcelona location we implemented a force sensor with a 3-axis accelerometer integrated to a wool glove, to measure both force of impact, movement and acceleration, displayer over a LED bar for our viewing pleasure, hooked up with a GSR (Galvanic Skin Response) sensor to measure the "arousal" level of its wearer.  To interface the sensors we used an Arduino bundled with a WiFI module, to send the sensed data over Glue.Things to the Trento location.

We did also manage to send data to Ubidots and The Things.IO.


At Trento side there was a dildo-shaped lamp (yes, a dildo), changing colors according to the data received from the glove by selectively turning RGB LEDs, using force, acceleration, arousal and muscular response data... well, you know, leave it to the Italians to sex-it up a Hackaton :)

One of the main challenge of the event was actually to set up everything from each side while talking to each group, unfortunately the co-location resources went bad and we ended up talking over Skype, and emulating both input and outputs isolated, but at the end we were glad it worked out.




The official name of the project was "The LoveTotem", to be honest the horny lamp would be a better name, but regardeless the name of the actual use case, what was interesting about the project, and the event, was to put a bunch of people together, with the right tools and attitude, and create something, whatever, as long as it works, you cannot save the world with a killer app in 4 hours, but building "anything" is the first step to get more stuff rolling... who knows? everything can be reused and interpreted in many different ways, with a different angle this would also make a good physical rehabilitation tool, a social game to take introverts into social engaging with physycal interaction with others, nnevertheless, I loved the lamp challenge... it was so out of my field that it was cool to try to design a matching application to feed love to the Totem.

 This was the official description of the project:
"LoveTotem": Suppose you are too far from your sweetheart and you want to know how really he/she feels, or share emotions without talk! Your partner can wear the LoveSensors: when you'll turn on your LoveTotem, you'll see it take strong/hot color if your partner is excited, or soft blue light if is relaxed. Love Totem uses an open hardware platform (Arduno Yun) and human sensors like (Muscle sensor,Temperature/Humidity, GSR) in order to track the state of a person and transmits these data through dedicated API to a cloud platform (GlueThings). On the other side, another Love Totem will retrieve these data, representing them with a mix of some colored leds. Leds are placed in a lamp, which we have designed and made using a laser cutter and a 3d printer.
At the end our team was one of the two winning teams of the event, with a caveat: the team members posted at SPECIFI site is wrong, Barcelona's team members are swapped with other team (Aitor is actually a colleague of work, but at a different group), the correct line-up is the following: Andrés Hernández Casaus, Hector Esteller, Pablo Carbajal and yours truly.

We got plenty of goodies, including Spark Cores for each of the members, sensors (I got a soil moisture sensor, the GSR and a couple of buzzers), along with a Shield-Shield.

Here is the full list of the developed projects:
  1. "SeeTy": a urban garden community that merges gardens around the world.
  2. "LoveTotem": a lamp to express remote feelings for lovers.
  3. "WineCheck": check wine bottles temperatures on your smartphone.
  4. "Remote Interactive House Control": remote management of houses temperature & humidity.
  5. "EmotionalBag": a bag monitoring and displaying its user's emotional status.
  6. "SmartGlove": a glove that senses the heart beat and the level of stress.
  7. "BluePresence": a smartwatch managing smartlights with power consumption profiling.
  8. "CarFinder": cars tracking on the web with GPS sensor.
If you ever stumble upon a Hackaton organized by the same people behind IoTogether, be sure to attend, besides the good folks assisting the event, and the electronic goodies, the food was sincerely amazing, no cold pizzas and warm beers, a full-catered event with food coming and going at the pace of cold beer and hot coffee, just what a maker needs.

Saturday 29 November 2014

Clean-up unused Linux Kernels in Ubuntu

Original article by Mark McBride

At development I tend to keep more than one Virtual Machine sandboxes, normally Unix-based running on a Windows host (because of reasons), so from time to time I have to clean-up the garbage and maintain the user-disk cuota as low as possible to avoid eating up the VM drive.

The original author makes a pretty good explaination on the command sintaxis (basically list the kernels and strip-down recursively to usable name strings to uninstall them), so I'm just going to copy here the actual command:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge

Only one caveat: I removed the -y argument from the apt-get purge command to avoid eliminating automatically, instead you will get prompted to purge the listed kernels.  To check the used disk space:

$ du -h /boot --max-depth=0

Network Printer with CUPS in a Raspberry Pi

Short story: I was tired of having to skpe or mail files to the secretary for her to print it in my behalf,  and working in a highly tech-oriented company, it was embarrasing, so the Raspberry Pi came to the rescue once again...

Sources:

Bartbania
Libre Geek

Install CUPS:

sudo apt-get install avahi-daemon cups cups-pdf python-cups
Once installed (it will take a while) add our user to the lpadmin group, in this case I'm assuming the default user "pi".

sudo usermod -a -G lpadmin pi

Install Samba and dependencies to make the Printer accessible over the network:

sudo apt-get install samba libncurses5-dev bridge-utils

Then edit the configuration file to enable network printing and sharing the printer, below are the most interesting lines in my configuration file:

pi@raspberrypi ~ $ sudo cat /etc/cups/cupsd.conf

# Allow remote access
Port 631

# Enable printer sharing and shared printers.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseRemoteProtocols CUPS dnssd
BrowseAddress 192.168.1.255
BrowseLocalProtocols CUPS dnssd
DefaultAuthType Basic
WebInterface Yes
ServerName 192.168.1.28

<Location />
 Order Deny,Allow
 Deny From All
 Allow From 127.0.0.1
 Allow From 192.168.1.*
</Location>

<Location /admin>
  Order allow,deny
  Allow @Local
</Location>

<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @Local
</Location>

Then either reboot the Raspberry Pi or restart CUPS:

sudo service cups restart

And that should be all, next we need to add the printer connected to the Raspberry Pi over the USB port, the process should be straight-forward.  The CUPS driver provides a webserver accessible over the socket specified by the RPi's IP and Port assigned in the cupsd.conf file.



Install Java JDK in Ubuntu

I recently had to install Java to be able to run Cooja properly, as surely I'm going to need this at any given moment when reinstalling, testing elsewhere, etc, I'm keeping the instructions here.

Taken from Ubuntu Guia.

Install Java Oracle version 8:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Check the current version

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Server VM (build 25.25-b02, mixed mode)


You can select between any installed Java version at any given time

$ sudo /usr/sbin/update-alternatives --config java

There are 4 choices for the alternative java
  Selection    Path                                           Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java         1063      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java         1063      manual mode
  3            /usr/lib/jvm/jdk1.8.0/bin/java                  1         manual mode
  4            /usr/lib/jvm/jre1.7.0/jre1.7.0_51/bin/java      0         manual mode
Press enter to keep the current choice[*], or type selection number:

Senzations 2014 IoT school and City Karma


I recently was lucky enough to attend Technical track of Senzations 2014 Summer School hosted in Biograd na Moru, Croatia.  It was an incredible experience traveling to Croatia, without taking merits to the event itself, one of the things I enjoyed the most was the City experience, and of course the Boat trip to the National Park Kornati.

The lecturers were great and gave plenty of insights on both Wireless Sensor Networks, M2M and IoT,and shared their current work on the field, most of the slides are available at the Program website, but I though about sharing some of the presentation links below:


As Intel was supporting the event, there were plenty of Intel Galileo development kits to use to prototype our very own IoT-driven applications, the core of the event: divide into teams and create an IoT application from the prototype to the business plan.  Here's mine with plenty of Grove sensors from SeeedStudio attached in the prototype phase.



Our team, the DreamTeam, scored big time and was one of the winners of the 4-days Hackaton with our project: City Karma, which had its own dorky video as well! The main idea was to target the lack of social awareness in cities, and City Karma was born:

A big shout to the DreamTeam: Berta Jadro, Adela Sockovic, Bruno Dunaj, Nikola Paic, Ivan Jokic, Stevan Jokic




The application was implemented using a Python script running in the Galileo Board, monitoring 3 types of events: loud scream for help, emergency button and assistance button, then posting a Twitter message indicating the location of the event, type and date, with a randomly generated Karma Code.  A person following the #CityKarma hashtag or the CityKarma twitter account then could see the new event, and could reply the Twitter message to inform the person in distress that help its on its way.

A mobile application would also allow to flash this alert to the screen, by monitoring the City Karma feed and using the user location to see if the user is nearby.


Then the helping hand would get Karma Points, plenty useful to show off and maybe get a free expresso or a discount in affiliated partners, maybe a nice tax reduction? what would it take for you to go out of your way and help a stranger?  Could you ignore a person nearby you asking for help? Let's hope the people frequenting this blog are natural Karma sponges, if not remember this:
When you carry out acts of kindness you get a wonderful feeling inside. It is as though something inside your body responds and says, yes, this is how I ought to feel. - Harold Kushner
The application was powered by MQTT over WiFI/GPRS, using a local Node-RED server to receive the help message, parse and post it to Twitter, and also to track the Twitter feed for responses, posting an update on the MQTT topic to notify the person in distress that his help request has been answered, by means of a LED notification.



If you want to take a peep at the code it is uploaded in my Github, keep in mind this is not production-ready code and was done only as a proof-of-concept.

To wrap this up, I'm really looking forward to next year event, I hope I can assist as both a participant or a lecturer, it was an incredible gathering of talent and knowledge, and a fun crowd to hang out.  A big thanks to Srdjan Krco (DunavNET) for organizing the event, Alex Gluhak (Intel Labs) for rolling out the hackaton and providing the equipment and tech support, and Charalampos Doukas/Jan Pernecky for the memories.



The presentation videos are available at Senzations YouTube channel

Setting up CSS Uniflash to program the CC2538DK in Contiki

When I first started trying-out setting Uniflash to work with the CC2538DK and Contiki, I stumbled upon this warning:

I first tried Uniflash v3.1.0.00026 with no luck, so I downgraded to version v2.2.00016, you might want to skip the next section as it mostly describes the pain and futility of my first attempts with the latest Uniflash version, mostly kept as a warning of the severed-head-on-a-pike type for others encountering the same errors, and maybe lurking a kind soul who has fought this monster and prevailed, willing to share the solution.

At the end the solution was to find the right combinations of magic ingredients:

The right CCXML recipe:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations XML_version="1.2" id="configurations_0">
    <configuration XML_version="1.2" id="configuration_0">
        <instance XML_version="1.2" desc="Texas Instruments XDS100v3 USB Emulator" href="connections/TIXDS100v3_Dot7_Connection.xml" id="Texas Instruments XDS100v3 USB Emulator" xml="TIXDS100v3_Dot7_Connection.xml" xmlpath="connections"/>
        <connection XML_version="1.2" id="Texas Instruments XDS100v3 USB Emulator">
            <instance XML_version="1.2" href="drivers/tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>
            <instance XML_version="1.2" href="drivers/tixds100v2cs_dap.xml" id="drivers" xml="tixds100v2cs_dap.xml" xmlpath="drivers"/>
            <instance XML_version="1.2" href="drivers/tixds100v2cortexM.xml" id="drivers" xml="tixds100v2cortexM.xml" xmlpath="drivers"/>
            <property Type="choicelist" Value="4" id="The JTAG nTRST Boot-Mode"/>
            <property Type="choicelist" Value="4" id="The Power-On-Reset Boot-Mode"/>
            <property Type="choicelist" Value="2" id="The Converter Usage"/>
            <platform XML_version="1.2" id="platform_0">
                <instance XML_version="1.2" desc="CC2538SF53" href="devices/cc2538sf53.xml" id="CC2538SF53" xml="cc2538sf53.xml" xmlpath="devices"/>
            </platform>
        </connection>
    </configuration>
</configurations>

The right CSS Uniflash version (mine was 3.1.0.00026).

And finally the right flashing command:

contiki/examples/cc2538dk$ sudo /opt/ti/uniflash.sh -ccxml /opt/ti/CC2538SF53.ccxml -operation Erase -program cc2538-demo.elf

Then the magic starts:

***** Texas Instruments Universal Flash Programmer *****
<START: 19:19:29 GMT+0100 (CET)>
> Configuring the Flash Programmer with the given configuration ...
> Flash Manager is configured for the following part: CC2538SF53
> Connecting to the target for Flash operations ... 
> Connected.
> Performing operation: Erase
> Completed current operation.
> Loading Program: cc2538-demo.elf
> Finish Loading.
> Disconnecting from target. 
Cortex_M3_0: GEL Output: CPU Reset.
<END: 19:19:56 GMT+0100 (CET)>
<Operation Time: 19.341s>
<Total Time: 27.662s>

This is not my preferred way to flash the CC2538DK, as now with the bootloader backdoor unlocked it is possible to program the devices over UART using the built-in bootloader BSL script, but there may be cases in which you accidentaly flash an image with the backdoor unlocked, and need to enable this again.

Create a GIT sandbox server for ad-hoc work

Some months ago I was working out of the office at a client's location and I had to move my development environment there, but due to a tight and restrictive IT policy, me a some colleagues were unable to set up our current GIT repository and share our work (the proposed zip-share-meld was not tempting at all...).  The easiest solution would be to host the repository on my laptop, but then again, setting up our GIT repo in a Raspberry Pi is more fun, specially when you have a video projector available at the office, and a RetroPie running with 2 extra game controllers.

Create a fresh bare repository on the server:
git init --bare newrepo.git
Add it as a remote in our local repo:
git remote add newrepo  git://user@server.com/newrepo.git
Push all branches:
git push --all newrepo