Adventures with Arduino part 1

    01 January 2015

    Few months ago I got myself an Arduino Uno board from Adafruit. I have had couple use cases I was going to try to use them for in order of importance

    1. Water leak detection e.g. put a sensor in crawl space or attic for early detection of water leaks
    2. Garage door open/close state - find out if the garage door has been left open
    3. Humidity and temperature monitoring around the house

    One nice thing about Arduino is that some of the small boards are really inexpensive. For example Arduino Nano board or Adafruit Trinket can run you anywhere between $3.50-$7.

    After receiving the board and playing with some of the basic examples I figured it was time to resolve how to push sensor data to a central location. Some of the options I discovered were as follows

    1. XBee modules. Approx cost per module ~ $20
    2. Bluetooth - Approx cost per module $7
    3. 315/433 Mhz remote control - Approx cost per module ~ $1
    4. Nordic Semiconductor nRF24L01+ modules - Approx cost per module ~ $1

    XBee and Bluetooth are really nice options however I considered them too overpriced for this particular use case so I went ahead and bought a pair of 433 Mhz and nRF24L01+ modules.

    315/433MHz modules

    First thing I tried was 433 MHz modules. They were easy to wire and configure since e.g. transmitter has only 3 pins and receiver 4 pins (although you only use 3) and using the rc-switch project libraries I was able to communicate between my Arduino and a Raspberry Pi. The drawback is that it’s fairly low bandwidth and payload size maxes out at 24 bit so pretty limiting.

    That said an interesting side benefit of these modules is that large number of remote controlled power outlets out there use either 315/433 Mhz bands e.g. Etekcity outlets. If you have a remote controlled device in your house you can look up what frequency it uses with FCC ID search. There is also the 303 Mhz frequency however I have not been able to find the modules for it yet.

    As a result of this tinkering I know am able to turn outlets around my house with my phone :-).

    Nordic Semiconductor nRF24L01+

    These are a lot more tricky to get going as they have total of 8 pins with one unused and it is easy to mis-wire things. It took me a lot of trying to get these going however I finally got it going and was able to pass data between the Arduino and a Raspberry Pi. Max payload on this is 32 bytes which should be enough for shipping out metric data and you can ship them at a pretty rapid rate. Libraries I ended up using were these

    RF24 library and NRF24PiHub

    Do note that these may not work with Adafruit’s Trinket.

    Next steps

    I have ordered some temperature and humidity sensors, water sensors and some Arduino Nanos and will be wiring it up :-), shiping metrics to Ganglia and alerting on it.


    Bosnia and Serbia Floods aid

    18 May 2014

    As you may have heard Bosnia, Serbia and in smaller part Croatia are facing worst floods ever in recorded history

    http://www.bbc.com/news/world-africa-27439139

    There are a number of ways to donate. Here are few that are being posted on Twitter from

    https://twitter.com/ncerovac/status/467785693427941376/photo/1

    https://twitter.com/DJ_Miss_AKA/status/468024802272616448

    I have not seen an easy way on those sites for people in the US to make donation. However Croatian Red Cross allows on-line donations with proceeds being transferred to Bosnian and Serbian Red Cross. You can read about it here

    http://www.hck.hr/en/page/emergency-appeal-for-flood-affected-people-in-bosnia-and-herzegovina-and-serbia-414

    The only drawback is donation page is in Croatian :-( so here is a quick guide.

    https://secure.webteh.hr/donate/79

    On this page you will need to pick who you are donating to

    • Pomoć za poplavljena područja u Bosni i Hercegovini - Aid for flooded regions of Bosnia

    • Pomoć za poplavljena područja u Srbiji - Aid for flooded regions of Serbia

    • Pomoć za poplavljena područja u Hrvatskoj - Aid for flooded regions of Croatia

    Pick the amount and currency e.g. 25 USD.

    Click on Autorizacija Kreditne kartice. Next screen will include your confirmation as well as currency exchange into Croatian Kunas e.g.

    10 CAD (50.90 KN)

    1 Canadian Dollar is about 5 Kunas so don’t despair :-).

    Payment info will look like this

    hck_donacija

    • Ime is name

    • Prezime Last Name

    • Adresa - Address

    • Grad - City

    • Poštanski Broj - Postal Code

    • Država - Country

    • Telefonski broj - telephone number

    Click Doniraj and that should be it.


    Building your own binary packages for Cumulus Linux (PowerPC)

    07 February 2014

    Cumulus Networks  is a new entrant in the network gear space. What separates them from other players is that they are not selling hardware but their own network focused Linux distribution called Cumulus Linux. Basically you buy a switch from one of their resellers or ODMs then pay Cumulus a yearly support license. There are a number of interesting things you can do like run your own code on the switch as well as use common Linux commands to configure the switch e.g. brctl, ports are exposed as Linux network interfaces etc.

    One of the first things we ended up doing is installing Ganglia agent so that we can monitor what’s going on on the switch. Cumulus switch we had was running a PowerPC based control plane so that made things a bit tricky since we couldn’t use any of the amd64 built packages. One way to build PowerPC packages would be to get an old PowerPC based Mac and install Linux on it. Unfortunately that seemed like a lot of work and overkill. I realized we could just use Qemu which is an Open Source machine emulator so I could run PowerPC machine on my own laptop :-). Quickest way to get up and running is as follows.

    On Ubuntu you will need to install following packages

    apt-get install qemu-system-ppc openbios-ppc qemu-utils

    Warning: Under at least Ubuntu 13.10 openbios-ppc doesn’t seem to work well. If you get a blank yellow screen after you start the install you will need to get openbios from other places e.g. https://github.com/qemu/qemu/tree/master/pc-bios

    Once you get those you will need to download Debian Squeeze for PowerPC. You will need to download

    • vmlinux

    • initrd.gz

    from

    http://ftp.debian.org/debian/dists/squeeze/main/installer-powerpc/current/images/powerpc64/netboot/

    as well as the netboot image e.g.

    http://cdimage.debian.org/cdimage/archive/6.0.8/powerpc/iso-cd/debian-6.0.8-powerpc-netinst.iso

    Reason why you need initrd.gz and vmlinux is that if you try to do an install straight off the CD-ROM your install will hang here

    Power PC install QEMU

    Once you have those pieces initiate the install with

    qemu-img create -f qcow2 squeeze-powerpc.img 10G
    sudo qemu-system-ppc -m 256 -kernel vmlinux \
     -cdrom debian-6.0.8-powerpc-netinst.iso \
              -initrd initrd.gz -hda squeeze-powerpc.img -boot d -append "root=/dev/ram" \
              -net nic,macaddr=00:16:3e:00:00:02 -net tap
    

    Now follow the installation process as you would if you were installing Debian or Ubuntu from scratch. When you are done with the install shut down the emulator. Now to invoke your PowerPC emulator execute

    sudo qemu-system-ppc -m 256 -hda squeeze-powerpc.img  \
               -net nic,macaddr=00:16:3e:00:00:02 -net tap
    

    Congratulations you are done. What you end up with is this

    root@debian:~# cat /proc/cpuinfo 
    processor    : 0
    cpu        : 740/750
    temperature     : 62-64 C (uncalibrated)
    revision    : 3.1 (pvr 0008 0301)
    bogomips    : 33.14
    timebase    : 16570400
    platform    : PowerMac
    model        : Power Macintosh
    machine        : Power Macintosh
    motherboard    : AAPL,PowerMac G3 MacRISC
    detected as    : 49 (PowerMac G3 (Silk))
    pmac flags    : 00000000
    pmac-generation    : OldWorld
    Memory        : 256 MB
    

    Running Arista vEOS under Linux KVM

    10 January 2014

    At my current job we run a lot of Arista gear. They are great little boxes. You can also run Ganglia on them :-) since they are basically Fedora Core 14 OS with some Arista proprietary sauce. You can find Arista specific Ganglia gmetric scripts here

    https://github.com/ganglia/gmetric/tree/master/arista

    On occasion I have wanted to test some things and Arista offers VM images you can run on your choice of virtualization. You can find more details here

    https://eos.aristanetworks.com/2011/11/running-eos-in-a-vm/

    I use KVM on my Ubuntu laptop and although booting the imaged worked I could not SSH into vEOS from my laptop. After a bit of testing I discovered that Arista’s document misses a very important option ie.

    -net tap

    So full invocation is really

    kvm -cdrom Aboot-veos-2.0.8.iso -boot d -hda EOS-4.12.3-veos.vmdk -usb -m 1024 \
        -net nic,macaddr=52:54:00:01:02:03,<wbr></wbr>model=e1000 \
        -net nic,macaddr=52:54:00:01:02:04,<wbr></wbr>model=e1000 \
        -net nic,macaddr=52:54:00:01:02:05,<wbr></wbr>model=e1000 \
        -net nic,macaddr=52:54:00:01:02:06,<wbr></wbr>model=e1000 \
        -net nic,macaddr=52:54:00:01:02:07,<wbr></wbr>model=e1000 \
        -net tap
    

    After that I was able to configure vlan 1 to e.g. 192.168.122.2

    Log in into the console you just fired up and type

    localhost#configure 
    localhost(config)#interface vlan 1
    localhost(config-if-Vl1)#ip address 192.168.122.2/24
    localhost(config)#username admin secret 0 secret
    

    You also want to set the password e.g. here I set it to secret and voila you can now SSH into 192.168.122.2. If you have too many SSH private keys loaded log in may not work so turn of public key authentication e.g.

    ssh -o PubkeyAuthentication=no admin@192.168.122.2
    

    Only note may be that if you just install libvirt /etc/qemu-ifup doesn’t quite work since it determines which bridge to connect to based on the default route To “fix” that add

    switch="virbr0"
    

    Just above this section in /etc/qemu-ifup

    # only add the interface to default-route bridge if we
    # have such interface (with default route) and if that
    # only add the interface to default-route bridge if we
    # have such interface (with default route) and if that
    # interface is actually a bridge.
    # It is possible to have several default routes too
    for br in $switch; do
        if [ -d /sys/class/net/$br/bridge/. ]; then
            if [ -n "$ip" ]; then
              ip link set "$1" master "$br"
            else
              brctl addif $br "$1"
            fi
            exit    # exit with status of the previous command
        fi
    done
    

    Bring your own device cell service / VoIP

    25 December 2012

    Recently I had to get my own mobile phone service and decided to forgo the standard post-paid cell service and go prepaid. Decision was largely cost based since I already had my own GSM phone and planned to buy a Nexus 4. I did quite a bit of research and ended up with Straight Talk service

    https://www.straighttalk.com/

    Straight Talk is a MVNO (Mobile virtual network operator) that leases network capacity from T-Mobile USA and AT&T.  To sign up you either order a SIM from their web site or you can pick up starter package at Walmart. I did the latter option. In the package they provided me with 2 different mini-SIM cards and a micro-SIM card. SIM cards are really T-Mobile and AT&T unbranded SIM cards. Pick the card that is supported by the phone e.g. if it’s a locked phone like AT&T use the AT&T SIM, change some of the phone settings (APN) and off you go. Quality of the signal is the same as if you used T-Mobile or AT&T. I  picked unlimited everything plan for $45/month with a T-Mobile SIM. If you sign up for auto refill they cut it down to $42.50. Drawback is lack of international roaming and iffy customer service ie. hold times can be 30-40 minutes.

    Another option I considered was T-Mobile’s prepaid service called Go Smart which is similarly priced

    https://www.gosmartmobile.com/

    I decided against it since cost was similar but with Straight Talk I have the option to switch to AT&T if I ever find T-Mobile coverage inadequate. That said Go Smart does have a wider array of calling plans so it may still be a good choice.

    While we are at it I can also recommend an inexpensive VoIP service called GalaxyVoice. I use their free-tier which gives you up to 60 minutes of outgoing calls a month and all I pay is for taxes and 911 compliance ~ $3/month. You just need to pay the signup cost of $25 and get your own SIP device.

    An extra bonus is that their web site is fairly unsophisticated and easy to automate for certain things :-) e.g. forwarding my home phone calls to my cell phone