#help-with-linux-sbcs
1 messages ยท Page 21 of 1
would you use a MOSFET or a BJT? I would lean towards FET
i think you can use a BJT ok for the ~20mA level stuff you'd be dealing with on an LED
ok I'll just go with what fits best on the board
Should those guides be amended to suggest that?
I haven't used subprocess before will the command subprocess.Popen(['sudo','shutdown','-h','now']) do the same thing as running sudo shutdown -h now in the terminal?
which guides?
any guide that details running an LED off of a GPIO pin
makes sense
Any thoughts on the subprocess call? I've seen a few ways to call a shutdown but don't know enough to distinguish which is preferred
otherwise it requires more discussion and quickly becomes less beginner friendly
yeah that makes sense. Maybe an addendum to each guide that points to a new guide that talks about safest practices? I'd love to write that if you allow outsiders to contribute
hmm..subprocess...it's been a while since i've done that. can't remember what the best option is.
but basic python docs should cover that
not really. that's where packages are hosted.
ahh ok
like add on libraries, etc.
look more in the core docs
i think...pretty sure it's a core thing
I'll just google core python docs, that should find it
part of the "batteries included" aspect of a python install
ah I was going to readthedocs.python.org not docs.python.org
"running external command" etc.
hmm this guide has you do it somewhat differently. I've got some reading to do it seems
Hereโs something that you probably wonโt want to do, but how can you restart or shut-down your Pi from software in python code? Well itโs both quite simple and quite tricky all at the same time, but in summary you can run some python code like this to shell out to the shutdown command: [โฆ]
hey it worked! woooooo
the original way I had it worked
I believe its max 16 source, 17 sink.
Oh good to know. I'm under that so we're good
Any advice on getting a neopixel strand working on a Raspberry Pi? Code seems to be working with libraries installed & sudo run. No errors showing. I think I had the wiring setup with the Adafruit 74AHCT125 (pictured). Am using GPIO 12, which is apparently OK, although I also tried same code switching to D18. Still no lights. Power supply strand is wired to is 5v 3a. Notice when I unplug & plug the power supply back in sometimes random lights in random colors show on the strip (hope I didn't damage anything). Thx for advice!
import board import neopixel pixels = neopixel.NeoPixel(board.D18, 20, brightness=0.2, auto_write=True) pixels.fill((0, 0, 125)) pixels.show() while True: pass
I know wiring is tough to see but it should be like the diagram on https://learn.adafruit.com/assets/64121
can you verify the neopixel strip is good on some other non-pi board?
i am attempting to get a Brain Hat working on Rasp Pi 4. There is a step: lobe-basic-prediction.py which gives this error: picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': Function not implemented I bumble around and read Adafruit's article: https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi/kernel-module-troubleshooting so i run the script there which puts an older version on. Now I get picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled. I have enabled the camera..but still get this. There is something screwy but I don't know what?
I have a service that starts my code on power on, if I stop that service, what happens to the gpio pins I have set up? Do they stay in the same configuration?
Are you sure that the camera's ribbon cable is attached correctly?
Yes. Just verified on a CPB. Lights are working on that strand.
ok, go back to pi, skip the level converter for now, and set number of pixels to 1 in code, and see if you can get that to work
OK - will give that a try. Just verified power supply was working by breadboarding up an LED. No prob there. I'll go direct from neopixel strip to the Pi & see what I can come up with.
I tried directly to Pi and although it wasn't working on outtermost pins (18, 12), when I switched to GPIO 10 it worked directly connected! When experimenting with the board, I tried a more powerful power supply & damaged another strip of lights. Could this have damaged pins on the Pi as well? My perception is this may be what happened. And now that I may have harmed a board, is there a decent test to check the integrity of pins? Thanks!
Hard to say, it would depend on your code and on the GPIO library. It may try to clean up after itself when quitting, or it might leave things as they are.
Interesting ok. I'll just make sure not to press the button that shorts a GPIO to gnd when testing
@heady cedar unfortunately possible ๐ฆ try just using them as simple digital in/out as a sanity check.
@steady rose thanks so much for your help. All this is useful. Will button test on the suspect pins. Cheers!
i was able to take an image using libcamera .... what i'm wondering is given Bullseye replaced raspivid and raspistill, if that means the rest of the infrastructure / APIs changed and the Brain Hat software goop is not compatible.... but i don't know.
Brain Hat on RPI Bullseye
Question: what would be the best product for powering and charging a pi zero 2 w with lipo
preferably with usbc but not 100% a requirement as I could swap the port manually
I have this working (buster) but only if I activate venv as root, what perms or groups do I need to adjust?
https://learn.adafruit.com/using-google-assistant-on-the-braincraft-hat/usage
`pi@grpi:~ $ speaker-test
speaker-test 1.1.8
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
Playback open error: -2,No such file or directory`
fixed it, purged pulseaudio and removed ~/.asoundrc
I suspect I'm gonna have to reinstall my 4b - it threw up in the middle of a headless upgrade to bullseye...
I can't find the weird hdmi adapter for it though
ssh?
Yeah, I just upgraded an original B successfully right before.
So nothing in theory wrong with my procedure
Any Mac users using Disk Utility to make backups of their Raspberry Pi SD cards? I used to use Disk Utility, New Image > DVD/CD Master Image, then rename it with an .iso extension, then I could etch it to a new SD card using balenaEtcher. I'm on BigSur now & haven't done this in a while, but the imaging is way faster than it ever was before (used to take about 20 mins), but the image, when copied with etcher, doesn't boot the pi. I know you can use terminal commands, but that's an ugly alternative b/c the prompt just remains bank after a press until the process is done (you can repeatedly press CTRL+T for updates on status, but it's very unfriendly). If folks have a better alternative (GUIs are always nice for new users) would love to hear what you use. Thanks!
Would appreciate pointers for backup software on windows as well
Hello I found trouble starting bluetoothctl on a raspberry pi zero w
I am using raspberry pi lite with the latest update
Linux raspberrypi 5.10.63+ #1459 Wed Oct 6 16:40:27 BST 2021 armv6l GNU/Linux
and bluetoothctl version 5.50
whenever I start the bluetooth I get stuck as you see in the screenshot
any advice on how to debug the problem ?
is a perma-proto Pi hat (https://www.adafruit.com/product/2310) likely to impede WiFi signal at all? I'll just have some fairly simple wiring with a couple resistors and NPN transistor, using both 3V and 5V power rails
Design your own Pi HAT, attach custom circuitry and otherwise dress your Pi Zero, A+, B+, Pi 2,ย Pi 3 and Pi 4 (any Pi with a 2x20 connector) with this jaunty prototyping HAT kit.To kick ...
Hi ๐ I am new to using pico-sdk library, but how can I change my board configuration? I am using Adafruit Qt Py RP2040, and I have not found a way how to switch the board from pico.h to adafruit_qtpy_rp2040.h. I am also having trouble with the pin numbering. If I want to use C/C++ for coding, where I can find a pinout for Qt Py RP2040 with numbers?
I can't help with most of that, but I can help with the GPIO numbering. Here is a pinouts image.
The GPIO numbers are the ones I think you're looking for.
Thank you, so if I want to send a true value to, let's say, A3, I will call gpio_put(1, true)?
Like I said, I can't help with most of that. ๐ I don't know anything about using the pico-sdk, unfortunately. Someone else may be able to help. But please be patient, most folks here are community members volunteering their time when they can.
If that's how it works, I would assume it would be gpio_put(26, true) for "A3"? But like I said, I'm stretching a guess here.
Yes, thank you. I will play with it for a while. But I see that the GPIO numbering is what I was looking for. Thank you once more for your time ๐
You're entirely welcome! Glad I had something to offer!
so im trying to use raspberry pi imager, i get this message when i try to write the recommended os to sd card. Error downloading, http/2stream 1 was not closed cleanly before end of the underlying stream - server ip <numbers listed here>
what does this mean?
possibly a shaky internet connection?
try manually downloading the image:
https://www.raspberrypi.com/software/operating-systems/
once i download it do i use imager then to put it on the sd card?
maybe something happening with their servers right now
i just got that launching the imager
well its been happening for two days now
but once you download the file, you can select it in the imager
"CHOOSE OS" button, and then scroll to last option
the "Use custom" option
just relaunched that app and it worked second time
so not sure what might be happening
thanks i'll give that a try
its been so frustrating. can't get the hyperpixel 4 to work, so trying to see if downloading the os fresh might do the trick
might want to check with pimoroni too. the latest OS could be breaking things.
that unfortunately happens
lots of under the hood linux changes that libraries then have to catch up to
hi, im trying to make the raspberry pi into a rubber ducky, the problem is that i did all the steps from diferrenrent guides, but it dosent run the code when plugged to the computer, it opens it as Drive E
Anyone with experience with mosquitto / paho mqtt on the Raspberry Pi? I've used this to send commands to the Pi to do things like play sounds & move a robot, but for some reason on my new Pi with Bullseye installed, I can't seem to get a connection to work with the same code. Output below:
File "/home/pi/control-pibot.py", line 119, in <module>
mqttClient.connect(serverAddress)
File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 914, in connect
return self.reconnect()
File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1044, in reconnect
sock = self._create_socket_connection()
File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
File "/usr/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/usr/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused```
FWIW -I was able to run this example on a Raspberry Pi Zero 2w with BullsEye ```
import random
from paho.mqtt import client as mqtt_client
broker = 'nam1.cloud.thethings.network'
port = 1883
topic = "REDACTED"
generate client ID with pub prefix randomly
client_id = f'python-mqtt-{random.randint(0, 100)}'
username = 'testv3application@ttn'
password = 'REDACTED`
def connect_mqtt() -> mqtt_client:
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to MQTT Broker!")
else:
print("Failed to connect, return code %d\n", rc)
client = mqtt_client.Client(client_id)
client.username_pw_set(username, password)
client.on_connect = on_connect
client.connect(broker, port)
return client
def subscribe(client: mqtt_client):
def on_message(client, userdata, msg):
print(f"Received {msg.payload.decode()} from {msg.topic} topic")
client.subscribe(topic)
client.on_message = on_message
def run():
client = connect_mqtt()
subscribe(client)
client.loop_forever()
if name == 'main':
run()
Thx @ruby night I'm running my own mosquitto broker on the same pi as the client. I've not used thethings network. I'll give your code a look and see if I can get a connection happening from my Pi. I suspect it's an issue with the local mosquitto server, given the error, but any leads I can investigate / eliminate are useful.
I'm looking to back up and image of my pi onto a flashdrive in order to back it up to the cloud. Is there a canonical/preferred method of doing that? Everything I've tried to do on the pi has had a half dozen methods of doing the "same" action.
or is it better to take the SD card out of the pi and use my windows machine somehow?
I'm following this guide for now https://www.tomshardware.com/how-to/back-up-raspberry-pi-as-disk-image
there is no canonical way. just use whichever seems easiest given your setup.
ok thanks. Real computers are confusing sometimes. Per that guide I'm supposed to run
sudo dd if=/dev/mmcblk0 of=[mount point]/myimg.img bs=1M
my call to lsblk produced the following (image incoming)
so does my call become sudo dd if=/dev/mmcblk0 of=/media/pi/pi_backup/myimg.img bs=1M?
I can mostly parse this, but what does bs=1M do?
@civic rune https://man7.org/linux/man-pages/man1/dd.1.html
was just there. Didn't initially realize that the bs parameter was related to dd
thx
sudo dd if=/dev/mmcblk0 of=/media/pi/pi_backup/myimg.img bs=1M doesn't seem to have any print outputs to tell status. Should I just wait?
I haven't done that for a couple of years but back then it didn't show anything unless there was an around or it was done
ok I'll just try to exercise patience
GUI wrapped around it will usually show a warning that it will destroy all data on the media etc and show progress bar
but DD by itself isn't very friendly
there's a way, by teeing or some other hook. but it's a hackish extra step. in general. just wait.
dd is a low level tool
btw if your linux is on the boot don't forget you can switch tty
and do something else
my linux on the boot?
if it's on the multi-user multi-apps mode
how can I tell that? It's just a stock pi with the latest raspbian installed
not sure if it works on pi
but try CTRL+ALT+Fn keys.
ie: ctrl+alt+f1 for tty1 ctrl+alt+f2 for tty2 etc
no, it won't let you if it's not in multi-user multi-apps mode
tty is just another session
you usually have 8 virtual sessions built-in in linux (ie: 8 possible sessions in local)
I often use that on my always up linux server so I can concentrate on web hosting process in a tty, mud/game server in another/ ftp in the 3rd etc
When I open another shell while one is running, is that using another session?
it's a tty in linux world, and yeah it will spawn another thread on the tty executable
that won't bother dd unless you use the media it's operating on
it's similar to connecting to another user throught RDP on windows except very lightweight and with a terminal
just need to be careful with TTY7 because sometimes that's Xwindow and might be too much for a pi
Interesting
might also want to lookup runlevel along with tty
if you are 100% sure you are never going to use it might as well not run in the runlevel that allows it to not waste the additional ressources
ok thanks. Thoughts on the output I got? It seems right
the general output seems okay but can't validate the 16gb or if you followed the guide correctly. I have a pi 2 that have like 4 or 8gb...
Still struggling to get my mosquitto set up as a broker on the same machine as my Pi & unsure what's going on. Same conf I'd used previously, just with latest software (Pi & paho-mqtt). When I try:
mosquitto_sub -h localhost -t โtest"
I can connect but
mosquitto_sub -h profgpi -t โtest"
gets Error: Connection refused
I have also added as allow_anonymous true line to mosquitto.conf. And as would be expected from above, I get active from systemctl is-active mosquitto Any thoughts?
so I couldn't do a 16gb backup partition on it
I followed it exactly, I'm just nervous since I'm not much of a real-computer programmer
can't even install windows 10 IoT on it
Like it said to contact microsoft at somne windows 10 IoT support chat so they can facepalm and sigh at me for an hour ๐คฃ
lol
I bought one 4 years ago and forgot it under a pile of xbox games boxes
was still connected to my TV and running for 4 years when I found it. Was like 1 clicck away from ordering one since I didn't think I had one ๐คฃ
Ordering another pi 2 or a pi 3 or 4?
I would have done pi4 but I don't really need something powerful because some microcontroller are almost as fast as the newest pi4
like the latest grand central or the teensy 4.1
can you disable wifi on a pi? I don't think it's likely that someone would try to hack our installation, and the consequences wouldn't be severe, but it might be nice to make it so someone can't sneak in. Would the pi need to be in range of wifi in the first place for that to happen?
which confuse me even more btw between if a pi is even necessary anymore, I understand the differences but they seem to be blurring lately
pi was good for me because pygame is such a useful library for playing music and tracking position in the music
something like a teensy 4.1 is reallt powerful, can do tons of gpios in real-time...
that's why I'm holding on to my pi2 until I can understand why it would be necessary to upgrade
thoughts on my security concern?
my model of the pi need a usb nanowifi dongle to have wifi so
and it already doesn't have a big range because it's so small
after starting pishrink I got the message that:
The filesystem on /dev/loop0 is now 940923 (4k) blocks long.
What does this mean?
but to attempt to answer from google it seems you can do it from the default raspberry pi desktop or otherwise it reduce to a can a disable wifi on linux problem
and for the linux problem every distro has a config file somewhere in /etc to do so
but that also mean you will need an ethernet cable to connect to it remotly
until you turn wifi back on
obvious but need to be stated ๐
Do you know what this means?
give me a sec
wow pi-shrink shrank it from 15 GB to 1.3 GB
hmm, I can't eject my flashdrive because it says bash is using it.
ahh, I need to cd out of there
oh loop is just ffor mounting image files
4k blocks is logical blocks size, 940923 * 4k longs in this case mean 3.5gb
do you have an sdcard in around 4gb or 8gb?
you can type mnt to see a list of what is mounted
might have to unmount it too
once you are sure bash isn't using it anymore in any tty
I know how do to just do cd .. to go upwards, but how can I get back to pi@rasberrypi:~ $?
in one swoop
make sure you use sudo and not su until you are skilled with linux
yeah I am decidedly not. I just use sudo wherever guides tell me to.
same for SSHing with root etc
you could brick your pi if you accidently break something as root as with a random command in su and you'd have to reinstall from zero
but no need to search something like what does command X does on raspberry pi to get a good idea generally
what does command X does on linux is sufficient. You are using linux 1st, a pi 2nd
Is this where I'd ask about pi pico stuff?
I am just trying to make sense of using the pi pico as an HID and needing to drive 12 LEDs with power from the USB port.
I'd just hook them up to VBUS, in parallel and then a resistor before any of GND pins, right?
I want to control them, but I'm thinking I'd better do that through some transistors
It's been recommended to me not to drive LED's directly from GPIO pins, I would recommend transistors
if you've verified the service is running (sudo service mosquitto status for example), see if you can do sudo netstat -aon | grep 1883 and see if returns anything (aka is the broken listening on the expected port (assuming 1883)) and if so, which ip(s). If configured to use SSL, then might need to configure a TLS setting to say 1.2. Hopefully, it's not firewalled on itself. Oh and just saw your replied where it shows running and works to localhost.. is profgpi the name in /etc/hosts going to the localhost address? What does sudo hostnamectl show for the hostname?
That's good advice but if you use a larger resistor to keep the current low and don't mind a slightly dimmer (and perhaps smaller) LED, you can certainly get by. I've used LEDs connected directly to the Pi for years with no issues (never burned out a pin).
I'm getting closer on getting mosquitto running on my Pi. Problems left seem like Pi config experts can help. One:
I had been booting mosquitto automatically using:
sudo systemctl enable mosquitto.service
The only way I can get mosquitto to boot with the conf file is via:
mosquitto -c /etc/mosquitto/conf.d/mosquitto.conf
Is there a way to enable the mosquitto service with the .conf file by default?
Also - I must have some sort of permissions thing happening that I don't understsand. When I run:
mosquitto -c /etc/mosquitto/conf.d/mosquitto.conf
1637422507: Error: Unable to open log file /var/log/mosquitto/mosquitto.log for writing.
Code doesn't crash, but this error shows up. I had to comment out the include & pid_file lines in the conf file to get things to run at all. At least I've got things running, @snow timber
Did same install I'd done earlier with Bullseye, but now all of a sudden the audio test & aplay play static instead of expected sounds. Have tried two different speakers. Any ideas? Thx!
Here is the command & output. Produces complete static - like no radio station on the dial:
speaker-test 1.2.4
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 192 to 2097152
Period size range from 64 to 699051
Using max buffer size 2097152
Periods = 4
was set period_size = 524288
was set buffer_size = 2097152
0 - Front Left
Time per period = 11.016858```
Have tried two working hamburger-style speakers plugged directly into Pi 3 A+'s speaker jack. raspi-config says headphones is the audio setup, which is what had been working before.
Other strange thing on audio issue. If I log in via VNC, open VLC player, load a local sound, and play it, it plays fine through the desktop. But through terminal the speaker-test or a simple aplay of the mp3 file comes up all static.
If I aplay, the output says:
Playing raw data 'gobble.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono
(yes, that is a turkey sound I'm trying to play).
And more weirdness on sound. Python code via pygame worked, even though these commands didn't.
$ cd /var/lib/dpkg/info/
$ egrep freedesk *list | egrep front | egrep oga
sound-theme-freedesktop.list:/usr/share/sounds/freedesktop/stereo/audio-channel-front-center.oga
sound-theme-freedesktop.list:/usr/share/sounds/freedesktop/stereo/audio-channel-front-left.oga
sound-theme-freedesktop.list:/usr/share/sounds/freedesktop/stereo/audio-channel-front-right.oga
Two of those were used by some command line thing that tests audio. I don't remember what invoked them.
I just used Audacity (very simply) to emulate the same exact test. ;)
Basically a person saying "Front, Left" or "Front, Right" or "Front, Center".
Apparently the command line program adjusted the balance so that only one speaker or the other would play (for Left and Right tests).
GNOME based installs probably included this; I was careful to install no GNOME stuff at all (as much as I could) for Bullseye (amd64, not for the RPi, in all of this).
Thx @faint sparrow Yes, the behavior is very strange. Speaker works playing .mp3s from Python using pygame, which is what I want, but I had using the speaker-test in my tutorial for students. Pretty sure I ran it under same exact bullseye install but got those different test results. Not a big deal, but was wondering if there was something simple I missed.
I want my Pi to be able to survive a power outage, but UPS's are expensive. So... would putting a Pi on a power bank work (assuming the bank could provide enough current, of course)?
In case anyone else runs across the mosquitto config issues moving to 2.0, you can still allow anonymous connections (which I needed to continue for an app I wrote that connected to the Pi).
Just add a connect.conf in directory: /etc/mosquitto/conf.d with just:
port 1883
include_dir /etc/mosquitto/conf.d
They can run on small li-ion cells, so powerbanks should be doable.
So, yeah.. if they can push sufficient current.
There are some that can give 3A, which should be plenty for my RPi4 + Fan
Yarp, or DIY.
What is "Yarp"?
"Yes"
Oh ok
Watch a film called "Hot Fuzz". ๐
My bench supply ($85 Korad) said the RPi4 drew about 800 mA routinely, but also requires > 1200 mA during start-up (from a power-off condition).
I'd be comfortable with a minimum of 20,000 mAH but how long that'd last is another question.
I really should get my powerbank/desk supply done.
Just the power sometimes goes on/off (for less than two minutes), so battery length isn't really a concern for me
Yeah if you can get it to automatically switch to the battery only when a wired supply fails that'd be great.
I'm looking at a couple of 12v SLA batteries and some 18650 packs, so I can get 12v and 5v to my desk.
Adafruit target boards that have battery connections (JST) have the right circuit to do that (create a fail-over).
I'm trying to understand why a systemctl service isn't working. From the output below it looks like I'm having a problem importing adafruit_cricket, which works when executing the code (control-pibot.py) from the command line, just not via the systemctl.
My service script:
pibot-mqttclient.service
can be found here:
https://github.com/gallaugher/crickit-pi-bot/blob/main/pibot-mqttclient.service
So when I use the command:
systemctl is-active pibot-mqttclient.service
I get a message:
failed
I'm still pretty new to the whole system log thing, but this should also be running on boot & when looking at:
journalctl -b -e
I can see:
Nov 21 19:39:20 profgpi python3[1230]: File "/home/pi/control-pibot.py", line 23, in <module>
Nov 21 19:39:20 profgpi python3[1230]: from adafruit_crickit import crickit
Nov 21 19:39:20 profgpi python3[1230]: ModuleNotFoundError: No module named 'adafruit_crickit'
Nov 21 19:39:20 profgpi systemd[1]: pibot-mqttclient.service: Main process exited, code=exited, status=1/FAILURE
Nov 21 19:39:20 profgpi systemd[1]: pibot-mqttclient.service: Failed with result 'exit-code'.```
But again, this code runs fine when executed from the prompt as
`python control-pibot.py`
The python code absolutely does what it's supposed to do from that point on. Any idea what I'm doing wrong? Thanks!
Anyone have a good example code or project for using Raspberry PI as a bluetooth BLE or classic bluetooth server device? I would like to connect to the RPI B3+ from my phone. I want to send/receive simple commands
Isn't that just a DIY UPS? Seems like that could be just as expensive as a true UPS unit
Or if less expensive then less reliable
There is the PiJuice, which works fine...
@civic rune a UPS starts with a battery .. and an oscillator.
The Adafruit target board load-switching scheme assumes two stable DC power supplies at exact voltages.
It selects between the two, and, I think, ensures power delivery is constant enough to guarantee no interruption in service to the client device.
I have an Ulimate GPS Hat plugged into my RPi. I am trying to find a guide to let me use the RTC to set my system time. All I have found is a guide for the i2c module. Any help is appreciated. Thanks.
@dusky pivot I'd mount the VFAT type volume and look at the config file(s) first.
I saw this but don't remember what obtained.
huh
@faint sparrow yep, thats the i2c guide i was talking about. my gps hat uses UART though.
Take a look at this example https://github.com/adafruit/Adafruit_CircuitPython_GPS/blob/main/examples/gps_time_source.py I hope it helps.
Thanks, that gave me the solution for a different part of the project I was having trouble figuring out.
Does anyone know if there is a formula to know how big your input voltage can be for an opamp with a given slewrate, to stay under that slewrate
So there is no distortion
I've hooked up an arcade button with an LED to my Pi 2 to gracefully shut it down and boot up following this guide: https://www.embeddedcomputing.com/technology/open-source/development-kits/raspberry-pi-power-up-and-shutdown-with-a-physical-button - however, the LED stays always on, I would expect it to turn off when the Pi is off. I have the LED plugged into the 5v power and GPIO 7. Any suggestions?
I did add gpio=7=op,dh to my config.txt and tried #4 as well in case I had them backwards (I can never remember how the numbering works)
Your LED should stay on if it's wired that way; the 5V pins will always have power regardless of off/on state, as long as the Pi is hooked up to a power supply, and the GPIO pins will drop to 0V when off. If you want the light to turn off, perhaps use a 3.3V-GPIO or a GPIO-GND connection instead?
If I used the ground and GPIO the light never turned on - I'll try the 3v now. Thank you!
For GPIO-GND, make sure the positive end of the LED is on the GPIO, and the negative side on the ground, and the GPIO is high on startup.
thanks, will try that
got it! Thank you @turbid rivet
Now I can gracefully shut down my Pi connected to my 3d printer!
i am using RPI with Adafruit motor HAT. I hook up a Stepper motor. Go through examples. These work great. MY CHALLENGE is the stepper motor is being sent power (constantly hear a click and the motor itself is getting hot) after the python code runs. Is there a way to disable/enable? It seems once I do a command like kit.stepper1.onestep() the stepper motor continues to get power.?
A stripper motor is meant to hold its position when powered so thatโs the expected behaviour
@hardy plaza Thank you. I understand holding position as expected behavior. But if I have code running on the RPI 7/24, the stepper motor is going to burn out and it's wasting power. ??
If itโs being driven correctly within its specification it will have a rated lifespan. As to wasting energy that goes with choosing a stepper. Itโs not wasting energy if holding a position is a requirement
There may be a hardware or software enable you can use if you want to power down the motor. I donโt know the specifics of that controller
Maybe a pin labeled โENโ?
@hardy plaza I'll look. Seems to me this is something that would be important to expose at the abstract level. But....hmmmm....
I would cut off power with a transistor as a starting point.
Maybe a solid state relay.
Battery powered projects that operate for many hours are (imo) non-trivial to implement.
Thereโs the Pimoroni H10 digital switch, an I2C controlled switch that can handle 40v @ 10A. But youโd need two of them.
I imagine that in 1000 yars the equivalent of arduino powered with antimatter will be taught in middle school and everyone will have the tooling to extract it
meanwhile if someone use an exotic power source at my fablab it becomes a topic of discussion for 3 hours
I bought a mystery power supply at a hamfest and waited years before experimenting with it.
Turns out it's a 12 VDC power supply that can deliver 'quite a bit' of current (> 10A but I think it may be closer to 20 A).
Weighs as much as my old Astron did.
the old school guy I'm listening to explain how to be careful with old electronics by using a variable regulated power supply
ie: add 5-10V to it every hour monitoring for stored power and temperature until you reach the rated voltage
stored power as in he once had an electronics that used 12V and would have 2000V stored in it after a few hours
When re-forming electrolytic capacitors on vintage (tube type) radios something like that can be done, to avoid popping them when full power is applied.
.
There is a release() function that should stop sending the stepper power, allowing it to spin freely again.
Try kit.stepper1.release() when you get a chance.
Pi friends, I can use help figuring out why my systemctl service script isn't executing. It's supposed to run a python script after the mosquitto client is running. I think this is a systemctl issue, not a mosquitto issue. The mosquitto client does run on boot, but the script, called pibot-mqttclient.service, fails.
I'm new to diagnosing these problems, but if I enter the command:
journalctl -b -e
the output is:
Nov 23 14:48:47 profgpi systemd[1]: pibot-mqttclient.service: Main process exited, code=exited, status=1/FAILURE
Nov 23 14:48:47 profgpi systemd[1]: pibot-mqttclient.service: Failed with result 'exit-code'.```
The `adafruit_crickit` module is definitely there because I can execute this python code that's supposed to be executed by the service by typing the following into the prompt:
`python control-pibot.py`
The `pibot-mqttclient.service` script I'm trying to run, but that's failing, is:
```[Unit]
Description=Pibot MQTT Script Service
After=mosquitto.service
[Service]
Type=idle
ExecStart=/usr/bin/python /home/pi/control-pibot.py
Restart=always
[Install]
WantedBy=multi-user.target```
Any ideas are most welcome!
could be issue with how library module was installed vs. how script is run in terms of user
sudo python control-pibot.py
^^ does that also run ok?
Ah @steady rose I think you've found out what's up! Running under sudo fails with that same error! So I assume this means that I need to modify my systemctl service so that it runs under the pi user instead of sudo (assuming that what you've pointed out is sudo must be what's running at startup). I assume I'd change this line:
ExecStart=/usr/bin/python /home/pi/control-pibot.py
It's not clear to me that this is running as the root user, or how I might switch this so it runs under pi, if that's what I need to do. Thx again for your patience (and expertise).
running as root is default
i haven't actually done this, but there's probably a way to specify a user id for the service to run as
so, yep, use that and set it to be the pi user
try adding a User= entry
@steady rose that works! Thank you for sharing your gifts. If you're somewhere that celebrates Thanksgiving, wishing you a happy. And may your sauce always be awesome!
Hello, I build a little circuit with a raspberry,npn transistor and led. I can turn on/off the led with the rpi over gpio. Then I thought putting out the led for another raspberry to turn it on/off. But I does not work like the LED. Why?
Is there a place to get old discontinued Raspberry Piโs? Iโd like to get a spare RPi 2 for a project, but the ones on eBay are ridiculously overpriced. Wondering if thereโs a site like swappa.com for R Pi?
why not just use a newer one?
The software Iโm using is not compatible with Python 3.
I have pi that I need to get an MP3 off of onto a flashdrive, but it's telling me the MP3 is write only. I tried:
sudo cp myfile.mp3 /pi/media/my_flashdrive
but it didn't work. What can I try next?
please ping me, I'm gonna be away from my PC
@civic rune maybe mount the flashdrive first ?
What do you mean by mount? It's plugged in and showing up
sudo mount /dev/sdb1 /media/usb
What does that do?
it mounts a device on /media/usb
I think you need to look up which device is your flashdrive in /dev/
Huh
then mount it on media
It showed up in media in the file system
what filesystem does it have
What's "it" here?
it is flashdrive ?
Yeah
You asked if it's a flash drive, I indicated yes it is. I may have gotten myself confused. I've used this drive on a separate pi before with no issues
I wonder if the problem is that the code running on the pi in question is being used
Let me head over there and try that, got caught up in another task
Is it the flash drive?
Yeah I don't either
But the drive seems fine to me.
Interesting, there's no "eject" button for the drive
๐
you confused me and I don tunderstand you. funny to me
What was confusing? I can be more clear
I should say then, that the micro SD card with all the software I worked on for months will not boot in an RPi 3, but does just fine in the two RPi 2Bโs I have but one of them is less than ideal for a spare. Iโm not interested in redoing all my software, which brings us back to the original question. Is there a web site where you can get an RPi 2?
so your rpi2 is dead and you want a new one ?
did you make a backup of you system ?
Perhaps I incorrectly assumed it was because the system on the microSD card is not using Python 3 and the software Iโm using will not run on Python 3.
Yes. I have 1 perfect RPi 2B, and would like to have a spare in case I need to replace the 1st one.
Iโd like to just pop in the microSD card so I donโt have to rewrite everything like I would for a newer RPi, which will not boot up from the microSD card that works just fine in an RPi 2.
So, is there a site you know of where people can get an RPi 2B besides eBay?
Is it possible to eject the flash drive from the terminal? I'm worried something went wrong
First see the USB drive by entering this command: fdisk -l.
Assuming your USB drive is /dev/sdb1, eject it with the following command: umount /dev/sdb1. Alternatively: eject /dev/sdb1.
Thanks. I'm gonna try a known good flash drive. Windows complains that this one needs to be fixed sometimes. Should have just used the known good one to start
That shows a bunch of stuff on /dev/mmcblk as well as a 14.5 GB drive on /dev/sda. The sda one is likely my 16 GB drive right?
So would it be umount /dev/sda?
sda should be the system disk
This may be helpful: https://www.youtube.com/watch?v=K-CHqJVHj4c
much simpler ๐
My flash drive is Patriot brand and the drive under SDA is labeled as "patriot memory"
Hm. Must be different. How does using the method in the video work for you?
I'm checking it out now. I have bad reception here so it's not loading quickly
What OS are you using? If it's Raspbian, they should be backward-compatible.
Have you tried running ls in /dev?
I know the ls command can take a filepath arg to look in a directory other than your current one.
There's nothing in dev?
Ok, I ran cd /dev first
Oh there's a bunch of stuff there, just not my flashdrive
ls in /media/pi shows only my flash drive
Can I run sudo umount my_drive there?
Let me try it thanks. Is it actually mounted?
Hmm it says it's busy
Are you in the flashdrive directory?
You'll have to back out of it first, then make sure it's not reading or writing any data to it.
I've backed out of all of them, let me double check
I've closed all windows besides the terminal that's pointing at /media/pi
Worst comes to worst, you can try shutting down, unplugging, and then restarting haha
Lol
Yeah
I think I'll do that
Didn't actually think of that, thanks
Any idea why I can rename a file? I'm getting permission denied errors
And any idea why an MP3 would be read only?
ls -l to see what's set, who owns, etc.
Ok thanks. I think I made a problem for myself by misusing sudo cp. I thought my drive was in pi/media but I actually seem to have copied and renamed the file to the name of my drive.
Having the same issue of no mounted flash drive/no eject button with a known good drive
My drive shows up as a drive on the desktop but no way to eject it
My file is on the desktop, do these commands move it to my flash drive? The drive is in /media/pi/pi_backup where pi_backup is the name of the drive.
cd Desktop
sudo cp my_file.mp3 /media/pi/pi_backup
?
man cp seems to indicate I'm right but I'm not sure
Let me try it. Any idea why the drives aren't showing up as normal?
Now the desktop is frozen :(
can then check what pi_backup has
What do you mean by "what pi_backup has"?
in terms of permissions and ownership
Ahh ok. I had to reboot, let me try what you're saying. Any idea why flash drives are not mounting as normal? I have no documentation as to what's been done to this pi
Do I include the file extension when I cp?
"flash drive" = like a USB thumb drive?
Like cp myfile.mp3?
Yes
what do you mean by normal?
It shows up on the desktop but doesn't show up in the usual place in the file explorer and there's no option to eject. umount gave me a "target is busy" error
Yeah looks like an old fashioned mech hard drive
if you double click it, what happens?
Opens up in /media/pi as /media/pi/pi_backup
what happens on the desktop? does a new window open?
Yup new file explorer window
with that window open, does it then show up as expected in file explorer?
I'm gonna try cp my_music.mp3 /media/pi/pi_backup unless something seems wrong there.
No. Not as expected
in the file explorer window that does open up, can you navigate around ok?
Ok this gave a permissions error. Use sudo?
Yes? I don't see anything wrong
weird. not sure why it shows up there but not in another.
what does ls -l /media/pi show?
what is pi_backup ?
Ok even with sudo I get the error
cp: cannot create regular file /media/pi/pi_backup/mymusic.mp3 Permission Denied
256 GB flash drive I used to create an image of another pi
Trying this, one sec
Here's what I get. Had to walk over into wifi range.
That long string is an MP3 that I mis copied (renamed it it seems to the name of my flash drive)
My old flash drive that I took out
it's owned by user pi and has read/write/execute permissions
what does df -T -H show?
One sec, had to help someone with something, be right back
What directory should I be in?
One sec, pic incoming
Drat you can't see the bottom one. I have to walk back and forth to get wifi signal
It's my drive it says /media/pi/pi_backup
What does this show me?
no worries. that photos is good enough.
What would your next step be? Idk what the people who set this up did to the mp3 to make it so inaccessible
Or to make flash drives mount wrong
Yes it shows the files
ok, try touch /media/pi/pi_backup/foo.txt
Permission denied
All I have done with this drive is create an rpi image on it (separate pi)
It was formatted as NTFS
yep. and it mounted as such.
not sure if you need anything extra to actually access it though?
Let me try copying another file over
i'd think if it mounted, you'd have ntfs support also
in the desktop file explorer thing - you're seeing the same stuff as ls?
Yup
can you create a new file/folder via that interface?
the flash drive. double click on whatever icon shows up on desktop. and then in there, create a new folder.
Cannot create a new folder nor new file
sudo chmod 777 /media/pi/pi_backup
What does that do?
getting desperate, but see if that takes and helps
it opens it wide up in terms of permissions
I cannot even rename files on the pi....
What the heck did they do to this thing?!
Should I try a third flash drive?
you have permission issues even outside of that flash drive?
touch ~/foo.txt
not sure. seems like something bigger is happening if you can't even create things in the local fs
Yeah I can't copy the mp3 from the desktop to anywhere
ok, something else is happening. but don't know what.
Dang ok.
I really need to get this file off. Is there a way to get it off of the micro sd card?
you're logged in as user pi based on the prompt
does it boot directly into desktop? or do you have to enter id/password?
Directly into desktop. I get the "ssh is enabled and default login is used" message
that means user pi has password raspberry
i'd try a reboot at this point. and then after logging in, try to do something in the pi home directory
something seems really unhappy if you can't even access your own local files and folders
Yeah the people who created the Mp3 (its a combo of songs) aren't here anymore and they didn't back it up anywhere...
What do you mean by "try to so something in the pi home directory"?
How can I create a file? With touch?
don't worry about flash drive at this point
try touch OatsNHoneyHello.txt
yes. can use touch.
and cat OatsNHoneyHello.txt
it'll create a blank file with whatever filename
touch foo.txt worked
just now? without any changes?
Yup
pwd
Where would that be created so I can look at it? I was just in ~
where are you currently located?
ok. and you did touch foo.txt and it worked?
Yup I see the file
hmm. now try touch ~/foo.txt
That ran
Nope this is the first time I've tried touch on the pis filesystem itself.
Ok I was able to copy the music to another part of the pi. Let me see if I can copy it to the flash drive now using the GUI
Permission error
flash drive like a sd card ?
No thumb drive
maybe it's ntfs formatted instead of fat32 ?
it is
can you write on it in windows creating a file manually on it with notepad ?
I can
and does it says ntfs from windows drive properties ?
Yes I used windows to format it as ntfs
I'm gonna be away from the system for a minute, I've been working long enough that I am managed to clock out. One moment
^^ was wondering that. don't think i've ever tried it.
you'll have to format it as FAT32, it works on windows because it was formatted with your windows account NTFS
format will delete all files, so save the ones you need
Ok I'll have to come back to this, I'm currently building another system that I'm behind on. Thanks for your help folks
no problem, I sucks at pi but not at linux ๐
I can't even login to my Pi anymore and don't even know where it is ๐
it worked at least enough to be able to ls the contents
What's weird is another pi had no issue creating an image of itself on the NTFS drive. In fact the guide required NTFS
creating an image format the drive
and I was able to add files from the other pi to it
and change its boot record
adding a file is another it
plus you have to mount it rw for that
Hm
where did I lose you?
I'm just confused as to why NTFS was fine for one pi and not for another
I guess the other pi could have an older OS that's incompatible
if you were dding, then it generally would not come in to play
Hmm ok, I'll have to come back to this after my deadline is past
Are there any actions I can take in the terminal to see if the file I want to copy is read only or something?
I am unable to mount my raspberry pi pico's filesystem. The device is new and just arrived today. When I hold boolsel and plug it into my windows laptop the filesystem does not mount.
double check USB cable
@steady rose (moving here) I used the power off button and now the pi isn't powering on
After removing and reinserting the power cable
Act light is not blinking
power button is just a simple NO type switch connected to GPIO?
Yup
and that just run a script that just runs sudo shutdown
I've tested the power on/off before and it worked fine. Crud
My main code which is run on startup handles shutdown
nothing with that should be affecting power cycling
what has changed since the last time the pi was power cycled?
I added the cables that connect the pi hat to the relays I'm using
But they are only connected to the pi itself via the spi pins
And the shift registers
if you've tried a few times and it's not powering
then need to work backwards to last known working setup
Shoot.
simply running sudo shutdown and cycling power should not cause this
I'll try using another pi with the same micro sd card and see if the SD card got borked
I'm using subprocess.Popen() to do it
generally same thing. that's just how you got to running shutdown from within python.
is the red LED coming on? just nothing on ACT?
Swap is easier. I'll try that.
Ok act is blinking on the new pi. Desktop seems to be coming up
So something about my wiring? Could having the mouse and HDMI plugged in do anything?
it shouldn't
Hm
would suspect interference on GPIO first
How would I test that? This is super weird
I've run it all plugged in without using the power button before and it was fine. The power button seems to have done something to the system??
I'm going to swap the SD card back and see what happens
I wired in my system but that's it
maybe the speed of light suddendly changed in the universe ? or neutronio runaway collision with the Pi ?
I'll try plugging everything in to the new pi and see if it's the same result
if multiple things, then systematically remove things and try again, etc.
work backwards towards last known working configuration
I don't see any shorts between my ferrules or anything like that
Oats is using mains I think if that matter cater
also possible something got zapped. but just need to work backwards to find out.
if you get all the way back to last known working, and it still does not work, then...well...not good. but should continue to investigate.
Wish we could have a small card along our nickname in here to show what are working on/boards/setup/etc while asking questions
working with mains is def a potential for zapping something
do you get video on the monitor ?
like blank screen or no input signal on the monitor ?
No input
And no action on the ACT led
Ok what could be going on with the hat? A short somewhere? It was working fine before
No chips are hot, no indication at all that anything is wrong.
I never used HAT before
but it seems related to hat? pi boots ok once removed?
Yup
I'd disconnect everything and just hook the PI to an hdmi thing with keyboard
at least you know where to look
and see if it works on it's own
I did that, that worked.
and the pi survived whatever it is
on both of them ?
I think at this point we need to see and have details of what
The issue comes when the hat is plugged in but it's a new issue
ie: take pic of setup if possible, how it's wired/attached, involved hats and models etc
Here's a pic
Worth it to continuity test the cables?
Ah I found a short...
Gotta trace it noe
Oh that's expected.
The problem began after using the power off button. It's just using GPIO 5 and GND.
Dang. Took all the wires out and it still won't boot
I think you are interesting OatsNHoney, I can't quite place how much you know or don't know ๐
I know nothing about real computers
You are probably like me in that you are like an alphabet soup
My experience is with MCUs
So something about my hat is preventing boot, but didn't before....
I don't see any shorts on the hat
It's a bad idea to remove the hat while it's powered right?
Man I'm so deflated. I was so close
I'm gonna move this to #help-with-hw-design
wait you did a custom pcb ?!
Nice
Shoot
PCB schematics??
Or is the PCB a secret
?
Hello, I build a little circuit with a raspberry,npn transistor and led. I can turn on/off the led with the rpi over gpio. Then I thought putting out the led for another raspberry to turn it on/off. But I does not work like the LED. Why?
Since I cannt explain why the circuit isnt working with a transistor, maybe a relay is better and easier to implement
relay probably uses enough current that you'd want to put a transistor in to drive it?
and add a diode against back emf from the coil, etc
I don't understand the part about putting the led out?
@wraith groveI want to switch the raspberrypi on and off with the transistor, like a LED.
Hmm, maybe the problem with the transistor is R_DS=0.1 ohm.
they went to the pcb help channel to get help about it because the problem seemed to be their custom PCB
Hi all, I trying to use a keyboard number on a rotary Encoder but what's killing me is the when I go one way it some times wants to go the other way.
So clockwise would be numbers 1
Anit clockwise would be number 2.
Any thoughts please
need more info. what's the encoder and how are you reading it? what do you mean by "keyboard number"?
sort of a secret? Idk, I bodged in an external power supply and it boots now, so I need to figure out what was going on to prevent booting in the first place
is the hat drawing power from the pi's GPIO header?
Yeah
Not any more but it was
I'm thinking that was the issue but I don't know. Next revision will have a separate 5V supply
Encoder EC11
And I mean number 1 number 2 on the keyboard
@civic rune that could very likely be the issue. not sure how directly 5V gets routed through the pi. there's a polyfuse to limit current. and other aspects have changed with pi models. but in general, that behavior (no boot) seems to line up with something external using the 5V rail and not playing nice.
@plush wave how are you reading the encoder?
Digital
I should have mentioned I jumpered in just the power and it wouldn't boot. So it was either the 3v3 line or the 5v line that didn't worm
Work
@plush wave software-wise
Thonny
@civic rune using the 3V rail brings even more potential fun ๐
@plush wave can you link to your code?
Need a min to get the laptop up again
Only 3v signals from the pi are now the data signals so it's all good.
I'm gonna run the next board all on external 5v and use level shifting for the data lines
@steady rose btn1 = digitalio.DigitalInOut(btn1_pin)
btn1.direction = digitalio.Direction.INPUT
btn1.pull = digitalio.Pull.DOWN
while True:
if btn1.value:
keyboard.press(Keycode.1)
time.sleep(0.1)
keyboard.release(Keycode.1)
didn't want to put the whole code down there is 26 functions on the thing
so that's not full code? it doesn't have anything that's reading the actual encoder pulses.
thats what i use for a keyboard encoder it was just not as good, what am i missing
something to read the encoder pulses
which can be tricky depending on what all you have in your setup.
do you have just a bare EC11?
yes
reading those pulses without losing count is tricky.
but maybe you don't need absolute counts? could just sense direction and increment/decrement something?
what functionality are you wanting the turning of the knob to provide?
its for lightroom
what do you want to happen when the knob is turned?
not sure what that means
it looks like you are wanting to simulate pressing a keyboard?
like you have some device that is driven by pressing 1 and 2 on a keyboard?
That's correct but I don't want to press the keyboard button loads of times
and you don't need absolute position info from the encoder? it's just: (1) not turning, do nothing (2) turning one way, send out 1 s (3) turning the other way, send out 2s
not 100% sure what your on about now but what are you thinking
i'm still not understanding how you want the knob to drive things. it seems like only direction is important. not actual position.
ok, i would like the encoder to pick up number 1 when turning clockwise, and when turning the other way i want it to pick up number 2, now I've done this and it works what i doing my head in is that it has a flicker of going the opposite direction that it shouldn't do
gotcha. so just direction. that's generally easier than keeping track of all the pulses to maintain an accurate absolute position count.
is btn1 in your code one of the encoder channels? the A or B signal in that diagram
import time
import digitalio
import board
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
btn1_pin = board.GP0
btn2_pin = board.GP1
keyboard = Keyboard(usb_hid.devices)
btn1 = digitalio.DigitalInOut(btn1_pin)
btn1.direction = digitalio.Direction.INPUT
btn1.pull = digitalio.Pull.DOWN
btn2 = digitalio.DigitalInOut(btn2_pin)
btn2.direction = digitalio.Direction.INPUT
btn2.pull = digitalio.Pull.DOWN
while True:
if btn1.value:
keyboard.press(Keycode.KEYPAD_NINE)
time.sleep(0.1)
keyboard.release(Keycode.KEYPAD_NINE)
if btn2.value:
keyboard.press(Keycode.KEYPAD_SIX)
time.sleep(0.1)
keyboard.release(Keycode.KEYPAD_SIX)
thats in 1 rotary encoder
where's btn2_pin defined?
GP bit?
btn1_pin = board.GP0
should be something like this for btn2_pin?
its in there i forgot to type it in when i did the message
those are the two pins you've connected the encoder A and B channels to?
retyped
sorry you lost me
what is connected to pins GP0 and GP1?
1 rotary encoder 1 for clockwise 1 for anit-clockwise
Yes.
A in GP0
B in GP1
C IN 3V tryed in group didn't work at all
that seems OK in general, since you are enabling internal pulldowns
the other way would be C to GND and then use internal pullups
but just inverts the signal, and doesn't generally matter for your application
So instead of digitalio.Pull.DOWN
It would be digitalio.Pull.UP if I wanted it on the GND
But wouldn't make a difference would it?
no. doens't matter for what you are doing.
Ok
that's the general signal that gets generated
read it left-to-right for clockwise
right-to-left for countercw
since you only care about direction, you'll want to change your logic to be something like:
watch for A to transition from LOW to HIGH. when it does, read B. if B is LOW, then you are turning CW. if B is HIGH then you are turning CCW
and for the keyboard part, you can use send:
https://circuitpython.readthedocs.io/projects/hid/en/latest/api.html#adafruit_hid.keyboard.Keyboard.send
instead of separate calls to press and release
So I need to change the code from press to send
that's one thing. it's just a simplification. it takes care of generating both the KEY_DOWN and KEY_UP event signals.
it's functionally equivalent to your existing code, except for maybe the actual amount of delay
the main thing that needs changing is the logic being used to read the encoder
tryed it same problem im now starting to think the encoder is too sensitive
just as i move it, the code is taking over before it gets to the clicking part
ok i tired something, i pulled the gp1 pin out and turned the encoder both ways and they both said the same number, even thou the gp1 pin has been pulled out
@plush wave using the debouncer library could help, here's a rough example:
import board
import digitalio
from adafruit_debouncer import Debouncer
PIN_A = digitalio.DigitalInOut(board.GP0)
PIN_A.direction = digitalio.Direction.INPUT
PIN_A.pull = digitalio.Pull.DOWN
PIN_B = digitalio.DigitalInOut(board.GP1)
PIN_B.direction = digitalio.Direction.INPUT
PIN_B.pull = digitalio.Pull.DOWN
CHAN_A = Debouncer(PIN_A)
CHAN_B = Debouncer(PIN_B)
while True:
CHAN_A.update()
CHAN_B.update()
if CHAN_A.rose:
if CHAN_B.value:
print("CW")
else:
print("CCW")
Cheers bud, I'll try it in the morning
@steady rose morning bud, when you have a sec its coming up with an error on line 3 its the """import Debouncer""" part
@plush wave probably just need to install the library. info on libraries:
https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries
can download bundle from here:
https://circuitpython.org/libraries
I'm looking at buying 2 64x32 LED matrices and the Rapsberry Pi Hat that drives them. Looking at this guide, the hat has a 5V 4A wall adapter plug that can power a matrix - if 2 are chained together does it power both?
I was looking at this guide: https://learn.adafruit.com/adafruit-rgb-matrix-plus-real-time-clock-hat-for-raspberry-pi
Cool
Is there any python module for controlling the brightness of an HDMI monitor connected to Raspberry Pi
I am using a UPERFECT 10.1" HDMI monitor hooked upto the raspberry pi, Now i want to control the brightness of that monitor via python program
There is a Python Module named as Screen-brightness-control that works great on Windows but is not working on raspberry pi
@faint sparrow Did you look at PyPI? The one you mentioned is first, but there is also https://pypi.org/project/brightnessctl/ or https://pypi.org/project/sys-backlight/
Hi Thanks for responding to my question, i did had look at the PyPi before asking the question here, I always look online myself to find the answer to my question and if i don't find the answer then i ask here,
The two modules you suggested doesn't work
The brightnessctl only works on intel Linux devices and as you probably know the Raspberry Pi is not an intel device, the other module sys-backlight allows only command line interface to change the brightness although i am not able to find any examples on how to run the command to even adjust the brightness from the terminal
Ah bummer, sorry
I've been happy with the Samsung T5, which are readily available, not particularly expensive, USB C, small and light.
Anyone got some resources for programming a diy joystick in micropython. Only examples I've seen are circuit python ๐ฆ
trying to make a flightstick system
Circuitpython is generally the preferred option for these types of peripherals due to its ease of usb hid implementation. However, the joystick code itself should be similar in both flavors of python, differences being circuitpython packaged it into a library somewhere for ease of use.
https://github.com/GuyCarver/MicroPython/blob/master/esp32/joystick.py is a good example of a joystick implementation, though itโs pins are defined based on an esp32.
Thanks. I'll take a look around. failing anything else I'll just go for the circuit python option
Might also be worth noting that a pi has no adc pins for joystick compatibility, and an rp2040 board only has 3-4 adc pins available for a maximum of 2 joysticks. If your flight controller needs more axes than that, you may have to look at some external hardware for help.
Yeah. or just stick to arduino...damn
hi mate, been very busy, i copyed the mpy file over to the board and placed it in the lib folder and error message comes up.....Traceback (most recent call last):
File "<stdin>", line 3, in <module>
MpyError: Incompatible .mpy file. Please update all .mpy files. See https://adafru.it/mpy-update for more info.
so i made a file for it then this error came up
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
ImportError: no module named 'adafruit_debouncer.Debouncer'
sorted the file
@steady rose hi bud all working now just one more thing when I do the test it response quick but when using program that is want it for its slow is there a code to speed the process time up
Or if anyone else can help
hi allm right what ive found is that the dial will not jump backwards which is brilliant but its now missing the pulse. i can get about 3 or 4 clicks to 1 code rear out. so basicly when i turn the dial it will read the number but then it takes about 3/4 clicks to read the number again.
I'm trying to write raspbian to fresh, just out of the box, SD card. The SD card shows up in windows in as D: but doesn't appear in raspberry pi imager. Is this weird?
although I can't seem to access the drive D:, I just get the blue spinning circle when I try
and my taskbar just crashed....something's up
my computer crashing and fixing itself solved the issue
Hi everyone, I followed this tutorial successfully and it is awesome for using a VNC and just a computer directly connected to the pi. https://www.hardill.me.uk/wordpress/2019/11/02/pi4-usb-c-gadget/ Iโm wondering if anyone knows if Itโs possible to use the pi as an ethernet and usb hub over usb-c to my MacBook? Specifically, can I plug into the pi Ethernet port and get ethernet and 4 additional usb-a ports through the 1 usb-c connection?
Hi guys, super basic question, I hope it's ok, but...
Is it possible to use a passively cooled Pi as a streaming device for a flat screen HD TV? If so, what would be the minimum specs able to smoothly stream?
What quality stream are you looking for? 720p, 1080p, 4K? What kind of audio? 2 ch stereo? 5.1 surround, what?
1080p, stereo sound. Nothing wild.
you'd need at least 4GB of RAM, I'd say, at a minimum. So a Raspberry Pi 4 B. I'd recommend either a USB 2.0 external drive with separate power supply or some kind of NAS setup that also is externally powered for storing videos. There's lists of compatible drives and such. It should be able to deliver 1080p video as long as you do not need to recode video.
Use Plex, obviously.
So, best bet is to download videos that are already 1080p. If you need to transcode video, a RPi is not going to be sufficient. You'd probably be better of with an Intel NUC or similar.
It's just for Netflix and HBO.
Only streaming from those sites.
And youtube.
Oh, so if you're using it through Raspbian and streaming, it should work fine. You may get penalized for browser compatibility and not get 1080p, like if you try to stream Amazon Video from a super powerful rig that runs Linux. It'll still give you the crap bandwidth option for no reason.
With only this streaming in mind via browser, your first recommendation is still valid?
Yeah, you can use an RPi 4 for this.
If all you're doing is hooking it up to a TV and running video off of YouTube or similar, then it'll work fine.
I mean, it's not going to blow your mind or anything, but it'll work. Then again, it's a $45 computer. ๐
I'm a simple man ๐
Thank you for taking the time.
I don't claim to be an authority on this (so perhaps someone in the know can chime in if I'm mistaken), but my understanding is that with a Pi 4 you'll get better video performance using the new Bullseye version of the Raspberry Pi OS, as it's now using the Linux KMS video driver. That would of course be if you're using the Pi's desktop environment.
I will. No reason to make this harder than necessary. Thanks.
I have installed pi_video_looper (tdicola) many times successfully. Recently, I came across an issue with the video looper installer. Its seems that the pyudev link must have changed, so it cannot find pyudev. I have installed pyudev manually, but the installer still fails. Any ideas? Here is the output from the installer. Searching for pyudev
Reading https://pypi.python.org/simple/pyudev/
Couldn't find index page for 'pyudev' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or working download links found for pyudev
error: Could not find suitable distribution for Requirement.parse('pyudev')
Thanks for the forum thread as well. Assuming that is up to date I will bring this to the attention of the right people. Also note https://forums.adafruit.com/viewtopic.php?f=50&t=185021
and also #help-with-linux-sbcs message
Thank you. I also have a post in the forums. Have not received a response.
which recommends https://videolooper.de/ (though that's not brand new either)
Yeah, the same thing happened to me (as that discord link shows). The disk image download that I mention works beautifully. Would be nice if the pyudev part could be fixed thoโ.
Hey, I have this product, and I am wanting to run it off a Raspberry Pi 3B, is that possible? and how can I do it? And will the code still work with NixOS? (sorry, super new to hardware) https://www.adafruit.com/product/3202
Oh, sorry, I should specify I am wanting to take a picture ever 5ish seconds, which requires shorting the green line to ground.
generally possible, since it just requires GPIO pins to control
can use this as a general reference:
https://learn.adafruit.com/portable-mini-timelapse-camera/overview
it's a trinket/arduino, but the code is super simple
So, I take a GPIO pin and run its voltage at like 5 volts and then drop it down to 0 for 500MS every 5 seconds?
GPIO pins on a Pi would be 3.3v, but you certainly have the right idea. On by default, then pulse off for ~50ms every 5 seconds.
for power
There's no datasheet, either, huh.
Oh, yah, your right. I misread 100ms as 1000ms.
Yah, they say "because its so simple" or something.
Usually, logic high is defined by Vss, so powering it directly off of 5V might make it harder for the data to trigger properly?
I know Neopixels struggle with that at times.
I guess you can try it out, and introduce some basic level-shifting if it doesn't work...
I'd rather not reverse-enginner the entire module for this haha
Lol yah. The reason I got it was because I needed to run three cameras and needed to get it fast.
If form factor isn't an issue, you could try using 3 USB webcams? A Pi 3B should have enough USB ports for that, and you should be able to get that up and running fairly quickly.
Form factor is an issue. Weight is very much an issue as well. Its going in a weather balloon, and the group I am doing it with is considered about with a lot.
Not to be sacrilegious in the RPi channel, but you could save a lot of weight by using a Wyze cam with an SD card in it set to record. I havenโt looked into that capability of the new ones, but at least the old ones would record if they werenโt connected to the internet.
Hmm, I did think about that, but wight is still an issue. Plus I already have the cameras, so....
anyone have problems with the pi touchscreen not being recognized under Buster?
what could have been done to an MP3 file to make it seemingly impossible to transfer to a thumbdrive? I have used the same thumbdrive on another pi without issue so I'm thinking it must be the file itself
What kind of error are you getting?
Permissions error.
I'm away from the system now, and have bad internet access there, but I can head over any time if you have ideas
whoami
ls -l (insert filename)
compare file permissions/owner to whatever you're logged in as
and same for destination
Is whoami a command?
Yes. It just tells you what the username of the logged-in user is.
Define "wrong"...?
Wrong is they show up in the file system but don't have the usual eject button
I'm trying to use the MCP2221A board. The passthrough serial port works fine, but I can't access the GPIO pins (using Blinka). When I try import board it tries self._hid.open(MCP2221.VID, MCP2221.PID) and gets "OSError: open failed". I could check the rights but I don't know which file to check.
do the checks here pass as expected?
https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221/post-install-checks
hid.enumerate finds the board.
device.open() fails with the OSError: open failed.
I'm confident in the USB connection because I'm using the serial port.
what operating system?
Linux denim 5.10.11-v7+ #1399 SMP Thu Jan 28 12:06:05 GMT 2021 armv7l GNU/Linux -- Raspberry Pi OS.
(but not the latest Bullseye release)
Yeah that worked as root.
did you go through the various setup here?
https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221/linux
udev, etc.
I did. I blacklisted the native MCP2221 driver and added a udev file.
have you rebooted since adding the udev? or unplug/replug the mcp may also work
I haven't rebooted.
try just unplugging/replugging the MCP in USB port
Okay, still can't open the device as 'pi' user.
did you rmmod the driver? or just add to blacklist?
I did both.
hmm. go ahead and try a reboot.
seems like something's interfering or some aspect of the permissions is not working
can also verify the VID/PID are as expected. it'd be in the output of hid.enumerate(), but buried in with all the other stuff
I get ['0x4d8', '0xdd'].
root: yes, pi:no.
My 99-mcp2221.rules file:
SUBSYSTEM=="USB", ATTRS{idVendor}=="04d8", ATTR{idProduct}=="00dd", MODE="0666"```
^^ that file is in /etc/udev/rules.d/ ?
total 8
-rw-r--r-- 1 root root 1917 Oct 26 2020 99-com.rules
-rw-r--r-- 1 root root 80 Nov 30 07:09 99-mcp2221.rules
hmm
(blinka) pi@raspberrypi:~ $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
>>> hid.enumerate()
[{'path': b'1-1.3:1.5', 'vendor_id': 9114, 'product_id': 32824, 'serial_number': '', 'release_number': 256, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 5}, {'path': b'1-1.1:1.2', 'vendor_id': 1240, 'product_id': 221, 'serial_number': '', 'release_number': 256, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 2}]
>>> device = hid.device()
>>> device.open(0x04d8, 0x00dd)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hid.pyx", line 113, in hid.device.open
OSError: open failed
>>> exit()
(blinka) pi@raspberrypi:~ $ sudo vi /etc/udev/rules.d/99-mcp2221.rules
(blinka) pi@raspberrypi:~ $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
>>> device = hid.device()
>>> device.open(0x04d8, 0x00dd)
>>>
not sure
it's working here
Any idea which file it is actually trying to open?
it's accessing via hid
(blinka) pi@raspberrypi:~ $ groups
pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
what groups is your user pi in?
pi adm dialout cdrom sudo audio video plugdev games users input netdev lpadmin gpio i2c spi```
weird. not sure what's happening.
seems like all the setup is correct
just to mention - the ADC is about the only useful thing on the MCP, the pi already has SPI, I2C, and GPIO
I'm using it to drive the zero2w with CircuitPython. Ctrl-C isn't working, so I want to have a control line (G3 to D18) I can use for out-of-band signalling.
Instead of while True: I test the value of D18.
I'll look at using one of the raspberry pi GPIO pins instead.
Thanks for walking me through it all.
The passthrough UART is nice, and I was surprised to learn that the pi zero 2 W can run on the shared USB power line.
has anyone experienced that you cant autoboot applications anymore with rc.local?
Yeah I think that doesn't work anymore
Let me find an article for you
so for ExecStart i should enter the absolute location of the pico 8 file
what is rc.d?
I believe so yes that's how I did it. When I'm home I can post the service file I use without issue. I didn't use Before or After since I didn't care
The rpi gpio header doesn't expose the pin that uses the ACT led right?
cool
it does need some extra command configuring right?
Yeah you have to make your script executable
The one you want to run on start
It should all be in the guide but it's been a few weeks since I read it.
There's an adafruit guide that I think does it the wrong way so I pointed you to that one
Added the Retroflag PiStation to the family. Repurposed a 2G Pi 4. Now, if I can just find an SSD that will fit under the flip top๐ค
Is it possible that I was having trouble copying an mp3 file to a thumb drive because it was in use by a running program?
was the running program playing it ?
Yes
yes, could be a I/O thing too, like the io channel is busy with playing a file
that happen on a computer when you install a program and reading othe files during install is really slow, the io channel is busy
Hmm that makes sense but doesn't explain my other issue: thumb drives not mounting right. They show up in the system but not as thumb drives and without the eject button
can you provide more info? are you sitll using linux? console? or XWindow? if so whicxh graphical manager? are you remotly connecting to it ?
if on linux/console, in mnt you won't see such things, that's a windows thing
eject would be properly doing umount on it before you remove it
and for the I/O remember when we spoke about TTYs ?
Yeah let me get over to the system. I was running a diagnostic on a different thing
The eject button I expect from the gui as I see it when the same drive is plugged in to a different pi
I had no hand, nor did anyone working here, in setting this up
Ok I stopped the program from running and rebooted. I still can't copy the mp3 to a thumb drive
whoami says pi and ls -l myfile.mp3 says -rw-r--r-- 1 pi pi
file should be readable by everyone
Hm
Can I tell if it's currently in use?
The problem is that I can't just find another copy of the mp3, it's a combination of multiple .mp3 files and was only stored here as far as I can tell
When I try to copy it, it says read only file system
Is there a way to get the file off of the SD card?
Right click, copy, and then using ctrl v in the flash drive because right click doesn't work in there for some reason
Is it possible that that's the read only file system?
it could be complaining about the flash drive, not the mp3
try just making a local copy
Hmmm but this drive works literally everywhere else.
Let me try one sec
That works.
I guess I can get a fresh flash drive
try copying some other file to flash drive
Hey that didn't work either! So it's the flash drive
Although weird that this drive works fine elsewhere including other pis. Should I format the fresh drive as EXT4?
is a USB thumb drive and using the graphical interface your only option?
have you tried scp?
file copy over wifi
so no wifi would be show stopper
and limit other options as well
is wired network available?
Is it possible to turn the pi off and physically pull out the sd card?
Ah yeah no wifi here. I've asked for a hot spot but no luck yet
I would need like a 300+ foot ethernet cable
It is. I could bring it to another pi that's within range of wifi
try copying mp3 to /boot partition
that's FAT and will show up on pretty much any PC
then what Hem is suggesting. power down, remove, use another machine to copy off
(i think that's the idea?)
Ok anything I should be aware of when copying to boot drive?
It would just be /boot, correct?
I need to use sudo it seems. Would that be
cd /home/pi/Desktop
sudo cp myfile.mp3 /boot
?
try it and see
Good pt
I've got a stomach bug, my thinking is slow atm
There it is. Now I gotta figure out how to get to the SD card without unplugging all the undocumented electronics
^^ oof. that doesn't sound easily accessible.
might have been worth trying to figure out why USB thumb drive was acting read only ๐ฆ
but could also spend just as much time on that
Yeah and it suddenly stopped booting
As well
I'm glad I got the file off when I did
Well a power cycle fixed it. I'm very glad
Im really new to Linux and the pi and have some probably very basic questions and was wonder if anyone could help me out!
it's usually suggested to just ask your question and if someone knows/is free, they'll help you ๐ Welcome to the server!
Haha thank you! Sorry, Iโm wondering if there is an easy way to loop videos on a pi through the terminal?
that's not basic ๐
I was expecting you to ask how to list the files in a folder or mount a usb stick or how to run commands as root/what is root ๐
Iโve done a whole tutorial that adafruit did on autoplaying videos from a usb which worked I just want to have the files on the pi and directly play them haha ๐
do you mean on a LCD or play them on the hdmi output ?
Hdmi, I have a 7โ screen that Iโve connected
Iโve used the app VLC on pi to run videos from a list. There are command line options, so I bet there is a loop. @unkempt cave
Would this work to expand GPIO for some digital/analog inputs, specifically on the CM4? https://www.digikey.com/en/products/detail/microchip-technology/MCP23016-I-SO/551892
Order today, ships today. MCP23016-I/SO โ I/O Expander 16 IยฒC 400 kHz 28-SOIC from Microchip Technology. Pricing and Availability on millions of electronic components from Digi-Key Electronics.
It would work for digital, but the chip has no analog functionality.
So could I just use an analog to digital converter for that?
Yep, there are ADC chips which also interface over I2C or SPI.
Just depends on how many channels you need, the sampling rate, the bit resolution, etc.
Will the square PIM470/PIM475 HyperPixel fit on the CYBERDECK HAT while mounted to a RPi 400?