New answers tagged

0

Processes don't share globals. Have a look at this: Exchanging objects between processes


0

Variables declared in a function are only accessible within that function and cease to exist afterwards. If you want to share a variable declare it in module scope and mark it global in each function you want to use it within. E.g. shared = 0 def func_1(): global shared shared = shared + 1 print ("func_1 shared=", shared) def func_2(): ...


0

Welcome, Tilen. I can't see that nibble will ever be >12 - don't forget you're starting from zero and reading 13 bits... This might explain why you're not getting any output...


1

I have installed OpenCV and and access it with Python 2. However, I'm unable to use OpenCV with Python 3. With python (Python 2) you have installed python-opencv from the repository which is the Python 2 version. If you try to use it with python3 this cannot work. You have to install OpenCV for the Python 3 version. Just do it with: rpi ~$ sudo apt install ...


2

CoderMike's Answer addressed the problems in your code, but if you are actually using the relay module pictured and have wired it in a similar manner there are more concerns. There are a number of similar (poorly-designed) relay modules on the market - they seem to infect ebay! They may work with Arduino (and TTL logic) BUT ARE A LOUSY DESIGN even for that ...


2

Firstly does the following turn your relay on then off? import RPi.GPIO as GPIO,time GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(7,GPIO.OUT) print('on') GPIO.output(7,GPIO.LOW) time.sleep(4) print('off') GPIO.output(7,GPIO.HIGH) You also need to add timeouts to your distance sensing code otherwise your code could get stuck in a while ...


3

By default Geany runs Python code using Python2. This can be changed under 'Build','Set Build Commands'. Then change Compile from python to python3 and Execute from python to python3. The serial read commands changed between Python2 (returns string) and Python3 (returns bytes), adding a .decode() converts bytes to string. If not sure which version of ...


2

From here # python2.7 >>> from pythonwifi.iwlibs import Wireless >>> wifi = Wireless('wlan') >>> wifi.getEssid() 'romanofski' >>> wifi.getMode() 'Managed' And here def scan(self): """ Returns Iwscanresult objects, after a successful scan. """ return Iwscan(self.ifname) So # python2.7 >>> from ...


-1

Hi @bark given you're a math graduate you might like to know that you have a full version of Mathematica 12.0 included as part of Raspbian. Mathematica has a built in benchmarking capability, which may meet your requirements. Mathematica supports parallel computing out of the box, and given the Pi's limited resource I've had more success creating a ...


3

Move the code that reads the log into your while True: loop. Don't start a new while True: for each LED as it will never terminate. Now that I'm home and have had a chance to look at this deeper (with a Raspberry Pi to test it on) I've re-written it to use RPi.GPIO (which works). #!/usr/bin/python3 import RPi.GPIO as g from time import sleep g.setmode(g....


1

The MPU-6050 is a great choice. To use it on Raspberry Pi 3, you need a python module. Follow instructions: 1. install the python-smbus package sudo apt install python3-smbus 2. Install this package from PyPi repository pip install mpu6050-raspberrypi If you find a problem, post an issue here.


5

Okay, I have solved my problem. I reinstalled Python 3.6. Then I used this command sudo apt-get install libhdf5-dev and then sudo pip install tensorflow and installed TensorFlow successfully! I think the problem was with my Python installation. Thanks to all of you for your kindness. Cheers!!!


2

As Julian mentioned, a Pi based solution won't win any calculation benchmark records. That isn't what they are intended for; however, if you are looking simply as a learning testbed then it is an inexpensive way to play with symmetric and asymmetric cluster type computing and algorithms/etc. I use a blend of Pi3s, Pi4s, and AMD64 arch machines operating ...


4

For a rough measurement, I generated a 2000 x 2000 matrix with random integer entries between 0 and 9, and timed computation of the determinant in SageMath (I did this twice, with similar results). On my Raspberry Pi 4B, the computation took 15 minutes, compared to just over 3 minutes on my 10-year-old desktop with a quad-core i7-860 processor. The least ...


4

12V pump will require 12V PSU. 20LPM is a pretty reasonable flow rate for a small pump so your pump PSU will need to have enough power to drive the pump - check the max current draw on startup (which will be higher than the running power draw) and size the PSU accordingly. Check the contact handling voltage/current for your relays. "5V" relays (as ...


0

Running the following commands have resolved the issue for me: sudo rmmod uvcvideo sudo modprobe uvcvideo nodrop=1 timeout=10000 quirks=0x80


1

I expect the error is given because there is no module named lcddriver.py which is what import lcddriver will be looking for. Rename lcddriver to lcddriver.py.


1

After the helpful keyword from joan, it was indeed a contact bounce and after a few attempts, here's what my loop looks like now. while True: print("Started loop sequence") if static_button.is_pressed: print("Static Button Pressed") print(static_running) if static_running==False: static_display() ...


0

thanks a lot for the reference. Cool stuff, I'll have a look. Meanwhile, I found a way to start reading the TFMini signal. I'm using the following script: ser = serial.Serial( port="/dev/ttyUSB0", baudrate = 115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) ...


0

There are dozens of posts (on this and other sites) explaining why rc.local is unsuitable for starting tasks on a modern systemd distribution. Rather than reposting you should search them yourself. There are many factors to consider, and unfortunately there seems to be no single guide which covers them all. You could start with You could start with rc-...


2

Depending how the ads1115 is connected to the PCA9546 there are several ways to approach. For example if the 4 ads1115 is pinned out to have different address ( the ads1115 support upto 4 address; 0x48,0x49,0x4a,0x4b) you may use this line of code to select 1 - 4 channels, assuming the address of the PCA9546 is 0x77 i2c.writeto(0x77, bytes([0x01]), stop=...


1

Question How to use Rpi4B to control multiple ADS1115 I2C ADCs, using PCA9546/TCA9548A I2C Multiplexer? Answer (1) PCA9645 Datasheet Section 6.1 explains the device slave address is 0x70 to 0x77. In other words, 7 PCA9645s can be placed on the same I2C bus. You use A2, A2, A0 address decode pins/bits to select which PCA9685 device (not channel) to use. ...


Top 50 recent answers are included