Wednesday 30 December 2020

Set up humidity and temperature sensor on Rasp Pi

 Having just purchased a new dehumidifier, I wanted to keep a check on the humidity in the property. I have couple of Raspberry Pi's spare so decided it would be a good idea to use these along with the DHT11 sensor. The sensor can be bought reasonably cheaply.

Set up of the sensor is really simple - I bought a pack of 5 from Amazon, I don't know how accurate with regard to humidity they are, but figured once I get a few readings I can work out the ideal time to remotely switch on the dehumidifier. For me the actual humidity was not as important as to the pattern the humidity was following.

There are 3 pins out on the sensor I bought, they are marked quite clearly, main thing to remember is the pin used for the data - I went for pin number 7, or gpio pin 4. 

I wanted to make the setup as small as possible so used a Pi 0, also wanted to use up a couple of 2gb cards I've had for ages, which really are to small and slow for much now - however by using the Raspberry Pi OS lite from here I managed to get everything working on the 2gb disk, with room to spare!!

I set up using ssh

To set up python3 and pip and the adafruit_dht library I followed instruction from this page;
https://github.com/adafruit/Adafruit_Python_DHT
sudo apt update
sudo apt install python3-pip
sudo python3 -m pip install --upgrade pip setuptools wheel
Then install the Adafruit_DHT library
sudo pip3 install Adafruit_DHT
Now to install python3 rpi.gpio control
sudo apt install python3-dev python3-rpi.gpio
I struggled with receiving the data in a useable form until after many searches I came upon;
https://electronut.in/dht11-rpi-cloud-plot/ 
this did exactly what I required, it was easy to set up and I could view the results online from wherever I happened to be. Thank you so much for taking the time to share it.

I've changed the code slightly, you need to make sure you put the correct pin number in this line;

 RH, T = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, 4) Pin number is the last number here.
Also original script stopped if the internet connection went down, I've changed it so that the program sleeps for a while then rechecks again. 
I've also set the time for each reading at 10 minutes, this is shown at the sleep(600) change the number to suit your own needs

"""

dht11_thingspeak.py

Temperature/Humidity monitor using Raspberry Pi and DHT11.
Data is displayed at thingspeak.com

Author: Mahesh Venkitachalam
Website: electronut.in

"""

import sys
import RPi.GPIO as GPIO
from time import sleep  
import Adafruit_DHT
import urllib.request, urllib.error, urllib.parse

def getSensorData():
    RH, T = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, 4)
    # return dict
    return (str(RH), str(T))

# main() function
def main():
    # use sys.argv if needed
    if len(sys.argv) < 2:
        print('Usage: python tstest.py PRIVATE_KEY')
        exit(0)
    print('starting...')

    baseURL = 'https://api.thingspeak.com/update?api_key=%s' % sys.argv[1]

    while True:
        try:
            RH, T = getSensorData()
            f = urllib.request.urlopen(baseURL +
                                "&field1=%s&field2=%s" % (RH, T))
            print(f.read())
            f.close()
            sleep(600)
        except:
            sleep(300)
            

# call main
if __name__ == '__main__':
    main()

That is most of it set up, you need to visit Thingspeak to set up your channels there, once you've done that go back to your pi and at the command prompt do;
 sudo python3 dht11_thingspeak.py YOURWRITEAPIKEY 
As I have ssh'd in, it will stop when I close the connection, so I used the nohup to keep it alive;
 sudo nohup python3 dht11_thingspeak.py YOURWRITEAPIKEY
To ensure the sensor is almost always on, I put a line in crontab so on reboot the script starts automatically
sudo crontab -e
scroll to last line and paste
@reboot sleep 200 && nohup /usr/bin/python3 /home/pi/dht11_thingspeak.py YOURWRITEAPIKEY
I found it would only work if I put the whole address in.

You can view the results of your sensor at

https://api.thingspeak.com/channels/YOUR_CHANNEL_ID



