Python Forum
Sending string commands from Python to a bluetooth device
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending string commands from Python to a bluetooth device
#7
Actually this is very helpful for me, and thank you for your every minute on this code. My goal is sending strings to the HC-05 with clicking on these buttons. And I think I can do this with using this code:

import bluetooth

def connect ():
    bd_addr = "00:19:08:00:30:24"
    port = 1
    sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
    sock.connect((bd_addr, port))
    sock.send("standby")
    sock.close()

connect()[error]Traceback (most recent call last):
  File "C:/Users/Ulaş/AppData/Local/Programs/Python/Python39/tryout8.py", line 1, in <module>
    import bluetooth
ModuleNotFoundError: No module named 'bluetooth'[/error]
I couldn't solve this error since I'm using win10 and As I understand it is much harder than doing it on linux. Like I said I can do this process on a windows program which is " https://www.microsoft.com/store/productId/9WZDNCRDFST8 " and when I write the strings (below) the arduino executes the command with using IR and RF.(this part is about Electricity which is the part that I understand mostly) Here is a photo of the Bluetooth terminal which is on the microsoft link.( For you to see the my usage style of that program). https://ibb.co/Rjssyvh >> As you can see on this when I wrote btcheck it responses as OK and I can understand that if it my pc is connected to the module or not. https://ibb.co/Pxt7k3h On this photo you can see that how I send the string commands such as standby, mute and head up.

Here are the strings that bluetooth module understands:

For checking bluetooth connection

btcheck

For the bed

head up
head down
head fwd
head rev
head stop
level up
level down
level fwd
level rev
level stop

For TV

standby
mute
program up
program down
volume up
volume down

For curtain

roller close
roller open
roller down
roller up
roller stop

For air conditioner

ac on
ac off
Reply


Messages In This Thread
RE: Sending string commands from Python to a bluetooth device - by Rovelin - Aug-31-2021, 05:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending a text from Python sawtooth500 2 335 Apr-14-2024, 01:56 PM
Last Post: sawtooth500
  Read data via bluetooth frohr 9 3,730 Jul-10-2022, 09:51 AM
Last Post: frohr
  Connect to HC-05 Bluetooth (NOT BLE) korenron 0 1,551 Jun-26-2022, 09:06 AM
Last Post: korenron
  Read buffer from bluetooth frohr 2 2,256 Jun-01-2022, 01:31 PM
Last Post: frohr
  Scan for Bluetooth device korenron 0 2,736 Jan-10-2022, 01:06 PM
Last Post: korenron
  ModuleNotFoundError: No module named 'bluetooth' Error Rovelin 4 12,479 Aug-31-2021, 04:04 PM
Last Post: Rovelin
  Python library for win32 console commands eldiener 3 3,614 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,076 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 2,340 May-18-2021, 06:31 AM
Last Post: Skaperen
  Bluetooth send message after connecting? korenron 2 2,744 Apr-26-2021, 05:50 AM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020