2012/04/29

Tonido Plug² SATA Harddrive spindown



I recently purchased a Tondido Plug² Computer. Unfortunately, the ARM / linux-based device has some rough edges. But, as this plug device comes with command line access, you can easily tweak it.

One problem is that the embedded SATA drive is continuously spinning. This is particularly annoying as the device advertises itself as a "go green" solution. The following community forum topic explains how to solve this issue with a few commands by using the Debian  laptop-mode-tools package:
http://www.tonido.com/forum/viewtopic.php?f=32&t=4219. It contains updates and more details and also has info on tweaking SSD drives. Other references:http://samwel.tk/laptop_mode/faq.

Warning: Although the solution below works on a default setup booting from flash, it is not supported nor recommended and it might brick your device! First install a boot partition on your SATA HD and experiment from there. 
More info: 
The steps that did the trick for me:
  1. SSH into your plug.
  2. apt-get interaction:
    • Update your repositories and upgrade your packages.
      apt-get update 
      apt-get upgrade 
      
    • Install laptop-mode-tools.
      apt-get install laptop-mode-tools 
      
  3. Modify the config file:
    • Open the config file in nano.
      nano /etc/laptop-mode/laptop-mode.conf 
      
    • Change the following settings.
      • Enable Laptop Tools
        ENABLE_LAPTOP_MODE_TOOLS=1 
        ENABLE_LAPTOP_MODE_ON_AC=1 
        ENABLE_AUTO_MODULES=1 
        
      • Set Drive Spin down Time In Seconds
        LM_AC_HD_IDLE_TIMEOUT_SECONDS=600 
        NOLM_HD_IDLE_TIMEOUT_SECONDS=600 
        
    • Save and close the file: CTRL-o, ENTER, CTRL-x
  4. Restart the laptop tools
    /etc/init.d/laptop-mode restart 
    
    
    


If it causes you problems, stop it and remove it:
/etc/init.d/laptop-mode stop 
apt-get remove  laptop-mode-tools 

2012/04/24

Bluetooth Connection of the Sunny Boy Inverter on Ubuntu


My photovoltaic panels are connected to the power grid through a Sunny Boy SB5000TL inverter. Although, this inverter comes out-of-the-box with bluetooth connectivity, this feature is only supported on Windows. Luckily, there exists a free tool that reads out the generation data on Linux: sma-bluetooth. This involves a few manual commands detailed in http://code.google.com/p/sma-bluetooth/wiki/ubuntu_compile_guide. The guide didn't work a 100% for me, so the next section details the steps I followed.

The code can be downloaded from http://code.google.com/p/sma-bluetooth.

In the terminal ( Ctl + Alt + T):
  • sudo apt-get install mysql-server mysql-client mysql-query-browser libmysqlclient-dev (the libmysqlclient-dev package is needed for compilation)
  • sudo apt-get install bluez libbluetooth-dev curl libcurl3 libcurl4-nss-dev
  • create a new Makefile in the sma-bluetooth-0.17 directory:
    gedit Makefile 
    
    Contents (make sure you use a tab, not spaces, in front of the gcc commands):
    smatool: smatool.o 
     
            gcc smatool.o -L/usr/lib -lmysqlclient -lbluetooth -lcurl -lm -o smatool  
     
    smatool.o: smatool.c 
     
            gcc -c smatool.c 
     
    
  • make
Now prepare the Bluetooth connection:
  • my bluetooth USB dongle is automatically up & read on ubuntu 11.10:
    $ lsusb | grep -i bluetooth 
    Bus 002 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) 
    
  • hcitool scan
  • workaround if hcitool scan gives no result: (seehttps://help.ubuntu.com/community/BluetoothSetup#Setup_Devices for details)
    sudo hciconfig hci0 inqmode 0 
    
  • cp smatool.conf.new smatool.conf
  • gedit smatool.conf
    • modify the lines as explained in the comments
    • you can optionally upload your data to the excellent pvoutput.org service - see http://pvoutput.org/account.jsp for details:
      • get the API key
      • configure your unique SID
    • use the bluetooth password for 'normal' usage (by default 0000 in some devices). I had trouble with the different password reserved for maintenance.
If you use mysql:
  • install the database / create the tables (this requires a user with admin rights):
    ./smatool --INSTALL 
    
  • an empty password is not supported
Running:
  • ./smatool
  • debug & verbose can help identifying errors:
    ./smatool -d -v 
    
  • ./smatool -? lists out all options available
My pv-output: http://pvoutput.org/list.jsp?userid=9300

Next steps:
  • schedule the smatool in cron
  • replace mysql with sqlite for easier is
  • deploy the config on a plug computer