I have installed bluetooth with
sudo apt-get install bluetooth bluez-utils blueman
I can find my mobile phone with
hcitool scan
The problem is when i try to use bluetooth in python file
import bluetooth
works fine. But when I try
nearby_devices = bluetooth.discover_devices()
It's not working. Error is
AttributeError: 'module' object has no attribute 'discover_devices'
Based on some web pages that should work.
P.s. basically I would like to send text file to my mobile device programmatically. And this is begining of that proces.
I have fixed the problem. It was very silly mistake. If I could I would delete the question. I have named my other file bluetooth in the same folder. So when I wrote import bluetooth it was my other python file that was imported not bluetooth module.
Related
I am currently building an application on Raspberry Pi using Python, and I am trying to connect to the wifi. The package I am using is wifi 0.3.8 installed via pip3.
The code looks like this for connecting:
cell = wifi.Scheme.find('wlan0', ssid)
scheme = wifi.Scheme.for_cell('wlan0', cell.ssid, cell, password)
scheme.save()
scheme.activate()
There are several problems I've encountered:
Uses ifup and ifdown
The current problem with the package is it uses /sbin/ifup and /sbin/ifdown. These are deprecated and do not work. My hack fix was to reroute to use /sbin/ifconfig wlan0 up and /sbin/ifconfig wlan0 down. Yes very hacky but it worked.
Modifies /etc/network/interfaces
The biggest problem I've encountered is modified /etc/network/interfaces by placing a connection string in there with something like:
source-directory /etc/network/interfaces.d
uface wlan0-[network-ssid-name]
Which breaks the wifi completely. I've had to re-type the entire configuration file to get it working again. It SHOULD be modifying /etc/wpa_supplicant/wpa_supplicant.conf only.
Would anyone have any suggestions on how to correctly connect to the wifi using Python?
I've been following this tutorial: https://circuitdigest.com/microcontroller-projects/arduino-python-tutorial
import pyserial didn't return any errors, but when I run my python code, I get the following error:
SerialException: could not open port 'com18': WindowsError(2, 'The system cannot find the file specified.')
Anyone know how to fix this?
I copy what you can read in the tutorial:
ArduinoSerial = serial.Serial('com18',9600)
Note: It is very important to mention the correct COM port name. It can found by using the Device manager on your computer.
When you have plugged your arduino, windows has chosen another COM number.
The port can be found directly in arduino IDE. It detects all devices connected on USB; but the IDE do not know which one is your arduino. In the menu tools / port you will see the list of COM on your computer.
If no COM is proposed, then you miss a driver for your card under windows --> google for it.
I am using Python 2.7 and wifi library (https://wifi.readthedocs.org/en/latest/) on a Raspberry Pi. I have managed to install wifi library using:
sudo pip install wifi
on the terminal. The library seems to work but I can't figure out the way to connect to a wifi using a password. The documentation on the website is a bit difficult to understand, especially if you are a Python noob like me. I used this:
>>> from wifi import Cell, Scheme
>>> Cell.all('wlan0')
and I got all the wifi networks available and also the one I want to connect to called test1. So I am sure that the library works. I followed the steps on the website but got a permission denied error at:
>>> scheme.save()
Also, before that there was this command:
>>> scheme = Scheme.for_cell('wlan0', 'home', cell)
Does anyone know what that 'home' refer to? Is it the SSID name? Can anyone help me connect to a wifi called test1 whose password is passwordtest1? Is there any easier way to connect to wifi through terminal so as not to use Python?. Thanks in advance.
After some research, I didn't find a way to connect easily to a wifi using Python on a Raspberry Pi. So I solved my problem by using the wifi command on the Terminal:
sudo wifi connect --ad-hoc SSID_Name
Which automatically asks me for an input: passkey> .Where you can actually type the password, press enter and after that it automatically connects to the wifi. After that I can run my Python script which needs a connection to the internet in order to run. The wifi command is preferable to other terminal commands when it comes to my problem cause it needs less time to connect to a wifi manually. For example it is preferable to the process which uses this terminal command:
sudo nano /etc/network/interfaces
I hope this helps everyone who has the same problem.
I wanted my raspberry pi to connect to an Informix database thru Python.
I tried installing the InformixDB module for python but I get an error as
NameError: name 'arch_' is not defined
But this is caused because I didn't have an Informix Client SDK installed on the pi which does the underlying work of connecting to the DB and the module is just a wrapper. I searched the IBM downloads but couldn't find the package for ARM architecture.
I've also tried the following links but to no good.
https://code.google.com/p/ibm-db/
https://code.google.com/p/ibm-db/wiki/README
Could someone help me with this ?
Try downloading the Informix Developer Edition for Raspberry Pi. It contains the engine and the client.
Regards.
I'm using PyBluez on Ubuntu 10.10. I would like to know how is possible to change the bluetooth name of the local device in software. I couldn't find any command related..
Invoke org.bluez.Adapter.SetProperty(u'Name', u'New name here') in the /org/bluez/<pid>/<device> object path on the org.bluez D-Bus bus.