The only snag with the original code is that it's written in Python2 which is being stopped, although I got it working, I eventually used 2to3 to convert the original code to python3. 
sudo apt install 2to3
then point at your file and 
2to3 -w my_file.py 
this will overwrite the original file.

Sunday 8 November 2020

Lirc and Mopidy for Raspberry Pi with Buster

Lirc  seems a lot easier to set up with Buster - if you are using it to control Mopidy it's a doddle to set up.

Set up is assuming you have set up Mopidy on a Raspberry Pi with Buster, you will also need to have installed mpc (sudo apt install mpc)

First of all you need to get your IR receiver, the kit here is what I've used.

To connect up to the GPIO pins there are lots of images here, I used pin 2 for 5v power, pin 6 for Ground and pin 12 (GPIO 18) for data/input. You can choose whichever pins suit, but remember which one you use for the data/input as you'll need to enter it in the conf later.

If using a similar receiver to the one in the link, the wiring is as follows, with the X on the receiver facing away from you;

Pin 1 is Ground, Pin 2 is Power and Pin 3 is Data/input.

If you have a lot of info etc on the sd card I would recommend backing up the card. 

Once you have the hardware in place and if relevant you've backed up the sd card.

Start here, ssh or open a terminal window, then;

sudo nano /boot/config.txt

Scroll down to this line, remove the # and enter the gpio pin number.

# Uncomment this to enable infrared communication.
dtoverlay=gpio-ir,gpio_pin=18
#dtoverlay=gpio-ir-tx,gpio_pin=17

ctrl x to save and close

sudo reboot

Once it's restarted

sudo apt update
sudo apt install lirc

Installation might fail on Buster here because of the .dist suffix, if so the following will help, then run the install lirc again.

sudo cp /etc/lirc/lirc_options.conf.dist /etc/lirc/lirc_options.conf
sudo apt install lirc

Once installed, open,

sudo nano /etc/lirc/lirc_options.conf

and change the following lines

driver = default
device = /dev/lirc0

ctrl + x to save and exit.

Now to set up the remote config files with the scan codes;

sudo nano ~/lircd.conf

If you are using the Keyes or similar remote you can try the codes below - if not you can either use irrecord to record your own, search sourceforge for similar brand or search google.

-------------------------

# brand:                      KEYES

# model no. of remote control:
# devices being controlled by this remote:

begin remote
  name  KEYES
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9281  4484
  one           622  1657
  zero          622   513
  ptrail        622
  repeat       9241  2236
  pre_data_bits   16
  pre_data       0xFF
  gap          109259
  toggle_bit_mask 0x0

      begin codes
          KEY_VOLUMEUP                   0x629D
          KEY_VOLUMEDOWN                 0xA857
          KEY_PREVIOUSSONG                 0x22DD
          KEY_NEXTSONG             0xC23D
          KEY_PAUSE                 0x02FD
          KEY_1                    0x6897
          KEY_2                    0x9867
          KEY_3                    0xB04F
          KEY_4                    0x30CF
          KEY_5                    0x18E7
          KEY_6                    0x7A85
          KEY_7                    0x10EF
          KEY_8                    0x38C7
          KEY_9                    0x5AA5
          KEY_0                    0x4AB5
          KEY_SHUFFLE         0x42BD
          KEY_NUMERIC_POUND        0x52AD
      end codes

end remote
--------------------------------------------------------------------
ctrl and x to save and exit

Now replace the original lircd.conf with the new one;

sudo cp ~/lircd.conf /etc/lirc/lircd.conf

and reboot
sudo reboot

Now test the remote by using irw, type irw at the command prompt, then point and press remote buttons, with a bit of luck you'll get something similar to this.


ctrl + c to exit irw 

Hopefully you've produced a similar result to the screenshot above.

Now to instruct what each button will do, if you use my existing file as a temp measure then adapt to your own needs using mpc, you will also need to run irexec.
Open a new file;

sudo nano /home/pi/.lircrc
and paste in the following
-----------------------------------

begin        
        prog = irexec
        button = KEY_PAUSE
        config = mpc toggle
end
begin
        prog = irexec
        button = KEY_NEXTSONG
        config = mpc next
end
begin
        prog = irexec
        button = KEY_PREVIOUSSONG
        config = mpc prev
end
begin
        prog = irexec
        button = KEY_NUMERIC_POUND
        config = shutdown –h now
end
begin
        prog = irexec
        button = KEY_SHUFFLE
        config = mpc shuffle
end
begin
        prog = irexec
        button = KEY_VOLUMEUP
        config = mpc volume +10
end
begin
        prog = irexec
        button = KEY_VOLUMEDOWN
        config = mpc volume -10
end
# insert your playlist name between the " " 
begin
        prog = irexec
        button = KEY_1
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end
# insert your playlist name between the " " 
begin
        prog = irexec
        button = KEY_2
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_3
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_4
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_5
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_6
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_7
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_8
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_9
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_0
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end
---------------------------
ctrl + x and y to save and exit

Need to make sure irexec starts on reboot, easiest way I found was to add it to cron

sudo crontab -e
scroll to the bottom and add
irexec
ctrl + x then y to save and exit

Reboot

When it comes back up, open your chosen web client for mopidy, start a track playing then try and control it using the remote. Good luck









Wednesday 21 March 2018

Set up Orange Pi One as part of a multi room audio system - using Mopidy & Snapcast

I usually use Raspberry Pi but as the Orange Pi One was so cheap I bought one about a year ago to try out. I couldn't get it to boot up and eventually gave up trying.
Last week somebody asked if I had ever used the Orange Pi with Mopidy and I thought it was about time I tried again.
Luckily this time I had a spare 8gb class 10 micro sd card - (I had previously tried with a 4gb class 4) and once I had downloaded the image and put it on the card I got results straight away. So only use a decent, fast card!!
Took some time to sort out the bits but basic run through is listed below, hope it helps somebody.

I used an Armbian image from https://armbian.com it seems to be a recommended source.and in here
There is plenty of choice, I tried a desktop system with Ubuntu and although I was impressed with the speed it went, I had problems with getting Mopidy to work, I put this down to Pulse Audio being preinstalled, but I now don't think it was Pulse causing the problems.

I used the Debian Stretch, this is command line only. But there are loads to choose from.
https://dl.armbian.com/orangepione/archive/ 
Armbian_5.38_Orangepione_Debian_stretch_next_4.14.14

So download and write image to card - put the card in machine and boot.

SSH in and you will be asked for name & password, name is root and password 1234.

You will need to change password, I went for musicbox.
Then you will create a new user, I called mine pi and password of raspberry.
Asks your name etc can just hit 'enter' all those, unless you want it personalised.
Instructions are on Armbian website on all this.

Whilst signed in as root I

apt update
apt upgrade

reboot

I then signed in as user pi and password raspberry - you could sign in as root and carry on.

I took ages to sort out Mopidy, it was playing but no sound, Snapclient and systems sounds were fine but not matter what I did I could not sort out Mopidy - eventually I came across  a link on Mopidy site and some of the files aren't installed in basic versions of Debian. Result is you need these files.

sudo apt install gstreamer1.0-alsa       Required for Mopidy
sudo apt-get update
sudo apt-get install avahi-daemon       Required for Snapcast (Client)
sudo reboot

Follow mopidy instructions for install and to run as a service (sudo dpkg-reconfigure mopidy)
Install Spotify

sudo apt-get install mopidy-spotify

You'll need pip for install later

sudo apt update
sudo apt install python-pip

You will need to fill in your /etc/mopidy/mopidy.conf file, I copy and pasted one from another Pi.
sudo nano /etc/mopidy/mopidy.conf file

Don't forget to visit github page to authenticate your Spotify account. Then enter the secrets into your /etc/mopidy/mopidy.conf file. 


You have plenty of choices for web extension, for simplicity I use musicbox web client so pip on and install.

sudo reboot

Try it and see if anything comes from speakers - if not;

Use alsamixer to check volume of card and get the card number, it was 1 in my case.

alsamixer

Make the file
sudo nano /etc/asound.conf

