I do this all the time. Two-way communications works just fine.
Yes I keep my ports open continuously. UNLESS I am running the IDE. The IDE requires that I not have any other programs trying to use the same serial port.
The code I use on the Arduino to open the port is much more simple than you're showing.
Python installations generally do not share modules between them. Modules installed for Python 2 will not be shared with the Python 3 installation (they are stored in different locations, etc).
At least for now, python and pip refer to the Python 2 versions of the toolchain. As such, most Python tools have a Python 3 equivalent. If you used
sudo pip ...
Machine: Intel 80386
This shared library object (.so) was compiled for the x86 instruction set, used predominantly on 32-bit PC style computers with Intel or AMD processors. All Raspberry Pi models use some variant of ARM, which is common in mobile devices. They are not compatible.
You either have to get the source code and ...
You have a few options:
Assign the two Pi's static IP addresses and connect them using an ethernet cable. The Pi Foundation has a series of lessons on doing this.
Create a WiFi access point on one of the Pi's.
Use a pair of USB to TTL devices like this one and connect their rx and tx pins (rx of one to the tx of the other). This tutoriual uses a console ...
Removing Python is not a minor issue the resulting problems can lurk unseen for a long period of time only to bite you later (e.g. a missing library that was uninstalled and not reinstalled breaks a seldom used feature). As a result, I think you would be better off backing up the important files you mentioned using SCP and starting over, by reimaging your SD ...
You have two bottlenecks here that are going to slow you down. First, there's the SPI, which was mentioned in a comment. That takes a few clock cycles in each direction and will limit you some. The second is writing to the SD card. I expect that the second is more important for your speed. Disk writes are generally much slower than computations, and the ...
Python 3 is a backward incompatible upgrade of the language. As already mentioned, so much was changed, that most programs won't work on Python 3 without modifications. Even worse, many Python libraries are not compatible with Python 3 yet.
This is why at least two versions are needed - legacy Python 2.x and new Python 3.x. This is exactly what you have on ...
First in raspi-config select Boot Options then Desktop/CLI then Console Autologin.
Then in a Terminal window run:
sudo nano /etc/profile
At the bottom add:
sudo python /home/pi/yourscript.py
Press ctrl+X and then press Y followed by ENTER twice.
/home/pi/ is the directory of your python file and yourscript.py is the name of your python code.
To check ...
Python3 isn't really an upgrade of Python2. Only trivial programs will run without at least being run through 2to3.
On the other hand, when there are minor updates, eg 2.7.2 -> 2.7.3 the 2.7 will be updated to the new version and the older one gets deleted. This is generally ok as there isn't supposed to be backward incompatible changes (I won't say this ...
When you write "\n" in a C program, the compiler replaces it with a single character. The \ is called an 'escape', and it gives a special meaning to the character following it -- in this case the n.
Commands sent to the devices must be terminated with a suitable line ending, so it knows where the command ends. Common line endings are \n (which is a single ...
The Pi has 2 UART, but only ONE is accessible via GPIO. This is accessible as /dev/serial0 (but needs to be enabled via raspi-config).
The change you propose to config.txt will not do what you think.
You can disable bluetooth and/or swap which UART is connected to the GPIO, but there seems to be little reason to do so - the default is adequate for most ...
I would suggest you to use Aspose.Cells Cloud SDK to convert XLSX to PDF.
Have a look on short example:
#set file name
filename = "input.xls"
outputfilename = "output.pdf"
#upload file to aspose cloud storage
#convert file to pdf
response = cellsApi.PostDocumentSaveAs(name=filename, body=body, newfilename=outputfilename)...
Fixed this problem.
I was running under python 3 but oauth2client and gspread were installed under python 2. To fix this, I ran pip3 install on gspread and oauth2client and all is running smoothly now.
You haven't told the system that you want to run a Python script. It probably assumes the script is a bash shell script.
You have a number of choices.
use the form python RUNME.py
add a shebang as the first line of your RUNME.py script. I use #!/usr/bin/env python
For choice 2 to work you need to ensure the script is executable with
chmod +x RUNME.py
Here is how you can do to remote debug python scripts on pi from eclipse (windows):
Install eclipse and pydev
Install pydevd on pi using pip install pydevd
In eclipse, create a new python project and add below lines at starting of the code:
import sys;sys.path.append(<path to pydevd>)
import pydevd;pydevd.settrace(<ip address of windows>, port=...
Idle 2 is installed but on recent Raspbian images Python v2 menu entries are disabled.
To activate it start the 'Main Menu Editor' from the Preferences menu.
Select 'Programming' on the left. After activating 'Python 2 IDLE' you should be able to start Idle 2 from the menu.
You may need to install the 'Main Menu Editor' program. For this use e.g.
sudo apt ...
You say you are using raspbian-stretch. With this and with most debian derivate you have python 2.7 installed. This is because the Debian operating system itself needs this version for its scripts to run. It is for historical reasons and because the maintainers haven't got it to upgrade all OS scripts to Python 3. I think they will do by time. If you call ...
The standard release of RPIO does not support the Pi Zero, Pi2, or Pi3.
You will need to build RPIO from the github of RPIO version 2.
Go to that github choose Clone or download and select Download ZIP.
Then do the following on the Pi where you saved the ZIP.
sudo apt-get install python-dev python3-dev
A "segmentation fault" is your program trying to violate its memory space. It sounds scarier than it is--nothing really got broken. If a debugger is unavailable to you, simply put in additional print(...) statements to pinpoint exactly where your segmentation fault is. Adding print() statements sounds silly but is surprisingly effective. Put one after each ...
I used the imagemagick module. I originally downloaded it to convert jpg the pdf. Just on a whim I tried it.
os.system('sudo convert file_name.xlsx file_name.pdf')
It will kick a few errors in the shell, and creates a folder for it name "_dername", not in the directory I specified, and give it a weird name that starts with "magick-", followed by some ...
Thank you all for your advice on my question. Based on the suggestion by user name joan, I did some research and ended up going the route of making a batch file to the correct directory. I am leaving the exact way that I did this here, for anyone else who runs into a similar issue. Thank you again to all.
Create batch script (yourscript.sh file) in /home/pi ...
Finally I discover that the problem it was not the code. The problem was an indentantion error imperceptible in Sublime Text. I only can see this problem opening the code with nano editor. The solution was select all the code (ctrl+a) and then click on the "Tab Size:" message on the right-bottom corner of Sublime Text interface and select "Convert ...
Refering to this and I would simply do:
wget http://packages.namniart.com/repos/namniart.key -O - | sudo apt-key add -
sudo sh -c 'echo "deb http://packages.namniart.com/repos/pi wheezy main" > /etc/apt/sources.list.d/libcec.list'
sudo apt-get update
sudo apt-get install python-dev build-essential libcec-dev cec-utils
and then finally install with pip:
You should be able to run
pip install --user RPi.GPIO
in the terminal window inside pycharm.
However before you do that I would recommend using a python virtual environment for the project. To do this you need to edit the project interpreter and:
Click on the Gear Icon at the top right of the window.
There is an option in there called: Create VirtualEnv
Use crontab as mentioned by Conor. You can run as many scripts as you want and they won't affect each other. I have these setup on all my Pis to run bash and python scripts. It looks a bit intimidating at first as crontab generates a template but you can erase all of it and use the configuration below.
$ crontab -e
## Crontab Configuration ##
29,59 * * * * ...
This is a common automation problem with a range of solutions from the last century or so - essentially, what you are working with is the inverted pendulum.
What you probably want to do to make this project a lot easier is to transform your axis so that you try to solve this problem instead: