Search This Blog

Wednesday, 25 July 2018

Building a low energy media server with Olimex Lime2

Objective : replace my current server (loud, HW RAID0, 2 * 1Tb discs, tower case), with something that is fault tolerant, silent, and consumes a bare minimum of power.

Requirements

  • redundant storage for all my music
  • fast network connection
  • low power consumption

Solution

So, let's do this!

  • Get the Lime2, install Debian on SD Card, connect to ethernet (I'm using Ethernet over power line)
  • Connect via ssh with uname root, password olimex
  • Hey - there it is!  Let's apt-get update and upgrade.
  • So I'll switch it off, and connect the HDD using SATA cable.  The power for the SATA is next to the SATA connector on the Lime2.
  • Now we need to format it.
root@A20-OLinuXino:/dev# fdisk -l

Disk /dev/nand: 7.4 GiB, 7969177600 bytes, 15564800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/nand1         63 15550919 15550857  7.4G 83 Linux

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mmcblk0: 7.4 GiB, 7969177600 bytes, 15564800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6f20736b

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       2048    34814    32767   16M 83 Linux
/dev/mmcblk0p2      34816 15564799 15529984  7.4G 83 Linux

We need to format the disk and create a file system,  let's go for ext4

root@A20-OLinuXino:/dev# fdisk sda

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x87e5db31.

Command (m for help): c
DOS Compatibility flag is set (DEPRECATED!)

Command (m for help): c       
DOS Compatibility flag is not set

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1953525167, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-1953525167, default 1953525167): 

Created a new partition 1 of type 'Linux' and of size 931.5 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Let's create the file system

root@A20-OLinuXino:/dev# mkfs -t ext4 /dev/sda1
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done                            
Creating filesystem with 244190390 4k blocks and 61054976 inodes
Filesystem UUID: ff9d77c0-dd69-4925-9c6c-36c818ee2578
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

Wednesday, 17 February 2016

Green spaces de-stress us

People have long thought that there is a health value of exposure to nature beyond the simple benefit of exercise and lowered pollution.

"Controlling for individual and regional covariates, we found that, on average, individuals have both lower mental distress and higher well-being when living in urban areas with more green space." [1]


"Quality of streetscape greenery in neighbourhoods is especially related to health.  The greenery–health relationship is strongly mediated by stress and social cohesion." [2]


"This research has demonstrated that mere exposure to views of nature can improve people's health and well-being by providing restoration from stress and mental fatigue. Moreover, this research has shown that views of nature can improve feelings of neighborhood safety and even lead to decreases in aggression and crime rates" [3]


1. White, Mathew P., et al. "Would you be happier living in a greener urban area? A fixed-effects analysis of panel data." Psychological science (2013): 0956797612464659.
2.  Sjerp de Vries, Sonja M.E. van Dillen, Peter P. Groenewegen, Peter Spreeuwenberg, Streetscape greenery and health: Stress, social cohesion and physical activity as mediators, Social Science & Medicine, Volume 94, October 2013, Pages 26-33, ISSN 0277-9536
3.  Groenewegen, Peter P et al. “Vitamin G: Effects of Green Space on Health, Well-Being, and Social Safety.” BMC Public Health 6 (2006): 149. PMC. Web. 17 Feb. 2016


x

Saturday, 13 February 2016

Enistic home energy switches

The controller unit is wired to the router.

If you look at the list of wired devices attached to the router, you can see the controller.  It's MAC address starts with 00:50:C2.

In my case, the address is 192.168.0.9

What's listening there?

matt@Linux2740p:$ sudo nmap -sU -p 53004 192.168.0.9
[sudo] password for matt: 

