Start Your Chinese Diesel Heater Remotely From Anywhere for £30 Using Telegram or Siri Using RPITX and Telegram-CLI on RPiZero
by AN32 in Living > Life Hacks
14085 Views, 4 Favorites, 0 Comments
Start Your Chinese Diesel Heater Remotely From Anywhere for £30 Using Telegram or Siri Using RPITX and Telegram-CLI on RPiZero
You need the controller that looks like this and the 433mhz fob. Also you need an sdr dongle with the realtek chipset (https://www.amazon.co.uk/NooElec-NESDR-Mini-Previously-Compatible/) (Cost £20 Jan 2019) and a Pi Zero W (https://thepihut.com/products/raspberry-pi-zero-w) (Cost £10 Jan 2019) and a piece of wire between 20cm and 70cm in length because we will be using the amazing RPITX to create the RF signal without any other hardware except the Pi Zero many thanks to F5OEO for creating it.
Capture the 433mhz Signals From Your Fob
Install the latest raspbian on the pi zero and add your wifi ssid and password to the wpa-supplicant (following instructions here: Installing the OS https://learn.sparkfun.com/tutorials/getting-start...
Add a 20-70cm piece of single wire to GPIO 4 on the pi zero. You can either solder or just tape over neighbouring contacts, wedge the conductor in to gpio 4 and tape over it to keep it in place.
Then ssh into your pi (either through logging into your router to see the IP, or through the hostname on mac) and login as pi (password raspberry)
Then clone Rpitx from github (instructions here: https://github.com/F5OEO/rpitx)
Now plug the rtl-sdr dongle into the pi. If it freezes for a minute this is just a power issue it will either unfreeze or you need a usb psu with more current. Check it is recognised:
lsusb
you should see the realtek usb device in the list
Now you have to run rtlmenu.sh from the rpitx directory. So lets say you cloned to /home/pi/rpitx
cd /home/pi/rpitx
sh ./rtlmenu.sh
When it runs click enter 3 times to accept the default frequencies and gain (35). If your capture doesn't work later come back and try with a lower/higher gain.
Have the controller in your hand, and choose the first option to capture, then press the on button and press enter again to stop capturing. You should of course see the symbol on the heater control unit flash, or if the heater is off it will say On and start up.
Choose the second option to replay and you should see the remote signal symbol flash on the diesel heater control - if it does happy days!! If not repeat with a different gain, check for an offset with your dongle with sdr#
Now you have to capture the other commands. Quit out of the script by selecting cancel
ls *.iq
this should now show you record.iq this is your capture, copy it to a new file:
cp record.iq dslon.iq
now run the script again (use the up arrow to go back to the sh ./rtlmenu command) and capture OFF, and then quit out, use the cp command again to make a copy and name it dsloff.iq now do the same with + and - and name them dslplus.iq and dslminus.iq
Compile Telegram-CLI and Set Up Your Bot
There is a tutorial to follow to install Telegram-CLI here: https://pimylifeup.com/raspberry-pi-telegram-cli/
There are a few issues though, if you follow the tutorial exactly you will still be missing some modules. When you get to the stage where you run the configure script it will end with an error telling you which missing modules you need, you can apt-get install the missing modules and restart it eg. if you are missing openssl run
apt-get install openssl-dev
Do this for each one that is missing until it completes, then run make. On the zero it will take a long time but you only have to compile once.
When you are done you need to register a new telegram account on another device and then go on to log into it using telegram-cli because the procedure described in the pimylifeup tutorials is out of date and new registrations are only by android and ios now. If you want to do it all on a computer, run an android phone emulator in virtualbox and use that to create the account. When you log into the account on telegram-cli you will see the activation code pop up on the device you have already registered.
Set up the bot as described in the pimylifeup tutorial, and test it by sending it a message from another client with ping and see if it responds with pong. If so good lets move on.
Lets create some scripts that call our commands. Make sure you are in the /tg directory (cd /home/pi/tg)
sudo nano dslon.sh
Now you can paste these two lines into the file and then ctrl-x Y to quit and save. We will add the shebang line so we can call these from the .lua script without using chmod. If you want you can chmod u+x to these anyway to call them just by name
#!/bin/bash
sudo ./sendiq -s 250000 -f 434.0e6 -t u8 -i dslon.iq >/dev/null 2>/dev/null
Now you need to repeat this for the other commands, name them dsloff.sh, dslplus.sh, dslminus.sh
Now you need to edit the .lua file so that it will call the commands
sudo nano actions.lua
now you want to add in your if then statements to call scripts we will create next. After the first if..then which looks out for 'ping' and responds 'pong' add these. Of course change the letters to ones of your preference. For quickness and siri control it makes sense to use single letter commands, you can of course have multiple commands for the same action.
if (msg.text=='T') then
os.execute('sh dslon.sh')
send_msg (msg.from.print_name, 'Heater On', ok_cb, false)
end
if (msg.text=='O') then
os.execute('sh dsloff.sh')
send_msg (msg.from.print_name, 'Heater Off', ok_cb, false)
end
Now if you want certain temperatures you can send 27 plus commands followed by the 35-x minus commands where x is the target temp. Just repeat the ox.execute line as many times as you need, or call a script where you repeat the send command. Thats it you're done
Enjoy Controlling Your Heater From Anywhere!
Install the screen command to open your bot and leave it running when you log out (apt-get install screen) As your power source might go down, you can add the screen command that launches telegram to a startup script (see https://www.dexterindustries.com/howto/run-a-prog... because the telegram ios app integrates with siri you can now start and stop the heater remotely handsfree in just a few seconds. Happy days! If you do not already have dedicated internet at the site with the heater you need a cheap mifi unit, the older 3g dongles are available for £15-£17 and of course you need a pay as you go sim. £5 of credit should last for years because the telegram app will use a few hundred kb a month at most. Some networks will have an expiry time for credit so be aware what it is. A new 3 sim includes some free data I believe when its registered. Of course the number of the sim doesn't matter so you can swap it with another at any time and it will all still work.. Just alter the wpa-supplicant.config to add ssid and password.
Many thanks to vysheng and F5OEO for making telegram-cli and rpitx