and enter the text
pcm.!default {
type hw
card 1 # your card number here
}
ctl.!default {
type hw
card 1 # your card number here.
}

Save and exit.

sudo reboot

Try again - hopefully there will be music!!

To set up for use as a multi room audio please read on - I assume you already have snapserver installed and running somewhere.

Below is only my way of making the multiroom system work - there are probably other ways but this works for us at home.
On clients where you intend playing music independently of snapserver/client, i.e. using the satellite as a standalone audio box as well as part of the multi room audio you need the webclient to have a stop button, as this means Mopidy will release the audio card, if it only has pause button Mopidy will keep hold of the audio card and snapclient will close when you try to use it.
Snapclient itself lets go of the card seconds after stream stops so it's not a problem going the other way.

Mopidy-moped has stop button but I prefer Iris. If the version of Iris doesn't behave try Mopidy moped
Unfortunately with many upgrades to Iris it's intermittent whether the stop button stops or pauses.
Current version is 3.14.2 however this doesn't stop, only pauses play
I am using 3.12.4 which does stop and clears playing track.
Up to you how you do it, but if you go for 3.12.4 remember not to upgrade.

Download, unzip and install the file

sudo wget https://github.com/jaedb/Iris/archive/3.12.4.tar.gz
tar -xvzf 3.12.4.tar.gz
sudo easy_install Iris-3.12.4

Open Iris and fill in your details on the settings page. 

sudo reboot

Play a tune using Iris and make sure that when you click the stop button, the music stops and the progress bar goes back to zero.

Download and install the latest version of Snapclient

sudo wget https://github.com/badaix/snapcast/releases/download/v0.13.0/snapclient_0.13.0_armhf.deb

sudo dpkg -i snapclient_0.13.0_armhf.deb

Install missing dependencies, there are a lot of them!!

sudo apt-get -f install

It won't install properly until you have got the dependencies

sudo reboot

You may need to reboot your snapserver machine - once back up you should see the Orange Pi appear in the list of clients. Start to play from snapserver machine, if you don't hear anything on the Orange Pi get a list of the audio card numbers and select yours from it.

sudo snapclient -l

sudo systemctl stop snapclient

Then run through the numbers until you find the right one

snapclient -s 1
snapclient -s 2

eventually as long as all is ok you will find the right number. If you are having problems shut down mopidy to make sure it's not holding onto the audio card.

Enter the correct card number in the

sudo nano/etc/default/snapclient 
snapclient_opts="-s 14"

Hopefully you'll be up and running now.





















Saturday 6 February 2016

Setting up LIRC for the Musicbox.

I wanted an easy way to use PiMusicbox without having to use the pc or phone to control it every time.
I tried it with buttons but decided to use a remote control in the end, I didn't have the knowledge to wire various buttons into GPIO. Using LIRC it's all set up for me, I just have to change a few files to make it do what I want.
With a 10 button remote it's a bit limited but I can change track, change volume, have a choice of 10 different playlists and shutdown the Pi.
I used to use google TTS to tell me the names of the playlists, that stopped - maybe because of Google requiring a confirmation of reality and it just wouldn't work. Now I record them myself as there are only 10 anyway and I don't change them very often.


The Receiver.

The Keyes one is below, only disadvantage I find is that the whole thing has to be on show, 

in some applications I find one with a detachable receiver easier to place.





I think it's quite straight forward, 
GND connects to ground, Pin 6 or GND. 
VCC connects to Pin 1 or 3.3v. 
DAT or IN connects (in my case) to Pin 12 (or GPIO18)

I have connected into Raspberry Pi A+, B+ and Zero and the pins are the same location.

Have a look here for pinout diagram for the Pi.

When installing LIRC, you will note that I change the ./etc/modules file and use pin 18, obviously if you connect onto a different pin you will need to change that.

The Keyes handset is the one that the config file on the following pages is for. If you want to use your own, perhaps an old TV remote, you will need to find or record the appropriate config file. It doesn't matter which receiver you choose. 


Installing LIRC

