Go to advanced search

by Garvan
Wed Mar 25, 2020 3:06 pm
Forum: Python
Topic: how to exit signal.pause() in code [SOLVED]
Replies: 4
Views: 123

Re: how to exit signal.pause() in code

scotty101 wrote:
Wed Mar 25, 2020 2:45 pm
You could just have a small while loop with a time.sleep in it.

Code: Select all

running = True

def say_bye():
    global running
    print("Exit")
    running = False

while running:
    time.sleep(0.1)
Thanks, I will try this.
by Garvan
Wed Mar 25, 2020 2:32 pm
Forum: Python
Topic: how to exit signal.pause() in code [SOLVED]
Replies: 4
Views: 123

Re: how to exit signal.pause() in code

I want to exit the program when a button is pressed in BlueDot. Is there a way to exit signal.pause()? Or an alternative to signal.pause()?

I can exit the program using Ctrl-C, but I will not have a keyboard attached in the finished project.
by Garvan
Wed Mar 25, 2020 1:18 pm
Forum: Python
Topic: how to exit signal.pause() in code [SOLVED]
Replies: 4
Views: 123

how to exit signal.pause() in code [SOLVED]

The BlueDot documentation https://bluedot.readthedocs.io/en/latest/recipes.html uses pause() to pause program flow while threads are waiting for signals. You can "exit" pause() by pressing Ctrl-C to terminate the program. How do I cause pause() to exit in code? For example, if I want a double-press ...
by Garvan
Wed Mar 25, 2020 10:51 am
Forum: Python
Topic: Pyton script crashes after 4 hours
Replies: 9
Views: 246

Re: Pyton script crashes after 4 hours

Should f.close() & g.close() be inside the wile loop? It looks to me that you are repeatedly opening URL's without closing them. This might be unrelated to your error.
by Garvan
Sun Mar 15, 2020 11:04 am
Forum: Python
Topic: Can you customize "exit" action using guizero?
Replies: 4
Views: 273

Re: Can you customize "exit" action using guizero?

You can put your cleanup code after app.display() and it will run when app.display() closes.

Code: Select all

from guizero import App, Text

app = App()
text = Text(app, text="hello world")
app.display()
print ("Cleanup")
by Garvan
Sun Mar 15, 2020 10:11 am
Forum: Python
Topic: [SOLVED] "Segmentation fault" running a Python3 script
Replies: 12
Views: 428

Re: "Segmentation fault" running a Python3 script

Do you have a "thingspeak_key"? You could push the results in the try section for testing, and when you have it working, adjust to your liking. thingspeak_key = 'XXXXXXXXXXXXXXXX' try: humidity, temperature = Adafruit_DHT.read_retry(sensormodel, sensorpin) if humidity is None or temperature is None:...
by Garvan
Sun Mar 15, 2020 9:36 am
Forum: Python
Topic: [SOLVED] "Segmentation fault" running a Python3 script
Replies: 12
Views: 428

Re: "Segmentation fault" running a Python3 script

Ok. I recommend holding the web code until you get the sensor and switches working. # Imports import Adafruit_DHT from energenie import radio, encoder sensormodel = Adafruit_DHT.AM2302 sensorpin = 4 tempthreshold = 20 GREEN_ON = encoder.build_switch_msg(True, device_address=1) GREEN_OFF = encoder.bu...
by Garvan
Sun Mar 15, 2020 9:01 am
Forum: Python
Topic: [SOLVED] "Segmentation fault" running a Python3 script
Replies: 12
Views: 428

Re: "Segmentation fault" running a Python3 script

I find it difficult to tell what is working and what is not working, so forgive the silly questions. Does this work? # Imports import Adafruit_DHT # Attempt to get a sensor reading. The read_retry method will # retry up to 15 times, waiting 2 seconds between attempts sensormodel = Adafruit_DHT.AM230...
by Garvan
Sun Mar 15, 2020 7:29 am
Forum: Python
Topic: same equation giving different answers
Replies: 2
Views: 164

Re: same equation giving different answers

This is an error

Code: Select all

    t=time.time()
    r=time.time()-t
Every time you call time.time() it returns the current time, so r will be equal to a tiny number.

What you should do is move r=time.time()-t down to after the button is pressed, so it is equal to the reaction time.
by Garvan
Sun Mar 15, 2020 6:43 am
Forum: Python
Topic: [SOLVED] "Segmentation fault" running a Python3 script
Replies: 12
Views: 428

Re: "Segmentation fault" running a Python3 script

A segmentation fault is a memory error, you are accessing (reading or writing) an un-initialized function or memory address. Normally in this case you will go through your code commenting out one line at a time, until you find our which line is causing the error. You might insert print statements to...
by Garvan
Sun Mar 15, 2020 5:59 am
Forum: Beginners
Topic: Can a python script edit itself?
Replies: 2
Views: 220

Re: Can a python script edit itself?

You should just try it, it would be quicker than asking, but it wont work the way you are hoping. The python source code is loaded into memory on start, so any edits you make to the source will not be executed until the program is run a second time.
by Garvan
Fri Mar 13, 2020 2:58 pm
Forum: General discussion
Topic: Why USB-C ?
Replies: 33
Views: 1343

Re: Why USB-C ?

<snip> https://www.raspberrypi.org/products/type-c-power-supply/ Clicking on this link and selecting the type I need tells me "there are no global supplies for this model".That said, I do have a working wart, official or otherwise, I don't really know. What I want is more options in design. I am lo...
by Garvan
Thu Mar 12, 2020 6:57 am
Forum: Python
Topic: alsa warnings and error in running speech recolonization code
Replies: 4
Views: 254

Re: alsa warnings and error in running speech recolonization code

You might get some information on the issue in this thread https://www.raspberrypi.org/forums/viewtopic.php?t=241919 from last year. The first line of the error message is the same. First thing I would make sure that my system is up-to-date. See: https://www.raspberrypi.org/documentation/raspbian/up...
by Garvan
Mon Mar 09, 2020 2:53 pm
Forum: Python
Topic: time.sleep
Replies: 4
Views: 376

Re: time.sleep

In your code you open a file, write to it, close it and then open it again. This will not work. Everything you wrote to the file the first time is deleted when you open it for writing a second time. And as mentioned above, you have no loop. Study this simple program. It opens a file, writes two line...
by Garvan
Sat Mar 07, 2020 4:06 am
Forum: Beginners
Topic: BlueDot with Raspberry Pi4 [SOLVED]
Replies: 10
Views: 422

Re: BlueDot with Raspberry Pi4 [SOLVED]

And what is output by the Python script? Mr.Ohanlon used to check in here, he may yet pop up. The script prints out the raspberry pi Bluetooth address, in my case DC:A6:32:20:9E:C6, then it sits there waiting for a connection. I got it working. In the BlueDot application on my phone, I selected "Se...
by Garvan
Sat Mar 07, 2020 3:09 am
Forum: Beginners
Topic: BlueDot with Raspberry Pi4 [SOLVED]
Replies: 10
Views: 422

Re: BlueDot with Raspberry Pi4

Do you have a Blue Dot application (such as the sample app) running when you try to connect from the phone? Yes, I run the script provided. from bluedot import BlueDot bd = BlueDot() bd.wait_for_press() print("Hello World") 1. My phone pairs successfully with RPi4 GUI interface . 2. I start the bd....
by Garvan
Fri Mar 06, 2020 12:56 pm
Forum: Beginners
Topic: BlueDot with Raspberry Pi4 [SOLVED]
Replies: 10
Views: 422

Re: BlueDot with Raspberry Pi4