Starting Nmap 6.40 ( http://nmap.org ) at 2016-02-13 10:05 GMT
Nmap scan report for 192.168.0.9
Host is up (0.0047s latency).
PORT      STATE         SERVICE
53004/udp open|filtered unknown
MAC Address: 00:50:C2:F4:C0:8C (Ieee Registration Authority  - Please see IAB Public Listing for More Information.)

Nmap done: 1 IP address (1 host up) scanned in 0.53 seconds

matt@Linux2740p:$ sudo nmap -sT 192.168.0.9

Starting Nmap 6.40 ( http://nmap.org ) at 2016-02-13 10:05 GMT
Nmap scan report for 192.168.0.9
Host is up (0.0049s latency).
Not shown: 999 filtered ports
PORT   STATE SERVICE
80/tcp open  http
MAC Address: 00:50:C2:F4:C0:8C (Ieee Registration Authority  - Please see IAB Public Listing for More Information.)

Nmap done: 1 IP address (1 host up) scanned in 7.70 seconds

Ah!  The controller is listening on UDP as we expected.  It also seems to have a TCP service on port 80!

wget returns an index.html file - let's look at the IP address in a web browser.

Interestingly, we have a web interface which I didn't know existed.  It allows me to switch the light on or off from the interface, so I know it's working.  Now to debug the UDP broadcast.

Possibilities;

1.  It's not listening / acting upon UDP broadcasts in the the way it's supposed to.
2.  I'm not sending UDP packets the way I'm supposed to.

Let's consider the second possibility first.

matt@Linux2740p:~$ sudo tcpdump -i wlan0 udp port 53004 -X
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:53:25.705798 IP Linux2740p.local.55106 > 192.168.0.9.53004: UDP, length 33
0x0000:  4500 003d 11c0 4000 4011 a790 c0a8 0006  E..=..@.@.......
0x0010:  c0a8 0009 d742 cf0c 0029 4da3 3030 3530  .....B...)M.0050
0x0020:  4332 4634 4330 3843 2c31 2c30 3030 4436  C2F4C08C,1,000D6
0x0030:  4630 3030 3233 3833 3045 383b 0a         F00023830E8;.

09:54:50.059829 IP Linux2740p.local.45243 > 255.255.255.255.53004: UDP, length 32
0x0000:  4500 003c b5e5 4000 4011 c41d c0a8 0006  E..<..@.@.......
0x0010:  ffff ffff b0bb cf0c 0028 c352 4646 4646  .........(.RFFFF
0x0020:  4646 4646 4646 4646 2c31 2c30 3030 6436  FFFFFFFF,1,000d6
0x0030:  6630 3030 3233 3833 3065 383b            f00023830e8;

The first case here shows the packets being sent from netcat-openbsd thus;

echo "0050C2F4C08C,1,000D6F00023830E8;" | nc -u 192.168.0.9 53004

The second case is what I get after sending a broadcast from Python.

Wednesday, 22 April 2015

Getting XBee comms up and running between a Raspberry Pi and Linux


  • Useful instruction on configuring XBee without the X-CTU program (Windows).  Make sure that the XBee on both ends is 9600 baud (it should be by default).
  • Set up minicom on the Pi and on the PC.  Make sure that serial port is set up as  9600 baud, 1N8 w. no hardware flow control.  Now typing in one minicom window will echo in the other.  Hey - we've got wireless comms!
  • Let's do this programmatically.  With minicom up and listening at one end, let's use python on the other.

#!/usr/bin/python
import serial
import time
connection = serial.Serial("/dev/ttyUSB0")
connection.baudrate = 9600
connection.setParity('N')
connection.setByteSize(8)
connection.setStopbits(1)

while True:
  time.sleep(5)
  connection.write("hello\n")


  • Well, that seems to work ok!  

Wednesday, 14 January 2015

Vegetable and Lemon Tagine

Into the slow cooker, add;

  1. Chopped onion, carrot, parsnip, swede, potato, celery.  Nice big pieces - thumb sized.  
  2. Fennel seeds, ground black pepper, garlic, saffron, bay leaves, powdered cinnamon.  A good portion of preserved lemon, cut into large slices.  Today I used a half a normal sized lemon.
  3. A tin of chickpeas with their water, a cup of white cooking wine, a good big glug of olive oil.
And I served it with couscous, to which I added some pickled veg (I'd done it in a raspberry vinegar with star anise), some very finely chopped mint, and some sea buckthorn oil.  And a bit of mushroom stock.

Top Notch!

Friday, 2 January 2015

A really good quiche!


  1. Clean button mushrooms and trim the stalks flush with the cap.  Put them cap side down in a baking dish that's just big enough to hold them, and add some chicken stock, white wine, butter and a glug of light soy sauce.  Bake, covered, at a moderate temperature, until almost cooked; then remove the cover.
  2. Meanwhile gently reduce finely chopped white onion and leeks in a frying pan with some butter.  To loosen it, add some of the juice from the mushrooms and continue cooking until the mixture is light brown and soft.  Then allow to cool
  3. Allow the mushrooms to cook until the juices have reduced, evaporated, and the mushrooms have caramelised on their caps from the butter.  Remove from the oven and allow to cool.
  4. Make a shortcrust case and blind bake.
  5. Make the quiche filling with 3 eggs and a half pint of double cream, seasoned with salt.
  6. Spread the onion and leek paste over the base of the pastry case, arrange the mushrooms, add grated cheddar.
  7. Put it in the oven and use a jug to pour the egg mix in until it reaches the case's rim.
  8. When the filling has started to set, add grated Parmesan and a good grinding of black pepper, then return to the oven until it rises like a souffle. 
  9. Give it long enough to cool before eating that it becomes just warm to the touch, and the risen filling has collapsed back to set and solidify.

The idea here is to concentrate flavour into the mushrooms, and avoid any leakage of moisture from them into the quiche as it cools.


Wednesday, 17 December 2014

Sumatran Slow Cooked Pork

Into a slow cooker, put;

  • some chopped onions
  • some batons of carrot
  • pork shoulder steak
  • about half a pint of water
  • some chicken stock powder
  • three big spoonfuls of coconut milk powder
  • four chopped fresh red chillies
  • a handful of baby tomatoes
  • three bashed lemon grass stalks
  • ten curry leaves
  • two star anise
  • a spoonful of tamarind paste
  • two cloves of finely chopped garlic
  • some halved dried organic apricots
  • a scant handful of raw cashew nuts
  • finely ground roast 
    • black peppercorns 
    • coriander seeds
      • (about a tablespoon of each)
    • four or five cloves
  • a good dose of ground nutmeg or mace
  • a small knob of butter
Slow cook until the meat is tender and add a glug of fish sauce before serving with boiled rice.

Nice!