#microcontrollers

1 messages Β· Page 6 of 1

errant shell
#

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.

#

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

lime knot
#

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

elfin sphinx
#

your option is to use C++

#

could you show a pic of your board ?

lime knot
#

sure. I can also post the corresponding gitlab repo

elfin sphinx
#

this does not look beginner friendly

#

best to follow your class instructor

#

regarding this board

lime knot
#

course is in a year so that a bit too long

elfin sphinx
#

you said you have an arduino , you could start with that

lime knot
#

Indeed. I just wanted to find out how to actually use the board when I have it. But project for the future then

hallow igloo
#

Hi saul

elfin sphinx
#

hi charizard

errant wigeon
#

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?

errant wigeon
#

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)

final oar
errant wigeon
#

Ok so when you see pip3, go ahead and just use pip in this environment

#

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

final oar
errant wigeon
#

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

final oar
#

β”‚ The ARM I2C interface is enabled

errant wigeon
#

sweet, that's good

final oar
#

I clicked ok

errant wigeon
#

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

final oar
#

(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:~ $

errant wigeon
#

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

final oar
#

sudo reboot
?

errant wigeon
#

yup

#

that'll do it

final oar
#

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

hallow igloo
errant wigeon
#

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

final oar
#

run this source env/bin/activate after ls Documents or

errant wigeon
#

so it'd look something like:
(typing out stuff one moment)

final oar
errant wigeon
#

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

final oar
#

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 $

errant wigeon
#
pip install --upgrade click
pip install --upgrade setuptools
pip install --upgrade adafruit-python-shell

try these three commands

final oar
#

(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 $

errant wigeon
#

Ok let's rerun the demo
python thermalcameraDemo.py

final oar
#

(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 $

errant wigeon
#

bleh

#

hmm

coarse folio
#

Install libgpiod-dev from your software repo?

errant wigeon
#

yeah, that looks to be it. I thought it was suppose to handle it

coarse folio
#

(Educated guess)

errant wigeon
#

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
#

You've got the Adafruit MLX90640 or just the sensor on a different board?

errant wigeon
#

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

final oar
#

(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:~ $

errant wigeon
#

righteo

#
sudo python libgpiod.py
final oar
final oar
# errant wigeon righteo

(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:~ $

errant wigeon
#

weee this is what I was hoping to avoid

final oar
#

"Get a raspberry Pi" they said, "it will solve all your problems" they said 🫠 πŸ˜†

errant wigeon
#

sudo pip install adafruit-python-shell

#

then rerun sudo python libgpiod.py

final oar
#

(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:~ $

errant wigeon
#

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

final oar
#

@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. "

errant wigeon
#

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

final oar
#

@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 πŸ˜†

errant wigeon
#

Ah, Central US so it's just past 8 pm (20:00) for me

final oar
#

@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.

errant wigeon
#

go get some rest. That's the best magic in the world.

final oar
errant wigeon
#

That is a skill I wish I learned sooner πŸ™‚
It's a good thing you're seeing that need to refocus now πŸ˜„

final oar
#

@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

https://paste.pythondiscord.com/raw/SZEQ

errant wigeon
final oar
final oar
# errant wigeon Woo! That's fantastic! The guide I got pointed to, https://learn.adafruit.com/ci...

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-x
x*%+++-+.+...*
.....-.x-%-%xxxx++-+.+...
......x.%-%xx
xx+x-x.x.+..
.....-.x-xxxx+++++.x.+...
......+.x-x
xx++++++.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-+-................
..-.-.+-+-*--.-.......... ......
...-.-.-.-.-.-..................

errant wigeon
#

Woo!!

#

that looks like it's capturing data!

final oar
# errant wigeon that looks like it's capturing data!

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.

errant wigeon
#

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 πŸ˜„

final oar
cursive hamlet
#

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()
elfin sphinx
cursive hamlet
elfin sphinx
cursive hamlet
#

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

elfin sphinx
#

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

elfin sphinx
cursive hamlet
#

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

elfin sphinx
#

Okay , can you run the new code and update me if the error still persists ?

cursive hamlet
#

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?

elfin sphinx
#

Yep, no worries. Just make sure you post the latest code that is uploaded on the board

cursive hamlet
#

Will do thank you!

fallen nexus
#

does a machine.soft_reset() automatically rerun main.py on a Pico W?

valid sail
#

Only if there is a main.py file, obviusly

mighty kite
#

Micropython on a Pico W, does it have support for asyncio?

spiral sandal
#

micropython has async/await, asyncio is just a lib using that, instead of using generators as coroutines so yes

fallen nexus
#

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)```
valid sail
fallen nexus
#

oops one sec

valid sail
#

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

fallen nexus
#
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

valid sail
#
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

fallen nexus
#

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?

valid sail
#

I have never used the bluetooth library

#

sorry

fallen nexus
#

ah no worries then :)

valid sail
#

good luck

fallen nexus
#

ty!

elfin sphinx
fallen nexus
#

although that doesn't seem like a great solution

elfin sphinx
fallen nexus
#

I appreciate that, thanks!

torpid verge
fallen nexus
torpid verge
#

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.

vale sleet
#

Can we use python in development board

subtle scroll
last haven
#

why would i need more micro controllers when i have my wife

errant wigeon
vale sleet
subtle scroll
#

Normal Arduinos you cant control with python

#

Esp32s you can

#

Same for raspberry pi's(not 100% sure tho)

elfin sphinx
# vale sleet Any dev board. Such as Arduino, ESP32, raspberry pi, etc

"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 this

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

lethal meteor
#

I saw your very good about this topic

#

So

#

The question is:

#

Can you run an os on esp32?

#

@elfin sphinx

elfin sphinx
#

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

spiral sandal
#

better have a psram enabled board though

elfin sphinx
#

it most likely is not what they are looking for (that is just my estimation )

spiral sandal
crystal karma
#

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

elfin sphinx
crystal karma
#

-_- I am avoiding installing a gui application if possible, but I will try

#

ty

errant wigeon
crystal karma
errant wigeon
#

Yeah that is not ideal

#

what's the issue you're running into with rshell?

errant wigeon
crystal karma
#

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
errant wigeon
#

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?

crystal karma
#

it can connect, but /tmp/hello is my cwd on my mac

errant wigeon
#

Hmm

crystal karma
#

and i can get a repl... but i can get one with cu

errant wigeon
crystal karma
#

phew

errant wigeon
#

huh. Yeah I wish I could offer more help here but I at least know where to find folks who can πŸ˜„

crystal karma
#
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

errant wigeon
#

And that's something at least πŸ˜… I'll take it

torpid verge
crystal karma
teal estuary
#

Micropython is janky

errant shell
teal estuary
crystal karma
static dome
#

my raspberrry pi can only output a maximum of 5 volts but is there any way I could increase this voltage

elfin sphinx
static dome
#

i would need maybe 10-12 volts

#

for a motor

elfin sphinx
#

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

static dome
#

oh ok, i'll try that out

#

thanks

crystal karma
#

Yes if you connect a motor directly to your pi, even if it's a 5v motor, it'll probably destroy the pi.

limber field
#

ohh good idea @torpid verge

hallow igloo
#

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

elfin sphinx
#

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

crystal karma
#

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.

limber field
#

opto-couplers are very useful @crystal karma

crude bay
#

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 πŸ˜‰

gusty shuttle
#

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.

wise talon
errant shell
crude bay
#

that's why I've asked if someone tried to do it

elfin sphinx
#

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 ?

crude bay
#

sure:
capture screen at 60Hz -> few simple operations with openCV -> send data over UDP/Serial to another device

elfin sphinx
#

what resolution ?

crude bay
#

there would be 60 * 96byte arrays sent over one s

#

input 720p max

elfin sphinx
#

not sure if the pi zero would be snappy at that

crude bay
#

I can easly to to 320p

#

hmm i guess no other way than testing it myself then

elfin sphinx
#

most likely yeah

you could also checkout some other opencv with pi zero projects to see what kind of results they are getting

crude bay
#

hmm that's true, but I plan to incorporate camera later, so maybe going with rpi 4 would be cheaper over all

elfin sphinx
#

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

crude bay
#

it's price/performance and size

elfin sphinx
#

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)

crude bay
#

150x100x100mm max (with case)

elfin sphinx
#

and you dont plan to connect any thing to the pi ? like ethernet cable , etc etc ?

crude bay
#

nah

#

just power supply

elfin sphinx
#

ok

crude bay
#

I mean the smaller the better

elfin sphinx
#

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

crude bay
#

ok, thank you very much πŸ™‚

#

I think I'll go with pi 5, and then try to downscale

static dome
#

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```
final oar
# final oar I will have to use LabVIEW software for data acquisition in real time, and savin...

@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?

errant wigeon
#

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.

errant shell
static dome
#

i don't seem to have permission to edit the files though

ornate prism
#

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

ornate prism
#

how would I make a device with a microcontroller to when I plug in it to the router it automatically gets the password?

errant wigeon
#

!rule 5

hasty zealotBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

errant wigeon
#

please refrain from asking about it and related questions.

ornate prism
#

okay πŸ‘

abstract cove
#

@elfin sphinx what details do you want to know

elfin sphinx
#

everything

abstract cove
#

like

elfin sphinx
#

(i dont have time rn , you post all the details and your problem , ill take a look when i am back)

abstract cove
#

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

elfin sphinx
#

it probably should go between the resistor and the button from first glance

abstract cove
elfin sphinx
#

anyway , describe everything , ill take a look later , i gotta go

abstract cove
#

so pin 2 is an INPUT?

elfin sphinx
#

yes , in this case , its supposed to read if the button is pressed or not

abstract cove
#

?

velvet cosmos
#

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

abstract cove
#

what does

velvet cosmos
#

Presumably you want to apply an if statement of some kind that checks the button state and then conditionally does something else

abstract cove
#

buttonState = !buttonState;

#

do

velvet cosmos
#

Inverts it

abstract cove
#

like

#

if its high

#

it becomes low

#

and if its low it becomes high

#

?

velvet cosmos
#

It doesn't actually change the voltage

abstract cove
#

then what does it do

frozen oyster
#

it just changes the value of the variable

velvet cosmos
#

It changes the variable to its opposite.

abstract cove
#

so..?

velvet cosmos
#

So nothing

#

That's all

abstract cove
#

so that line is just irrelevant

#

?

velvet cosmos
#

Well no

frozen oyster
#

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"

abstract cove
#

what is XYZ

#

i have no prior arduino experience

#

oh

velvet cosmos
#

It's a placeholder

abstract cove
#

its just a statement

#

so the opposite means like switching the value from HIGH to LOW?

velvet cosmos
#

Inverting the variable just changes its value to the opposite of whatever it currently is

#

Yes

frozen oyster
#

what was your intention behind this block? c++ if(buttonState == HIGH){ buttonState = !buttonState; delay(500); }

abstract cove
#

its a code my teacher gave me

#

idk

#

😭

velvet cosmos
#

Are you supposed to fix it or what?

abstract cove
velvet cosmos
#

Because the state isn't assigned to again before the next time it's checked

#

This is like doing
a = 5
if a == 10:

abstract cove
#

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

frozen oyster
#

ah I see the issue, here they have button and buttonState as different things, as they should be

abstract cove
#

because like

#

button wasn't defined

#

so...???

#

i assumed my teachers forgot State

velvet cosmos
#

No, the state is tracking persistently

#

It's so that the value flips every time you press the button

frozen oyster
#

well from my understanding of the code what they actually forgot was int

velvet cosmos
#

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

abstract cove
#

oh so i change ButtonState back to button

velvet cosmos
#

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,

abstract cove
#

yeah this is why

velvet cosmos
#

They forgot / are missing the decl for button

abstract cove
#

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

velvet cosmos
#

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

abstract cove
#

so

#

how do i get the button to control it

abstract cove
velvet cosmos
abstract cove
#

is it buttonpin?

velvet cosmos
#

No

abstract cove
#

buttonstate

velvet cosmos
#

Yes

abstract cove
#

so

#

if button is high

#

i put button as buttonstate?

velvet cosmos
#

Wdym button as buttonstate

abstract cove
#

button = buttonState

velvet cosmos
#

No

#

Button is for reading whether the switch is closed or not

#

You use it to control buttonstate, not the other way around

abstract cove
#

buttonState = !buttonState;

#

this is the code my teacher gave me though

#

if button == HIGH then buttonState will be changed to low

velvet cosmos
#

Yes

#

Like I explained earlier

#

It's a toggle.

abstract cove
#

then we do that by

#

button = buttonState

velvet cosmos
#

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

abstract cove
#

i want to cry

#

buttonState controls the

#

what does it even control bruh

#

:/

velvet cosmos
#

Currently nothing

#

But you are trying to turn a speaker on and off, yes?

abstract cove
#

yes

velvet cosmos
#

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

abstract cove
#

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

velvet cosmos
#

Try and see

abstract cove
#

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?

elfin sphinx
#
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);
  }

}
abstract cove
#

a template

#

and yeah

#

i also dont have much time to learn arduino either

elfin sphinx
#

if this is in your curriculum , i highly doubt that

#

anyway

abstract cove
abstract cove
elfin sphinx
abstract cove
#

im trying to

elfin sphinx
# abstract cove

this is your most recent schematic , right ? the one that you are using

elfin sphinx
abstract cove
elfin sphinx
abstract cove
#

its not easy with 0 guidance and having school end at 6pm everyday

elfin sphinx
#

nothing is easy

abstract cove
#

i can't start with the basics now

elfin sphinx
#

should have done that when you had time thhen

#

anyway , arguing is not doing anyone good here , lets see if this can be fixed

abstract cove
#

so for my current code

#

the speaker just buzzes

#

i cant switch it off

elfin sphinx
#

what is your expected behaviour ?

abstract cove
#

when i press teh button

#

it should turn off

#

and when i press it again

#

it should turn on

elfin sphinx
#

then what is the purpose of that LDR ?

abstract cove
#

no idea mate

#

i dont know what LDR is

elfin sphinx
#

this thing

abstract cove
#

oh

#

uh

#

the led and speakers are supposed to turn on based off of the value of the photoresistor

elfin sphinx
#

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

elfin sphinx
abstract cove
#

to turn it on and off

#

the photoresistor controls how loud or soft

#

or how bright or dim

#

thank you for your help sir

elfin sphinx
#

?

#

i am trying to see what can be done , i am trying to replicate your setup

abstract cove
elfin sphinx
#

ok

abstract cove
#

because i have to revise for 2 tests

elfin sphinx
#

next time try to ask a little early

#

and actually learn the subjects you are that you are required to learn

abstract cove
#

and it won't matter

elfin sphinx
#

its put in your curriculam for a reason

abstract cove
#

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

elfin sphinx
#

arduino sounds like a good introduction to microcontroller world

#

you should know multiple things , microcontroller world uses lots of C++

abstract cove
#

1 year is not enough to learn the basics of arduino AND solve the real-world problem so yep here i am

elfin sphinx
#

1 year is more than plenty to learn arduino

#

you can learn arduino in about a month

abstract cove
elfin sphinx
#

yeah , but you have an year

#

which is more than at least 3 months

abstract cove
#

and jump straight into the solving part

elfin sphinx
#

theres tons of free online resources , you can learn from the basics if you want

abstract cove
#

my classes from 8am-6pm i reach home at 7, have 5 concurrent projects ill try my best

#

thanks for trying to help

elfin sphinx
#

ask teachers to teach from the basics

abstract cove
#

they have a schedule to follow

#

sure i can ask them about the basics but ill still have a weak foundation

elfin sphinx
#

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 ?

abstract cove
elfin sphinx
#

so you have a subject in the curriculum , and they did not teach anything for 1 year and then slapped you with an assignment ?

elfin sphinx
#

that sounds far fetched to me , idk if it does to you

abstract cove
#

the subject will last for 1 year

#

its 2months in

#

currently

#

and the assignemnt is just more like homework

elfin sphinx
#

and you have been taught nothing for the first 2 months ?

abstract cove
#

and the rest were on how to use the arduino uno

#

so im just stupid

#

πŸ‘

elfin sphinx
#

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

abstract cove
#

and did not explain what each thing does

#

or the syntax either

abstract cove
elfin sphinx
abstract cove
#

they told us to experiment during the lesson

#

so my iq is just under 100

elfin sphinx
#

but not teaching anything is wrong , the teacher is supposed to teach first and then let kids experiment

abstract cove
#

they only taught how the circuit board works

#

not the code

elfin sphinx
#

have you been taught C++ ? not particulary for this class , but like ever ?

abstract cove
#

no

#

python yes

elfin sphinx
#

***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

neon linden
#

does anybody know a library I can use for arduino

elfin sphinx
spiral sandal
static dome
#

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

errant wigeon
#

Can you post a picture of your wiring? I'm guessing you've mixed up a couple of wires and might have shorted something

static dome
static dome
#

red and black to power/ground rail

#

10k ohm resistor between vcc and data pin

errant wigeon
#

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

static dome
#

sounds good

errant wigeon
#

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

static dome
errant wigeon
#

Yeah that wiring looks right

#

Do you have another ds12b20?

#

and where did you buy this one from?

static dome
#

it came in a pack of 5 but i'm having the same issue with all of them

static dome
#

i believe the brand is BOJACK

errant wigeon
#

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

static dome
#

i'll take a look, thanks for all the help i appreciate it

static dome
#

I need help connecting my MCP3008 Analog to Digital Converter, I'm not getting any voltage readings

elfin sphinx
# static dome I need help connecting my MCP3008 Analog to Digital Converter, I'm not getting a...

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

ornate prism
#

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

elfin sphinx
#

cramming all of this together into something the size of flipper zero will be challenging

ornate prism
#

Ah

night elbow
#

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?

limber field
#

lots of stuff works automatically with linux , you will be suprised , give it a try @night elbow

limber field
#

do you do lots of sound production stuff ?

#

wonder if this can run on a pi , its a recording studio package @night elbow

night elbow
#

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

limber field
#

i havent looked at voice recognition for a long while , wonder whats been happening , and if a rpi 3 can use it at all

night elbow
#

i’ll be using a rpi 5 so hopefully it is able to do proper processing

limber field
#

ooh a 5 will do , may even do OpenCV stuff also , hmm ponder poder

night elbow
#

yea i’ve done opencv stuff on a rpi 3 and mannnn was it a hassle

#

1 fps was the best i was getting

#

πŸ˜‚πŸ˜‚

limber field
#

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 ?

night elbow
#

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

limber field
#

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

night elbow
steady sky
#

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?

dry panther
#

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 ?

errant shell
night elbow
#

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?

elfin sphinx
#

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

night elbow
# elfin sphinx a venv should not affect the working of library can you explain your problem in...

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.

night elbow
#

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 πŸ™‚

elfin sphinx
final oar
#

@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()`
hasty zealotBOT
#

: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.

errant wigeon
# final oar <@459119350851567626> Hi, since I am encountering many problems with LabVIEW sof...

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?

final oar
midnight nest
#

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)
elfin sphinx
midnight nest
elfin sphinx
#

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

midnight nest
midnight nest
#

i had a delay of 1 second first before lowering it trying to see if it was to slow

elfin sphinx
#

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

midnight nest
#

i have a connection open on a port of the device that shows when i get correct data. any trash data it just ignores.

elfin sphinx
#

try to send b'00000001'

#

and see if that works

midnight nest
#

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

elfin sphinx
#

what do you get on the microcontroller ?

midnight nest
#

nothing

elfin sphinx
#

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

midnight nest
#

i am going to grab my oscilloscope and go hardware checking for a bit. thank you very much for the help πŸ™‚

midnight nest
#

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?

limber field
#

reduce baud rate @midnight nest

midnight nest
limber field
#

how is it set up , PC-->usb/serial --->mcu ?

#

@midnight nest

midnight nest
#

PC => splitter
splitter => MCU
=> hardware serial monitor

limber field
#

hmmm splitter , can you define - i can imagine lots

midnight nest
#

is a custom made hardware splitter where we go from USB into custom made serial connection that works on 24volts on 300 bauds

limber field
#

did you look at all the signals on a scope , are the transitioning edges clean , nice and square

midnight nest
#

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 πŸ˜„

limber field
#

so , PC -->usb--> device x ( usb / TTL / 24 VDC ) --> interface on mcu board , limited to 300 baud for testing , data being garbled

midnight nest
#

was being garbled not anymore. as i said the monitor was faulty the problem is solved by now πŸ™‚

limber field
#

ahh ok , hmm i always use some inverters along the chain to square up signals

#

24 VDC interfacing , was this for something aincient

midnight nest
mystic jasper
#

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

limber field
#

can pygame do it , read different type of joysticks ? @mystic jasper

spiral sandal
#

gamepad api had a big change

limber field
#

question is latency , if important

spiral sandal
#

depends more on usb stack than sdl layer i guess

mystic jasper
#

I am reading from a serial port so it isn't recognized as a gamepad/hid device

spiral sandal
#

serial is faster than HID

mystic jasper
#

indeed it is, but matplot lib is slow in rendering the graphs

spiral sandal
#

probably input buffering at some point

limber field
#

I should do a direct wire , usb / serial - loopback test for max baude rate

#

another thing for the to-do list

spiral sandal
limber field
#

theres ADC-->serial / usb --> PC , projects out there , isnt FTDI 232 ,maxing out at 4 Mbits ??

spiral sandal
#

yeah ftdi and ch34x can get to 4 quite easy but that only throughtput not link latency

limber field
#

now Im daydreaming what are the SDR setups doing

spiral sandal
#

eg you can have insanely fast bandwith for an ADC with wifi but clock will be very late

limber field
#

kind of a jitter , timing wobble ?

spiral sandal
#

more like "broadcast delay" delay πŸ˜„

limber field
#

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

spiral sandal
#

well usually the hot stuff is not written in python, but i only used gnuradio-grc

limber field
#

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

spiral sandal
#

it is mostly python+qt except the dsp stuff that is usually compiled to native

limber field
#

im avoiding QT , its all payware yes ? found out Tkinter and Pygame windows can be squished together

spiral sandal
#

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

limber field
#

Tkinter is a simple control panel for me , can be in W10 or on a raspi ubuntu

spiral sandal
#

panda3d has a gui modeled after tkinter it is as ugly and efficient

limber field
#

well if i want to do waterfalls or fast display of a FFT , dont know if Pygame can do it

spiral sandal
#

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

limber field
#

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

spiral sandal
#

well it can even run in Terminal without a gpu

#

not joking πŸ™‚

limber field
#

I still need to try SSH login , for headless , will it all runn faster headless ?

spiral sandal
#

yeah you can ssh + egl

limber field
#

hmmm 3D rotate a cube ?

spiral sandal
limber field
#

doodles

#

math for 3D rotation is confusing

spiral sandal
#

but Panda3D can do more so better one tool to nail them all

limber field
#

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 ?

wraith gazelle
#

raspberry pi is dead

#

what are people using?

elfin sphinx
wraith gazelle
#

3x original price

elfin sphinx
#

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

wraith gazelle
elfin sphinx
# wraith gazelle 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

wraith gazelle
limber field
#

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

digital furnace
#

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?

pearl gale
# digital furnace I'm a bit lost here, I know that Industrial servo motor can be controlled via di...

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?

digital furnace
# pearl gale Speaking from a hobby motor perspective here, most motors are controlled from pi...

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?

errant wigeon
pearl gale
winter ingot
#

can i connect a 3.5mm audio jack to an arduino and use that microphone for speech recognition?

winter ingot
#

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

fervent viper
digital furnace
#

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

pearl gale
# digital furnace

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?

limber field
#

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

errant shell
kind pond
#

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

elfin sphinx
kind pond
elfin sphinx
elfin sphinx
kind pond
#

can you trust me,brother

elfin sphinx
kind pond
#

Are you saying that everyone who works on Arduino or Raspberry Pi works on building robots and thinking models?

elfin sphinx
#

ill let keith respond , this sounds troll ish to me

kind pond
#

you say to me come here, then i asked another one, did you read it?

pearl gale
pearl gale
#

Same type of repetitious messages

errant wigeon
#

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.

kind pond
#

can i?

#

just stop

#

or i leave

elfin sphinx
#

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

kind pond
#

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

errant wigeon
elfin sphinx
#

btw @kind pond i dont accept random friend requests , you are free to ping me here if you need some question answered

kind pond
# errant wigeon What would you like to learn about?

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

errant wigeon
# kind pond 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.

elfin sphinx
#

this (i am not attacking , i am just letting you know that i dont do DMs , if you wanna ask me something ping me here )

errant wigeon
#

I am aware of the situation.

elfin sphinx
#

i think ill take the leave now , good luck πŸ‘

kind pond
kind pond
#

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

errant wigeon
#

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)

digital furnace
digital furnace
digital furnace
#

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

errant shell
#

"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.

errant shell
tawny ivy
spiral sandal
#

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()

errant wigeon
night elbow
#

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.

spiral sandal
#

also please put some code attached to sys.excepthook to cut any motor / power down for people safety

night elbow
# spiral sandal most of the time your program is busy waiting on frame to arrive from camera ( ...

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.

limber field
#

asyncio - still on my , to-do list

spring willow
#

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

azure zenith
#

circuitpython is wicked

spring willow
elfin sphinx
# spring willow 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

spring willow
#

I might be able to find some functions online for more simple HID

elfin sphinx
#

honestly dont think it will get simpler than circuitpython πŸ˜‚

#

but good luck πŸ‘

#

sorry for the circuitpython shilling πŸ˜…

spring willow
#

Hahah

#

Love micropython

mystic jasper
#

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 :(

elfin sphinx
#

so you should use a different pin for your ADC

limber field
#

try all of them , one by one

elfin sphinx
#

you dont need to try , just use what they say in the datasheet

mystic jasper
#

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?

elfin sphinx
# mystic jasper I am extremely new to programming microcontrollers so I don't have a lot of impl...

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

mystic jasper
mystic jasper
#

So the takeaway is that the rp2040 has only 3 ADC channels, the fourth being the VSYS pin and that pin is basically useless

elfin sphinx
elfin sphinx
# mystic jasper So the takeaway is that the rp2040 has only 3 ADC channels, the fourth being the...

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

mystic jasper
#

Saul Goodman, a real Goodman

elfin sphinx
#

glad i could help πŸ˜…

dapper karma
#

do yall help out with micropython because my code is having terrible memory problems

elfin sphinx
#

post your code , circuit diagram , error , what you want to happen and what actually happens

ivory bridge
mellow canopy
#

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.

mellow canopy
#

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!")```
elfin cargo
#

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??

spring willow
#

@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

elfin sphinx
#

what do you mean without success ??

#

what have you tried ? what is not working ?

#

(also what exactly do you want to make ? )

spring willow
#

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

elfin sphinx
elfin sphinx
#

for gamepad, i believe there is some circuitpython library

#

the setup remains pretty much the same , you just change the code

#

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

#

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 )

spring willow
#

Thanks dude, will do as you say! Ima dig deep into this ✌️

#

Will show the result!

harsh ingot
#

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

opal forge
#

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

shy roost
#

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

hallow igloo
mental fiber
#

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.

GitHub

This project is used to generate API documentation for makeblock micropython products. - Makeblock-official/micropython-api-doc

#

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?

spiral sandal
mental fiber
mental fiber
# spiral sandal mblock looks like a yet another closed ecosystem. scratch vm has a python [tra...

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.

spiral sandal
#

the problem is indeed undocumented "niche"

#

if it is not well documented you will go farther by buildin your own niche ....

mental fiber
#

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.

GitHub

This project is used to generate API documentation for makeblock micropython products. - Makeblock-official/micropython-api-doc

spiral sandal
#

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

mental fiber
#

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.

spiral sandal
#

"But i currently have novapi and have to work with it. " why ? school assignment ?

mental fiber
#

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))

spiral sandal
#

that's horrible code

mental fiber
#

-novapi library and the - mbuild. Cant find it in the internet.

mental fiber
spiral sandal
#

i do

mental fiber
#

got it from github

spiral sandal
#

if it is time to try to educate your teachers maybe the school level is the source of the problem ...

mental fiber
#

I myself have it in blocksπŸ˜…

mental fiber
#

a more universal board -like a rassberry pi would be so much easier or even an arduino mega

spiral sandal
#

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 ...

mental fiber
#

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.

spiral sandal
spiral sandal
#

but someday you may have to, that's the point of doing useless things in school πŸ˜„

mental fiber
#

It like scratch - come so pathetic

neon turret
#

Can someone help me with running raspberry pi and camera

elfin sphinx
neon turret
#

I am unable to open camera

elfin sphinx
neon turret
elfin sphinx
#

what is the error ?

neon turret
elfin sphinx
# neon turret

do you know how to use it ?? are you followign any tutorial ?

neon turret
#

No

#

When i open my camera. Black screen appear

elfin sphinx
#

how do you open your camera ?

elfin sphinx
# neon turret No

you really should follow a tutorial if you dont know what you are doing

neon turret
#

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

elfin sphinx
neon turret
elfin sphinx
neon turret
#

Yez

elfin sphinx
#

the ribbon connector

#

i would double check it

#

also , restart your pi

neon turret
elfin sphinx
#

also , restart your pi

neon turret
#

Correctly connected

elfin sphinx
neon turret
#

Command not found

elfin sphinx
#

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-*

neon turret
#

How can i check for os version

elfin sphinx
# neon turret

right , so this is bullseye , not the latest version

the latest version is called bookworm , you have bullseye

neon turret
#

So what should i do now

elfin sphinx
#

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 ?

neon turret
#

Yeah i will try that

potent furnace
#

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

elfin sphinx
# potent furnace 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

potent furnace
#

thanks

shy roost
#

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!!

velvet cosmos
shy roost
#

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

neon turret
#

I am trying to run a camera with raspberry pi.can anyone help

neon turret
elfin sphinx
neon turret
#

this opened the camera for 2 seconds and closed

elfin sphinx
neon turret
#

But it closed automatically

#

I want the camera to remain and open and click a picture when i want

elfin sphinx
elfin sphinx
neon turret
#

Okay

#

Thankyou so much brother

elfin sphinx
#

no worries ✌️

shy roost
#

@velvet cosmos , this is what I have in the terminal:

neon turret
elfin sphinx