• You Jun

Khadas Blog  | How To  Send LAN IP Address To Telegram Chat

Updated: Mar 9, 2020

Get your Khadas VIM SBC to notify you when it boots up!

1. Login To Your Khadas VIM Via SSH

$ ssh khadas@x.x.x.x $ khadas@x.x.x.x's password: khadas

2. Create A Bash Script

$ cd /home/khadas $ nano

3. Paste The Following Telegram Web-Request String

...paste this into the nano editor...but edit it first! !/bin/bash curl "<bot-api-key>/sendMessage?chat_id=<chat-id>&text=<name-of-your-vim>"$(hostname -I | sed 's| |%20|g')""

Substitute these variables with your own, I will explain how to get them later:

  • <bot-api-key>

  • <chat-id>

  • <name-of-your-vim> and exit the following keys... [ Control-X ] [ y ] [ Enter ]

Do note that you can modify $(hostname -I | sed ‘s| |%20|g’) to include additional information that you want to pull from the Khadas VIM. Just remember to substitute all spaces with %20 using sed!

4. Edit The rc.local File To Run The Bash Script On Boot

$ sudo nano /etc/rc.local
...above the line that says "exit 0"...add the following line... /home/khadas/ and exit the following keys... [ Control-X ] [ y ] [ Enter ]

5. Reboot Your Khadas VIM To Test

Alternatively, just run the bash script within the ssh session, to see if it works, before you reboot to do a final test.

$ bash /home/khadas/

You should see this as the result:

6. How To Get A <bot-api-key>

Open your Telegram Chat app for your smartphone or PC, and type “botfather” into the search field. Here’s a link if you can’t find him: for... botfather to botfather using these commands... /start /newbot <input name of your bot> <input user name of your bot>

The <bot-api-key> will be highlighted in red colour! Copy it!

7. How To Get A <chat-id>

Create a new group. Press the compose button, then press New Group.

Add at least one user into this group. Don’t add TeleCast v1.0, add another user or even the bot you created earlier in step 6.

Just press next to continue on.

Give your group a name…in my case, I called it the VIM_Demo_Group.

Press the three dots  and then press Info.

Inside the information pane, press + Add Member.

Add the bot you had created previously in step 6. Telegram search is a bit flaky, be sure to type your bot’s full name, exactly.

Now visit the TeleCast v1.0 bot for real, and type /start, to begin interacting with it. Here’s a link if you can’t find it:

Now you may add TeleCast v1.0 into your newly created Telegram Group.

After TeleCast v1.0 has been added to your group, type /telecast.

Return to the TeleCast v1.0 bot (, and type /chn, it will then display your <chat-id> of the group you just created! Copy it! It always starts with a -minus sign. Remember to copy the minus sign as well!

8. Naming Your Khadas VIM With <name-of-your-vim>

You can name your Khadas VIM anything you like, just be sure that it follows some rules…

"My Name" should be spelt as "My%20Name" without the double-quotes. Any special characters should be converted to web-safe characters, please refer to:

For The Lazy:

If you don't want to go about getting your own <bot-api-key>, and <chat-id>, you're welcome to use mine first. Simply copy this exact string into your bash script.

#!/bin/bash curl ""$(hostname -I | sed 's| |%20|g')""

<bot-api-key> 606694295:AAEnUENJJwhDBBQzehVtupaxFdQ-2T6p0LA <chat-id> -285153354 <name-of-your-vim> VIM%20Booted%20

You can visit the Telegram Group here, its not a secret, you're welcome to add your own bots, just don't spam please:

Khadas Products Used In This Post:

Links To Other Articles (in progress):

367 views0 comments