This example sends a message from the Pico LTE to a Telegram chat through a Telegram bot and the Telegram Bot API, over the cellular connection. No extra hardware is needed.
Before you begin
Hardware
- Sixfab Pico LTE or Pico LTE 2Registered and active in Sixfab Connect, connected to the computer with the micro USB cable.
Software
- Thonny with MicroPython and the Pico LTE SDKSet up as in the quickstart.
- config.jsonIn the root of the board: Prepare the configuration file.
- Telegram accountIn the Telegram app or on the web.
Create bot
-
Start BotFather.
Search for BotFather in Telegram and start a chat with it.
/startlists its commands.
-
Create bot.
Send
/newbot, then the bot’s name, then its username. The name and the username are different: the next steps use the username.
-
Keep token.
BotFather gives you a token for the HTTP API, such as
1234567890:XXX9WhkY694zP856M4xNLcr9pXX-xxxxxxx.Keep the token secret: anyone with it controls the bot.
Find chat ID
-
Start chat with bot.
Open the bot in Telegram and send
/start.
-
Read chat ID.
Open
https://api.telegram.org/bot<YOUR_ACCESS_TOKEN>/getUpdatesin a browser, with your token. The chat ID is theidofchat:{ "ok": true, "result": [ { "update_id": 679821252, "message": { "message_id": 15, "from": { "id": 70*******, "is_bot": false, "first_name": "YOUR_NAME", "username": "YOUR_USERNAME", "language_code": "en" }, "chat": { "id": 70*******, ⬅ CHAT_ID "first_name": "*", "username": "*", "type": "private" }, "date": 1686954941, "text": "/start", "entities": [ { "offset": 0, "length": 6, "type": "bot_command" } ] } } ] }If the result is empty, see Troubleshooting.
Run example
-
Set token and chat ID in config.json.
{ "telegram": { "token": "YOUR_BOT_TOKEN_ID", "chat_id": "YOUR_GROUP_CHAT_ID" } } -
Run script.
Open
examples/telegram/send_message.pyfrom the SDK repository in Thonny and click Run.
INFO: Sending message to Telegram channel... INFO: Result: {'status': 0, 'response': ['+QHTTPGET: 0,200,268', '{"ok":true,"result":{"message_id":14,"from":{"id":5612730189,"is_bot":true,"first_name":"Pico LTE","username":"Pico LTE BOT"},"chat":{"id":70*******,"first_name":"YOUR_NAME","username":"YOUR_USERNAME","type":"private"},"date":1696047950,"text":"PicoLTE Telegram Example'], 'interval': 0} -
Check chat.
The message appears in the chat with the bot.

Troubleshooting
If /getUpdates returns {"ok":true,"result":[]} and no chat ID, send a few messages to the bot, then reload the page.