TextPlayBulb : REST Enabled PlayBulb Using Raspberry Pi 3, BLE and Telegram : 3 Steps - jacobsonlonarterfes
Introduction: TextPlayBulb : REST Enabled PlayBulb Using Raspberry Protease inhibitor 3, BLE and Telegram
This instructable shows how to connect to a PlayBulb Colour in bluetooth LED lamp using Python, a Boo Pi 3 and Bluetooth library and to protract the controls via a REST API for an IoT scenario, and as a bouns, the project too shows how to put out the REST API to control your PlayBulb over an IM schoolbook client e.g. Telegram, much as lecture your automated home via text.
This visualize is establish on 3 modules :
- pyBulbDriver : Connect to the PlayBulb via BLE gatttool and python.
- pyBulbServer : Using the pyBulbDriver to expose the playbulb control via REST API.
- pyBulbMessenger : Connecting to a telegram bot to send and receive commands via telegram client installed happening whatsoever smart phone, and using the REST API to issue commands to the PlayBulb.
You derriere ringer the project via git deposit : https://github.com/FireLin/textplaybulb.git
Goal of Project:
To create a base tool for interacting with your bulb via diverse modalities such every bit texting for now, future scenarios could involve speech communication commands, gesturing to the lamp ... etc.
Other resources used to make this instructable:
- PlayBulb Color Bluetooth Protocol : https://github.com/Phhere/Playbulb/blob/master/pr...
- Connecting Python to Playbulb via Bluetooth : https://github.com/ianrenton/playbulb-tools
- Setting up the telegram bot : https://web.instructables.com/Idaho/Set-upward-Telegram-B...
Contribution
pyBulbDriver is extended to cost more flexible and parameterized for ease of future denotation, building a scenario to allow you to fiddle with texting your lamp. Simple interface for testing and fiddling around.
Restriction
The number one wood is written for PlayBulb Colour, for other types of PlayBulb e.g. Original Beaver State standard candle, the bluetooth code in pyBulbDriver necessarily to changed according to the aforementioned protocol.
You motivation to register a telegram account, and get an api key, which you minimal brain damage in the pyBulbMessenger.py, take after the setting up the telegram bot in Other resources.
Step 1: Setting Up the Project
1. Acquiring your API key from Telegram
>> Follow the current instructable to get your API key https://www.instructables.com/Idaho/Set-up-Wire-Bo...
>> Add your api key to protean api in pyBulbMessenger.py
2. Setting your PlayBulb Name in pyBulbDriver
>> For the gatttool to find the drop a line twist, set your device name to be scanned using pyBulbDriver.scanForBulb("PLAYBULB Colouring material"). Example can be found in pyBulbServer.py to fix upward your REST Server
3. To protrude the labor
>> You need to start pyBulbServer.py first, then followed by pyBulbMessenger.py for the texting. You can test the pyBulbServer commands victimization CURL.
4. Material Needed :
>> Razz Pi 3 and PlayBulb Color or PlayBulb Candle
>> Installing Telegram for Mechanical man or iOS
5. Installation of Rasberry Pi 3 LE Bluetooth :
HTTP://www.elinux.org/RPi_Bluetooth_LE
Step 2: Walking Through the Code
pyBulbDriver.py
pyBulbDriver contains the driver classes for connecting to the PlayBulb via BLE
pyBulbDriver can be exploited also for any other generic projects, as IT only contains the code to scan and set finished playBulb connections.
The main Genus Apis for Drug user Application port :
- scanForBulb(devicename:String) > To scan for the PlayBulb operating room PlayBulbs via their device name
- setBulbColor(s:int ,r:int ,g:int ,b:int) > To define the light and RGB color (0 to 255) values
-
setBulbEffect(s:int ,r:int ,g:int ,b:int ,mode:int ,onbeat:int, offbeat:int) > Connatural to setBulbColor, but includes the type of effect and speed. To know much assay the color communications protocol Effects section https://github.com/Phhere/Playbulb/spot/master/pro...
Therein class you will also uncovering other helper methods meant for data integrity check and not for user interface
- convertRGBToHexaCmd(s,r,g,b)
- convertIntToHex(number)
- checkModeAndSpeed(mode,offbeat,onbeat)
- checksRGBInBounds(s,r,g,b)
pyBulbServer.py
pyBulbServer exposes the User Application user interface into Reposeful hyperlinks using PUT and JSON to send and receive data to the pyBulbDriver. Also the scan and low-level formatting of the BLE connection is made when the server is activated.
pyBulbResource(Resource) channels the calls to the Lie Server using color and effect to define the bulb command.
Example For high an effect :
http://127.0.0.1/medulla/impression
JSON Carry > {data':'{"s":0,"r":255,"g":255,"b":255,"m":1,"on":15,"off":15}'}
pyBulbMessenger.py
Finally pyBulbMessenger is responsible for interfacing the Telegram bot connected to your telegram smart phone client. For more details about how to configure and connect to a telegram bot check https://www.instructables.com/id/Set-rising-Wire-Bo....
cmdHandler(bot, update) is where the text commands are characterized and connected to the PlayBulb via the Reposeful API.
Currently the project exclusively take over text, another finish is to also send registered voice messages that would be sent to a speech recognizer to activate other commands (Not Implemented Notwithstandin).
Step 3: Conclusion
The current computer architecture intent was more approximately simplification than scalability. Still missing group connectivity, also more applications concerning texting the bulb either for straight bidding or playful interaction is still under research.
By subscribing to git repo OR succeeding, more details will seminal fluid on these updates. The cause for such a project was to interface the playBulb and creating a Quiet user interface for ease of growing in an IoT (cyberspace of things scenario) but too to open the chance to use assorted modalities via the IM Client telegram much as pictures, voice and textbook to interact with appliances from a research perspective.
Be the First-class honours degree to Share
Recommendations
-
Anything Goes Contest 2022
Source: https://www.instructables.com/TextPlayBulb-REST-Enabled-PlayBulb-Using-Raspberry/
Posted by: jacobsonlonarterfes.blogspot.com
0 Response to "TextPlayBulb : REST Enabled PlayBulb Using Raspberry Pi 3, BLE and Telegram : 3 Steps - jacobsonlonarterfes"
Post a Comment