Decode and transmit Hisense Aircond IR codes using RPi and LIRC
Update PIP
python -m pip install --upgrade pip
Install required libraries
pip install virtualenv
Follow steps to setup LIRC for Buster
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=235256
Run command to generate mode2 file:
mode2 -d /dev/lirc1 -m > test.mode2
Aim remote at RPi and Ctrl+C once done
Navigate to new workspace folder
cd path/to/workspace
git clone https://github.com/Palt0n/kh-serverstats.git
Create python virtual enviroment with venv
python -m venv env
To activate venv
source env/Scripts/activate
To check if venv is activated
which python
- This command should return the path for python.
- This path should be located in the local env folder
If you want to exit venv later (DONT EXIT NOW!), use
deactivate
Have to repeat the pip upgrade in venv
python -m pip install --upgrade pip
Ensure that venv is activated, then install the libararies using pip
pip install -r requirements.txt
Or run
pip install numpy
pip install matplotlib
To obtain Y for X values
python plot_mode2.py
Adjust value until a good R squared value is obtained
Once good values are obtain, edit parse_mode2.py
with the new values and run:
python parse_mode2.py Hisense_Aircond_Power.mode2.example
Run command to store conf file:
irrecord -a test2.lirc.conf
sudo lircd --device /dev/lirc0 --driver devinput
sudo lircd --device /dev/lirc0
sudo cp test2.mode2 /etc/lirc/lircd.conf.d/test.conf
sudo /etc/init.d/lirc restart
pip freeze > requirements.txt
Aircond uses LRC to calculate its Checksum
XX = Checksum,00000000,0000----,00000000,00000000,0000----,00000000,X,Checksum,00000000,00000000,00000000,00000000,00000000,--------,--------,X,00000000,00000000,Temp----,--------,00000110,10000011
30 = 00001001,00000000,00001000,00000000,00000000,00000001,00000000,X,01101011,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,11100010,00000110,00000110,10000011
29 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,01011111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,11010010,00000010,00000110,10000011
28 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,01001111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,11000010,00000010,00000110,10000011
27 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,00111111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,10110010,00000010,00000110,10000011
26 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,00101111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,10100010,00000010,00000110,10000011
25 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,00011111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,10010010,00000010,00000110,10000011
24 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,00001111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,10000010,00000010,00000110,10000011
23 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,11111111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,01110010,00000010,00000110,10000011
22 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,11101111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,01100010,00000010,00000110,10000011
21 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,11011111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,01010010,00000010,00000110,10000011
20 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,11001111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,01000010,00000010,00000110,10000011
19 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,10111111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,00110010,00000010,00000110,10000011
18 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,10101111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,00100010,00000010,00000110,10000011
17 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,10011111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,00010010,00000010,00000110,10000011
16 = 00001010,00000000,00001000,00000000,00000000,00000010,00000000,X,10001111,00000000,00000000,00000000,00000000,00000000,00011010,10010101,X,00000000,00000000,00000010,00000010,00000110,10000011
How to Calculate First Checksum:
00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000 00001000
00000001 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010 00000010
^ Raw Values from start until Second "X" (Omit all zero)
________________________________________________________________________________________________________________________________________________
00001001 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010 00001010
^ Checksum Calculated using XOR
How to Calculate Second Checksum:
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
00011010 00011010 """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """"""""
10010101 10010101 """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """"""""
00000110 00000010 """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """""""" """"""""
^ Raw Values after Second and Third "X"s (Omit all zero)
________________________________________________________________________________________________________________________________________________
10001001 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101 10001101
^ Calculated using XOR
11100010 11010010 11000010 10110010 10100010 10010010 10000010 01110010 01100010 01010010 01000010 00110010 00100010 00010010 00000010
________________________________________________________________________________________________________________________________________________
01101011 01011111 01001111 00111111 00101111 00011111 00001111 11111111 11101111 11011111 11001111 10111111 10101111 10011111 10001111
^ Checksum Calculated using XOR
________________________________________________________________________________________________________________________________________________
01101011 01011111 01001111 00111111 00101111 00011111 00001111 11111111 11101111 11011111 11001111 10111111 10101111 10011111 10001111
^ Checksum from raw
pi@raspberrypi:~ $ irsend SEND_ONCE MY_REMOTE MY_TEST
do_connect: could not connect to socket
connect: No such file or directory
sudo systemctl start lircd.service
sudo systemctl status lircd.service
sudo systemctl restart lircd && irsend SEND_ONCE MY_REMOTE MY_TEST2
sudo rm /etc/lirc/lircd.conf.d/test.conf && sudo nano /etc/lirc/lircd.conf.d/test.conf
while(exit 0); do irsend SEND_ONCE MY_REMOTE MY_TEST2; sleep 1;done