Tag Archive: Wireless


I’ve seen a number of projects posted using the Amazon Kindle as a “standalone” wireless display and decided it was time to join the party. I picked up a secondhand kindle from eBay for £20 and got cracking.

First step was rooting/jailbreaking the kindle. Pretty easy using the instructions from http://www.mobileread.com/forums/showthread.php?t=88004

I then enabled SSH over WiFi so I didn’t have to mess around booting into diagnostics mode and plugging in to USB every time I wanted to make changes.

Lees-Air:~ leetickett$ ssh root@192.168.0.229

Welcome to Kindle!

#################################################
#  N O T I C E  *  N O T I C E  *  N O T I C E  # 
#################################################
Rootfs is mounted read-only. Invoke mntroot rw to
switch back to a writable rootfs.
#################################################
[root@kindle root]#

The most helpful project to get me started was https://github.com/antimega/kindleframe it uses PhantomJS and pngcrush on a linux server to prepare the image. Handily I already have a Centos server I could easily use for this. I tweaked Chris’ script a little- starting with the shell script called by cron;

#!/bin/sh
cd /var/www/html
phantomjs update.js
convert morning.png -resize 80% screenshot.png
convert morning.png -rotate 90 screenshot.png
pngcrush -c 0 -nofilecheck screenshot.png screenshot_crush.png

Then update.js. I had to tackle a few issues;

  • Cycling between different pages (achieved by dividing the current minute by 5 and choosing a URL based on the remainder)
  • My SSRS report takes 15 seconds to run (using setTimeout(takeScreenShot, 20000); ensures the report has loaded before the screenshot is taken)
  • My SSRS report requires authentication (simply adding page.settings.userName = ‘x’; and page.settings.password = ‘y’;)
var page = require('webpage').create();
var d = new Date();
var n = d.getMinutes();
var url = '';
var px_top = 120;
var px_left = 10;
if (n%5==0)
{
 url = 'http://pvoutput.org/intraday.jsp?id=26603&sid=24317';
}
else if (n%5==2)
{
 url = 'http://pvoutput.org/list.jsp?id=26603&sid=24317';
}
else
{
 url = 'http://192.168.0.188/ReportServer/Pages/ReportViewer.aspx?%2fTEL+Wall+Thing%2fWallDash&rs:Command=Render';
 page.viewportSize = {
  width: 1920,
  height: 1080
 };
 page.settings.userName = 'xxx';
 page.settings.password = 'yyy';
 px_top = 45;
 px_left = 470;
}
page.open(url, function () {
	page.clipRect = { top: px_top, left: px_left, width: 1000, height: 750 }; 
	page.evaluate(function() {
    	document.body.bgColor = 'white';
	});
        var elapsed = 0;
	setTimeout(takeScreenShot, 20000);
	function takeScreenShot() {
            	page.render('screenshot.png');
            	phantom.exit();
    	}
});

Then added the script to cron to run every minute and voila.

Once SSH’ed onto the kindle you’ll need to;

mntroot rw

Then proceed to create the script to grab the image and display it (I also added a few lines to display the battery %age in the bottom corner);

#!/bin/sh
cd /var/tmp/root
rm screenshot_crush.png
eips -c
eips -c
wget http://user:pass@tickett.dyndns.com:777/html/screenshot_crush.png
eips -g screenshot_crush.png
local batt=$(cat /sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity)
batt=${batt%%\%*}
eips 1 39 "$batt"

I’ve setup port forwarding on my firewall to allow traffic through on an obscure port, added a .htpasswd and you’ll notice i’m using an external domain name in my script (i’ve substituted something fictitious)- this allows me to use the display anywhere with an internet connection (literally anywhere as I can tether to my mobile phone).

And here it is;

IMAG1435

IMAG1433

IMAG1432

Here’s how the SSRS report looks in it’s full glory (you can see the area i’ve chosen to display on the kindle);

wall_dash

