Wednesday, 28 December 2016

Setting up Raspberry Pi with DarkIce and Node

Operating System

Load the SD Card with Raspbian following these instructions
https://www.raspberrypi.org/documentation/installation/installing-images/mac.md

drop a file called "ssh" into the boot folder

connect using airport express

setup wifi using command-line (plenty of explanations on google)

Install stuff

sudo apt-get update
 (that may avoid problems later with that missing line in the v8.h header file)
sudo apt-get install nodejs
sudo apt-get install mongodb

Set up samba so you can browse the folders from the mac

sudo apt-get install samba samba-common-bin
nano /etc/samba/smb.conf

in the [home] section
 read only = no
 browsable = yes

sudo smbpasswd -a pi

$ sudo /etc/init.d/samba stop
$ sudo /etc/init.d/samba start

Problems trying to install the application packages using npm

Ran into this
https://www.raspberrypi.org/forums/viewtopic.php?t=127939&p=856473


Tuesday, 11 August 2015

How I put my home automation system together and what I would do if I did it again

Main controller

I bought a Ninjablock.

You can't actually buy them anymore because the company has wholly moved on to their new offering, the Ninja Sphere (https://ninjablocks.com/ninjasphere/buy).

The NinjaBlock annoyed me in the end because it was for programmers only, and was not robust.  e.g. if you turn it off on the wall (or have a power cut) the CPU can blow.  I got it repaired under warranty but they told me that the solution was to do design a circuit myself that would do a soft shut-down when power is taken away.  Screw that!  Any time I had any issue with it they were like "oh that's easy you just <blah blah blah blah whole lot of technical linux steps>".  And their 'cloud' seemed to reset every few weeks.

If I did it again (which I'm about to) I would consider either
1/ a 433MHz cape for a Raspberry Pi (cheap overall and standalone)
2/ a 433MHz USB device on my mac mini that is always on (requires a computer that's always on)
Then for either of those I would write software that would run on the device and communicate with your phone via an app or website.

Remote controlled sockets

When I set my system up, Maplins was selling these in packs of 4 for 20 quid or something - cheap!
http://www.rapidonline.com/Electrical-Power/Conrad-Radio-Controlled-Switch-Socket-433MHz-Frequency-4-Channel-544123

.. and they were 3kW rated so you could plug a 2.5kW heater into them (unlike one above which is 2kW)

I also got these for behind the wall installations of lights (only 1kW rated..)
http://www.intertechno.at/produkte/empfaenger/schalter/CMR-1000.html

And this one for behind the wall installations of heaters (3.5kW rated)

Since Maplins have discontinued those plug-in sockets I would have to check whether their new model works (specs look right)

If I did it again, I would probably keep going with the 433Mhz actuators because they were so damn cheap.  Maybe I would ensure that my radio frequency controller was compatible with other systems just in case, though (e.g. ZigBee, Z-Wave...)

Heaters

While the dreamt-of goal was to have elegant wall-mounted heaters, we took the cheap option and got a flock of these Dragon 2.5kW heaters.
Here's a link on Google shopping

Why?
Because
- per-heater they were cheap: around 100 pounds instead of 400+++ pounds for an electrified oil column heater that you like the look of,
- they were very effective: the heated air rises in a column that circulates around the room very effectively, and
- it was easy: you just plug them into one of those wall-plugs above and go.

If I did it again, I would have a serious think about investing in elegant wall-mounted radiators that I liked because having these oil column heaters in each room was a little yuck.

NOTE: we needed to get the non-digital ones so that we could turn them on and off at the wall effectively (using those remote switches).  If you get a digital heater that resets when you turn it off/on then it won't combine with the wall plugs.

Temperature sensing

The ninjablock came with some 433Mhz temp sensors ... they were OK but sometimes I had a little trouble with the range until I got the base unit's aerials in just the right position.  Need to do research into what to use instead now that Ninjablocks discontinued their block & temp sensor offering.

Software

I largely leveraged the ninjablocks cloud/rules platform, and created my own website 'remote control' because their cloud interface was waaaayyyyy too slow and cumbersome for the phone.  I put a shortcut to my website on my phone's home screen and when I clicked it I would see something like this


If I did it again, I would probably have a similar concise website like in the image above, but maybe add to the platform some email communication too. ("Hello, this is the house - you seem to have gone out.  Should I turn the heating off? Click Yes or No.")

(You could detect when people have gone out by their phone disappearing from the wifi network)

Sunday, 2 February 2014

Building Arduino .hex file for NinjaBlock [rewrite branch]

Get Arduino
http://arduino.cc/en/Main/Software

Download the code either by downloading .zip, or using GitHub
https://github.com/ninjablocks/arduino/tree/rewrite

The following libraries need to be added
cd ~/Documents/Arduino/libraries/

  ln -s ~/AUTOMATION/arduino-master/aJson aJson
  ln -s ~/AUTOMATION/arduino-master/DHT22 DHT22
  ln -s ~/AUTOMATION/arduino-master/DMD DMD
  ln -s ~/AUTOMATION/arduino-master/I2C I2C
  ln -s ~/AUTOMATION/arduino-master/MMA8453Q MMA8453Q
  ln -s ~/AUTOMATION/arduino-master/Ninja Ninja
  ln -s ~/AUTOMATION/arduino-master/NinjaObjects NinjaObjects
  ln -s ~/AUTOMATION/arduino-master/NinjaObjectsPi NinjaObjectsPi
  ln -s ~/AUTOMATION/arduino-master/RCSwitch RCSwitch
  ln -s ~/AUTOMATION/arduino-master/Sensors Sensors


  ln -s ~/AUTOMATION/arduino-rewrite/common common
  ln -s ~/AUTOMATION/arduino-rewrite/decoder decoder
  ln -s ~/AUTOMATION/arduino-rewrite/encoder encoder
  ln -s ~/AUTOMATION/arduino-rewrite/onboard onboard
  ln -s ~/AUTOMATION/arduino-rewrite/ports ports
  ln -s ~/AUTOMATION/arduino-rewrite/rf rf
  ln -s ~/AUTOMATION/arduino-rewrite/serial serial

You have to have the ninjablocks source code in your libraries folder right alongside the symbolic links to the 'libraries' (which you get from the trunk)

So the folder structure is

/Users/mike/nb/libraries/ajson [symbolic link]
/Users/mike/nb/libraries/common [folder from github]
etc..

And in Arduino, set the 'Sketchbook location' in preferences to /Users/mike/nb, i.e the folder ABOVE the libraries folder... 



Flashing NinjaBlock with new Arduino .hex file

To flash an arbitrary .hex file, run this from the command prompt
scp <path to .hex file> ubuntu@ninjablock.local:/home/ubuntu/NinjaBlock.hex
enter password: temppwd

ssh ubuntu@ninjablock.local

sudo stop ninjablock
sudo /opt/utilities/bin/ninja_update_arduino /home/ubuntu/NinjaBlock.hex
sudo start ninjablock

To flash the standard hex again, use this from the ssh console opened above
sudo stop ninjablock
sudo /opt/utilities/bin/ninja_update_arduino
sudo start ninjablock