Monday, 15 April 2019

OLD VERSION - Amazon Prime using a Raspberry Pi & KODI

updated 3.April.2019

This is a copy of the OLD (manual install) version. See HERE for the latest.


03 April 2019: Amazon incorporated a major security update a few days ago, requiring build-in encryption chips, which does not work with Kodi....... 
>> See the new update above

Fed up having to slog my laptop to the living room to watch Amazon PrimeVideo, I pressed a spare Raspberry Pi into service.
The most recent release of the open source multimedia centre, libreElec Kodi 18, for RPi has the required streaming service and Amazon Add-on which once again allows Amazon Prime (and many others) to run perfectly.

With great thanks to Sandmann79 & Varstahl who build this Add-on.

I will show here how to do a complete new, clean install from scratch, using a windows10 PC to download and install the libreELEC Kodi media center for the Raspberry Pi.

This install was originally done on in December 2017, but requires the occasional update if/when Amazon changes (regularly) their settings or something. About once a year I just do a fresh install just to keep up with the changes.
My latest LibreElec install is now #0104  4th Jan 2019.




Updates: 

Amazon regularly changes things, some break this setup. SO... If you find the player not working after you updated Widevine, it can usually be fixed by updating to the latest LibreELEC Kodi and Prime Addon. 

If you already had Kodi installed and working, you only need to do steps 1.2 and 1.3 to download the latest Kodi build and Prime Addon, and then continue at step 4.

If that doesn't work, first check the Kodi thread (step 1.2) to see if something has already been reported as broken and may already be worked on. If so please hang in there as everybody is a volunteer and does this in their free time! 


NOTES
  1. Available in all countries where Amazon PrimeVideo is available (since version 0.5.0).
  2. Doing this installation from an Mac or Linux shouldn't be much different, but you'll have to work out your own details. Afraid I can't help there.
  3. This install turns your RPi into a dedicated KODI system, so you won't be using it for anything else (to install KODI on a general purpose RPi, see this KODI how-to)
  4. Disclaimer: It is your responsibility to comply within your locations legal requirements for streaming content.
You need
  • one Raspberry Pi, version 2 or 3,
  • micro-SD card, at least 8Mb
    • after the install you need to have 2+ Gb left for the widevine decoder extraction to happen.
  • HDMI cable (to connect Raspberry to your TV or monitor) ,
  • PC to download files and load to SD card, and
  • a valid, working Amazon Prime account
    • this is not a free-to-view hack
    • should work in all countries where AmazonPrime Video is available.

Steps: 

1. Download installation files 

On your PC 

1.1. Download and install libreELEC for Raspberry Pi onto SD card

Go to https://libreelec.tv/downloads/ 
  • Download the libreELEC USB-SD Creator app, and open it.

libreELEC USB-SD Creator
  •  In (1) select your version: I am using a Raspberry Pi 3 so selected version 'Raspberry Pi 2 and 3'
  • In (2) select 'Download' button and a window pops up where you select your directory where you want the file to go. Once you select the folder, the Creator will immediately download the file and you should see it in the bar
 
  • If not already done, connect your Raspberry's microSD card to your PC (you may need a MicroSD to USB converter).
  • In (3) select your microSD card location (in my case E:\)
  • In (4) hit Write, and sit back.

  • When the write is complete, close the Creator, and eject your SD card. 

