Hot answers tagged

4

Unfortunately the CPUTemperature class does not support reading from a remote Pi, even if you provide a remote pin factory. There's an issue to add it but it's probably not a priority: https://github.com/gpiozero/gpiozero/issues/581 For now you can try doing it with pigpio itself: http://abyz.me.uk/rpi/pigpio/python.html#file_open


4

I duplicated what you did using an up-to-date Raspbian Buster in a Pi 4 B. (I wish all questions were as clear and complete as yours!) Double-clicking the file on my machine brought up the thonny IDE. (Note: The 'any' key doesn't work because input() needs an enter to complete.) On reboot, I observed the same result you did. However, installing xterm ...


3

Set up a simple REST-API with PHP for example that triggers local controlling code. You may want to add some form of authentication tho like supplying a password in the request. A request would be along the lines of: http://pi1.domain.com/relay/on/1?pw=password


2

As you wrote in a comment you only want to start the web browser. Wrap it into a python script isn't needed. That's only an additional layer of execution and waste of resources. Just start the browser direct. Because we need a graphical environment try this service: rpi ~$ sudo systemctl --force --full edit run-browser.service In the empty editor insert ...


2

You must add , at the end of line 19. Like "token": "my api token",. So your pushover.py gonna be like it: #!/usr/bin/python import httplib, urllib conn = httplib.HTTPSConnection("api.pushover.net:443") conn.request("POST", "/1/messages.json", urllib.urlencode({ "token": "my api token", "user": "My user token", "html": "1", "title": "...


2

In your code, the return command is placed outside the get_distance function. The return command can only be used when it is in a function, so it returns the output of the function you specify. When you use return distance, you should keep it in the function or it won’t make any sense to Python. Right now, it ends with global start.


2

Create a file: nano /etc/systemd/system/startupbrowser.service Put all lines below there: [Unit] Description=testfile service [Service] ExecStart=/usr/bin/python /home/pi/Documents/testfile.py StandardOutput=syslog StandardError=syslog Restart=on-failure User=root Group=root SyslogIdentifier=testfile [Install] WantedBy=multi-user.target Save ...


2

2020 Update: Nowadays modern Linux distributions, including Raspbian, use systemd instead of old style SysV as init system. For downstream compatibility SysV is only emulated by systemd but will lose support more and more by time so you should not use SysV anymore, in particular /etc/rc.local! For more information about this have a look at Compatibility ...


1

In my case the current from my power supply to the relay module was not sufficient at 1.0 amps. I swapped it out with one rated at 2.0 amps and that got my relays switching. Thank you all.


1

Well, this should be asked into IoT and maybe they'll tell you to ask into Electronics. With rpis being catch-all wizards I guess I'll drop you a line anyway. Does mac tx and radio tx commands are used for same purpose? Absolutely not. It's better to start from the raw radio tx. Look at the example: radio tx 48656c6C6F // Transmits a packet of [0x48][...


1

If you don't care about execution time, increasing your swap size from 100MB to a couple of GB will triple the amount of available memory. Projecting your current code efficiency (1 GB or RAM needed to process 16 MB of data), you should be able to process up to 48 MB of data at once. sudo dphys-swapfile swapoff echo 'CONF_SWAPSIZE=2048'|sudo tee /etc/dphys-...


1

Don't continually call the dutycycle function. You are probably resetting its function many times per second. Try something like ... import time ... if len(sys.argv) > 3: # converteer de waarde 255 tot max 100 voor PWM. roodwaarde = (int(sys.argv[1]) * 100) / 255 groenwaarde = (int(sys.argv[2]) * 100) / 255 blauwwaarde = (int(sys.argv[3]) * ...


1

I answered your question according to "what you expect to do". Honestly, it's not a good idea to show the camera stream over a remote desktop tool like VNC. You should improve your code to stream the camera over the HTTP protocol to create an RTC connection. You could do it with the help of OpenCV on python. Although, I suggest you install the motion ...


1

I am using X11 forwarding on the raspberry and putty on windows. This way you can see the display of the raspberry on your laptop. I haven't had issues with it. To set it up you need to enable ssh in raspi-config. Then edit sudo nano /etc/ssh/sshd_config and uncomment the line X11Forwarding yes install xming and putty on your laptop and set up putty under ...


1

You are not allowed to use commands in systemd services.: The command to execute must be an absolute path name. Source: systemd.service You should add the exact path of the command. You can find that by this command: which python You would get the output as it: /usr/bin/python Finally, use the output of which command to your systemd service. ...


1

You can do it if the device is the same. The point of a virtual environment is to be able to replicate it everywhere you need it. Make a script that installs all necessary dependencies from a requirements.txt file and use it. Use the command bellow to get the list of all python packages installed: pip freeze > requirements.txt Then install the ...


1

Web browsers work very hard to keep what happens within the browser from changing anything else on the computer running the browser. This is essential to maintaining security from malicious web sites. One way of doing what you want is to run a small server on the Raspberry Pi and have the web page, also running in a browser on the Raspberry Pi, send a ...


1

Try to change the webcam1 = cv2.VideoCapture(1)(the one that raises the error) to webcam1 = cv2.VideoCapture(-1). Also, check the camera drivers by ls /dev/video* to make sure all cameras plugged.


1

Well since after renaming the filname of the project file thrown me another saying that: No module named 'VL53L1X' It led me to manually add the path of the module to the file. I have modified the example code to this import importlib.util spec = importlib.util.spec_from_file_location("VL53L1X", "/usr/local/lib/python2.7/dist-packages/VL53L1X.py") ...


1

/dev/tty1 is NOT a USB port. This is the default console. There should be no need to "open" it and certainly repeatedly opening and closing stdin is just going to cause character loss. I suspect the (unspecified) RFID reader is designed to emulate a keyboard. Just read as you would a keyboard!


1

Why are you repeatedly opening and closing the port ? You could just open it once at the start of your program, wait for data and close it when you are done with it and when an exception occurs. Otherwise I believe something like this could work too: import sys for line in sys.stdin: # do something Alternatively you could use a dedicated library for ...


1

I am also facing the same error. You must add these lines on ~/.profile export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv source /usr/local/bin/virtualenvwrapper.sh export VIRTUALENVWRAPPER_ENV_BIN_DIR=bin


1

It seems like my Raspbian Buster image was corrupted or something.I kept refreshing my sd cards from the raspbian buster image that I had downloaded from the official raspberry site. This time I downloaded a new RB image from the site and the problem went away.


Only top voted, non community-wiki answers of a minimum length are eligible