Those boards officially run Jetson Linux, on ARM64 architecture. The latest versions of Jetson Linux is Ubuntu 22.04. That should be considerably better than the old Jetson Nano, which had a very old Ubuntu. ARM64 has decent support the last 2-3 years in mainstream ML/numeric libraries. But expect problems if you run older versions, or more less commonly used libraries with C/C++ dependencies.
#microcontrollers
1 messages Β· Page 6 of 1
That is not a board that can run Python. Most beginner friendly alternative would be to use Arduino IDE and C++. If you want to use microcontrollers that run MicroPython, get an ESP32
i do have an arduino. I just got this board because of a class and been wondering how to even use it
not sure about arduino since its a non arduino board
you can probably treat it like a arduino pro micro
your option is to use C++
could you show a pic of your board ?
sure. I can also post the corresponding gitlab repo
this does not look beginner friendly
best to follow your class instructor
regarding this board
course is in a year so that a bit too long
you said you have an arduino , you could start with that
Indeed. I just wanted to find out how to actually use the board when I have it. But project for the future then
Hi saul
hi charizard
Hey today did not go as planned for me, I won't have time to work through the problem right now. Have you enabled GPIO on the pi?
I don't think I did
ok, we're going to need to enable the gpio and the i2c pins
let me see if I can find a tutorial really quick
(ok actually looking at the error's you hit, we'll run this first)
If you're in your thermal camera directory and env you can run:
pip install --upgrade Adafruit-PlatformDetect
(I dropped the 3, because the env *should* solve that part, but I'm not 100%. If you get the same error we'll go on to the gpio and i2c setup)
(env) myberrypi@raspberrypi:~ $ pip install --upgrade Adafruit-PlatformDetect
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: Adafruit-PlatformDetect in ./env/lib/python3.11/site-packages (3.60.0)
Ok so when you see pip3, go ahead and just use pip in this environment
I'm going to keep helping you here, but so I can quickly jump to it, I'm making a note of the help thread
#1204591033615257611 message
Ok now we're going to run the raspi config and enable gpio and i2c
(I haven't gotten my pi upgraded yet, that's part of why my day didn't go as planned, so I'm going to be guessing a few things here, asking you how it went, and then fixing what I got wrong)
Go ahead and run
sudo raspi-config
it'll open up a configuration menu
you'll use the arrow keys to move around, then enter to select the menu you want. We're going to want 'interface options'
scroll down to I2C and hit enter
when it asks you if you want to enable i2c, hit yes
β The ARM I2C interface is enabled
sweet, that's good
I clicked ok
sudo apt-get install rpi.gpio
go head and run this ^
I *think* it'll help. idk. This is the part I was trying to get working today, but my demo pi isn't ready yet
(env) myberrypi@raspberrypi:~ $ sudo apt-get install rpi.gpio
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'python3-rpi.gpio' for regex 'rpi.gpio'
Note, selecting 'python-rpi.gpio' for regex 'rpi.gpio'
Note, selecting 'rpi.gpio-common' for regex 'rpi.gpio'
python3-rpi.gpio is already the newest version (0.7.1~a4-1+b4).
rpi.gpio-common is already the newest version (0.7.1~a4-1+b4).
rpi.gpio-common set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 137 not upgraded.
(env) myberrypi@raspberrypi:~ $
ok
it's already installed.
hmm.
can you reboot the pi, then sign in via ssh, then navigate to the directory and activate the environment again? Some changes might have needed a reboot
sudo reboot
?
Then I do my ls Documents, open my Thermal camera folder, run this python -m venv env , then this source env/bin/activate and open a nano and paste my code?
I think I had to do it all again today from yesterday's
Or I'm just doing a long and not necessary approach π€
ls Documents
python -m venv env
source env/bin/activate
pip install adafruit-circuitpython-mlx90640
python thermalcameraDemo.py
Where are you from?
actually you already have created the env, so you don't need to do python -m venv env, you just need to run source env/bin/activate
then similarly, you don't need to reinstall the library with pip
run this source env/bin/activate after ls Documents or
so it'd look something like:
(typing out stuff one moment)
myberrypi@raspberrypi:~ $ source env/bin/activate
(env) myberrypi@raspberrypi:~ $
Once you sign in, you want to navigate to the folder your program is in. We're going to use change directory (cd)
cd Documents/ThermalCamera
Next we're going to activate the environment:
source env/bin/activate
And that's most of what I wanted to do. Now I want to see if the changes fixed the bug you had, so we'll run the python file:
python thermalcameraDemo.py
myberrypi@raspberrypi:~ $ source env/bin/activate
(env) myberrypi@raspberrypi:~ $ cd Documents/ThermalCamera
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $ source env/bin/activate
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $ python thermalcameraDemo.py
ImportError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/myberrypi/Documents/ThermalCamera/thermalcameraDemo.py", line 5, in <module>
import board
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/board.py", line 50, in <module>
from adafruit_blinka.board.raspberrypi.raspi_5b import *
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_5b.py", line 6, in <module>
from adafruit_blinka.microcontroller.bcm2712 import pin
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm2712/pin.py", line 5, in <module>
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py", line 8, in <module>
raise ImportError(
ImportError: libgpiod Python bindings not found, please install and try again! See https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/libgpiod.py
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $
hmm
pip install --upgrade click
pip install --upgrade setuptools
pip install --upgrade adafruit-python-shell
try these three commands
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $ pip install --upgrade click
pip install --upgrade setuptools
pip install --upgrade adafruit-python-shell
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting click
Downloading https://www.piwheels.org/simple/click/click-8.1.7-py3-none-any.whl (97 kB)
ββββββββββββββββββββββββββββββββββββ 97.9/97.9 kB 1.9 MB/s eta 0:00:00
Installing collected packages: click
Successfully installed click-8.1.7
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: setuptools in ./env/lib/python3.11/site-packages (66.1.1)
Collecting setuptools
Downloading https://www.piwheels.org/simple/setuptools/setuptools-69.0.3-py3-none-any.whl (819 kB)
ββββββββββββββββββββββββββββββββββ 819.5/819.5 kB 4.7 MB/s eta 0:00:00
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 66.1.1
Uninstalling setuptools-66.1.1:
Successfully uninstalled setuptools-66.1.1
Successfully installed setuptools-69.0.3
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting adafruit-python-shell
Downloading https://www.piwheels.org/simple/adafruit-python-shell/adafruit_python_shell-1.8.0-py3-none-any.whl (8.5 kB)
Collecting clint
Downloading https://www.piwheels.org/simple/clint/clint-0.5.1-py3-none-any.whl (35 kB)
Requirement already satisfied: Adafruit-PlatformDetect in ./env/lib/python3.11/site-packages (from adafruit-python-shell) (3.60.0)
Collecting args
Downloading https://www.piwheels.org/simple/args/args-0.1.0-py3-none-any.whl (4.2 kB)
Installing collected packages: args, clint, adafruit-python-shell
Successfully installed adafruit-python-shell-1.8.0 args-0.1.0 clint-0.5.1
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $
Ok let's rerun the demo
python thermalcameraDemo.py
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $ python thermalcameraDemo.py
ImportError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/myberrypi/Documents/ThermalCamera/thermalcameraDemo.py", line 5, in <module>
import board
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/board.py", line 50, in <module>
from adafruit_blinka.board.raspberrypi.raspi_5b import *
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_5b.py", line 6, in <module>
from adafruit_blinka.microcontroller.bcm2712 import pin
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm2712/pin.py", line 5, in <module>
from adafruit_blinka.microcontroller.generic_linux.libgpiod_pin import Pin
File "/home/myberrypi/Documents/ThermalCamera/env/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py", line 8, in <module>
raise ImportError(
ImportError: libgpiod Python bindings not found, please install and try again! See https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/libgpiod.py
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $
Install libgpiod-dev from your software repo?
yeah, that looks to be it. I thought it was suppose to handle it
(Educated guess)
the problem is with the pi os, and the forced env, I'm less familiar with the scope of different package installs
The example code is:
cd ~
sudo apt-get install python3-pip
sudo pip3 install --upgrade adafruit-python-shell click
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py
sudo python3 libgpiod.py
but with the env we're dropping the 3 from both pip and python
we've also already got pip so,
cd ~
pip install --upgrade adafruit-python-shell click
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py
python libgpiod.py
is probably the correct code here.
But I was hoping to have a pi running this by today and I don't
@final oar give this a shot
You've got the Adafruit MLX90640 or just the sensor on a different board?
Yup I was running it on a circuit python board, a qtpy esp32s2
but I have a pi 5 so I was trying to get it running today. Which I didn't get working, which is a symptom of today just not being what I planned
(env) myberrypi@raspberrypi:~/Documents/ThermalCamera $ cd ~
pip install --upgrade adafruit-python-shell click
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py
python libgpiod.py
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: adafruit-python-shell in ./Documents/ThermalCamera/env/lib/python3.11/site-packages (1.8.0)
Requirement already satisfied: click in ./Documents/ThermalCamera/env/lib/python3.11/site-packages (8.1.7)
Requirement already satisfied: clint in ./Documents/ThermalCamera/env/lib/python3.11/site-packages (from adafruit-python-shell) (0.5.1)
Requirement already satisfied: Adafruit-PlatformDetect in ./Documents/ThermalCamera/env/lib/python3.11/site-packages (from adafruit-python-shell) (3.60.0)
Requirement already satisfied: args in ./Documents/ThermalCamera/env/lib/python3.11/site-packages (from clint->adafruit-python-shell) (0.1.0)
--2024-02-07 01:37:36-- https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2608 (2.5K) [text/plain]
Saving to: βlibgpiod.pyβ
libgpiod.py 100% 2.55K --.-KB/s in 0.004s
2024-02-07 01:37:37 (686 KB/s) - βlibgpiod.pyβ saved [2608/2608]
Installer must be run as root.
Try 'sudo python3 libgpiod.py'
(env) myberrypi@raspberrypi:~ $
That's me for a while now. Tried Arduino Mega, then ESP32 and then moved to Pi
(env) myberrypi@raspberrypi:~ $ sudo python libgpiod.py
Traceback (most recent call last):
File "/home/myberrypi/libgpiod.py", line 14, in <module>
from adafruit_shell import Shell
ModuleNotFoundError: No module named 'adafruit_shell'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/myberrypi/libgpiod.py", line 16, in <module>
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
RuntimeError: The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell
(env) myberrypi@raspberrypi:~ $
weee this is what I was hoping to avoid
"Get a raspberry Pi" they said, "it will solve all your problems" they said π« π
(env) myberrypi@raspberrypi:~ $ sudo pip install adafruit-python-shell
error: externally-managed-environment
Γ This environment is externally managed
β°β> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
For more information visit http://rptl.io/venv
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
(env) myberrypi@raspberrypi:~ $
I mean. It does. Kind of. But there's new problems. Like if you want the best miles per gallon, get an electric vehicle because there's no gas thus it's the best because you divide by zero. But then you have the new problem of needing car chargers.
yup.
right.
ugh.
So. What's happening is that these guides and references and install guides were written prior the the forced env.
And now Pi has changed a bunch, but the adafruit documentation hasn't changed.
Ok. I have to call it here. I need to replicate your setup before I can effectively guide you further. Let me put a bit in the adafruit discord to help make your problem easier for the other helpers to read
@errant wigeon Do you think it would help to post on GitHub as it suggests at the bottom in the error?
" If you are running the latest package, your board may not yet be supported. Please
open a New Issue on GitHub at https://github.com/adafruit/Adafruit_Blinka/issues and
select New Board Request. "
The pi 5 absolutely should be supported by now
if not I need to make a pull request to make a giant warning so others can see it. But I cannot fathom that not being supported by now. (I've seen some blinka on the pi 5 I *think*).
I am going to step away and address some chores then hopefully start getting my pi ready to go, so I can at the very least duplicate the errors you're running into. But as a result, I'm going afk for a while. I'll be checking in from time to time to see if anyone has chimed in. If no one does in the next good while (8 hours maybe? depending on time) feel free to post your question again. I tried to get as much info as I could laid out, so hopefully someone will have an answer. Just gotta wait a bit and hack at it in the mean time
@errant wigeon Can I just ask what the time is there for you? Just so I know if we're on different timeframes?
It's 2 am for me π
Ah, Central US so it's just past 8 pm (20:00) for me
@errant wigeon I think it's time I start focusing on other studies and revise on other subjects in the meantime... I really tried to invest my time on this, which in turn made me miss some classes so now I have to catch up on my missed lessons (which is no one's fault but mine btw)... I need to manage my tasks better and perhaps moving on to the other modules.
I do at the same time feel responsible to be present and responsive here since you and others are offering help.
Focus on studies, and ask for help when you can. Don't worry about matching my time zone, I can be flexible too, and others are very capable and can help at other times too.
go get some rest. That's the best magic in the world.
Yes, I think I got so focused to get this done to try and see if I can get it on LabVIEW later that I get so invested and need to learn to take a step back and do something else and return to it later...
That is a skill I wish I learned sooner π
It's a good thing you're seeing that need to refocus now π
@errant wigeon I got it running!! π€©
I mean my friend helped but still, we're able to achieve things now π
pip3 install adafruit-circuitpython-mlx90640 --break-system-packages
Woo! That's fantastic!
The guide I got pointed to, https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
Is.. A lot, and while break system packages isn't a setting you should usually do, it's probably the right call in this case
I exit the env
Read 2 frames in 1.02 s
............-.+-%#%++x++++x
...........-..x-#X%++++xx
..........-..+.%-##++++x
.............x-%#%-++++x+
........-.-..+.%-##-++x
.........- .+.x-%#%-+-++
........-.+.x.x-%##+--+-+x
.......-.-.x-x-x%#+%-++-++
.........x-%%x#+#++-+++-+
........+-%%x%+#+%++-++-+*
......-.x.##%x#+%++.-+--+
.......x.%-#%xx*#+x+-.---
......+.%-#-#%x%%+-+..+..*
.......x.%-#-%xx*%+++..+.+..
.......x.%-%-xx*%x+-+.+.+..*
.......+.%-%-x-x-x*%++.+.+...
......x.x-%-x-xx*%+++-+.+...*
.....-.x-%-%xxxx++-+.+...
......x.%-%xxxx+x-x.x.+..
.....-.x-xxxx+++++.x.+...
......+.x-xxx++++++.x.+.+.+.*
.....-.+-x-xxx*++-+.+.+.+..
.......+-xx*+-.+.+.+..*
........+-x-++..+.+..*.
Read 2 frames in 1.02 s
........-.x-#+######-++++**+++
.........--%#%####xx-+++++
........-.+%x#%##%#-+++++
.......--**xx%%##X#xx-++++++
......-x+x%%%#%##%#-******++
.....-xx%%%%%%#%X#x+---+++
....+.%x#%%#%%#%##x%--.-.---++
...*.xx#%##%%%%#%%#......---*
...%#%#%%#x%%x%%-x.... .....-*
...x-%x#%##%%xx%x+x.-.... . ....
...x%x#%%%xx%xx%.+ . . . .
...+-xx%x%%xxxx%x+x.-.. ..
..+.++x%x%xxx+xxxx-+.. . . ..
.-.x-x%x%xx++xx%x++-- . . .
-.x-%+%%x%+%xx%%+x-+.... . ..
..%#%%%x%+xx%%x++--... . ...
-.%-#+#%%%x%x%xx++-.. .. ... ..
.-##%#%%%%%xxx+**........ ...
-.x-##x#%%%xxx+**.-.... ... ..
.-.%-#+#x#%%xx++--..... .. ....
...%-##+%+++-............ ..
...-%%%x-+-................
..-.-.+-+-*--.-.......... ......
...-.-.-.-.-.-..................
It is indeed π₯°
Now I need to find a way to open the code in VS code and change the frames to be less frequent
I need to find a way to take the Pi to uni and be able to connect to wifi there if I want to be able to work from uni and from home
I will take the sensor to uni to test the bung design enclosure made to protect it from the temperatures within the climatic chamber. When I designed the bung (that gets placed in the lateral porthole) I got support from the technical officer to design an inclined plane with the idea to be able to rotate the bung in the porthole and be able to have the camera directed at different angles within the chamber since the location of the device under test is unknown as of now. There's two more students undergoing different tests. We will all have a sensing element to monitor and test circuit board assemblies undergoing environmental testing and thermal cycling from -40Β°C to +125Β°C whilst the CBAs will be powered up.
I will have to use LabVIEW software for data acquisition in real time, and saving data for post analysis, creating a GUI for login details in the main menu for the test operator, date, time, and also have alarm limits.
Ok. I'll be free in a few hours to dig into this a bit more
I think a smart way to run this is to write your code on your windows machine in VS code, save the code, then copy it to the pi.
There's a program related to ssh, (ssh lets you sign into the pi and run code on it from a different computer) called scp (Secure Copy Protocol) which lets you copy files from one machine to the other
assuming you're on your windows machine, and you want to send the files to the pi, the command will look something like:
scp fileImMoving.py myberrypi@raspberrypi:~/Documents/ThermalCamera
For this example, you need to be in the same directory as fileImMoving.py, otherwise it won't be able to find the file you're moving to the pi
then on the pi you can rerun the code with the newly moved file
ok have to step away, but hopefully that gives you a direction, I'll be back later on. Feel free to keep asking questions here, lots of other folks might have the answers π
@errant wigeon thank you. I am on Windows so will most likely work on my code there. I'll save all this information
Hey all I have been struggling with this problem for hours so any help would be greatly appreciated, I am writing some code which used a Rpi Pico W to collect data and log it to an SD card using MircoPython. This code works flawlessly when run from thonny but for some reason it breaking when run in headless mode and I have no idea why. I have used LED flashing to narrow the breaking point to the line: sd=sdcard.SDCard(spi,Pin(13)). I will attach the code extract below. Any advice would be greatly appreciated!
import sdcard
import os
import time
#Define any LEDs
onboardLED = Pin("LED")
#Test flash function
def testFlash():
onboardLED.value(1)
time.sleep(0.5)
onboardLED.value(0)
time.sleep(0.5)
onboardLED.value(1)
time.sleep(0.5)
onboardLED.value(0)
time.sleep(0.5)
onboardLED.value(1)
time.sleep(0.5)
onboardLED.value(0)
time.sleep(0.5)
testFlash()
### Initialise the screen
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
WIDTH =128
HEIGHT= 64
i2c=I2C(0,scl=Pin(5),sda=Pin(4),freq=200000)
oled = SSD1306_I2C(WIDTH,HEIGHT,i2c)
def startUpText():
oled.fill(0) # Clear display
oled.text(("Startup"), 0, 0)
oled.text(("Text"), 0, 20)
oled.show()
time.sleep(3) # Allow time for sensor to respond
startUpText()
# Initialize the SD card
spi=SPI(1,baudrate=2000000,sck=Pin(10),mosi=Pin(11),miso=Pin(12))
sd=sdcard.SDCard(spi,Pin(13))
# Create a instance of MicroPython Unix-like Virtual File System (VFS),
vfs=os.VfsFat(sd)
# Mount the SD card
os.mount(sd,'/sd')
# Again, open the file in "append mode" for appending a line
file = open("/sd/sample.txt","a")
file.write("Appended Sample Text at the END \n")
file.close()
testFlash()
vfs=os.VfsFat(sd)
# Mount the SD card
os.mount(sd,'/sd')
you are creating your vfs file system , but you are not using it
instead of βοΈ code , do this π
vfs=os.VfsFat(sd)
# Mount the SD card
os.mount(vfs,'/sd')
Brilliant thank you for the advice I will try it, out of interest do you know why this would result in it working through thorny but not headless?
Tbh , if the code correctly works on the thonny it should have no problem working headless. ( But this is given that the code works as expected on the thonny regardless of how much time it was running on there. Meaning if the code was running fine for 5 mins on PC then when u tried headless mode , it crashed after an hour , it's not really a headless problem ).
If I run it on thonny it initialised and runs as long as I want but if I run it headless it wonβt even get through the initialisations
Also there could be other areas for user error , like running one code on the thonny , but not actually save it on the board , etc etc
One area could be that you are not giving enough power to board in headless mode
Hmm yeah that could be true I suppose but from the laptop itβs sunning from a usb 2 port and the power brick that it runs in headless from is 2.1A 5w
For reference if I run the full script and omit the SD card stuff the oled screen still works fine
The problem is specifically with that line
Okay , can you run the new code and update me if the error still persists ?
Yeah I will do, I am not in my lab right now but I will be this afternoon if itβs ok to message then?
Yep, no worries. Just make sure you post the latest code that is uploaded on the board
Will do thank you!
yes, it rerun main.py
Only if there is a main.py file, obviusly
Micropython on a Pico W, does it have support for asyncio?
micropython has async/await, asyncio is just a lib using that, instead of using generators as coroutines so yes
weird, it doesn't seem to do that π€
is there a simple way to turn bluetooth on and off through the bluetooth and aioble library? If so maybe I don't have to soft reset
Basically I'm trying to connect to a BLE device, but the BLE device only allows for one connection at a time so I'm trying to handle exceptions where the pico was previously connected but can't connect again due to the previous connection
something like this pseudocode
async def connect_ble():
attempts = 0
try:
connect to device
print('connected')
return
except Exception as e:
print(e)
reset bluetooth
attempts += 1
print(attempts)```
maybe in a Raspberry Pi Pico W doesnt work, for me in a Raspberry Pi Pico works
so a main.py like this should work, right?
import machine
def main():
led.value(toggle)
machine.soft_reset()
main()```
oops one sec
toggle and led where is defined
yes it should work
if dont work, try calling main() again
the only problem is that it will be a recursive function
but with variables and conditinals it should work
import machine
led = machine.Pin("LED", machine.Pin.OUT)
def main():
led.toggle()
machine.soft_reset()
main()```
so when I run the file, it turns the LED on and then nothing else happens
import machine
called: bool = False;
led: machine.Pin("LED", machine.Pin.OUT);
def main():
global called
led.value(1);
if(not called):
called = True;
main();
main();
you can also optimize it by making called a local variable, but that would be another story
this should work
changing machine.soft_rest() to machine.reset() in the code I posted worked I believe as the LED now blinks
however I had to factory reset it as there was no way for me to get it out of that loop lol
do you know if the bluetooth library has a function to turn off bluetooth, reset it, or disconnect from all BLE devices?
ah no worries then :)
good luck
ty!
afaik, machine.soft_reset() just clears the python objects , it doesnt affect the hardware like BLE
I believe you're correct after playing around with it more. I believe what happens, is that my Pico connects to my BLE device and then the BLE device will not accept any other connection even if it's from the Pico. So I might have to do the machine.reset() to kill the first connection
although that doesn't seem like a great solution
prob not , there must be some way to reset bluetooth programatically
Ill update you if i find anything
I appreciate that, thanks!
If you are using aioble, aioble.stop() will shutdown aioble and stop the BLE radio. If you are using low level bluetooth, BLE.active() turns off BLE
I assume aioble.start() and BLE.active() turn them back on as well?
See the aioble examples how to start aioble. I have never needed aioble.start(). For low level, BLE.active(True) will start the radio. I think you need to configure as if you start from scratch, i.e. I wouldn't rely on configurations done befire shutting BLE down.
Can we use python in development board
You mean the ESP32 Dev ?
why would i need more micro controllers when i have my wife
This isn't really on topic for this channel. Please try to stick to discussions about embedded systems.
hahahahaha
Any dev board. Such as Arduino, ESP32, raspberry pi, etc
Normal Arduinos you cant control with python
Esp32s you can
Same for raspberry pi's(not 100% sure tho)
"dev boards" that you talked about can be grouped into two categories - microcontrollers and SBCs
microcontrollers are boards that are very limited in power , with few kb of RAM , few MB of total storage, running at few megahertz to few hundred megahertz. those are made specifically for interfacing with hardware , interfacing with sensors , etc . ESP32 and Arduino are microcontrollers
SBCs on the other hand are MUCH more powerful than microcontrollers with few gigs of RAM , 100s of gigs of storage, running at few thousand megahertz aka few gigahertz. Those are basically a modern computer shrunk down. The tradeoff being , it will be somewhat less powerful than a regular PC , but still pretty comparable to one. Raspberry pi zero , zero w, zero 2 w, 3, 3B+, 4 , 5 all fall under this category (the raspberry pi PICO is a MICROCONTROLLER , not a SBC)
now coming to our normal full fledged python that we run on our PC, python requires significant amount of resources to run which the tiny microcontrollers just cant do. So you cant run python on those tiny microcontrollers. You can however, run a full fledged python on the SBCs.
now , some nice people looked at python , shrunk it down , super optimized it to run on as less of resources as possible , this new python is called as micropython. This micropython can run on microcontrollers (not all of them , but a lot. ex- arduino UNO, nano , etc cant run it but ESP32 , pi pico can run it)
difference to note is that, micropython is very different from python (in terms of libraries ) , most of common libraries from python are absent in micropython. Some of the common libraries from python have a micropython equivalent library. Ex- if you want to make requests in python , you use the requests library, but that library is not available in micropython. Micropython has a similar library called urequests that provides a similar functionality.
https://docs.micropython.org/en/latest/library/index.html#
you can find out what libraries are present in microypthon on here 
there are also few libraries that are specific to few boards , so for example , the ureqeusts library will require the board to have a wireless/wifi silicon chip.
the raspberry pi pico board basic version does not have a wireless chip on it , so that library will not work on it
but the raspberry pi pico W edition board does have a wifi chip on it , so you can use that library on it
there is another thing called circuitpython , it is similar to micropython in the context that both of them are used to program microcontrollers (circuitpython is actually a fork of micropython ). circuitpython offers a more extensive set of libraries to work with lots and lots more of hardware and sensors compared to micropython.
now all of this is about running the python ON THAT PARTICULAR BOARD ITSELF.
if you just want to **control ** your board using python , you can use pyfirmata . (for more info about pyfirmata, read the pinned comments) . but the major drawback is that , you have to have your board connected to a machine that sends pyfirmata commands , like your computer with a wire.
TLDR - if you want to run full fledged python (aka , normal python you run your PC/laptop), get a SBC ( examples of SBCs are listed above ) , an arduino nano , uno , esp32, pi PICO , pi PICO W , **cannot ** do it
I saw your very good about this topic
So
The question is:
Can you run an os on esp32?
@elfin sphinx
if you mean an os like windows or mac or ubuntu or something similar, then no
if it cant run python , it certainly does not have the resources to run a full fledged general purpose os
you can however , run real time operating systems on there , but those are VERY different from normal OS like windows
yes and also run some emulators see fabgl https://github.com/fdivitto/fabgl
better have a psram enabled board though
it most likely is not what they are looking for (that is just my estimation )
Espressif ESP32 Official Forum
hey guys, I have a pi pico with micropython, and I am wondering was sort of workflow I can do to send python files to it instead of copying it into the terminall. I tried rshell but it seems broken. Its ls command just does LS on my host system
i use the thonny editor , it opens the pi pico's filesystem in a sidebar, i can easily drag drop open files to and from it
Yeah I'm sure there's other ways to avoid the gui, but it's (as always) a question of how much do you want to fight and take on different learning curves when tackling a specific learning curve. The micropython discord probably has more insight, but the first answer will probably be Thonny or Mu (I think Mu works with micropython easily? Now that I say that I'm not sure..).
Thonny is working fine, I just want to avoid having to use my mouse a lot. I've been editing in vim, and luckily thonny updates its buffer automatically. So I save in vim, alt tab, ctrl c, click the repl, paste.. it works but not ideal.
I'd ask about rshell in the mircopython discord, a lot of the developers there appear to use that (I see a conversation mentioning it last month). I'm pretty confused by ls not working for the drive, but I have no experience with it and they do.
it just does not work. cp, ls, etc just shows my host system instead of the board's fs
and thank you. I looked for and couldn't find a micropython-specific discord some how
Using buffer-size of 32
Connecting to /dev/cu.usbmodem2101 (buffer-size 32)...
Trying to connect to REPL connected
Retrieving sysname ... rp2
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ...
Setting time ... Feb 16, 2024 17:52:50
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
/private/tmp/hello> /private/tmp/hello>
/tmp/hello
that was after activating an rshell instance?
>rshell
Welcome to rshell. Use Control-D to exit.
/home/dhylands/Dropbox/micropython/rshell> ls -l /flash
something like that?
it can connect, but /tmp/hello is my cwd on my mac
Hmm
and i can get a repl... but i can get one with cu
It's a relatively new discord, so it's harder to find right now
phew
huh. Yeah I wish I could offer more help here but I at least know where to find folks who can π
Cannot access '/flash': No such file or directory
/private/tmp/hello> ls -l /
2336 Feb 5 19:44 Applications/
No sweat, I appreciate the help, and you at least showed that I am not using the tool incorrectly
https://github.com/dhylands/rshell?tab=readme-ov-file#rsync
^ This is the site I was using to guess at what's going on, maybe it has something I missed
And that's something at least π I'll take it
Have you tried mpremote? It's the official tool for Micropython, see https://docs.micropython.org/en/latest/reference/mpremote.html
Hm nope. No idea how I never saw that mentioned. Literally everything I searched only mention raw terminal, rshell, or thonny. Will try it out ty
Micropython is janky
what do you mean?
Ok
Much nicer. Thank you
are you more of a circuitpython stan?
my raspberrry pi can only output a maximum of 5 volts but is there any way I could increase this voltage
how much increase ? why do you need this voltage for ?
dont drive motors through your pi , it most likely will damage your pi
get an external power supply for your motor , like a 12v DC adapter
Yes if you connect a motor directly to your pi, even if it's a 5v motor, it'll probably destroy the pi.
ohh good idea @torpid verge
yes it will destroy as it can only provide 50-60 mA of current. on the other hand motors require 500-600mA of current. Using GPIO directly for motors is a good idea if you want to cook food with Pico
think they are talking about a pi , not pi pico (but the conclusion is same , dont drive motors from the board directly)
and motors can require much higher currents (also dont forget about the spikes )
500mA is an understatement imo
yes. Flyback, stall current, etc
I remember when I was first getting into microcontroller being so stoked after I bought a motor and then realizing I couldn't use it yet. I think I ended up buying some NPN transistors to make a darlington pair.
opto-couplers are very useful @crystal karma
hi y'all quick question, has any of you ever tried to hook up capture card to rpi zero via usb?
i don't need a high resolution or place to store long recording, I need to work on live data from external video source
and to go as cheap as possible π
Is anyone familiar with stm32 and pyserial where you can talk to the tesla bms over UART according to collin80 github TeslaBMS?
I am working on a python serial script that just works at 612,500 baud to rx tx communicate to the tesla bms modules.
I came here to ask this exact same question
What is the actual question? The RPI is a small Linux system, any (video) capture card with Linux drivers should work. Something that is USB class compliant would be the best best, as it can use standard drivers
the question is would rpi zero be efficient enough to perform without any significant delay, or should I aim at a little better module than rpi zero
that's why I've asked if someone tried to do it
the work on live data part seems to be the main concern for performance
also , the usb port on pi zero is a usb 2.0 port , which is not particulary high speed given you are going to capture a video stream
maybe you can explain what exactly you want to do instead of the vauge work on live data part ?
sure:
capture screen at 60Hz -> few simple operations with openCV -> send data over UDP/Serial to another device
what resolution ?
not sure if the pi zero would be snappy at that
most likely yeah
you could also checkout some other opencv with pi zero projects to see what kind of results they are getting
hmm that's true, but I plan to incorporate camera later, so maybe going with rpi 4 would be cheaper over all
if you want cheap , buy a second hand laptop
the price/performance for the raspberry pis dont make much sense
you can get a much higher performing machine as a second hand laptop than a rpi
it's price/performance and size
how small does the thing need to be ?
if its constraint is credit card sized, then maybe
(there might be better alternatives for that too imo)
150x100x100mm max (with case)
and you dont plan to connect any thing to the pi ? like ethernet cable , etc etc ?
ok
I mean the smaller the better
also , i suggest you get the pi 5 for just a few bucks more , a lot of improvement over the old one for a few bucks more
so if you havea future perofrmance intensive project , you have a powerful machine
I'm trying to hookup my accelerometer (ADXL345) to my raspberry pi 4 and I'm running into a syntax error, not sure why
Here's my code
import time
import board
import busio
import adafruit_adxl34x as adxl
i2c = busio.I2C(board.SCL, board.SDA)
accelerometer = adxl.ADXL345(i2c)
Error:
File "/home/pi/accelerometer.py", line 4, in <module>
import adafruitadxl34x as adxl
File "/usr/local/lib/python3.7/dist-packages/adafruitadxl34x.py", line 33, in <module>
from adafruit_bus_device import i2c_device
File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 15, in <module>
from circuitpython_typing import ReadableBuffer, WriteableBuffer
File "/usr/local/lib/python3.7/dist-packages/circuitpython_typing/__init.py", line 79
def read(self, count: Optional[int] = None, /) -> Optional[bytes]:
^
SyntaxError: invalid syntax```
@errant wigeon Hi Keith, a little bit of update since I got the sensor running. I've been attempting to connect my Raspberry Pi 5 to LabVIEW 2023 Q3 via Target Configuration on Hobbyist and had no success... Then found a video mentioning using the 2020 community version and install OS 2019 on Pi 2, 3 and 4 to avoid bugs.... So I thought I'll probably downgrade software and have bugs on my Pi 5 since it's a new version and struggle...
https://www.youtube.com/watch?v=lwoXP2GdRAU&t=3s&ab_channel=EducationalEngineeringTeam
Someone also opened an issue about it https://github.com/MakerHub/lvrt-deb-pkg/issues/14
I followed the guide from NI instruments and they're using version 2020 for LabVIEW and I don't think Pi 5 was released then
https://learn.ni.com/learn/article/getting-started-with-raspberry-pi-and-labview-community-edition
The problem is two more students would have a common main menu on the data acquisition so we need to be on the same software version...
After one week ish (back and forth with NI, uni staff) I managed to open a technical reques ticket with NI engineers. Then the week after (This Monday) I had a meeting and the engineer saw it does not communicate, told me to open NI MAX and it was not seeing the Pi... He went away to figure it out, this Wednesday he emailed me this:
"Hope you are doing fine.
It's just a short update regarding the process. I've started the collaboration process with my colleagues to understand what could cause the connection issue. For now the main idea is access permission issue. It would be nice to connect to the Raspberry Pi with Remote Desktop.
Please see the following external articles that provide steps how to do that.
https://raspberrytips.com/remote-desktop-raspberry-pi/
https://www.nextpcb.com/blog/raspberry-pi-remote-desktop
I'll keep you informed regarding any other ideas."
I've installed TeamViewer on my Pi and I presume they'd want remote access if we were to meet in the future.
Anyway I regret getting the Pi5, and the technician in uni said if I want the Pi 3 they have and give back the Pi5, but I don't know if I am going to have problems with the Adafruit MLX90640 sensor downgrading two levels down since most projects were done on Pi4? What do you think?
Hey I'm going to be away from the computer for a while today, so it'll be a bit before I can really dig in
the MLX camera will work with the pi 3, but the pi 5 will probably be the better hardware. I don't know if the pi 3 OS has changed since 2020 off the top of my head, so the demo might not work on the 3
Another option is to drop the way the labview program is trying to read from the camera and switch to another method,
the pi/camera could write to a temp file, and the labview program could read that file at steady intervals, that way you they don't need to talk to each other. You could also have the python code host a small webpage and the labview program grab info from the webpage.
Are you running this with standard Python or CircuitPython? But yeah, that looks like a legit syntax error in the library... You can go into the file and fix it there
standard python
i don't seem to have permission to edit the files though
Im not really sure how to do or where to send this so Im just gonna send this in multiple channels, but redirect me to the correct one if im wrong, I wanna make a micro controller / ardiuno where you plug it into a router and it automatically spits out all the people on the network into a file, how would I do this? and what materials / tech should I use
how would I make a device with a microcontroller to when I plug in it to the router it automatically gets the password?
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
That's going to be out of the scope of what we can answer on this server
please refrain from asking about it and related questions.
okay π
@elfin sphinx what details do you want to know
everything
like
(i dont have time rn , you post all the details and your problem , ill take a look when i am back)
its due at 6pm
π¨
supposed to make the speaker play something
and the led should light up
im currently stuck at what the yellow wire does
const int LDRpin = A0;
const int buttonPin = 2;
const int ledPin = 10;
const int speakerPin = 11;
int LDRvalue = 0;
int playNote;
int ledBrightness;
int buttonState = LOW;
int reading;
void setup() {
// assign the pin as INPUT or OUTPUT
pinMode(ledPin, OUTPUT);
pinMode(speakerPin, OUTPUT);
pinMode (LDRpin, OUTPUT);
pinMode (buttonPin, INPUT);
Serial.begin(9600);
}
void loop() {
// read button value from buttonPin variable
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH){
buttonState = !buttonState;
delay(500);
}
if (buttonState == HIGH){
//read value from LDRpin
LDRvalue = analogRead(LDRpin);
delay(100);
playNote = map(LDRvalue, 0, 1024, 0, 255);
//play output tone using speakerPin
tone(speakerPin, playNote);
ledBrightness = map(LDRvalue, 0, 1024, 255, 0);
//turn on LED through ledPin to adjust the brightness
analogWrite (ledPin, ledBrightness);
}else{
digitalWrite (ledPin, LOW);
noTone(speakerPin);
}
}
my code
it probably should go between the resistor and the button from first glance
like electricity flows from the button to the yellow wire to pin 2
anyway , describe everything , ill take a look later , i gotta go
so pin 2 is an INPUT?
yes , in this case , its supposed to read if the button is pressed or not
then if pin 2 receives an input, we give pin 10 and 11 a signal
?
This is called a pull down resistor
It works like this:
When the switch is open, the pin is connected to ground through the resistor, so it will be at logic low
When the switch is closed, it creates a voltage differential between the positive supply and the pin
So the pin goes to logic high
If you read the voltage on the pin, you will therefore see low of the button isnt pressed
And high if it is
Simple as. It lets you read the button state as a low vs high value
what does
Presumably you want to apply an if statement of some kind that checks the button state and then conditionally does something else
Inverts it
It doesn't actually change the voltage
then what does it do
it just changes the value of the variable
It changes the variable to its opposite.
so..?
Well no
well no exactly, so what you are doing is basically saying "if it is x is high set it to low, and if it is still somehow high do XYZ"
It's a placeholder
its just a statement
so the opposite means like switching the value from HIGH to LOW?
Inverting the variable just changes its value to the opposite of whatever it currently is
Yes
what was your intention behind this block? c++ if(buttonState == HIGH){ buttonState = !buttonState; delay(500); }
Are you supposed to fix it or what?
lemem give u the original one
Because the state isn't assigned to again before the next time it's checked
This is like doing
a = 5
if a == 10:
const int LDRpin = A0;
const int buttonPin = 2;
const int ledPin = 10;
const int speakerPin = 11;
int LDRvalue = 0;
int playNote;
int ledBrightness;
int buttonState = LOW;
int reading;
void setup() {
// assign the pin as INPUT or OUTPUT
pinMode(ledPin, CHANGE);
pinMode(speakerPin, CHANGE);
pinMode (LDRpin, CHANGE);
pinMode (buttonPin, CHANGE);
Serial.begin(9600);
}
void loop() {
// read button value from buttonPin variable
button = digitalRead(CHANGE);
if(button == HIGH){
buttonState = !buttonState;
delay(500);
}
if (buttonState == HIGH){
//read value from LDRpin
LDRvalue = analogRead(CHANGE);
delay(100);
playNote = map(LDRvalue, 0, 1024, 0, 255);
//play output tone using speakerPin
tone(CHANGE, playNote);
ledBrightness = map(LDRvalue, 0, 1024, 255, 0);
//turn on LED through ledPin to adjust the brightness
analogWrite (CHANGE, ledBrightness);
}else{
digitalWrite (ledPin, LOW);
noTone(speakerPin);
}
}
we're supposed to the change the parts with "CHANGE"
?
perhaps my INPUT and OUTPUT are wrong
ah I see the issue, here they have button and buttonState as different things, as they should be
because like
button wasn't defined
so...???
i assumed my teachers forgot State
No, the state is tracking persistently
It's so that the value flips every time you press the button
well from my understanding of the code what they actually forgot was int
Button state starts as low
Press the button: it turns high
Press again: it turns low again
Every time you press it, the saved state flips
oh so i change ButtonState back to button
That way the button works like a toggle
You press it to turn something on, and press the same button again to turn it back off
Buttonsate is tracking this persistently,
They forgot / are missing the decl for button
so my teachers are just clowning
?
do i just set button as 0
ok now the speaker is making noise
but i cant stop it with the button
You can just declare it on the same line that it has its value assigned
Just add the correct type before it to make it a decl
I assume int
yeah i put int button = 0; at the start
Remember how there is a variable that toggles high or low every time you press the button?
is it buttonpin?
No
buttonstate
Yes
Wdym button as buttonstate
button = buttonState
No
Button is for reading whether the switch is closed or not
You use it to control buttonstate, not the other way around
buttonState = !buttonState;
this is the code my teacher gave me though
if button == HIGH then buttonState will be changed to low
No
It's already done
You don't need to touch it
When you press the button, the state flips
The end
Now you need to USE the state
To control something else
yes
Ok, so there you have it
You have a variable that turns on or off every time you press the button, use that variable to decide what to do to the speaker
buttonState controls pin 11
which is connected to teh speaker
right?
im not sure if we have to add in anything to the code
it should be fine as it is
Try and see
what am i supposed to try bruh
i dont even know the syntax for arduino let alone code
π
do you know what im even supposed to do or are you just tryna solve the thing with me?
then you should probably learn it
const int LDRpin = A0;
const int buttonPin = 2;
const int ledPin = 10;
const int speakerPin = 11;
int LDRvalue = 0;
int playNote;
int ledBrightness;
int buttonState = LOW;
int reading;
void setup() {
// assign the pin as INPUT or OUTPUT
pinMode(ledPin, CHANGE);
pinMode(speakerPin, CHANGE);
pinMode (LDRpin, CHANGE);
pinMode (buttonPin, CHANGE);
Serial.begin(9600);
}
void loop() {
// read button value from buttonPin variable
button = digitalRead(CHANGE);
if(button == HIGH){
buttonState = !buttonState;
delay(500);
}
if (buttonState == HIGH){
//read value from LDRpin
LDRvalue = analogRead(CHANGE);
delay(100);
playNote = map(LDRvalue, 0, 1024, 0, 255);
//play output tone using speakerPin
tone(CHANGE, playNote);
ledBrightness = map(LDRvalue, 0, 1024, 255, 0);
//turn on LED through ledPin to adjust the brightness
analogWrite (CHANGE, ledBrightness);
}else{
digitalWrite (ledPin, LOW);
noTone(speakerPin);
}
}
my teacher just gave us an arduino uno board
a template
and yeah
i also dont have much time to learn arduino either
it is, but it's not a subject that counts towards my GPA
uh huh
then you are still supposed to learn it if its a subject
yes
im trying to
this is your most recent schematic , right ? the one that you are using
dont act like you are , we all know the reality
lets just see what we can do with the current situation
i've spent the past 1h and 50min trying sir
yes
fixing your current project is not learning
you have admitted that you dont know arduino nor C++
you should start with the basics , not by trying to fix random code
its not easy with 0 guidance and having school end at 6pm everyday
nothing is easy
its an assignment due in 8 minutes
i can't start with the basics now
should have done that when you had time thhen
anyway , arguing is not doing anyone good here , lets see if this can be fixed
what is your expected behaviour ?
when i press teh button
it should turn off
and when i press it again
it should turn on
then what is the purpose of that LDR ?
this thing
oh
uh
the led and speakers are supposed to turn on based off of the value of the photoresistor
its supposed to be sensing light
but you just say that you want buzzer to buzz when you press the button and stop when you press it again
then what is the purpose of the button ?
to turn it on and off
the photoresistor controls how loud or soft
or how bright or dim
thank you for your help sir
i submitted my current code
ok
because i have to revise for 2 tests
next time try to ask a little early
and actually learn the subjects you are that you are required to learn
i can fail this subject
and it won't matter
its put in your curriculam for a reason
the point of the subject is to solve real-world problems
why they chose to use arduino? i have no idea
we are already learning python
no idea why they couldnt have used that instead
arduino sounds like a good introduction to microcontroller world
you should know multiple things , microcontroller world uses lots of C++
1 year is not enough to learn the basics of arduino AND solve the real-world problem so yep here i am
with ample time
im saying the duration of this subject is very short, hence they have to skip the basics
and jump straight into the solving part
theres tons of free online resources , you can learn from the basics if you want
my classes from 8am-6pm i reach home at 7, have 5 concurrent projects ill try my best
thanks for trying to help
then learn it in school
ask teachers to teach from the basics
they can't just teach during class
they have a schedule to follow
sure i can ask them about the basics but ill still have a weak foundation
if its in your curriculum , they are compelled to teach it
unless that subjects had some prerequisits which you did not meet π
how old are you ?
im 14 this year
so you have a subject in the curriculum , and they did not teach anything for 1 year and then slapped you with an assignment ?
u got that part wrong
that sounds far fetched to me , idk if it does to you
the subject will last for 1 year
its 2months in
currently
and the assignemnt is just more like homework
and you have been taught nothing for the first 2 months ?
we had a learning journey last week, no class the week before that
and the rest were on how to use the arduino uno
so im just stupid
π
so they did teach you , why are you portraying that they didnt π€·ββοΈ
its fine to not understand some subjects , its fine to lag behind
but dont fool yourself by blaming it on others
you are not doing anyone any good by fooling yourself
they gave us a template
and did not explain what each thing does
or the syntax either
i have no time to argue with you rn, i have another math assignment due tmr
thats absurd
get your parents to submit a written complaint about the teacher
but not teaching anything is wrong , the teacher is supposed to teach first and then let kids experiment
have you been taught C++ ? not particulary for this class , but like ever ?
***if *** what you are saying is true , then its wrong and a written complaint from parents to the school principle is due
you dont just give kids some random code that they know nothing about and a circuit board and expect them to know how they work together
does anybody know a library I can use for arduino
https://www.arduino.cc/reference/en/libraries/
more than 4000 libraries, choose whatever you'd like
I'm trying to hookup a ds18b20 temp sensor to my raspberry pi 4 but after I make all the wiring connections it heats up super fast and I'm not sure why
Can you post a picture of your wiring? I'm guessing you've mixed up a couple of wires and might have shorted something
orange wire is connected to gpio 4
red and black to power/ground rail
10k ohm resistor between vcc and data pin
You've got the ds18b20 flipped around
pin 1 of it's package should be ground
going off of the datasheet, you've got ground connected to pin 3
Nope I'm wrong
Give me a minute to grab a similar package
sounds good
missed bottom view there ok now that I have a similar package and tape on the ground wire give me a minute to go back through it
can you show the cables on the raspberry pi?
It's possible you've just got a bad package
Yeah that wiring looks right
Do you have another ds12b20?
and where did you buy this one from?
it came in a pack of 5 but i'm having the same issue with all of them
just off amazon
i believe the brand is BOJACK
The one idea i have is to drop the resistance of the pullup resistor to 4.7k, but chances are you've got a faulty package or just an entirely faked product since all 5 are behaving similarly. One wire is a common enough thing though, chance are some other folks here might see something I just completely overlooked if there's anything.
You could always flip one around and try it really quickly but it *shouldn't* work. but if they're trashed components anyway there's no reason not to try
This is a similar issue, with a similar conclusion unfortunately.
Again, I could have missed something obvious too, so keep an eye here in case someone else catches my error
i'll take a look, thanks for all the help i appreciate it
I need help connecting my MCP3008 Analog to Digital Converter, I'm not getting any voltage readings
if you want someone to help you , make it as easy for them to look at your problem and give inputs
example in this case -
you are saying "i have a problem"
but are nott providing your impelementation details like circuit diagram , code , a photo of the circuit , etc
now if someone were to help , they would have to invest 10 minutes with you just to get you to give them details
instead , if you had posted all the details in the first place , someone would have just took a look at your stuff and gave you suggestions on what to do
I wanna make a maybe simple??? project that's basically just a infared emulator, with some extra components to mess around with tvs etc, and I want to make a UI similar to the flipper zero what should I use to build this
depends on what you want to do with it
mess around with TVs is not really descriptive
an IR LED and an IR receiver along with any modern day microcontroller like arduino ,esp32 should be able to emulate IR remote pulses
they can also be easily interfaced with a screen like ssd1306 0.96 inch OLED display
cramming all of this together into something the size of flipper zero will be challenging
Ah
has anyone here used a wireless microphone with a raspberry pi? if so, would any wireless mic work that has a usb dongle that plugs into the pi?
lots of stuff works automatically with linux , you will be suprised , give it a try @night elbow
sounds good, thank you!
do you do lots of sound production stuff ?
wonder if this can run on a pi , its a recording studio package @night elbow
i do, but the pi isnβt for that. iβm planning on trying to use voice recognition to do robotic control
those raspberry pi usb mics that plug right in would be a bit too far as the robot would be on the ground and iβd be standing up
firgured a wireless one being close to my mouse like a clip on one from amazon would be better
i havent looked at voice recognition for a long while , wonder whats been happening , and if a rpi 3 can use it at all
iβll be using a rpi 5 so hopefully it is able to do proper processing
ooh a 5 will do , may even do OpenCV stuff also , hmm ponder poder
yea iβve done opencv stuff on a rpi 3 and mannnn was it a hassle
1 fps was the best i was getting
ππ
i just used a big machine , there is also , simpleCV , dont know if it has advanced
mmm heard putting opencv on a pi tkaes forever , is there a package with it built in , raspberry OS ?
that i donβt know. it was a while back when i put it on the rpi 3 but i can remember it took me a bit to get everything properly installed
not way too long though
hmm did you ever try to use , vlc player , it can stream audio , video , webcam data stream to another computer , and receiving vlcplayer can display it
i actually have not, sounds like a good idea. iβll give it a try too. thanks!
hi, is routing traffic through usb0 possible? I'm trying to make a access point with raspberry pi zero 2w (where rpi is connected to computer with ethernet), where wlan0 (onboard wifi) will get the traffic from connected devices and usb0 (with gadget mode enabled) route it further. I've already set up the access point itself, dnsmasq seems to work too, but even though I can connect to ap with my phone there is no internet connection. Any ideas? Is this iptables case?
To do a master's degree in artificial intelligence, is it better to do 3 years of computer science before or 3 years of electronics ?
If you want to work with sensors/IoT (and ML) then electronics. Otherwise computer science
Has anyone here worked with making gpiozero work in a virtual environment on a raspberry pi 5? I'm doing a project that needs the python code to be run in a venv but I can't seem to get gpiozero working to use as an output to control a TT motor. Does anyone have a solution?
a venv should not affect the working of library
can you explain your problem in detail ??
circuit diagram , code, what is actually happening and what you want to happen
deal
so as for the code, it is the following
from gpiozero import Motor
from time import sleep
Motor1 = Motor(2,3)
while (1) :
Motor1.forward()
sleep(5)
Motor1.backward()
sleep(5)
Motor1.stop()
sleep(5)
when I run this normally, it works fine, but when I run it inside the venv, I get the following error:
"RuntimeError: Cannot determine SOC peripheral base address"
I googled ways to fix this and pip installed all the recommended libraries that I came across but it still wouldn't work.
as for the circuit, it is just a rpi 5 linked to a L298N motor driver that drives a TT DC motor and is powered by a 6V battery. I currently don't have my own sketch of it but it is like this: https://projects.raspberrypi.org/en/projects/build-a-buggy/1
i am using GPIO pins 2 and 3 to drive the motor.
update: problem solved
deleted the venv and remade it including --system-site-packages then i reinstalled the extra libraries i needed
more extensive googling finally paid off π
well , glad that you got it resolved π
i was surprised at first because , on rpi new OS , you kind of have to use a virtual env , you cant use the system python
@errant wigeon Hi, since I am encountering many problems with LabVIEW software for my data logger when using the Raspberry Pi and MLX90640 sensor.
My supervisor mentioned getting a file from Pi with the array from the sensor, then opening the file in LabVIEW so instead of having them connected directly, I'll do a step by step Pi file saved to local Laptop/OC and then file to LabVIEW. However, I do not know how I can save a file from the Pi which is connected remotely on my laptop using SSH to save it on my laptop.
At the moment this is the code I am using in VS code connected via ssh:
`import time
import board
import busio
import adafruit_mlx90640
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
Set the backend explicitly to Agg (non-interactive)
matplotlib.use('Agg')
i2c = busio.I2C(board.SCL, board.SDA, frequency=800000)
mlx = adafruit_mlx90640.MLX90640(i2c)
print("MLX addr detected on I2C")
print([hex(i) for i in mlx.serial_number])
mlx.refresh_rate = adafruit_mlx90640.RefreshRate.REFRESH_2_HZ
frame = [0] * 768
while True:
stamp = time.monotonic()
try:
mlx.getFrame(frame)
except ValueError:
# these happen, no biggie - retry
continue
print("Read 2 frames in %0.2f s" % (time.monotonic() - stamp))
temperatures = np.array(frame).reshape((24, 32))
# Display temperatures as a heatmap using matplotlib
plt.figure(figsize=(6, 4)) # Adjust the width and height as needed
plt.imshow(temperatures, cmap='seismic', interpolation='nearest', vmin=-40, vmax=140) # Adjust the colormap and interpolation method
# Create a colorbar with a range from -40 to 140 degrees and a spacing of 20
cbar = plt.colorbar(ticks=np.arange(-40, 141, 10))
# Save the figure instead of showing it
plt.savefig('heatmap.png')
# Clear the plot for the next iteration
plt.clf()`
:incoming_envelope: :ok_hand: applied timeout to @gleaming light until <t:1711338024:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
Hey, sorry for the delay. Life has ramped up lately.
Let's see. If the communication is difficult, let's start thinking about a different way to send the data. You can easily post the data in python to a website, but that requires internet that the pi can access, a website that can receive data, and then the pi also has to check that website for new commands. Is everything going to be on the same network? Or will you be on different networks?
Hey, I think I will go a different route due to time limitation. Thanks for all your support π
Good day,
i am trying to send a decimal 1 82 83 through pyserial to my microcontroller. But i seem to not be able to get the data on the microcontroller. below my python code on how i was trying to send the data. i tested with realterm if my connection is working and there it works so it is a issue of my code. (the baudrate is correct it is a very slow uart based connection)
import serial
import time
ser = serial.Serial('COM4',baudrate=300)
data = 1
data2 = 82
data3 = 83
while True:
ser.write(data)
print('data is being transmitted:',data)
time.sleep(0.05)
ser.write(data2)
print('data is being transmitted:',data2)
time.sleep(0.05)
ser.write(data3)
print('data is being transmitted:',data3)
time.sleep(0.05)
which microcontroller ? what is the circuit diagram ? what is the code on the microcontroller end ?
I don't have the code on the controller end. Is a black box testing project. All i know is that it accepts a uart connection working on a 300 baudrate that works with decimal ascii inputs on the tx and rx connections.
have you tried connecting to it any other way ?? meaning have you made sure that you can send data correctly to that device by other means ?
are you using correct ports for that ?
make sure any other port is not using the same port ( ex - you are using COM3 in your python program as well as you have open a seperate serial monitor window with the same port
also , try increasing the delay between sending the data
like , maybe wait for a second
yes i used realterm to send the data
yes i use the same port as the realterm uses and closed that before trying to use my script
i had a delay of 1 second first before lowering it trying to see if it was to slow
how do you verify if the device receives t he data ?
also , what does the output of this program show ?
you should print the return value of ser.write
so do print(ser.write(data))
so that we see if it wrote the bytes or not
i have a connection open on a port of the device that shows when i get correct data. any trash data it just ignores.
this is what i get in my terminal when i do print(ser.write(1))
i'll try now what you suggested
print(ser.write( b'00000001')) gives me a 8 on the terminal
sounds correct, you sent 8 bytes
what do you get on the microcontroller ?
nothing
well , thats strange , it should work
it is most likely about the settings of serial port
serial.write has lots of other option , make sure you are using the correct ones
i am going to grab my oscilloscope and go hardware checking for a bit. thank you very much for the help π
alright after some fiddling around with the hex output i managed to get my data on the serial monitor. wich is a big leap for me already. but now the data i get is like 10% correct and all the rest i get random trash values for some reason.
values i should see are 1 52 53 in hex respective
any idea how i can improve the stability of those hex values?
reduce baud rate @midnight nest
baudrate is already only 300 and figured out that the product to monitor the serial connection was not functioning proprely that's what caused the issue above
PC => splitter
splitter => MCU
=> hardware serial monitor
hmmm splitter , can you define - i can imagine lots
is a custom made hardware splitter where we go from USB into custom made serial connection that works on 24volts on 300 bauds
did you look at all the signals on a scope , are the transitioning edges clean , nice and square
yup they are. that's how got figured out that the monitor was bad
so we took it apart and replaced the transistors and resistors of the monitor and now it works perfectly again π
so , PC -->usb--> device x ( usb / TTL / 24 VDC ) --> interface on mcu board , limited to 300 baud for testing , data being garbled
was being garbled not anymore. as i said the monitor was faulty the problem is solved by now π
ahh ok , hmm i always use some inverters along the chain to square up signals
24 VDC interfacing , was this for something aincient
yes and no. is a system that has been designed 15 years ago ish but is being redesigned with purpose to be used in older setups
I'd like to see my joystick readings as I update them in realtime, but sadly matplot lib is too slow.
import serial
from itertools import count
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from collections import deque
xs: deque[int] = deque(maxlen=40)
y1s: deque[float] = deque(maxlen=40)
y2s: deque[float] = deque(maxlen=40)
idx = count()
plt.xlabel("x-axis")
plt.ylabel("y-axis")
plt.gca().set_ylim(0, 4)
ser = serial.Serial("/dev/ttyACM0", 115200)
def animate(i):
x = next(idx)
y1, y2 = map(float, ser.readline().decode().split())
print(y1, ", ", y2)
xs.append(x)
y1s.append(y1)
y2s.append(y2)
plt.cla()
# re-rendering _everything_ seems wasteful
plt.plot(xs, y1s, label="Channel 1")
plt.plot(xs, y2s, label="Channel 2")
plt.gca().set_ylim(0, 4)
plt.legend(loc="upper left")
ani = animation.FuncAnimation(plt.gcf(), animate, interval=0, save_count=40)
plt.show()
What do people usually use?
data being generated is space separated voltage values, for each axis
can pygame do it , read different type of joysticks ? @mystic jasper
depends on SDL version used
gamepad api had a big change
question is latency , if important
depends more on usb stack than sdl layer i guess
I am reading from a serial port so it isn't recognized as a gamepad/hid device
serial is faster than HID
indeed it is, but matplot lib is slow in rendering the graphs
probably input buffering at some point
I should do a direct wire , usb / serial - loopback test for max baude rate
another thing for the to-do list
probably a good idea sometimes you can get surprises https://danluu.com/input-lag/
theres ADC-->serial / usb --> PC , projects out there , isnt FTDI 232 ,maxing out at 4 Mbits ??
yeah ftdi and ch34x can get to 4 quite easy but that only throughtput not link latency
now Im daydreaming what are the SDR setups doing
eg you can have insanely fast bandwith for an ADC with wifi but clock will be very late
kind of a jitter , timing wobble ?
more like "broadcast delay" delay π
I have been looking into SDR , have a old 8 bit ADC maybe it can do 400 khz ? , was going to set up a breadboard modelling thing so MCU can measure frequency , generate SQR wave but somehow link it to a SIN generator
or somehow do the QUADrature , SDR thing and stream it into serial as fast as possible
has anyone here looked at stuff like , sigrok , logic analysers using python
well usually the hot stuff is not written in python, but i only used gnuradio-grc
Im interested in analog / digital signal processing using python , Cython ? - hmm keep hearing about GNURadio , gotta look , if something is entirely python I have a chance , as soon as it branches to C , have not learned C
im avoiding QT , its all payware yes ? found out Tkinter and Pygame windows can be squished together
tkinter should have burnt with python2
about qt i don't know, i know that PyQt was GPL-ly annoying, Qt-embedded too commercial for any hobby use. PySide looks quite free to use
( and i still don't know where to put Qt-jambi π )
for sim stuff i don't use pygame but Panda3D instead
though i love them both
Tkinter is a simple control panel for me , can be in W10 or on a raspi ubuntu
panda3d has a gui modeled after tkinter it is as ugly and efficient
well if i want to do waterfalls or fast display of a FFT , dont know if Pygame can do it
with zengl it can do anything very fast on GPU
but too much work, just use Panda3D
in Panda3D you can display matplot / pygame drawings ... anything you want without pain
3 sines , 0 ~ 255 values
wanted to add sprites for animated control stuff , just to see if i can
then squeeze it into a Tkinter window
mmmm will look at Panda3D , i get tired of reinventing the wheel
but can it run on a RPi3 ? , using a pi as a Graphic interface to control GPIO port stuff
I still need to try SSH login , for headless , will it all runn faster headless ?
yeah you can ssh + egl
hmmm 3D rotate a cube ?
indeed exact same as this one https://pygame-web.github.io/showroom/pythongit.html#src/test_panda3d_cube.py
https://pygame-web.github.io/showroom/pythongit.html#src/test_pyglet.py can do fast stuff too
but Panda3D can do more so better one tool to nail them all
mmm cool thanks -- been stuck stuck
ohhhh it cant run , i usually just get source and run it local , bang on it
saw some , sluggish examples of RP2040 interfacing to a small screen for ham radio stuff , wasnt used right - asking to much of a 2040 maybe
anyone using there RPIx as a Graphic controller for offboard MCUs ?
what do you mean by dead ?
3x original price
how does that make it dead ? it means that more and more people want it
but anyway , there are pretty good alternatives to rpi , it will depend on what is your application
know of some? am mostly just looking for cheap single-purpose servers
laptops make great servers , they are a bit more power consuming than the rpi (depends on the laptop ) , but you get a lot more peroformance with it
if you want small form factor , then there is orange pi , banana pi , asus tinker board, rock pi, jetson nano(mostly for AI ML stuff), etc etc
there is also zima board if you talk about storage servers
will look these up, thanks a lot!
there likely is something cheaper than a RPi ( good news ) , I however have 2 collecting dust ( RP3B+ ) , using Ubuntu on it and pouring Python 3.12 into it to use the GPIO port for blinkys and MCU interfacing - the goal is to use python and do some blinkys and more
I'm a bit lost here, I know that Industrial servo motor can be controlled via digital or analogue inputs to the servo amplifier. But I can't quite figure out how programming languages are supposed to get involved with servo motors
Is there a difference between industrial and hobby servo?
Speaking from a hobby motor perspective here, most motors are controlled from pins on the microcontroller. In the case of plain DC motors you just need to put current through them. A program can set the pins of the microcontroller to high or low to control how current flows. In the case of a servo motor things get a tad bit more complex. They usually require 3 signals: current, ground, and a control signal which tells the motor how much to move and in what direction. This control signal can be generated by programs running on the microcontroller.
Does this answer your question?
About halfway answered, so it's still using digital inputs even when programming languages are involved - Generating pulses that tells the servo amp how far, how fast, how strong it should move? So these 'boards' are basically acting like PLCs but far, far more sophisticated?
I'm still somewhat at a loss on where and how to get into this whole thing. Does ot mean that I have to get a board so I can control a servo motor, right? Or can I control it via a PC directly? Or do I have to control the board with the PC in order to control a servo motor?
It's going to heavily depend on what you're trying to interface with. In theory you can control different motors in tons of different ways, but it sounds like you have a specific motor, and that'll probably have a lot of restrictions and limitations. Do you have the model number, part number, or other information about what you're talking about?
As keith said there's many different ways to control different motors, I used a simple pwm controlled servo motor in my example. What specific model did you have in mind?
can i connect a 3.5mm audio jack to an arduino and use that microphone for speech recognition?
battery β> relay β> arduino β> powered arduinoβ> 3.5mm jack β> microphone β> programming β> microphones hears certain phrase β> microphone sends power back to arduino β> arduino powers tens unit after hearing phrase
would this work
how do you even do that?
This
Been trying to find out how I can make this work but I dunno where to start at all
Don't have formal training and stuff so it's kinda confusing for me to find relevant info
Most infos are about working with hobby servo, but nothing on industrial servo
And I have no idea if the basis behind hobby and industrial are interchangeable or not
This looks like something used in a professional environment. Did you buy this yourself or do you need to use it at work? Where are you based btw if you don't mind me asking?
might want to package it up on the shelf , save it for later - get some experience with small stuff , everyone learns by blowing stuff up in early stages ... blow up some cheap stuff
@digital furnace
Start by finding the datasheets / manual of the parts that you have. Ideally you will want a programming guide for the controller. If you cannot find that, then this is not really a beginner project (and possibly not intermediate either)...
Is there anyone trying to build robots, or models and ways of thinking and reasoning?, and testing the results On a Raspberry Pi, for example, or something else
are you trying to survey this server about people using microcontrollers ??
it seems that you have some other question in mind that you want to ask , please just ask that question directly instead of asking if someone knows x thing or y thing , etc
we have already went over this in #python-discussion
Have we ever talked about trying to build robots, or models and ways of thinking and reasoning? in β python-discussion
you asked about people who did EE , worked with arduino/raspberrypi and wrote software for PC , and it covers what you are asking
anyway , you are not asking your question still , just ask it , dont ask if somone has done x thing or if there is an expert in Y around
ok, what is my question?
you would know , now ask the question
you know, you say "you are not asking your question still",This means that you know my question, and while you read every question I ask, you do not find this question in it
can you trust me,brother
your statements and question till now have indiciated that you want to know if there are people working with robotics and EE stuff are in the server or not
you have already been answered that there indeed are
you still continue to ask about the same thing
this usually indicates that you have some other question related to it in mind
Are you saying that everyone who works on Arduino or Raspberry Pi works on building robots and thinking models?
ill let keith respond , this sounds troll ish to me
you say to me come here, then i asked another one, did you read it?
I was just about to say this sounds like a bot to me
..
Same type of repetitious messages
No. That is not what they mean.
You have asked a question that has a 'yes' answer. But there has to be a reason you're asking it. That's what we're trying to find out.
Why would you like to know if anyone has played with robots/models, reasoning systems.
i can tell you what you want really if you need to see your self, bu i will not, its not my jib, its your job, brother can you let me spend time to find what i look for it, not what you look for it?
can i?
just stop
or i leave
that is making no sense to me tbh
now , let us treat this point as clean slate
if you have a microcontroller question , feel free to ask here
to you? its my questons, its me need to learn, no you, if you have answer to help me welcome , if you want learn, ask
What would you like to learn about?
btw @kind pond i dont accept random friend requests , you are free to ping me here if you need some question answered
How do I create a copying process between two files inside a folder inside a memory in the Raspberry Pi, with two conditions: that the two files be empty forever, and that the copying process continues forever and gives the results
keep attacking me
I'm going to ask you to stop engaging in this way with others. I understand that a misunderstanding took place, however continuing to treat this negatively will result in a mute or ban.
(i am not attacking , i am just letting you know that i dont do DMs , if you wanna ask me something ping me here )
I am aware of the situation.
i think ill take the leave now , good luck π
ok, can give me answer for what you have asked me to ask ?
..
thats why i was ask my 45 questions step by step
You will not be able to be patient with me, and how can you be patient with what you have not known about?
bye
Unfortunately I'm not completely clear as to what you're asking. Under the format you specify, it sounds like you'll want to look into shutil (https://docs.python.org/3/library/shutil.html) and you'll also want to learn about using os.path.getsize (https://stackoverflow.com/questions/6591931/getting-file-size-in-python)
Those two together should let you look at a file, check its contents, then copy them where you want.
However, if you keep doing this forever it will end up taking up too much space on the pi (this is true of any system). Even if the files are empty, your operating system still needs to store the file name and file path somewhere, and there's usually a limited number of files you can have on a drive because of this--this is your inode limit. (it becomes very difficult to fix and causes a lot of unique problems--it's a problem most folks don't run into unless you write dumb code, which is how I know about it. I wrote dumb code and made too many files that were small so I had only used 30% of disk space, but had used up 100% of inodes (https://stackoverflow.com/questions/653096/how-to-free-inode-usage)
It kinda counts as cheap stuff, I think? These are parts that has been stripped from a scrapped machine and I've spent awhile just sorting through its old PLC program and stuff to understand servo better.
This is usually used for industrial work... The mass production kind. Technically, the customer paid for it, we just had the machine returned to us once they decided that they want it scapped like... a decade later? Right now I'm using it as learning material to figure out how servo works
Yeaaah, I have the manual and everything. Just not the controller, I have no idea which controller I should be getting to maximise its full potential
So far, most 'examples' I managed to find are using servo motors like stepper motors and using sensors and switches to determine their position
So far I've learn about inputs to control position, speed, and torque, but I have no idea how to make servo output them as data
Or which controller that can utilise those data
I feel like I'm missing a gap of knowledge here or something
I'm getting the impression that servo isn't just a better stepper motor? But I also don't know how I can access its higher functions either
I don't have the tools for it aaaaand I don't know where to find said tools
Been drifting on the internet for months trying to find an answer
"servo" is just the principle of a motor combined with encoder and regulation loop. There are hundreds of incompatible implementations of this principle. You need information on your particular motor/controller, or at the very least exactly the kind/type you have.
MR-J2S-xA SERVO AMPLIFIER INSTRUCTION MANUAL, chapter 3. SIGNALS AND WIRING seems to have all the info needed to make this run? At least in speed and torque modes. Position mode seems to require one more part, which I dont know if you have?
I think he is trying to replicate a malware
with Panda3D, and here the ouput is made via IIP the iterm2 image protocol, but there are other protocol available like Sixel
here's the driver in python ```py
base.screenshot(namePrefix="/tmp/out.bmp", defaultFilename=0, source=base.win)
direct.task.TaskManagerGlobal.taskMgr.step()
with open("/tmp/out.bmp","rb") as img:
sys.stdout.buffer.write( b"\x1b7\033]1337;File=inline=1:")
sys.stdout.buffer.write( base64.b64encode(img.read()) )
sys.stdout.buffer.write( b"\a\x1b8")
sys.stdout.flush()
While it's possible, given the questions and the background about building robotics I kind of doubt it at the moment. I at present am not worried about it.
Hello. I'm looking for some help getting my TT DC motors to working while multiprocessing on a RPI 5. I've done alot of internet browsing for solutions but haven't really found anything. The purpose of my code is to do multiprocessing for speech recognition to drive a robot, and object detection using a usb camera to go to object. The problem I'm having is that when I run my code that does multiprocessing for these two processes and for example I tell the robot to "move forward", it will successfully execute the function which is confirmed by the print statements, but the motors won't move. I have tested driving the motors normally in a different python file without multiprocessing and it works fine. Here is my code:
https://paste.pythondiscord.com/OTRA
Thanks for the help.
most of the time your program is busy waiting on frame to arrive from camera ( cap.read() is a blocking call ), try asynchronous programming or run a capture thread queue for images
also please put some code attached to sys.excepthook to cut any motor / power down for people safety
I get that, thank you. I looked into both and did some research which helped grow my understanding. But before I started to try to implement asyncio, I decided to try to initialize the gpiozero components inside the voice_command function. Turns out doing that made it work. But I need to do more testing to make sure it is actually working the way I want, not just "working". If it's just "working" then I feel like asyncio would be the next move.
asyncio - still on my , to-do list
Hello! Iβm experimenting a lot with my Raspberry Pi Pico with micropython rn, and Iβm curious if it somehow is possible to make the pi pico appear as a HID device on my PC? I have not figured it out, but it would be cool to use buttons as HID inputs for gaming etc
it is very much possible
i suggest you take a look at circuitpython
circuitpython is wicked
Iβve tried it out a bit, but prefer micropython π
ahh ok
well , you can still do it using micropython , i havent done it myself using micropython so i dont know what exact libraries you should be looking at , but you can 101% do what you are doing using micropython too
i prefer circuitpython because it is pretty easy compared to micropython imo, you get good libraries developed by circuitpython people that do what you exactly want
Sounds interesting indeed, well I might give it a shot! Will try a few different methods when I come home
I might be able to find some functions online for more simple HID
honestly dont think it will get simpler than circuitpython π
but good luck π
sorry for the circuitpython shilling π
I'm making a simple two analog-stick gamepad, using the rpi pico (non-W variant), so far I've successfully added a single joystick and my computer can read the inputs, but hit a hurdle when I added the second joystick. I for the life of me cannot get GPIO_29 to do the ADC properly, it just seems to be stuck.
from machine import ADC
from utime import sleep_ms
vsys_pin = ADC(3) # same as ADC(29)
while True:
print(vsys_pin.read_16()) # always reads 2000Β±80 (no matter the joystick position)
sleep_ms(20)
I found a github discussion that addresses a similar problem on the Pico W, but mine's a Pico (plain, not even headers, I put them on myself)
Might use a analog 2:1 mux for the third input, but then I'd loose the nice round_robin feature :(
GPIO29 is used interanally to measure the VSYS/3 voltage
so you should use a different pin for your ADC
try all of them , one by one
you dont need to try , just use what they say in the datasheet
https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf datasheets are your bestfriends
I am extremely new to programming microcontrollers so I don't have a lot of implicit knowledge about them.
I did see that pinout diagram in the datasheet but I probably just don't know how to read one.
I am a little confused as well, so the dark green color in the legend corresponds to ADC, I've used ADC{0,1,2} they indeed work and they also correspond to GP26, GP27, GP28, these are the GPIO pin numbers used in the SDK, but the pinout doesn't have any information on GPIO29...(Which the SDK mentions that it can be used in ADC mode)
Googling revealed that GPIO29 is the VSYS pin on the rpi pico and the datasheet also confirmed that I can use it in ADC mode and measure voltage (I have no idea what VSYS means Google says it's the battery voltage?)
Also why is PIN 33 (the one you have circled) labelled AGND and not ADC3 if it can be used as an ADC pin?
so this board is based on the main microcontroller RP2040 (the black thing in the middle with the raspberry pi logo on it)
this RP2040 chip has this pinout (see the image below) ,you will see that there are loads of pins
now when raspberry pi made a board using this chip , they decided that they want to use one of the ADC pins to measure the VSYS voltage , hence the GPIO29 is used to measure VSYS voltage.
VSYS is the main system input voltage, which can vary in the allowed range 1.8V to 5.5V, and is used by the on-board
SMPS to generate the 3.3V for the RP2040 and its GPIO.
(according to datasheet)
basically , you can power your board directly through that pin , and that voltage can vary between 1.8V to 5.5V.
now , why is it not shown in the pinout ? Because that pin is not a general input output pin available to user , it is a pin of the chip used internally by the board.
Why can you use it ? because people designing the board and firmware have made it such that you can access it. (remember that since it is used internally , you cant really connect the pin anywhere , so there is basically no point in giving that pin on the board )
think of it like this , you want your program to know , what is the current voltage on the VSYS line . You wont have to connect anything to any pin , you can just measure it , why ? because there is already an internal pin that does this and you can just read the value of that pin.
Also why is PIN 33 (the one you have circled) labelled AGND and not ADC3 if it can be used as an ADC pin?
It is not a pin that can be used as ADC , it is a special pin that is used to set the ground reference for the ADC measurements. So , you can have a different ground with respect to which you can measure the ADC voltages. (you dont need to worry abaout it just yet , you can read on google bit more if you'd like )
Reading datasheet is indeed a skill and might not be obvious at start , you will get better at it the more you do it.
datasheet is like the absolute document for the board / IC . Whatever the pins do , all the information about them , limits , working conditions , etc etc. are in the datasheet
for example, you didnt know what VSYS pin was
you should have looked in the datasheet , the datasheet describes the pins and their function
just to show you what other useful information is in the datasheet,
here is the whole circuit connections of the board , also called as schematic
https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf here is the datasheet for the actual IC , RP2040
Ah! Thanks for the information!
It clears a lot of things!
I don't know what information to parse out of this, perhaps it'll make sense when I'm a little more competent
So the takeaway is that the rp2040 has only 3 ADC channels, the fourth being the VSYS pin and that pin is basically useless
yeah no worries, you dont have to get what it means (i surely didnt when i was starting out )
you will start to understand it as you do more of this stuff
no the fourth ADC measures the VSYS pin voltage. the ADC pin is different from the VSYS pin ( see the diagram below that shows how there is circuit between them )
and it is useful in some cases. So for example lets say you are powering your project from a li-ion battery , you would attach that battery to the VSYS pin
and then by utilizing the fourth ADC , you can measure the current battery voltage , and maybe show it as roughly how much % battery is left (i said roughly because for liion batteries , the current voltage is not the best way to gauge how much charge is actually left )
the takeaway would be , there are only 3 ADC channels available to you for measuring external things on the pi pico
Interesting
Saul Goodman, a real Goodman
glad i could help π
do yall help out with micropython because my code is having terrible memory problems
soo , yes
post your code , circuit diagram , error , what you want to happen and what actually happens
You are going to face when working with NODE-MCU ... your code needs to be memory efficient
Any idea how to write and read from serial port? I wanna be able to manipulate my LCD_I2C screen for my Arduino within python. This is what i got but i don't see anything on the lcd.
#include <LiquidCrystal_I2C.h>
#define chars 16
#define rows 2
LiquidCrystal_I2C lcd(0x27, chars, rows);
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
}
void loop() {
if (Serial.available()) {
String data = Serial.readString();
lcd.clear();
lcd.print(data);
delay(1000);
}
}
Python:
import serial
ser = serial.Serial(port="COM3", baudrate=9600)
ser.write(b"Hi from python")
Nvm, got it working.
Anyone whos interested how i got it working, this article is great: https://projecthub.arduino.cc/ansh2919/serial-communication-between-python-and-arduino-663756
Any idea why this doesn't work but if i yield it works?
import serial
ser = serial.Serial("COM3", baudrate=9600, timeout=0.1)
def write(text: str) -> None:
ser.write(bytes(text, "utf-8"))
write("Hello from python!")```
hi guys I program a pic16f687 and I have a problem with recovering adc values; here is my code:
void init_analog_inputs() {
// Initialization of analog inputs
ANSEL = 0b00010100;
}
unsigned int read_analog_input(unsigned char channel) {
// Read the analog value from the specified channel
ADCON0 = (channel << 2) | 0b00000001; // Select channel and activate ADC
delay_us(10); // Waiting for acquisition
GO_nDONE = 1; // Start conversion
while (GO_nDONE); // Wait for the conversion to complete
return (((unsigned int)ADRESH << 8) | ADRESL); // Return the conversion result
}
void main(void) {
UART_Init(9600); // Initialize UART with a rate of 9600 baud
init_analog_inputs(); // Initialize analog inputs
//init_digital_outputs(); // Initialize digital outputs
unsigned int adc_values[2]; // Array to store the analog values read
while(1){
// Reading analog values on the 5 channels
adc_values[0] = read_analog_input(2);
adc_values[1] = read_analog_input(4);
// Send analog values via UART
char buffer[50];
sprintf(buffer, "Analog Inputs: %u %u \n", adc_values[0], adc_values[1]);
SendString(buffer);
delay_ms(1000);
}
}
But I receive values like min and max:
Analog Inputs: 64 45056
Analog Inputs: 64 45056
Analog Inputs: 64 45056
Analog Inputs: 64 45056
Analog Inputs: 64 45056
Analog Inputs: 64 44800
Analog Inputs: 64 45056
Analog Inputs: 64 44800
Normally I have to get between 0 and 1023??
@elfin sphinx I think I need your help, I took your advice and installed circuitpythonβ¦ I am now trying to make it work as a HID without success πΆ Do you by chance know some guide etc?? Thanks
https://dronebotworkshop.com/pi-pico-circuitpython/ here is one out of many (scroll down to the HID keyboard section )
what do you mean without success ??
what have you tried ? what is not working ?
(also what exactly do you want to make ? )
Thanks a lot! I asked chat gpt but it is stupid tbh
Tried to find info on Google
The goal is to use push buttons connected to GP15,16 etc as inputs as a gamepad
Like Logitech controllers etc
The tricky part is setting up the HID for windows to recognize (I believe)
As a plug n play device
yeah , forget that GPT exists
did you not follow the tutorial i sent you ?? it should emulate a keyboard
for gamepad, i believe there is some circuitpython library
the setup remains pretty much the same , you just change the code
https://docs.circuitpython.org/projects/hid/en/latest/examples.html#simple-gamepad there is eve a circuitpython guide for making a gamepad
decide what exactly you want to do , ex - I want to make a gamepad with these keys
decide what keys you want your gamepad to have , take a look at example above
google if people have already made such projects or smiliar projects , take a look at thier code , see what libraries they use , then google information about those libraries , and then see if that is what you want
https://learn.adafruit.com/customizing-usb-devices-in-circuitpython/hid-devices#custom-hid-devices-3096614 there is also this thing , it is custom report descirptors for your device
https://www.pcbway.com/project/shareproject/Raspberry_Pi_Pico_Gamepad.html there is this project that is about gamepad with pi pico
just saying that there is loads of stuff around , you gotta start making stuff , start tinkering , start experimenting
and ask specific questions
so you are trying to do something , and its not working , ask , give all the details and ask questions
just "i want to do something like this " and then just researching about it wont help , you gotta start doing at some point
decide what features, keys , you want your gamepad to have , and then start from there ( decide if you want to emulate a gamepad at all , because depending on your needs, you can get away by just emulating a keyboard )
Thanks dude, will do as you say! Ima dig deep into this βοΈ
Will show the result!
Sup, I got this error on my raspberry pi pico H: OSError: [Errno 30] Read Only File, I want to write something to it, I need to measure distances and want that in a file, but this is now a read only file?
this is my csv cod
e
code
How should I run my python code on raspberry PI for production usage?
I created a software and connected bunch of hardware, im selling my solution and im wondering how should i deploy my software to raspberry PI which i use as controller for my solution
Good day. One question Please. I am using python CAN (https://python-can.readthedocs.io/en/stable/index.html) for sending and receiving messages. I have been trying to send messages. What I am doing is using the library to send a message and write the characteristics of that message on a CSV doc. The code I have used is the following:
#!/usr/bin/env python
import time
import can
import os
import csv
import pdb
os.system('sudo ifconfig can0 down')
os.system('sudo ip link set can0 type can bitrate 125000')
os.system('sudo ifconfig can0 up')
def main():
with can.Bus(interface='socketcan', channel = 'can0',receive_own_messages=True) as bus:
#print_listener = can.Printer()
#pdb.set_trace()
print_listener = can.CSVWriter("in.csv")
can.Notifier(bus, [print_listener])
bus.send(can.Message(arbitration_id=1,data=[1], is_extended_id=False))
bus.send(can.Message(arbitration_id=2,data=[1], is_extended_id=False))
bus.send(can.Message(arbitration_id=3,data=[1], is_extended_id=False))
#message = bus.recv()
#print(message.arbitration_id)
time.sleep(1.0)
print_listener.stop()
bus.shutdown()
if __name__ == "__main__":
main()
The thing is that it writes what it should ib the CSV, but when seeing the signal in an oscilloscope, it send infinite messages. Any hint on how to just send the messages I want /(not infinite messages), would be appreciated.
Thanks a lot in advance
Any ideas?
I am currently working with novapi to build a moveable robot - (lets not go into the functionalty just yet). I have the code but its in "blocks" in mbuild. I want to use python as it's a lot more flexible and easier to debug and whatnot. But i cant seem to find a way to do it. There is a python editor in mbuild but it doesnt seem to work as expected. I have got only one resource -https://github.com/Makeblock-official/micropython-api-doc/tree/master/docs/novapi
I cant follow the instruction here and make it work with python. Any one knowledgeable or experienced enough to help? Any help will be highly appreciated.
There are code which runs on python in this board - so I know it is possible. I just dont know how to integrate the api and the different libraries to be able to upload the code. The straight forward route to using python with novapi is "mbuild software's python editor" but doesnt seem to work right or its just me who needs proper guidance. Any idea on a solution?
mblock looks like a yet another closed ecosystem. scratch vm has a python transpiler/runner , blockpy allows to do python <=> blocks , there are plenty of open software/harware solutions around to build your own with any cheap SBC + mcu
ill look into that and reply Thanks for the reply.
And what about the libraries? I meant the different modules i have been using are already available in mblock as they were the manufacturers. Will i be able to access the libraries in other software you mentioned and be able to upload to a microcontroller board?
We cant, I just checked. I can either use mblock or mlink. My objective here is to control hardware with mblock's libraries within the novapi board with python and not "blocks". Its pretty small niche - so either mblock or mlink2 or smtth.
if it is really opensourced then you would have no problem adding python
the problem is indeed undocumented "niche"
if it is not well documented you will go farther by buildin your own niche ....
also maybe https://www.ros.org/blog/why-ros/
its not open sourced i guess. Checked multiple formums, websites and what not. It is within the mblock software. Here is one resource which i found out - https://github.com/Makeblock-official/micropython-api-doc/tree/master/docs/novapi
THis is for the api and there is novapi and exactly the components i need to handle but cant get past the explanation. There are instructions though but cant understand it. Could you help? And its written in chinese.
well "not open sourced" and not maintened == does not exist :/
do not waste your time, build your own or join a community that play along with industry standards
what do you suggest me to do here? I got block code which i hate to work with. I want to integrate python with the board and components but its not as easy as it seems. I want it to work with a specific board -(novapi) so thats another thing. If it was an arduino or a rassberry pi then i would be a lot more easirer. But i currently have novapi and have to work with it.
"But i currently have novapi and have to work with it. " why ? school assignment ?
yes kinda
STEM project. Have made the sytem work with mblock "blocks" but seems inefficent. I know python -"fairly" so why not use it ? And it more flexible for debugging and writting even
take a look at thi piece of code:
import novapi
from mbuild import gamepad
while True:
time.sleep(0.1)
if(gamepad.is_key_pressed("Up")):
print("Up")
elif(gamepad.is_key_pressed("Down")):
print("Down")
elif(gamepad.is_key_pressed("Left")):
print("Left")
elif(gamepad.is_key_pressed("Right")):
print("Right")
elif(gamepad.is_key_pressed("N1")):
print("N1")
elif(gamepad.is_key_pressed("N2")):
print("N2")
elif(gamepad.is_key_pressed("N3")):
print("N3")
elif(gamepad.is_key_pressed("N4")):
print("N4")
elif(gamepad.is_key_pressed("L1")):
print("L1")
elif(gamepad.is_key_pressed("L2")):
print("L2")
elif(gamepad.is_key_pressed("R1")):
print("R1")
elif(gamepad.is_key_pressed("R2")):
print("R2")
elif(gamepad.is_key_pressed("Start")):
print("Start")
elif(gamepad.is_key_pressed("Select")):
print("Select")
elif(gamepad.is_key_pressed("L_Thumb")):
print("L_Thumb")
elif(gamepad.is_key_pressed("R_Thumb")):
print("R_Thumb")
else:
Lx = gamepad.get_joystick("Lx")
Ly = gamepad.get_joystick("Ly")
Rx = gamepad.get_joystick("Rx")
Ry = gamepad.get_joystick("Ry")
print("Lx=%d, Ly=%d, Rx=%d, Ry=%d, " % (Lx, Ly, Rx, Ry))
that's horrible code
-novapi library and the - mbuild. Cant find it in the internet.
you think so?
i do
got it from github
if it is time to try to educate your teachers maybe the school level is the source of the problem ...
I myself have it in blocksπ
well not possible. have to work with what we have.
a more universal board -like a rassberry pi would be so much easier or even an arduino mega
industry would be more like STM32 for cutting costs. But don't mistake "easier" with "well supported" . Almost each manufacturer has equivalent hardware. price is in support quality ( or marketing power) . But for you to make a difference is your ability to work with unknow hardware with buggy tools and badly translated datasheets.
and blocks if forced to ...
so im doomed - no way to use python? But there is code for python to run for the board. I wonder how. And there is no support what so ever from the developers (with python integration). Not even a youtube vid from the community. It very very speific. Yea alright. Thanks for the talk. Guess have to work with blocks. Seems so childish and very very inefficient. Alright -i gotta make mechanism and whatnot - Thanks again.
yeah but blocks programming is not waste, especially for automotive and dsp eg https://sivantoledotech.wordpress.com/2011/08/26/first-steps-with-gnu-radio/
not doing automation here.
but someday you may have to, that's the point of doing useless things in school π
It like scratch - come so pathetic
yea hopefully
Can someone help me with running raspberry pi and camera
what help did you need ?
I am unable to open camera
why is that ?
what is the error ?
do you know how to use it ?? are you followign any tutorial ?
how do you open your camera ?
you really should follow a tutorial if you dont know what you are doing
Actually i saw on youtube that in interface the camera should be there and it should be enabled. But in my case there is no camera option in interface
I even tried doing this
have you connected your module correctly ?? make sure the ribbon connector is in the correct way
what os version are you using ?? are you using the latest one and have you updated everything ?
Everything updated
is the camera inserted correctly ?
Yez
i dont really see anything , but make sure that the pins are actually making contact with the connector (make sure you have not inserted it the other way around)https://www.youtube.com/watch?v=VzYGDq0D1mw see this video for instructions
also , restart your pi
Correctly connected
now run
rpicam-hello command
what is the version of your OS ?
where did you get the OS for your raspberry pi ?
on the latest OS , all the libcam-* modules are renamed to rpicam-*
right , so this is bullseye , not the latest version
the latest version is called bookworm , you have bullseye
So what should i do now
well , technically speaking , what you are donig should work with bullseye as well
but , if you can , you should wipe your SD card , flash the latest OS , and use that
@neon turret is that something you can do ?
https://www.raspberrypi.com/software/operating-systems/ download the OS from here
Yeah i will try that
How do I know which cable is for what on a fan(in my case its got 3 wires black, red and yellow)?
The Fan is the MagLev HA40101VA-000U-C99
check datasheet
if its a small fan like you see in a pc or smth , most likely black is gnd , red is vcc , and yellow is used to control the speed of the fan with a suitable PWM signal
but for accurate information , refer to datasheet
thanks
Good day. One question please.
I want to send data from python to ESP32. I have manage to send one value, but when I try to send multiple values, separated by comas, it does not send back what it should. The codes I have is the following:
import serial
import numpy as np
import time
import csv
import serial
# Open serial connection
ser = serial.Serial('/dev/ttyUSB0', 9600) # Adjust 'COM3' to match your Arduino's port
# Get input values from user
ldo = int(input("Enter LDO value: "))
setting_hex = input("Enter setting in hexadecimal: ")
# Send data to Arduino
ser.write(f"{ldo},{setting_hex},\n".encode())
print("---------------")
print("ldo =",ldo)
print("setting_hex =",setting_hex)
print(f"{ldo},{setting_hex}\n")
print("---------------")
# Read and print values sent back by Arduino
response = ser.readline().decode().strip()
ldo_received, setting_hex_received = response.split(',')
print("Values received from Arduino:")
print("LDO:", ldo_received)
print("Setting in hexadecimal:", setting_hex_received)
# Close serial connection
ser.close()
At the ESP side, I have the following:
void loop() {
int ADCcount;
int ldo;
String settingHex;
////////////////////////////////////////////////////////////
while(1){
// Check if data is available to read
if (Serial.available() > 0) {
// Read the data from serial
String data = Serial.readStringUntil('\n');
// Extract LDO value and setting in hexadecimal
ldo = data.substring(0, data.indexOf(',')).toInt();
settingHex = data.substring(data.indexOf(',') + 1);
// Send values back to Python
Serial.print(ldo);
Serial.print(",");
Serial.println(settingHex);
}
}
}
The idea is that the first number to send is an integer, and the second value corresponds to a hexadecimal value.
Thanks a lot in advance!!
What does it send back instead?
Hello @velvet cosmos . It sends the first value both times...
For example if I try to send 1,0xFF, it sends back 1 and 1
I updated my os to bookworm but still facing issues
run rpicam-hello and show the output
if you saw the picture ,it means the camera is working
But it closed automatically
I want the camera to remain and open and click a picture when i want
yep ,that is what the rpicam-hello script is programmed to do
this is when you start and write the code that does what you want
no worries βοΈ
@velvet cosmos , this is what I have in the terminal:
if it was working fine and if you didnt change anything in config or anything
i would suspect its some physical connection problem like broken cable or you accidently shorted camera or such