1.2. Download KODI 18 

  • Go to https://forum.kodi.tv/showthread.php?tid=298461 
  • Please take a second to read the heading 'Fair Warning' and 'Installing' 
  • Download the most recent build  (i used build #0101, 04-Jan-2019). Pick the version for your Raspberry!  (RPi 3 users use the RPi2 builds).
    SAVE the .tar file to your PC. We'll use it later.
    • In my case this file is called "LibreELEC-RPi2.arm-9.0-Milhouse-20190104215518-#0104-gdf9076a.tar"

1.3. Download the Amazon Prime Add-on

Unfortunately, the Amazon Prime Add-on is not in the base Kodi repositories so we have to install it manually.   There are a few Amazon Prime add-ons on Github, but I use the original by Sandmann79.

  • On the top right select the green "Clone or download" and select "Download ZIP". Save to your pc. We'll use it later.
    • At this time the file is called "xbmc-master.zip"
    • On downloading you may get a virus warning! As this certainly raised my alarm bells, I checked this with Sandmann79 and he replied it's due to the zip containing an AutoHotKey script executable for windows which you can remove. See here for the discussion.
  • Read the "Instructions to install Widevine Library" at the bottom of the page. "2. LINUX"  (as we're installing on a RPi)

1.4. Download SSH client  (PuTTy)

To install the widevine library on the RPi we'll use PuTTy as SSH client to remotely use the libreELEC system command line editor.
  • Go to https://www.chiark.greenend.org.uk/~sgtatham/putty/ 
  •  In the second paragraph you find "The latest version is xxx. Download it here"  (current version 0.70). Select the 'Download it here' link.
  • All we need is the basic putty.exe file, so go down to the second box "Alternative binary files" and select the 32-bit "putty.exe" file.
  • Download the file to your pc and make a note where you download it to or create a short-cut to it as you'll need it later.

2. Raspberry Pi  KODI Setup

On your Raspberry Pi

2.1. LibreELEC/KODI initial setup

  • Insert the SD card into your Raspberry Pi.
  • Hook up RPi to your TV  (or monitor)
  • Hook up a keyboard (and mouse) to your Raspberry: this is for this installation only, although might be handy later also.
  • Fire up your Raspberry.  You should now see the libreELEC setup screen. 
Hit 'Next' and you'll go to the Interface window
  • Interface window: Give your Raspberry libreELEC a name for identification on the network. I called mine 'kodi'. Hit 'Next' to set up Sharing and remote access.

  •  Sharing and Remote Access: To install Amazon, for now you must allow both SSH and SMB ('samba') in order to remotely drop further files from your pc to the RPi after the initial boot. (we will shut down SSH again at the end of the install)
  • Hit 'Next' and you'll find yourself in the KODI main menu.

To install Amazon, which is not in the Kodi or libreELEC official repositories, we must allow Kodi to download from external
  • Go back to Main Menu > Settings > Systems > Add-ons.
  • Go back to Settings, then > System Settings, and activate the Unknown sources so that KODI will accept the Amazon Add-on install from zip file.
    If you're not seeing this option, you must first switch to Advanced in the left menu. Kodi will give you a warning about this action.

  

2.2. Connecting to your wifi network

picc of main menu, settings
  • Move up the menu to select the 'Settings' button (the cog-wheel) to get to the System settings.
  • Select 'LibreELEC' and then 'Connections'
  • Select your wifi network and enter your wifi code.  Once you've done this, libreELEC will reboot into wifi mode and return to the main menu

3.  Install Widevine on the RPi

NOTE:Since the #0207 (2018) build, Kodi does the Widevine extraction automatically so this step is no longer needed
I'm leaving this step here for reference only. 

Chromium-Widevine is the plugin required to enable the RPi to play streaming video encoded with Widevine (which Amazon uses).

On your RPi
  • From the main menu, go to Systems, then System Information, and make a note of your RPi's IP address.
From your PC 
  •  Open PuTTy


  • At "Host Name (or IP address)" type the IP address for your RPi, and check that Connection type is SSH.
  • You can save the info for future quick access by giving it a name in "Saved Sessions" and hit Save.
  • Hit "Open"
    • login as: root
    • password: libreelec



  • Type the following commands
     wget http://nmacleod.com/public/libreelec/getwidevine.sh
     chmod +x getwidevine.sh
     ./getwidevine.sh
  • This will install widevine and should tell you "successfully installed libwidevinecdm.sh"
  • Exit PuTTy.

4. Copying KODI 18 and Amazon Add-on to RPi

Still on your PC


  • Open file explorer and in the address bar type "\\" and the name you gave your RPi kodi system (in my case 'kodi' so I type "\\kodi").  In Windows this looks like

  • If this doesn't work (e.g. because you are using something other than Win10 smb file sharing), use the RPi's IP address instead of the name (so it becomes "\\xxx.xxx.x.xxx")
  • You should now see the RPi directories. Select the 'Downloads' directory

  • On your PC, select the directory where you saved the KODI 18 and Amazon files under steps 1.2 and 1.3.
  • Copy the "xbmc-master.zip" file to the "Downloads" directory on your RPi
  • Copy the  KODI 18 .tar file (in my case "LibreELEC-RPi2.arm-9.0-Milhouse......tar") to the "Update" directory on your RPi.
  • Wait for the copying to finish!   
  • Optional: If you want, this is a nice time to download Kore, the official remote for KODI App for your smartphone or tablet.  (After a year, I find I actually don't use it..)



  5. Reboot your Raspberry pi KODI

Back on your Raspberry.

  • In KODI, hit the power icon (left top) and select 'reboot' 
  • As it reboots, you'll see the "upgrade in progress" in the left top corner of the libreELEC startup screen.
  • Once you're rebooted and updated, you're ready to start with the actual install of the Amazon Add-on.

6. Install repository and Add-ons

note: the layouts have changed a bit since I originally did this in 2017, but the menu structure I believe is still be valid.
  • Go to the KODI >Main Menu. 
  • Go to the >Add-on menu
  • Select >Add-on browser, and >install from zip file.


  • Select Home folder, then downloads
  • Select your xbmc-master.zip and amazon .zip files.


This has now installed the repositories which contain the actual add-on, so now we'll install the actual Add-on.
  • from the Add-on browser menu, select > Install from repository
  • you should now see your Sandmann79s Repository. Select it.

  • Select > Program add-ons, and there > Browser Launcher
  • Go back to the Sandmann79s Repository and
  • Select > Video add-ons > Amazon VOD
You should see the following window




  • Select > Configure and select the following:
    • Playback with Input Stream 
    • 'Enable DRM check' OFF, 'Switch audio track' ON  (see Note below)
    • Language: as you need. 

  • Since the #0207 (2018) build: The first time you select a video/movie to play, Kodi will tell you it needs to extract Widevine. Accept this and accept the Google terms. You must have at least 2Gb of free space for this to work.
    If, after doing this, it doesn't play your movie immediately, please reboot and try again.

NOTE: We did a Kodi 18 install: 'DRM check' disabled and 'switch audio track' enabled should give multi-channel audiotracks (if available). If you have problems set 'DRM check' enabled and Switch Audio track disabled and you should at least get good stereo audio. [communication with Sandmann79]
If (for whatever reason) you're using KODI 17: you must have 'DRM check' enabled.


  • Go back up the VOD menu and select > Connection
  • Select > Sign in ... and enter your Amazon Prime membership details.
SMALL PRINT: By entering your login details for Amazon you assume a certain risk in doing so. Both Milhouse and Sandmann have been active with Kodi for a long time. The source code for the software is open source. The add-ons do not store login data, just an authentication cookie. Even so, you have no guarantee that the security measures won't be breached.

You should now have Amazon up and running !

  ENJOY

links:

Thursday, 6 December 2018

KilnMonitor: a low-cost, non-intrusive, remote monitor for an electric ceramic kiln.



My wife is a studio potter, and mentioned she would like to be able to "keep an eye" on her kiln firings without having to trot to the kiln every hour or so.
Apart from the very expensive industrial-type controllers that include a remote feed, I couldn't find anything either available or even home-built. So I set to the challenge...

The result is a non-invasive log of the electricity use which is stored in the cloud and can be readout from anywhere (with internet access).

Screen capture from my kilnmonitor remote on ThingSpeak (a glaze firing)

The latest / live data of our kiln is shown below, with the full thingspeak page here. If the time is 'now' (and the red power line not complete) then a firing is in actual progress. If the curve looks nothing like the reference curves, it is (hopefully!) because we're firing a non-standard profile.

latest firing profile with references bisque (g) and glaze (b)

 

The build

Early on I decided against trying to measure the kiln temperature direct: you cannot 'piggy-back' on your existing thermocouple (they are far too sensitive for that) and adding a second one, whilst feasible, was considered both too expensive and too intrusive as you need an R or S type to measure up to the 1300ºC required. 
So instead I am using a non-intrusive indirect measurement: the kiln's electricity use. 

Initially I built a prototype that gave real power by measuring both voltage and current, and that worked well.  However, I didn't like the requirement to physically wire into the kiln high-voltage wires, so I dropped the voltage measurement and assume it constant (as most home power monitoring gadgets do). And as it turned out, the lack of measuring the exact voltage does not introduce an unacceptable variation.

Measuring only the electricity amperage turns out to give a perfectly suitable 'signature profile' of your firings which you'll become familiar with very quickly. It has been in use here for well over a year now and many firings.
 
figure 1: Comparison of measured profiles for three bisque firings
(program: 100ºC/hr to 600ºC, then 200ºC/hr to 950ºC, 30min soak).
Ramp switch-over, start of soak and finish are clearly identifiable on all,
plenty good enough as "fly on the wall" monitor.

The monitor consists of a single ESP-32 micro-controller which does all the high-speed sampling (over 90kHz!) of a non-invasive AC current sensor and once a minute sends the sum value via the light-weight and very fast MQTT protocol to a ThingSpeak channel which can be viewed from anywhere with web access.

The monitor itself is so small it fits literally inside a business card box. 
A red and a green LED light complement the setup for a local visual indication of the system starting up (red steady), connecting to wifi (red blinking), measuring 'zero' (green blinking) and measuring a 'kiln firing' signal (green steady).


figure 2: the KilnMonitor and AC current measurement sensor.

Components in this build
  • NodeMCU ESP-32 ESP-32S WiFi Development Board
  • 100A non-invasive AC current sensor split core transformer (SCT-013-000)
  • 3.5mm Mini Stereo Jack Chassis Panel Mount Headphone Input Socket Connector 
  • 1 m stereo jack extension cord
  • USB-mini power source, 0.5A minimum (e.g. a phone charger will do fine) 
  • 70 x 50 mm PCB prototyping board
  • a red and a green LED
  • assortment of wire, resistors etc.
  • a box to protect it in (mine is a business card box)
and

Version I was an experimental prototype build on a breadboard, but it had been so popular in the pottery studio that it was in constant use. For longevity, this version II was soldered on prototype board and attached to the case using standoff columns. 

Interested?

I am currently looking for further feedback. If you are interested in trying this monitor, please contact me via a comment.

Wednesday, 27 December 2017

Watching Amazon Prime using a Raspberry Pi & KODI


updated 29 Deccember 2019

Fed up having to slog my laptop to the living room to watch Amazon PrimeVideo, I pressed a spare Raspberry Pi into service.
The most recent release of the open source multimedia centre, libreElec Kodi 18, for RPi has the required streaming service and Amazon Add-on which once again allows Amazon Prime (and many others) to run perfectly.

With great thanks to Sandmann79 & Varstahl who build this Add-on.

I will show here how to do a complete new, clean install from scratch, using a windows10 PC to download and install the libreELEC Kodi media center for the Raspberry Pi. I use a Raspi 3.

This install was originally done on in December 2017, but requires the occasional update if/when Amazon changes (regularly) their settings or something. About once a year I just do a completely fresh install just to keep up with the changes.
My latest, completely fresh, install is now 29th December 2019 (LibreElec 9.2.0,  Kodi 18.5 compiled 2019-11-23). 



15 April 2019: Amazon incorporated a major security update earlier this month, requiring build-in encryption chips, which does not work with Kodi in HD. However, it will still play Standard Definition (960x540). If you had Kodi installed I recommend a complete fresh update, as the new version also includes automatic updates.
This large update of the blog now also includes a much much simpler way to install the add-ons, using directly accessible repositories and no longer needs remote access to the Pi.
For those interested, here is the old (manual, no longer working) setup.

Updates: 

Amazon regularly changes things, some break this setup. SO... If you find the player not working for whatever reason, it can usually be fixed by updating to the latest LibreELEC, Kodi and Prime Addon. 


NOTES
  1. Available in all countries where Amazon PrimeVideo is available (since version 0.5.0).
  2. Doing this installation from an Mac or Linux shouldn't be much different, but you'll have to work out your own details. Afraid I can't help there.
  3. This install turns your RPi into a dedicated KODI system, so you won't be using it for anything else (to install KODI on a general purpose RPi, see this KODI how-to)
  4. Disclaimer: It is your responsibility to comply within your locations legal requirements for streaming content.
You need
  • one Raspberry Pi, version 2 or 3,
  • micro-SD card, at least 8Mb
    • after the install you need to have 2+ Gb left for the widevine decoder extraction to happen.
  • HDMI cable (to connect Raspberry to your TV or monitor) ,
  • PC to download files and load to SD card, and
  • a valid, working Amazon Prime account
    • this is not a free-to-view hack
    • should work in all countries where AmazonPrime Video is available.

Steps: 

1. Download and install LibreELEC for Raspberry pi

On your PC 

Go to https://libreelec.tv/downloads/ and go to the downloads_new pages. (i'm leaving it like this in case the 'downloads_new' becomes the normal).
  • Download the libreELEC USB-SD Creator app, and open it.

libreELEC USB-SD Creator
  •  In (1) select your version: I am using a Raspberry Pi 3 so selected version 'Raspberry Pi 2 and 3'
  • In (2) select 'Download' button and a window pops up where you select your directory where you want the file to go. Once you select the folder, the Creator will immediately download the file and you should see it in the bar
 
  • If not already done, connect your Raspberry's microSD card to your PC (you may need a MicroSD to USB converter).
  • In (3) select your microSD card location (in my case E:\)
  • In (4) hit Write, and sit back.

  • When the write is complete, close the Creator, and eject your SD card. 

2. Raspberry Pi  KODI Setup

On your Raspberry Pi

  • Insert the SD card into your Raspberry Pi.
  • Hook up RPi to your TV  (or monitor)
  • Hook up a keyboard (and mouse) to your Raspberry: this is for this installation only, although might be handy later also.
  • Fire up your Raspberry.  You should now see the libreELEC setup screen. 
  • Hit 'Next' and you'll go to the Interface window
  • Interface window: Give your Raspberry libreELEC a name for identification on the network. 
  • In the network screen select your network and, if using Wifi, select your wifi network and enter your wifi code. 
  • I called mine 'kodi'. Hit 'Next' to set up Sharing and remote access.

  •  Sharing and Remote Access: To install Kodi, for now you must allow both SSH and SMB ('samba') in order to remotely drop further files from your pc to the RPi after the initial boot. (we will shut down SSH again at the end of the install).
  • If you want to be able to access your Kodi from remote, allow Samba and/or SSH (SSH for advanced users only).
  • Change the SSH password as recommended; by trial and error I found it must be over 8 characters long and have both uppercase letters and numbers.
  •  Hit 'Next' and you'll find yourself in the KODI main menu.

(for those who have been here before, the rest is now much more straight forward )


    3. Install repository and Add-ons


    Go to the KODI >Main Menu. 
    • Go to the >Add-on menu
    • Select the Search box and enter "kodinerds". 
    • From the search results, select & install
      "Add-on repository - Kodinerds Add-ons" (kodinerds.net 9.0.103.103)
    • Go back to the main Add-ons menu 
    from the Add-on browser menu, select > Install from repository
    • select  'Kodinerds Add-ons'.
    • select 'Add-on repository'
    • you should now see your Sandmann79s Repository. Select it and install it.
    • Go back up to Add-ons/Install from repositories. This should now also have the Sandmann79s repository.
    • In Sandmans repository, select > Video add-ons > Amazon VOD (the second one down)
    • Install it (accept additional add-ons to be installed also).
    You should now have Amazon VOD in the main Add-on menu. Yeah!

    Almost time to go enjoy yourself.

    • Open Amazon
    • Open the Amazon VOD menu (left side) and select > Connection
    • Select > Sign in ... and enter your Amazon Prime membership details.

    • The first time you select a video/movie to play, Kodi will tell you it needs to download "inputstream adaptive". Select "yes".
    • Also let it extract and install Widevine. Accept this and accept the Google terms. You must have at least 2Gb of free space for this to work.
    • This will take several minutes. 
    • After you have done this, if your movie/video does not play immediately reboot and try again.
    Note: Titles in the lists shown in red are not available under prime free, so these won't play irrespective. 
    Note2: search doesn't always work, and also saving in the Watchlist doesn't seem to work anymore. I found saving it to Favourites works. You can then find your movies/shows not in Amazon VOD but in the KODI main menu Favourites.

      The big Small Print: By entering your login details for Amazon you assume a certain risk in doing so. Sandmann has been active with Kodi for a long time. The source code for the software is open source and has been checked by security paranoid folk. The add-ons do not store login data, just an authentication cookie. Even so, the risk is all yours.

      You should now have Amazon up and running !

        ENJOY

      links:


      OLD VERSION - Amazon Prime using a Raspberry Pi & KODI

      updated 3.April.2019 This is a copy of the OLD (manual install) version. See HERE for the latest. 03 April 2019 : Amazon incorporated ...