Most of the installing information has been copied from Alex's site here - thank you
I have used same to install on Pi 0, Pi B+ and A+, but I should try it on an old setup first just in case. 

The config files relate to the Keyes brand of remote - widely available and remarkably cheap

SSH into the pi;

sudo apt-get update
                    
sudo apt-get install lirc

Click yes to any questions, ignore any messages once installed.
---------------------------------------------------------------------------

You have to modify two files before you can start testing the receiver.

Open and add to your /etc/modules file

sudo nano /etc/modules

lirc_dev
lirc_rpi gpio_in_pin=18

Ctrl & x then y and enter to save and exit.

Change your /etc/lirc/hardware.conf file to:

sudo nano /etc/lirc/hardware.conf

########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"

# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false

# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false

# Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################

Ctrl & x then y and enter to save and exit.

Now restart lircd so it picks up these changes:

sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

Edit your /boot/config.txt file and add:

nano /boot/config.txt

dtoverlay=lirc-rpi,gpio_in_pin=18

Ctrl & x then y and enter to save and exit.
Reboot to implement the changes.


Testing the IR receiver is relatively straightforward.
Run these two commands to stop lircd and start outputting raw data from the IR receiver:

sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

Point a remote control at your IR receiver and press some buttons. You should see something like this:


space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903 
 
Press ctrl & c to exit
If there is no reaction then check the receiver is connected properly, that you have a battery in your remote and run through the above steps again.

This config file is just for the Keyes brand of remote control.
You will need to record/search for your own remote if you wish to use a different one, you can try the LIRC site or use irrecord to record your own.

To set up config files, open the lirc config files;
 
nano /etc/lirc/lircd.conf

Clear any info in there, then paste all the text between the ###'s.
Once pasted use Ctrl & x then y enter to save and exit.
#########################################################################
# Please make this file available to others
# by sending it to
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan 19 10:13:19 2014
#
# contributed by
#
# brand:                      KEYES
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  KEYES
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9281  4484
  one           622  1657
  zero          622   513
  ptrail        622
  repeat       9241  2236
  pre_data_bits   16
  pre_data       0xFF
  gap          109259
  toggle_bit_mask 0x0

      begin codes
          KEY_VOLUMEUP                   0x629D
          KEY_VOLUMEDOWN                 0xA857
          KEY_PREVIOUSSONG                 0x22DD
          KEY_NEXTSONG             0xC23D
          KEY_PAUSE                 0x02FD
          KEY_1                    0x6897
          KEY_2                    0x9867
          KEY_3                    0xB04F
          KEY_4                    0x30CF
          KEY_5                    0x18E7
          KEY_6                    0x7A85
          KEY_7                    0x10EF
          KEY_8                    0x38C7
          KEY_9                    0x5AA5
          KEY_0                    0x4AB5
          KEY_SHUFFLE         0x42BD
          KEY_NUMERIC_POUND        0x52AD
      end codes

end remote
#########################################################################

Make sure you have saved and closed the above file. 

To make sure the changes have been picked up by LIRC, stop and restart LIRC

sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

type irw
then enter

Point the remote at the sensor, press a button and it should say on screen what that button is programmed to do.

ctrl & c to exit.


We want it to run on boot, so need to add irexec into startup.sh

nano /opt/musicbox/startup.sh
and add almost near the end

sudo -u root irexec -d


Decide what each key will do.

This is where you decide what each key will do.

To assign what the keys actually run you need a new config file so
You will see all the operations are done using mpc a full list of options is here
nano /root/.lircrc

 then copy and paste all the text between the lines.
-------------------------------------------------------
begin
        prog = irexec
        button = KEY_PAUSE
        config = mpc toggle
end
begin
        prog = irexec
        button = KEY_NEXTSONG
        config = mpc next
end
begin
        prog = irexec
        button = KEY_PREVIOUSSONG
        config = mpc prev
end
begin
        prog = irexec
        button = KEY_NUMERIC_POUND
        config = shutdown –h now
end
begin
        prog = irexec
        button = KEY_SHUFFLE
        config = mpc shuffle
end
begin
        prog = irexec
        button = KEY_VOLUMEUP
        config = mpc volume +10
end
begin
        prog = irexec
        button = KEY_VOLUMEDOWN
        config = mpc volume -10
end
# insert your playlist name between the " " 
begin
        prog = irexec
        button = KEY_1
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end
# insert your playlist name between the " " 
begin
        prog = irexec
        button = KEY_2
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_3
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_4
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_5
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_6
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_7
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_8
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_9
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end

begin
        prog = irexec
        button = KEY_0
        config = mpc stop; mpc clear; mpc load "Your playlist here";mpc play;
end
------------------------------------------------------
Copy between the lines and paste into the .lircrc file.
Ctrl&x  y & enter to save and exit
Reboot system to pick up all changes – it might take a while esp if it’s still scanning for new music.

Sudo Reboot

I have 10 playlists on the remote - as I can't remember which is which I have done some recordings of the playlist name, stored them as mp3's in a folder called 'talky', assigned them using .licrc. 
Now when I press button 1 it says 'All my tracks', button 2 'This Weeks Specials' Button 3 'Films and shows'. Pressing the button again plays that playlist otherwise move on to one I want. Therefore button 1 looks like this in .licrc


begin
        prog = irexec
        button = KEY_1
        config = mpc clear; mplayer ~/talky/everything.mp3;
        config = mpc load "All my Tracks";mpc shuffle;mpc play;

end

Good luck - I hope it worked
################################################################################

This is a full config including a list of all the codes you can use with the remote

# Please make this file available to others
# by sending it to
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan 19 10:13:19 2014
#
# contributed by
#
# brand:                      KEYES
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  KEYES
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9281  4484
  one           622  1657
  zero          622   513
  ptrail        622
  repeat       9241  2236
  pre_data_bits   16
  pre_data       0xFF
  gap          109259
  toggle_bit_mask 0x0

      begin codes
          KEY_VOLUMEUP                   0x629D
          KEY_VOLUMEDOWN                 0xA857
          KEY_PREVIOUSSONG                 0x22DD
          KEY_NEXTSONG             0xC23D
          KEY_PAUSE                 0x02FD
          KEY_1                    0x6897
          KEY_2                    0x9867
          KEY_3                    0xB04F
          KEY_4                    0x30CF
          KEY_5                    0x18E7
          KEY_6                    0x7A85
          KEY_7                    0x10EF
          KEY_8                    0x38C7
          KEY_9                    0x5AA5
          KEY_0                    0x4AB5
          KEY_SHUFFLE         0x42BD
          KEY_NUMERIC_POUND        0x52AD
      end codes

end remote

KEY_0
KEY_102ND
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_A
KEY_AB
KEY_ADDRESSBOOK
KEY_AGAIN
KEY_ALTERASE
KEY_ANGLE
KEY_APOSTROPHE
KEY_ARCHIVE
KEY_AUDIO
KEY_AUX
KEY_B
KEY_BACK
KEY_BACKSLASH
KEY_BACKSPACE
KEY_BASSBOOST
KEY_BATTERY
KEY_BLUE
KEY_BLUETOOTH
KEY_BOOKMARKS
KEY_BREAK
KEY_BRIGHTNESS_CYCLE
KEY_BRIGHTNESSDOWN
KEY_BRIGHTNESSUP
KEY_BRIGHTNESS_ZERO
KEY_BRL_DOT10
KEY_BRL_DOT1
KEY_BRL_DOT2
KEY_BRL_DOT3
KEY_BRL_DOT4
KEY_BRL_DOT5
KEY_BRL_DOT6
KEY_BRL_DOT7
KEY_BRL_DOT8
KEY_BRL_DOT9
KEY_C
KEY_CALC
KEY_CALENDAR
KEY_CAMERA
KEY_CANCEL
KEY_CAPSLOCK
KEY_CD
KEY_CHANNEL
KEY_CHANNELDOWN
KEY_CHANNELUP
KEY_CHAT
KEY_CLEAR
KEY_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