I tried a third time, just to confirm the python script was running. It does not connect, no error message, nothing. So what do I report to the author/developer/maintainer on https://github.com/martinohanlon/BlueDot? I would feel like a fool saying "it does not work", with nothing useful to add.
by Garvan
Thu Mar 05, 2020 9:56 am
Forum: Beginners
Topic: BlueDot with Raspberry Pi4 [SOLVED]
Replies: 10
Views: 422

Re: BlueDot with Raspberry Pi4

I was unable to get it to work, and I uninstalled BlueDot.

Sorry.
by Garvan
Mon Mar 02, 2020 1:45 pm
Forum: Beginners
Topic: Make the onboard LED blink using python - RP3B+
Replies: 7
Views: 310

Re: Make the onboard LED blink using python - RP3B+

Prettier?

Code: Select all

import os
import time

for j in range(10):
	os.system('echo 1 | sudo dd status=none of=/sys/class/leds/led0/brightness') # led on
	time.sleep(1)
	os.system('echo 0 | sudo dd status=none of=/sys/class/leds/led0/brightness') # led off
	time.sleep(1)
  
by Garvan
Sun Mar 01, 2020 8:31 am
Forum: Troubleshooting
Topic: is it worth trying to fix damaged RPi4B?
Replies: 2
Views: 137

is it worth trying to fix damaged RPi4B?

I guess I pluged and unpluged the HDMI cable one too many times, and I dislodged a tiny chip beside HDMI 1 (marked 5V=POX or something like that, the writing is tiny). It looks like an adjacent chip is damaged also, above and to the left in the attached photo. https://i.imgur.com/v8AUfwu.jpg Can pro...
by Garvan
Mon Feb 24, 2020 5:28 am
Forum: Beginners
Topic: Fasted Image recognition for raspberry pi
Replies: 2
Views: 149

Re: Fasted Image recognition for raspberry pi

It should be easy to follow some tutorials on QR code scanners in RPi+Python, and then based on this experience (checking, speed, performance etc.) decide if it will work for you. For example: https://www.pyimagesearch.com/2018/05/21/an-opencv-barcode-and-qr-code-scanner-with-zbar/ You might expect ...
by Garvan
Sun Feb 16, 2020 9:32 am
Forum: Beginners
Topic: BlueDot with Raspberry Pi4 [SOLVED]
Replies: 10
Views: 422

Re: BlueDot with Raspberry Pi4

Forris wrote:
Sat Feb 15, 2020 4:25 pm
From the BlueDot documentation, under 'Pair a Raspberry Pi and Android phone:

'You may receive errors relating to services not being available or being unable to connect: these can be ignored.'
I would happily ignore the error messages if it worked. I will remove it and start over. One more try.
by Garvan
Sat Feb 15, 2020 8:33 am
Forum: Beginners
Topic: BlueDot with Raspberry Pi4 [SOLVED]
Replies: 10
Views: 422

BlueDot with Raspberry Pi4 [SOLVED]

Hi, Have others succeed in getting BlueDot https://bluedot.readthedocs.io/en/latest/gettingstarted.html working with Raspberry Pi 4? This is my experience so far: Using a Huawei phone, I installed the application, I could not get the phone to pair using the GUI, because it reported my phone had no u...
by Garvan
Fri Feb 14, 2020 12:28 pm
Forum: Arch
Topic: Really slow wifi! (manjaro ARM)
Replies: 4
Views: 347

Re: Really slow wifi!

DougieLawson wrote:
Sun Feb 09, 2020 12:03 pm
iwlist channel | grep Current
Thank you. This is useful.
by Garvan
Wed Feb 12, 2020 9:07 am
Forum: Beginners
Topic: Raspberry pi 4 wi fi
Replies: 4
Views: 245

Re: Raspberry pi 4 wi fi

Assuming you have the default desktop, like I have: 1. Right click on the bar where the WiFi icon used to be, and select "Add / Remove Panel Items" 2. A dialog will open where you can select the "Panel Applets" tab, and press the "Add" then select "Wireless and Network" which should be near the bott...

Go to advanced search