I’ve chosen not to kill powerd and framework for now, so the kindle will still go to sleep. The next step- if I ever get round to it, will be trying to save power by sleeping or disabling WiFi between updates. I’ve found a little bit of information on how this might be possible (http://www.mobileread.com/forums/showthread.php?t=221497) but still some way off.

I will no doubt add some additional screens (weather forecast, router traffic, network monitoring etc), and it would be nice to have a way of scrolling between images using one of the kindle keys.

Wouldn’t it be great if you could buy something like this off the shelf? Why should we have to hack an existing device? I stumbled across an interesting kickstarter campaign doing exactly this, unfortunately it’s a tiny 2″ screen (https://www.kickstarter.com/projects/914874115/displio-wifi-display-that-tracks-whats-important-t)- maybe one day!

I’m also in the market for a bigger device (i’d love to replace the 21″ monitor which sits on my wall) but for a portable option 9″ or 10″ would probably suffice. A real shame the Kindle DX was discontinued, that would have been perfect (although could do with losing the keyboard). Also looks like a few similar devices; Asus eeeReader DR900, Onyx BOOX M96 (they seem quite expensive and I haven’t looked into whether they have been (or even need to be) rooted, or how easily something similar could be achieved on Android).

Other similar projects worth a look;

http://www.shatteredhaven.com/2012/11/1347365-kindle-weather-display.html
https://randomcoderdude.wordpress.com/2015/01/31/using-the-kindle-as-an-information-display
https://github.com/ufuchs/weather-on-kindle4nt
http://hackaday.com/2015/02/16/wi-fi-connected-e-ink-display/

I became aware of AlertMe a few months back when I was looking for a device (relay plug/socket) which I could use to monitor (energy/power consumption) and control (switch on/off) devices in my home remotely. I have been playing with the Smart Energy products and been pretty happy (though still looking to hook them up to my own home automation solution in the future: https://tickett.wordpress.com/2013/01/12/reverse-engineering-zigbee-communications/).

I then noticed a Smart Heating product appear on their site, promising:

Features

  • Wireless enabled home thermostatic controls unit connects to the AlertMe Hub gateway
  • Transforms hard to manage controls into a simple and intuitive online dashboard or Smart Phone interface
  • Enables remote control of heating/cooling online from anywhere
  • Set and forget it and even manage holiday mode online
  • Adds convenience and enhanced comfort while addressing cost and waste
  • Professional install and set-up

Unfortunately, the product wasn’t listed in their online store. After a quick phone call I was informed it’s only available through British Gas, branded Remote Heating Control. British Gas sell the pack for £199 to existing customer or £229 to new customers- this includes installation which seems reasonable if you’re not comfortable with installing yourself (but a bit of a rip off otherwise- I can’t imagine the units costing any more than £100). Then to be told I’d have to wait 45days for installation wasn’t the best news either!

Never-the-less, I waited and as promised the British Gas engineer came and installed the "hub", "wireless receiver" and "wireless thermostat":

I find it slightly odd that the indicator light on the hub is not used (the AlertMe hub light indicates whether it is online/offline etc):

The wireless thermostat is "meant" to be wall mounted (has no stand) but I can imagine many of you, like me will want to have it freestanding.

I was slightly disappointed that I couldn’t utilise the existing AlertMe hub provided with my Smart Energy pack (I did try, managed to pair the device but the AlertMe dashboard doesn’t have the functionality for me to actually use it):

Notice the lack of a radiator icon present in the British Gas dashboard:

The iPhone app seems to crashes quite a lot, but works eventually and comes in really handy (though you can only turn the heating on/off/auto and adjust the temperature until the next event- as defined in the schedule seen above):

The addition of a "boost" like function would be really hand to just override the temperature for set period of time. And there is currently no access to modify the schedule from the iPhone app at this time.

I haven’t tried to install the app on an iPad yet, although I did try to access the website. Whilst I was able to logon, the site didn’t really work- I could see the schedule but not drag any of the sliders to adjust it.

All in all, it serves it’s purpose really well- definite room for improvement but I’m sure we’ll see that as the product matures (and hopefully tinkerers will provide alternative interfaces etc).

More 433Mhz RF Hacking

I touched on the smoke detectors and door/window sensors I ordered last week: – here are a few more details.

The smoke detectors were £5.75 each – http://www.ebay.co.uk/itm/260990530306#ht_3800wt_1385 (all now sold out, but more available on a separate listing from the same seller – http://stores.ebay.co.uk/greatgougo)
The door/window sensors were £2.50 each – http://www.ebay.co.uk/itm/200759112077?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_500wt_1170 (shop link if/when the listing ends – http://stores.ebay.co.uk/HI-AYY-STORE)

The RF signals broadcast by both devices are not decoded by the RFXCom receiver/transceiver RFXtrx433. This meant finding a way to receive and decode myself.

I already had a few jeenodes (http://jeelabs.com/products/jeenode) knocking about and a 433Mhz plug (http://jeelabs.com/products/ook-433-plug) – there are many alternatives available. I fired up some sketches from the jeelib library (https://github.com/jcw/jeelib/) but wasn’t getting any output when triggering the door/window sensors or the smoke detectors;

I found a discussion on the jeelabs forum (http://forum.jeelabs.net/node/87) which led me to an application called ProtocolAnalyzer (http://wiki.nethome.nu/doku.php/analyzer/start). ProtocolAnalyzer describes a real simple circuit design which brings the RF signal voltage down to a safe voltage to pump into the microphone/line-in port:

I didn’t even have the right components so I improvised:

I only had a 4K7 variable resistor rather than fixed, and I think those fixed resistors are about 370 ohm so I doubled up. I didn’t have any capacitors, so I’ve omitted for the time being but that might be the reason I’m getting slightly inconsistent results as you will see later.

I fired up ProtocolAnalyzer and immediately started to see data coming in (without activating the sensors)- this suggested my CurrentCost devices and such were probably being heard. Many of the signals were being identified as conforming to the "Pronto" protocol, but the data wasn’t very helpful (nor was the way in which it was being displayed). To read the data you had to drill-down on each record. As I ultimately wanted to compare a large result set in an attempt to find patterns and work out which bits/bytes/words meant what this wasn’t really practical.

So I disabled all of the decoders and enabled just the raw signal capture:

I could now drill down and determine the pulse spec:

Which I could then use in an Arduino sketch to capture data. I used the ookRelay2 sketch and modified the Home Easy (HEZ) decoding function to decode my new devices:

class HezDecoder : public DecodeOOK {
public:
HezDecoder () {}
// see also http://homeeasyhacking.wikia.com/wiki/Home_Easy_Hacking_Wiki
virtual char decode (word width) {
if (400 <= width && width < 1600) {
gotBit(width <= 600);
return 0;
}
if (width >= 3000 && pos >= 5) {
for (byte i = 0; i < 6; ++i)
gotBit(0);
alignTail(64); // keep last 56 bits
return 1;
}
return -1;
}
};

As soon as I activated one of the sensors data started to flood in:

[ookRelay2]
HEZ 51 85 171 42 51 3
HEZ 166 106 85 101 102 32 51 85 171 42 51 3
HEZ 153 169 90 85 153 3
HEZ 51 85 171 42 51 3
HEZ 51 83 171 42 51 3
HEZ 51 85 171 42 51 3
HEZ 166 106 85 101 102 32 51 83 169 42 51 3
HEZ 51 85 171 42 51 3
HEZ 170 86 85 102 6 50 51 85 171 42 51 3
HEZ 51 85 171 42 51 3
HEZ 204 85 171 42 51 3
HEZ 51 83 181 170 50 3
HEZ 51 85 171 42 51 3

I’m not 100% sure of the reason for the receptions (I think some protocols rebroadcast multiple times to enable validation). Nor am I sure of the reason for the discrepancies (you can see most of the packets are HEZ 51 85 171 42 51 3 but a few contain different values).

I took the most common result and recorded it along with the jumper position (presumably indicating the home code):

I followed a methodical approach of moving the jumpers and recording the result- ending up with a pattern something like:

ABCD-EFGHIJ?? IJ GH EF AB CD
NNNN-NNNNNNNN HEZ 51 51 51 51 51 3
NNNL-NNNNNNNN HEZ 51 51 51 51 179 2
NNNH-NNNNNNNN HEZ 51 51 51 51 83 3
NNLN-NNNNNNNN HEZ 51 51 51 51 43 3
NNLL-NNNNNNNN HEZ 51 51 51 51 171 2
NNLH-NNNNNNNN HEZ 51 51 51 51 75 3
NNHN-NNNNNNNN HEZ 51 51 51 51 53 3
NNHL-NNNNNNNN HEZ 44 51 51 51 181 2
NNHH-NNNNNNNN HEZ 51 51 51 51 85 3
NLNN-NNNNNNNN HEZ 51 51 51 179 50 3
NHNN-NNNNNNNN HEZ 51 51 51 83 51 3
LNNN-NNNNNNNN HEZ 51 51 51 43 51 3
HNNN-NNNNNNNN HEZ 51 51 51 53 51 3
NNNN-NNNNNNNN HEZ 51 51 51 51 51 3
NNNN-NNNNNNNL HEZ 51 51 51 51 51 3
NNNN-NNNNNNNH HEZ 51 51 51 51 51 3
NNNN-NNNNNNLN HEZ 50 51 51 51 51 3
NNNN-NNNNNNHN HEZ 51 51 51 51 51 3
NNNN-NNNNNLNN HEZ 43 51 51 51 51 3
NNNN-NNNNNHNN HEZ 53 51 51 51 51 3
NNNN-NNNNHHNN HEZ 85 51 51 51 51 3
NNNN-NNNNLLNN HEZ 171 50 51 51 51 3
NNNN-NNNHNNNN HEZ 51 53 51 51 51 3
NNNN-NNHHNNNN HEZ 51 85 51 51 51 3
NNNN-NHNNNNNN HEZ 51 51 83 51 51 3
NNNN-HNNNNNNN HEZ 51 51 53 51 51 3

So I could see that the jumpers in pairs appeared to directly affect each byte of data being returned. I think built this table to demonstrate how I think they correlate:

DDDD-AAAAAAAA
3210-76543210
A0 = Not Used
A1 = Not Used
HEZ AA32 AA54 AA76 DD32 DD10
NN = 51
NL = 43
NH = 53
LN = 179
LL = 171
LH = 181
HN = 83
HL = 75
HH = 85

Next steps:

  • Configure each of the sensors with unique jumper configurations
  • Determine and position the sensors
  • Add the 433Mhz receiver to the jeenode connected to my raspberry pi (running DomotiGa) and modify the sketch to decode these signals as well as receiving 868Mhz broadcasts from other jeenodes
  • Tweak the DomotiGa code to interpret the received data

Home Automation Update

Not a lot to say- just a quick update. I’ve ordered a few more bits to add to the home automation project. These have already come:

-RFXCom 433Mhz transceiver
-Byron 433Mhz switch, pir, remote plug/socket & "in ceiling switching module".
-Linksys SPA3102

And I’m still waiting for (or haven’t ordered):

-433Mhz smoke alarms
-433Mhz doorbell
-433Mhz door/window open/close sensors
-Wifi or 433Mhz bathroom scales

Here’s a quick shot of one of the raspberry pis hooked into a little portable LCD, the RFXCOM transceiver, the CurrentCost EnviR and a Jeelabs Jeenode:

The next step I decided to tackle was getting a few real basics pieces of information from my Enigma2 digital satellite receiver into DomitiGa. I decided to use the nifty little shell script module to execute:

#!/bin/bash
rm current
wget -q http://192.168.0.222/ajax/current
cat current | grep "Name:" | sed 's/.*: (.*)<.*/1/'
cat current | grep "Title:" | sed 's/.*: (.*)<.*/1/'
cat current | grep "Recording Status:" | sed 's/.*: (.*)<.*/1/'

Which returns three lines with: The current channel, programme and whether a recording is in progress. I hope to take this a lot further and start capturing stats from my VDSL & ADSL modems, fileserver etc. You can see the satellite details below "Sky: Lounge":

I have been meaning to get my gas meter, hot & cold water monitored for a long time. The gas meter is relatively straight forward as it provides a convenient RJ11 socket with pulses- I just needed a sketch to load onto a jeenode to catch and report these pulses. I decided to try the sketch from the OpenEnergyMonitor project (http://openenergymonitor.org/emon/emontx) found here: https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTx_Pulse

I made some changes:

-Set freq to 868Mhz
-Set nodeID and networkGroup
-Unset UNO

I think that’s it:

/*
EmonTx Pulse example

An example sketch for the emontx module for
CT only electricity monitoring.

Part of the openenergymonitor.org project
Licence: GNU GPL V3

Authors: Glyn Hudson, Trystan Lea
Builds upon JeeLabs RF12 library and Arduino

*/

#define freq RF12_868MHZ // Frequency of RF12B module can be RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.
const int nodeID = 2; // emonTx RFM12B node ID
const int networkGroup = 212; // emonTx RFM12B wireless network group - needs to be same as emonBase and emonGLCD needs to be same as emonBase and emonGLCD

const int UNO = 0; // Set to 0 if your not using the UNO bootloader (i.e using Duemilanove) - All Atmega's shipped from OpenEnergyMonitor come with Arduino Uno bootloader
#include <avr/wdt.h> // the UNO bootloader

#include <JeeLib.h> // Download JeeLib: http://github.com/jcw/jeelib
ISR(WDT_vect) { Sleepy::watchdogEvent(); }

typedef struct { int power, pulse, misc1, misc2; } PayloadTX;
PayloadTX emontx; // neat way of packaging data for RF comms

const int LEDpin = 9;

// Pulse counting settings
long pulseCount = 0; // Number of pulses, used to measure energy.
unsigned long pulseTime,lastTime; // Used to measure power.
double power, elapsedWh; // power and energy
int ppwh = 1; // 1000 pulses/kwh = 1 pulse per wh - Number of pulses per wh - found or set on the meter.

void setup()
{
Serial.begin(57600);
Serial.println("emonTX Pulse example");

rf12_initialize(nodeID, freq, networkGroup); // initialize RF
rf12_sleep(RF12_SLEEP);

pinMode(LEDpin, OUTPUT); // Setup indicator LED
digitalWrite(LEDpin, HIGH);

attachInterrupt(1, onPulse, FALLING); // KWH interrupt attached to IRQ 1 = pin3 - hardwired to emonTx pulse jackplug. For connections see: http://openenergymonitor.org/emon/node/208

if (UNO) wdt_enable(WDTO_8S);
}

void loop()
{
emontx.pulse = pulseCount;
pulseCount = 0;
//Serial.println(pulseCount);
send_rf_data(); // *SEND RF DATA* - see emontx_lib
emontx_sleep(10); // sleep or delay in seconds - see emontx_lib
digitalWrite(LEDpin, HIGH); delay(2); digitalWrite(LEDpin, LOW); // flash LED
}

// The interrupt routine - runs each time a falling edge of a pulse is detected
void onPulse()
{
lastTime = pulseTime; //used to measure time between pulses.
pulseTime = micros();
pulseCount++; //pulseCounter
//Serial.println("Pulse!");
emontx.power = int((3600000000.0 / (pulseTime - lastTime))/ppwh); //Calculate power
}

void send_rf_data()
{
rf12_sleep(RF12_WAKEUP);
// if ready to send + exit loop if it gets stuck as it seems too
int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}
rf12_sendStart(0, &emontx, sizeof emontx);
// set the sync mode to 2 if the fuses are still the Arduino default
// mode 3 (full powerdown) can only be used with 258 CK startup fuses
rf12_sendWait(2);
rf12_sleep(RF12_SLEEP);
}

void emontx_sleep(int seconds) {
for (int i=0; i<seconds; i++) {
delay(1000);
if (UNO) wdt_reset();
}
}

L

I received a couple of 20′ poles last week so thought i’d have another go at getting the dishes hooked up… I didn’t make any progress using "guess work" so decided I need to find a better way!

Getting on the roof the other end is going to be a bit tricky so I started at this end. Here’s a picture I took with my iPhone (remarkably good quality):

Zoomed to 100% of where I think I’m aiming:

I wanted to get a bit closer- so took this with my Canon 5D Mark II & Canon 70-200mm f2.8L IS @ 200mm @ 100%:

This is from google maps (you can see the other side of the two houses in the shot above- notice how close to the destination marker A they are):

Google maps again (this is looking roughly at the angle between the houses- it looks like I might just about miss the tree on the right hand side):

I’ve ordered a few cheap laser (lazer?) pointers from eBay which I hope to strap to the dishes for some further testing next week…

Watch this space!

L

I had a few minutes to continue setting up the wireless link and take a few snaps. Here’s the dish mounted:

And a bit of a close-up:

I found a better way of determining the bearing between the two properties using google earth (I had previously used googlecompass: https://tickett.wordpress.com/2012/02/15/setting-up-getting-started-with-ubiquiti-nanobridge-m5/):

Unfortunately I don’t really have any way of determining the dish’s current bearing (other than a visual guestimate). Google earth also shows the elevation profile:

Which seems to pretty much agree with the AirLink tool. Admittedly when I first used it I didn’t really know what I was looking at in the graph:

It surprises me the bearing isn’t displayed anywhere (that I can see?). I think I’m going to need a slightly longer pole to mount both the dishes giving sufficient clearance above the houses/trees in the path. I wonder what length I can get away with- the current pole is about 2 metres long and waves about quite a bit in the wind. I guess I just need something a little sturdier.

More soon :)

L

Last week I ordered 2x ubiquiti nanobridge m5 25dBi wireless devices in an attempt to bridge the networks of two local houses. I’m not usually one for reading instructions but found it slightly odd that I didn’t really know where to start with regard to mounting/aligning the dishes.

I managed to find http://googlecompass.com which allowed me to read a bearing between the two premises:

Fortunately one of the houses already had a pole mounted on the roof with an old terrestrial tv aerial on. I started by taking this down and fitting one of the nanobridges to the existing pole and remounting it (roughly at a 20° bearing angled a few degrees down). This wasn’t fun being at the top of a ladder 20ft or so up!

I then found http://www.ubnt.com/airlink which allows you to enter the details of the wireless device types and locations providing feedback on expected signal etc (I found the website only worked in Safari, not in Chrome).

The first mistake I realise I made was not plugging in and testing the m5 before mounting it! I panicked a little after plugging it in and not seeing any new DHCP leases on my router! Fortunately I found out the m5 has a static ip address 192.168.1.20. I changed my ip so I was on the same subnet and managed to access the webui.

I have yet to mount the nanostation at the other end, and expect things NOT to be straight forward as there’s not really line of sight or an existing convenient pole to mount the dish but fingers crossed I’ll get it working eventually!

I will post pictures of the installation and more information once I get the other end up.

L

I blogged previously about replacing one of my switches with something a little smaller, quieter, lighter and greener: https://tickett.wordpress.com/2011/12/29/a-few-small-updates/ this was all part of a pretty big rewiring of the network and relocation of the A/V equipment.

All of the devices were in a cabinet in the corner of the living room:

But now I wanted to add the new switch and relocate into the utility room adjacent:

And re-run the wires a little differently (I’d previously used existing holes to get upstairs):

I’ve already pulled most of the equipment out of the cabinet and the cables just keep on coming:

The previous excess cable "neatly" spooled behind the cabinet:

Some hours later- a little progress:

Now upstairs. You can see the grey "conduit" I ran alongside the copper pipes with the existing cables:

Here’s the new hole in the ceiling:

And in the floor to allow cables to be pulled without lifting the floor:

Now the carpet’s back down and the cupboards are back in place:

First few lengths of Cat5e pulled through for 2 connections in the master bedroom:

Back downstairs, lots of velcro to tidy things up:

The comms cab starting to take shape (still a mess but I’ve still got a lot to do):

L

%d bloggers like this: