Tag Archive: Raspberry Pi


Further to several posts about Raspberry Pi Digital Signage driving our office screens (https://tickett.wordpress.com/2014/12/03/anonymous-authentication-sql-server-reporting-services/), we recently restructured SQL Server Reporting Services. We updated the html/javascript file the Pi looks at (which redirects to SSRS) but it continued to try and use the old path.

This was fixed by SSH to the Pi then delete the browser cache;

pi@raspberrypi ~ $ cd /home/pi/.cache/chromium/Default/Cache/
pi@raspberrypi ~/.cache/chromium/Default/Cache $ rm -R *
pi@raspberrypi ~/.cache/chromium/Default/Cache $ sudo reboot
Advertisements

Kicking back for a week at Center Parcs. Came fully prepared with Raspberry Pi & 2TB Portable Hard Drive fully loaded but forgot the damn remote! My HTC One has an IR remote built in, but the Microsoft MCE remote isn’t listed. Every result googled turned up was an XBMC or Media Center remote which only works over the network/LAN.

Eventually, after trying a dozen or so IR apps with no luck, we found ZappIR.

zappir

After trying a few combinations- Console/Media Manager -> Microsoft -> Media Manager MCE Media Center Code Group 2- Bingo!

Now back to kicking back! Nice little hot tub, steam room and sauna in the back garden!

11042999_10155192464790567_1824434695954957278_n

I have just setup an SSRS report for my helpdesk to show open calls, unread e-mails, some KPIs and graphs. I bought a cheap monitor, wall mounted and attached a raspberry pi.

I started with the latest Raspbian image and spent some time tweaking it to boot into x and launch chromium with the homepage set to the URL of my report. Unfortunately it was pretty flakey and always prompted for username/password so I had to VNC in every morning to authenticate.

Yesterday morning chromium decided it no longer wanted to load the report. I tried running;

sudo apt-get update
sudo apt-get upgrade
sudo raspi-update

And rebooted… Or at least I tried to but it would no longer boot- hanging on a message along the lines of;

mmcblk0: error -110

Rather than start again from scratch I decided someone else must have already tackled this “kiosk” style scenario and went on the hunt. Enter Raspberry Webkiosk; http://www.binaryemotions.com/raspberry-webkiosk/ (after a quick trial I paid the €9.90 “donation” to get the full version).

The image took care of the operating system, booting straight into full screen chromium with the home page set to the report URL but I was still stuck with the authentication prompt.

I hoped I could simply enable Anonymous Authentication in IIS, but the report server virtual directories don’t appear in IIS and the information available online all suggests this can’t be done.

The next idea was to try and configure chromium to remember the login credentials. Whilst I was able to save the username and password the prompt still persisted.

Final idea was to try and use an asp/html script of some sort. I then remembered a site I stumbled across recently with some sample/demo reports; http://www.reportsurfer.com/ which didn’t require authentication. I took a look at the html source and could see some simple javascript being used to pass the credentials.

So I built a simple “proxy” page in the default IIS site to redirect to the SSRS report and pass the username & password (the script must be on the same hostname/port to work).

<html>
  <head>
   <script>
var _0x1751=["\x61\x66","\x76\x76"];

function getHTTPObject() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    }
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
    }
    return false;
}	

function runReport() {
  var http = getHTTPObject();
  var url= "http://rs-01/ReportServer/Pages/ReportViewer.aspx?%2fTEL+Wall+Thing%2fWallDash&rs:Command=Render";
  http.onreadystatechange = function() {
    if (http.readyState == 4) {
      if (http.status == 401) {
        runReport(); 
      }
      if (http.status == 200) {
        document.location = url;
      }
    }
  };
  http.open("get", url, true, _0x1751[0x0], _0x1751[0x1]);
  http.send(null);
  return false;
}
    </script>
  </head>
  <body onload="runReport();">
  </body>
</html>

To use the script yourself, you essentially need to amend the top line;

var _0x1751=["\x61\x66","\x76\x76"];

The first value is the username and the second value is the password (hex encoded just to add some really basic obfuscation). Obviously this is easily reversible so you should create a new account with only permission for the specific report(s) they should be able to access. You can use http://string-functions.com/string-hex.aspx to convert your login details to hex.

Then simply update the report URL;

var url= "http://rs-01/ReportServer/Pages/ReportViewer.aspx?%2fTEL+Wall+Thing%2fWallDash&rs:Command=Render";

And you’re all set!

helpdesk

The first project I backed on Kickstarter was delivered some time back but I’ve only recently gotten around to trying to do something with it.

I have a bunch of JeeNodes from JeeLabs and wanted to use them as a starting point so read a few articles about getting the RFM12B on the EVE talking to the Raspberry Pi. They suggest bridging CE1 to SS RFM12 and bridging G21/G27 to the third pin of the chip which appears to be FSK/DATA/nFFS (according to the data sheets I’ve seen)- oh and don’t forget to add an antenna!

I then found some code suggested to be working on the older v1 raspi with an RFM01 chip fitted rather than the RFM12B I have: http://www.susa.net/wordpress/2012/08/raspberry-pi-reading-wh1081-weather-sensors-using-an-rfm01-and-rfm12b/

Another site gave some pointers around modifying the code for the v2 raspi: http://amcc.me.uk/2013/01/eve-alpha-collects-weather-data/

The setup seems to work very well with either revision (1 or 2) of the Raspberry Pi though a couple of additional lines of code in wh1080_rf.c need to be tweaked to suit revision 2:

// RPi (Rev1) Init GPIO21 (on pin 13) as input (DATA), GPIO22 (pin 15) as output (nRES)
*(gpio.addr + 2) = (*(gpio.addr + 2) & 0xfffffe07)|(0x001 << 6);
Becomes:
// RPi (Rev2) Init GPIO27 (on pin 13) as input (DATA)
*(gpio.addr + 2) = (*(gpio.addr + 2) & 0xff1fffff)|(0x001 << 6)
And:
// RPi (Rev1) - GPIO21
status = ((*(gpio.addr + 13)) >> 21) & 1;
Becomes:
// RPi (Rev2) GPIO27
status = ((*(gpio.addr + 13)) >> 27) & 1;

I then went on to comment the RFM01 definition in rfm01.h and uncomment the RFM12B definition:

//#define RFM01
#define RFM12B

I also added the following definitions for the RFM12B as without them the code wouldn’t compile:

#define LNA_20 (3 << 4)
#define LNA_14 (1 << 4)
#define LNA_6 (2 << 4)
#define LNA_0 (0 << 4)
#define LNA_XX (3 << 4)

Remove this line from wh1080_rf.h:

#define USE_BMP085

Then onto the main wh1080_rf.c starting with updating to the correct spi port:

static const char *device = "/dev/spidev0.1";

I then used http://tools.jeelabs.org/rfm12b to get all the hex values to update the following lines:

uint16_t cmd_drate = 0xC606;
uint16_t cmd_freq = 0xA640;
uint16_t cmd_config= 0x80e7;
uint16_t cmd_power= 0x82dd;
uint16_t cmd_sync= 0xced4;
uint16_t cmd_afc= 0xc483;
uint16_t cmd_dcycle = 0xc800;
uint16_t cmd_pll= 0xcc57;
uint16_t cmd_fifo= 0xca83;
uint16_t cmd_dfilter = 0xc2ac;

Now when I:

make clean
make
sudo ./wh1080_rf

Initialising RFM12b
SPI: mode 0, 8-bit, 1000 KHz
Ctrl+C to exit
LNA_0,RSSI_73 idx 0 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_79 idx 1 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_85 idx 2 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_91 idx 3 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_97 idx 4 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_103 idx 5 4.21 5.32 4.17 3.26 4.21 5.26
LNA_6,RSSI_73 idx 6 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_79 idx 7 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_85 idx 8 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_91 idx 9 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_97 idx 10 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_103 idx 11 4.21 6.32 5.21 4.26 5.38 4.26
LNA_14,RSSI_73 idx 12 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_79 idx 13 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_85 idx 14 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_91 idx 15 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_97 idx 16 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_103 idx 17 5.26 5.26 4.21 5.21 5.26 4.35
LNA_20,RSSI_73 idx 18 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_79 idx 19 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_85 idx 20 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_91 idx 21 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_97 idx 22 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_103 idx 23 4.30 5.26 4.21 5.26 5.26 4.35
RSSI Duty 0.32

.

So the “interference” I can see suggests that something is hopefully working! I’m still playing around in an attempt to work out what I still need to tweak.

L

At long last I found the time to get Gambas2 compiled and running on Raspberry Pi with Raspbian Wheezy and DomotiGa (http://domotiga.nl).

Things were made extra hard by my determination to not expand the 2GB rootfs so I had to strip some stuff out- but it does mean you can restore to any SD card 2GB or larger.

SSH is enabled but I didn’t put vncserver on this time.

I didn’t document the process- but essentially kept trying to

./configure

gambas2 and each time an error came up I used http://www.debian.org/distrib/packages to try and determine what I needed to install. Because of the lack of free space I had to wget and

dpkg –I

to install many of the packages- I couldn’t use

apt-get

. I used

df –h

to check on free space as I went and

find / -type f -size +5000k

to find and remove large files (cache/docs etc).

Shell login: pi
Shell password: raspberry
Mysql root password: raspberry

Download

http://tickett.net/downloads/raspbian_gambas_domotiga.img.7z
http://tickett.net/downloads/raspbian_gambas_domotiga.img.7z.md5

Mirror

http://speedy.sh/J3MhY/raspbian-gambas-domotiga.img.7z
http://speedy.sh/srE7C/raspbian-gambas-domotiga.img.7z.md5

Please let me know how you get on!

L

Multi-Tasking!

As usual- I have far too many projects on the go, but here’s a sneak peak of one that’s currently edged to the top of "the list":

My intention is to try and fit:

  • At least one with a raspberry pi and some for of MAME style emulator and 2 sets of joystick/arcade controllers
  • At least one with a touchscreen running some form of SWP / itbox style pub quiz machine software (monopoly, bullseye, spot the difference etc)
  • Possibly one with a console xbox/playstation as I seem to recall having a fairly successful emulator disc with a ton of games already working without any real work required

Firstly I will be ripping the CRT screen / monitor out of them all, and all/most of the wiring. I have ordered a few different 19" 4:3 flat panel LCD monitors to try fitting, a few different video adapters and a few "arcade style" controllers I hope to be able to re-use. I have only opened one up so far and was pleasantly surprised how accessible everything was:

Also there appears to be a relatively common looking motherboard/hard-drive combination with relatively standard VGA ports etc- so I may even try hooking it up and see if the old thing has any life in it? No idea what operating system/software might be on there (I picked them up as non-working for parts).

There’s a thread on the Raspberry Pi forum I’ve been following: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=35&t=6813 so hopefully it won’t be long before Raspbian has a nice compiled MAME binary and frontend. I have also been playing with some itbox style swp emulators and roms with quite a high level of success (unfortunately they appear to all be for winxp/7):

Who wants to be a millionaire. And:

Spot the difference :)

I eagerly await delivery of my various eBay purchases!

L

*EDIT* This image has now been succeeded by a Raspbian / Wheezy based image: My raspbian SD image is now available: https://tickett.wordpress.com/2012/08/16/raspbian-wheezy-gambas2-domotiga/

After an earlier post https://tickett.wordpress.com/2012/06/05/domotiga-running-on-raspberry-pi/ I received a few requests for the sd card image. So here it is.

The following are all the login/passwords you may need:

login: pi/raspberry
msql: root/raspberry
vnc: raspberry

This is based on the official Raspberry Pi debian squeeze image, with the following additional items installed:

ssh enabled
mysql-server
tightvncserver
subversion
gambas2.24

It just fits on a 2 GB card:

pi@raspberrypi:~/domotiga$ df -H
Filesystem Size Used Avail Use% Mounted on
tmpfs 98M 0 98M 0% /lib/init/rw
udev 11M 148k 11M 2% /dev
tmpfs 98M 0 98M 0% /dev/shm
rootfs 1.7G 1.5G 60M 97% /
/dev/mmcblk0p1 79M 29M 50M 37% /boot
pi@raspberrypi:~/domotiga$

All packages have been upgraded to their latest stable version from the squeeze repository.

If you don’t know how to get into the guy, you can either login to the console then run:

startx

Or via ssh run:

vncserver :1 –geometry 1024x728 –depth 16

Then use any vnc client to connect to the desktop. Now execute gambas2 from the run menu:

I have already opened the DomotiGa project so just click on it:

Click "Run" from the toolbar, Debug menu or press F5:

Download links:

http://tickett.net/downloads/raspi_squeeze_gambas2_domotiga.img.7z

http://tickett.net/downloads/raspi_squeeze_gambas2_domotiga.img.7z.md5sum

Mirror:

http://speedy.sh/nAMsr/raspi-squeeze-gambas2-domotiga.img.7z
http://speedy.sh/v9ETB/raspi-squeeze-gambas2-domotiga.img.7z.md5sum

Let me know how you get on!

L

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’m there! After quite a few hours of pain- I’m finally there. I ended up having to compile gambas2 from source- see previous posts:

https://tickett.wordpress.com/2012/06/04/gambas2-on-raspberry-pi/

https://tickett.wordpress.com/2012/06/04/gambas2-on-raspberry-pi-part-2-were-good-to-go/

Hopefully tomorrow I’ll have a few devices up and running!

L

And as if by magic… several moments after my previous post:

I’m off out for a while but if it’s possible will share the compiled version (I’m not sure how yet… but I’m sure I will work it out!). And then to go back to trying to get DomotiGa up and running!!

L

%d bloggers like this: