#microcontrollers

1 messages ยท Page 21 of 1

hybrid current
#

will that not work

hallow igloo
#

remo.tv would be the easiest for sure

#

Other people will be able to control the car too.

#

although I believe there is a private room option too

hybrid current
#

Does it matter what kind of motor driver I use?

#

I'm using a L298n btw

hallow igloo
#

They have support for certain motor controllers, there is a custom hardware file you can use to set up your own motor controller.

hybrid current
#

it's on the github right?

hallow igloo
#

yeah.

#

it looks like remo already has support for L298n

hybrid current
#

ok, thank you, saved me so much time

#

I was about to quit this idea

hallow igloo
#

glad I could help. Let me know if you need any help setting up the remo software.

hybrid current
#

ight thank you so much

hallow igloo
#

They have a good discord server too.

reef brook
#

Can someone please lend me a hand with a micropython esp32 build? i cannot for the life of me get the toolchain working

rustic karma
#

What should i use an arduino or Rasberry pie for my rc car

#

I am using python

#

or Cython in arduino

wheat loom
#

Depends on what you want to do

quasi spire
reef brook
# quasi spire Maybe I can help you.. What is the problem?

thankyou, basically i want to build a version of micropython with mcpwm built into it. theres a github for it but you need to build it yourself and i cant get a esp-idf toolchain working on anything (linux/windows). i was wondering if anyone here had done it before.

sudden hamlet
#

What's the error

quasi spire
#

MicroPython is implemented on top of the ESP-IDF, you should be able to use this mcpwm api

night shoal
#

can anybody send me an invite to the ArduPilot discord?

quasi spire
#

@reef brook if you have an specific repository for you project I can try to compile from my side.

reef brook
quasi spire
#

Compilation worked fine here. I was able to generate a firmware binary from this repo. The step-by-step is a little bit crappy, but in the end it worked

#

Can you send the error that you had experience?

reef brook
#

oh wow okay what did you use? i ll send you it now

quasi spire
#

I'm currently compiling that on a ubuntu machine

reef brook
#

thats what i got in VS Code, the in ubuntu i got maybe 15 errors. i got stuck on click.py not installed. but it was installed and i couldnt make it find it for the life of me

quasi spire
#

I had to create a virtualenv to install all dependencies from esp-idf

#

as you can see on my screenshot

#

I didn't use cmake...

#

I have used plain make

#

Also, I have used IDF v4

reef brook
#

honestly im not used to linux at all this was my first time using it pretty much i tend to do everything on windows

quasi spire
#

It should work on windows as well

reef brook
#

i know i used IDF4, instaled all the prerequisites, then the idf, then the requirments.txt stuff and it still had alot of issues

#

did all the git checkout to make sure i had the correct versions.

#

i tried following some tutorials but i ust thought they might be outdated and thats why

quasi spire
#

can you try to use make inside micropython_esp32_mcpwm/ports/esp32

#

?

#

if the idf.py is in your path and you did all those steps it's supposed to work

#

try this first

reef brook
#

hold on i just need to reinstall it... i deleted it in rage last night

quasi spire
#

hahaha, no problem

reef brook
#

did you already have the idf installed then ?

quasi spire
#

yup, but i did the checkout to the requested commit hash

reef brook
#

okay last night when i went to install it it said some things couldn't be found from the prerequisites. when i get to them i'll let you know

quasi spire
#

sure, no problem

reef brook
reef brook
quasi spire
#

Sounds great

#

please, let me known if you see any error

reef brook
#

so im not sure if im just really lost with this but heres the first one

quasi spire
reef brook
#

yeah :/

quasi spire
#

it does not need sudo in any of those commands

reef brook
#

so i installed it and now it says it needs installing again ๐Ÿ™ƒ

quasi spire
#

๐Ÿ˜ฎ

#

which is the message?

reef brook
#

ive got to here now

#

@quasi spire

quasi spire
#

yup, that is expected ๐Ÿ˜‰

#

now you have the idf.py tied to your current session. If you close your terminal you are going to need to use the export.sh again.

#

you can go to micropython_esp32_mcpwm/ports/esp32 and try to make it

#

you can use just make rather then cmake

reef brook
#

it says i need a CMakeList.txt

#

which i guess is for the cmake bverison but you didnt use that ?

quasi spire
reef brook
quasi spire
#

you env variable is pointing to a different esp-idf repo

#

echo $ESPIDF ----> Should point to $HOME/esp/esp-idf in your case

#

but it seems to be pointing to $HOME/development/esp32

reef brook
#

so how do i change that/

#

sorry i have no idea what im doing

hallow igloo
#

am using the C

#

hmmm

quasi spire
#

no, no, i'm wrong.

#

it seems to be something else

reef brook
#

oh okay

quasi spire
#

cd /home/development/esp32/esp-idf
./install.sh

#

them

reef brook
#

i dont even have a folder called development

#

shall i install the esp idf there?

#

make the folder then reinstall it all there

#

@quasi spire any chance we can chat screen share it might end up quicker?

quasi spire
#

But, I can't do it right now

#

:/

reef brook
quasi spire
#

not sure winch timezone you are...but i need +2hs

#

I'm working right now

#

kind of working...hahah

reef brook
#

ahh okay im in UK hbu? my work is the same if i was at work i would still be doing this

reef brook
quasi spire
#

I'm in brazil.

quasi spire
#

I'll ping you when I`m availb

reef brook
#

awesome thanks ๐Ÿ™‚

quasi spire
#

Hey! @reef brook i'm ready

reef brook
#

๐Ÿ™‚

reef brook
humble kraken
hasty ferry
#

i need some help with arduino ide

#

i created a simple header file in the new tab

#

in this header file im creating an class

#

now i cant create an object of this class in the ino file

errant wigeon
#

@humble kraken Huh that's odd. Maybe they had low traffic and chose not to staff it in favoring of staffing their own forum?

humble kraken
#

@errant wigeon clearly circuitpython stole it lemon_fingerguns_shades

ashen dock
#

how do I connect my raspberry pi to my pc, many tutorials just skip it like its no big deal but how

sturdy ridge
#

You can SSH into the pi to connect to it and use it from your computer. You can get an FTDI USB board and connect to it using serial to send two way data.

ashen dock
#

i need to isntall raspberry pi os onto the pi

sturdy ridge
#

You would download the raspberry pi OS image and flash it to the SD card connected to your computer, and then plug the SD card onto your pi

#

From then on the pi is a full computer you can connect to your monitor, mouse and keyboard

ashen dock
#

wdym image

#

im not trying to download a jpg onto my raspberry pi

sturdy ridge
ashen dock
#

i already downloaded it

sturdy ridge
#

It's an "image" of the OS in that it's a full snapshot of a working OS

ashen dock
#

my micro sd card not showing up (i didnt plug it in or anything)

sturdy ridge
#

So plug it in?

ashen dock
#

what do i need to do for it to show up

#

what do i plug it into??

#

thats the question

sturdy ridge
#

The SD card

ashen dock
#

its a micro sd card

sturdy ridge
#

Yes, plug it into your computer

ashen dock
#

so my pc is meant to have a micro sd card slot

#

because i dont think it has

sturdy ridge
#

If you only have a normal SD card slot, you can get an adaptor, or you can find another computer which has a micro slot

#

Most new laptops have a microSD slot nowadays

ashen dock
#

i plugged in my micro sd card into my brothers laptop.

#

guess what it did

#

it blacked out the screen and he cant come back in

ashen dock
#

i used a type-c card reader

#

please help ๐Ÿฅบ

humble kraken
#

the top black bit

#

that lets you plug it into a normal SD card slot

#

if you think the USB-C reader should be working normally just try it with another computer

jovial gazelle
#

which better

#

arduino

#

or

#

stm32

#

?

gentle vapor
#

what do you mean by better ? ๐Ÿคท
what do you mean by arduino ? ๐Ÿ˜›

vestal lava
#

From which project ?

sturdy ridge
#

STM32s are basically objectively better lol

#

Nowadays they are superior in basically every way including price usually, and nucleos support Arduino libraries

#

(not that you would use them)

strong ice
#

So I'm having trouble setting a static IP on the new Raspbian. Can anyone please help?

my "etc/dhcpcd.conf":

interface static_wlan0
static ip_address=192.168.1.23
static ip6_address=<address here>
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
#

any ideas?

sudden hamlet
#

what's the trouble

strong ice
#

hostname -I returns 192.168.1.17

#

it should be 192.168.1.23

strong ice
#

am i doing something obvious wrong?

strong ice
#

got it, another device was using the ip, i'm dumb

rapid escarp
#

lmao

#

i need help

#

how do you use python on the raspberry pi

#

like I know importing libraries and stuff but

#

what intermediate projects can you really do with it

#

plz reply so I get an @

errant wigeon
#

@rapid escarp what kind of projects are you interested in? A raspberry pi can run most any python code you can write, but it's small so it might run out of memory or be slow if you ask it to do heavy lifting like machine learning

rapid escarp
stuck thicket
#

Desk of Ladyada - It's a Keyswitch Cornucopia plus Stemma Sunday https://youtu.be/_Q4SqlQpvOo

The Great Search - Resistive touch screen driver replacement for STMPE610/STMPE811
https://www.digikey.com/short/7mt7b04f
A week or two ago we showed off some mechanical keyboard ideas we had. Well, prototypes came a few days ago and we quickly threw together prototypes for the individual MX/Kailh breakout and a dual-key FeatherWing. The reverse...

โ–ถ Play video
rapid escarp
#

@stuck thicket why are you spamming ur live randomly

errant wigeon
#

Actually, @stuck thicket is an awesome place to find pi projects!

rapid escarp
#

where?

#

website?

errant wigeon
#

One second to pull it up

#

They have a learn page that's an amazing starting place

rapid escarp
#

thanks ill check it out

errant wigeon
#

are there kinds of sensors you're interested in?

#

motion, air quality, etc

rapid escarp
#

im planning on getting a 30 dollar arduino kit from amazon with an ultrasonic sensor. would that work with the pi too?

#

@errant wigeon

errant wigeon
#

Ehh, yes and no. The ultrasonic sensor uses 5v logic, the pi uses 3.3v logic. You can get away with it by adding a resistor to help protect the pi. Give me a moment to find an example that does that

sturdy ridge
errant wigeon
#

(but don't worry about it being the right part, everyone slowly builds up a collection of electronics from various projects, and when another project in the future comes along you'll have a part ready to go)

errant wigeon
rapid escarp
#

so i would need a 330 ohm and 470 ohm resistor

#

im not sure how to tell if that's included in that amazon item i just showed u

errant wigeon
#

That looks like a solid kit--and it looks like it's got an HC-SR04, which is the same sensor in the tutorial

rapid escarp
#

IC 74HC595 resistor

errant wigeon
#

So what you actually want is a voltage divider, you have some wiggle room when it comes to those

rapid escarp
#

voltage divider

#

ok

#

oh ok so you just make the voltage divider circuit

#

using resistors

errant wigeon
#

bingo!

rapid escarp
#

ayy

#

thanks

errant wigeon
#

your example image uses a 10k and 20k resistor, this tutorial uses a 330 and a 470 resistor

rapid escarp
#

would I need to buy a different resistor?

#

cuz im pretty broke as a teen i can only buy that one kit right now

errant wigeon
#

I'll bet you can make due with that set

rapid escarp
#

ok thanks so much

errant wigeon
#

if you have 3 of the same resistor, lets say 10k, you can make a divider by sticking the three in a row

#

if you sample at x:

5v- [10k] - x - [10k] -[10k] - GROUND

#

it's the same as:

5v- [10k] - x - [20k] - GROUND

rapid escarp
#

that makes sense

errant wigeon
#

which is a nice introduction to resistance in series

#

Regardless, you should be able to make it work.

rapid escarp
#

so i could make that work with whatever resistors I have as long as I put the correct amount

errant wigeon
#

With some handwaving, yes. There's some issues, but you shouldn't run into them with a pi and that kind of kit.

rapid escarp
#

ok

#

last question

#

how would I tell the specs for a 330 or 470 resistor

#

in ur example u referred to the resistors as 10k and 20k

errant wigeon
rapid escarp
#

does k stand for kiloohms?

errant wigeon
#

Kilo ohms, but yes. Most will be 4 bands: three to say the value, and one to say the tollerance of the resistor: how accurate to the previous three bands are to their measured value. There's also a maximum amount of power they can take before the blow up/melt, (really just break, it's not going to blow up, but it might get super hot)

rapid escarp
#

and how would you know which corresponds to which? btw can i friend u so if i need help with something u can help me out? thanks for the help ๐Ÿ™‚

errant wigeon
#

Actually I might have misspoken--it's been ages since I've had to worry about tolerance or power rating--give me a minute to pull out some old stuff

rapid escarp
#

sure

errant wigeon
#

Right I did misspeak--The fourth band is the tolerance, not the power rating

#

Unless you're working with sensitive things, you don't usually have to worry about it, a pi isn't sensitive enough to really worry about it

rapid escarp
#

thanks for the help

errant wigeon
#

No problem. Feel free to reach out in the future, but you're probably going to get faster help in this channel than by dming me directly

rapid escarp
sturdy ridge
#

A bachelor's in electrical engineering probably given their username lol

errant wigeon
#

I've completed an undergrad degree in electrical engineering, I've been doing contract programming for the past few years, and am looking to go back and get a graduate degree myself.

#

@sturdy ridge haha spot on

rapid escarp
#

wow that's impressive

#

i gtg

errant wigeon
#

You're exploring electronics and python at a way earlier age than I ever did. That's impressive from my point of view. But never worry about comparing yourself to others--it doesn't help. Just make sure you're happy exploring what you're interested in, and you know what next step you want to take.

#

Cheers!

sturdy ridge
#

I didn't even start electronics or python till first semester tbh

rapid escarp
#

im trying to figure out my interests lol

#

like i want to do something in math cuz im like 3 grades ahead of my peers in math and im also good at programming

errant wigeon
#

Everyone has such unique paths to this section of python, I love it

#

@rapid escarp That's awesome! If it keeps you happy, keep at it! There's a huge world to explore

rapid escarp
#

i was thinking of cs, but i dont want to be depressed working a 9-5 for the rest of my life

#

thanks

#

im still doing competitive programming and i find it fun, but i just don't want to end up like how most ppl would following cs

sturdy ridge
#

It's just the times you work

#

You have to work at some hours of the day

errant wigeon
#

9-5 is why I'm looking at being done with contract programming ๐Ÿ˜„

#

I like that consistency

sturdy ridge
#

9-5 is great, doubly so with some flexibility

rapid escarp
#

hmm i didn't know that

errant wigeon
#

For sure. And everyone has different lives, schedules, goals, etc. And those change with time too. What might be a perfect schedule for one person might not work for another person.

rapid escarp
#

yeah im currently exploring so many things at once. I'm learning how to program an android app, im starting to make python projects, and im learning video editing for a yt channel

#

guess i just continue exploring

sturdy ridge
#

What's important about work is the work you do + work culture, the exactly times are less important and they just need to fit your other scheduling requirements (exercise, family, etc)

rapid escarp
#

i like that

#

yeah

sturdy ridge
#

9-5 copying data from one spreadsheet to another is a lot more boring than 9-5 making robots

rapid escarp
#

yeah that is true

rapid escarp
#

would learning how to make circuits and stuff like that only be useful in electrical engineering?

sturdy ridge
#

Learn electronics properly, learn some mechanical engineering stuff (CAD, machine design)

rapid escarp
#

and what would be a good place to start learning electronics

#

@sturdy ridge

sturdy ridge
#

Works for the first year and a half of an electrical engineering degree

rapid escarp
#

@sturdy ridge tysm

dry helm
#

I am very new to the Raspberry pi, in fact this is my first time working with it. I have a some questions that I really need an answer to:

do I write the script in the IDLE and run it from the terminal
I want to use the Cloud Speech API so I want someone to explain to me how to use it in the Raspberry, how do I code it, and I want the result that I get in the end to be displayed on an LCD Display, how to do that

#

I have alot of knowledge in robotics but I never touched a raspberry

#

I would extremely respect if an experienced robot builder gives me some help for my project

sturdy ridge
hybrid current
#

how do I change the raspberry pi camera resolution?

dry helm
#

And do I run the code from the same IDLE where I coded it or do I have to go run it from the terminal

sturdy ridge
#

doesn't matter, it's just like anything else in python. You can run it from the terminal, or from your editor

edgy basin
#

I'm wondering how to connect my 1.8inch lcd with my micro:bit controller like this

sudden hamlet
#

like what

edgy basin
#

wdym?

#

Oh

#

Like the picture bellow

#

You see how it has LCD1IN8 under math

#

I can't find an extension for it

#

Oh wait

#

I found it

dense hollow
#

hey, where can i learn Arduino from the scratch?

hallow igloo
#

The way I learned, and still learn, is to just google exactly what I am trying to do.

#

You are probably working with some sort of sensor if you are using a micrcontroller so start by googling how to set that up

#

and how to upload code to the arduino of course

acoustic swift
#

How would I go about being able to transmit data along a usb cable that could then be picked up by a raspberry pi? Using primarily python.
Because I want to make for example, a ldr component that returns data on light intensity

#

I've seen some stuff in serial data but have not fully understood it yet

sturdy ridge
#

From your PC?

#

You need a UART to USB adaptor, then enable the serial port within raspi's config, and just connect the two

#

Find the corresponding com port (windows)/tty port (Linux/Mac), use pyserial to open it up and send data over it

#

Use the raspi library to read from serial

small python
#

The raspberry has USB ports so it has uart to USB adaptors inside.

#

You just need to configure the serial port and enable it. You can connect a modem to the usb and use internet thru the USB configure the modem with the serial communication and enable with ipconfig the port for Ethernet.

tall goblet
#

Is there a way i can control relays over a really simple website hosted on a Raspi?

sturdy ridge
#

raspberry pi usb ports have no ftdi chips, they're mostly just for power

#

you need a separate adaptor

sturdy ridge
#

do the rest as usual

timber cipher
sturdy ridge
#

@tall goblet

gentle vapor
#

you're reading it wrong, it uses the FTDI first to setup the pi because it's a pre-W version

#

but I realize it's not actually relevant to the discussion, or more accurately I'm not sure what the original poster wanted to do

#

also I deleted my post when I wanted to edit it, great job me

sturdy ridge
#

either way, this is for controlling the raspi terminal over usb right?

#

not for transmitting general data like you would on normal uart?

gentle vapor
#

yeah, I think the original question was for reading a sensor through USB

#

to which I say: read the sensor through GPIO

sturdy ridge
#

have to get the data to the computer somehow

timber cipher
#

that waw my understanding as well. i wouldnt touch the USB ports for that. use a wireless transceiver.

gentle vapor
#

that's what I don't understand in the question

sturdy ridge
#

Why not?

#

It's a pretty common setup even

#

Generally it's a microcontroller not an SBC but it's a common DAq type setup

#

I did this a couple weeks ago with an STM32, which did have ftdi over the usb

timber cipher
#

USB is too finicky and complicated when you have all those pin headers right there just asking to be used.

sturdy ridge
#

We're talking about uart, it's nowhere near as complicated as any wireless setup

#

also what do you mean by "those pin headers"

gentle vapor
#

the question states "data that could be picked up by a pi" so I assumed the PC receiving the data is the pi, and the data is the sensor light detection

sturdy ridge
#

pretty sure they want to connect their PC to a raspi which is connected to a sensor

gentle vapor
#

if the computer is a PC, I would connect the sensor to a microcontroller (like a pi pico) and transmit the data over USB via the pico's ability to present as a serial port

sturdy ridge
#

data that could be picked up by a pi -> the sensor data, being transmitted over a USB

#

they probably only have a raspi

#

and a raspi works fine for the job, no harder than an mcu, you just need an ftdi usb cable

#

(assuming you don't have real time sampling requirements)

timber cipher
#

then you are restricted to within physical reach of the PC

sturdy ridge
#

it's a data acquisition system, you're almost always limited to the physical reach of the PC in cases you need to use those

#

he specifically asked for about a usb cable

#

i'm sure they don't mind a cable limited setup if they're asking for a usb cable

gentle vapor
#

if we go through a raspberry pi computer, I think the serial gadget mode on Zero and 4 can be used for other things than control the pi, but I wouldn't know the specifics, the gadget mode can do ethernet too and then you can use network software and later when you go wifi the code is unchanged ๐Ÿ˜‰

sturdy ridge
#

If you use a uart setup, you can easily swap out the uart cable with an HC05 and that will be even less change

#

nothing changes on the pi side, on the PC side you just have to connect the bluetooth device and swap out the TTY/COM number

gentle vapor
#

many options !

timber cipher
#

use a messenger pigeon is the only way

sturdy ridge
timber cipher
#

every part of that article is gold

sturdy ridge
#

I just love the tone it's written in

#

I'm always rolling while reading this part

Thus, this technology suffers from poor latency. Nevertheless, for large transfers, avian carriers are capable of high average throughput when carrying flash memory devices, effectively implementing a sneakernet. During the last 20 years, the information density of storage media and thus the bandwidth of an avian carrier has increased 3 times as fast as the bandwidth of the Internet

#

Also

In December 2005, a Gartner report on bird flu that concluded "A pandemic wouldn't affect IT systems directly" was humorously criticized for neglecting to consider RFC 1149 and RFC 2549 in its analysis.

timber cipher
#

Since the developers used flash memory instead of paper notes as specified by RFC 2549, the experiment was widely criticized as an example in which an optimized implementation breaks an official standard.[citation needed]
emphasis added

icy nest
#

Hello

hasty zealotBOT
#

:incoming_envelope: :ok_hand: applied mute to @near lintel until 2021-03-23 11:42 (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

steady flare
#

does anyone have a reccomendation on how get ideas for projects to make

#

ive been struggling to think of something to make but nothing comes to mind

gentle vapor
steady flare
#

aight thanks a lot

gentle vapor
twin roost
#

@sturdy ridge Very cool read.

#

I wish Discord would hit the chat window buffer on a <TAB> key hit and improve the completion. Like get it together lol

vestal inlet
#

ayy yoooo microcontroler check

quasi spindle
#

any tips for newbies at python

#

?

dire hollow
quasi spindle
#

ok thx

hallow igloo
#

hi

toxic shuttle
#

hi

elder crystal
#

Hi

#

How would I go about creating an arduino alarm clock which scrapes audio from the web?

#

Any ideas?

#

I was thinking that i could get around the scraping by having my computer beam audio via bluetooth

#

but i'd still need to store it somehow

#

and it would also be better to have it self-contained

hallow igloo
#

hi, how can i see information about a pid?

errant wigeon
#

@elder crystal so on it's own, that's a huge project. You'll want to split into smaller projects, like an audio file scraper, and an arduino/microcontroller that plays audio files at preset times. What kind of microcontroller/arduino do you have? Some of them aren't very powerful and have trouble doing too much at once

#

@hallow igloo PID as in proportionalโ€“integralโ€“derivative controller, or PID as in Process ID?

hallow igloo
#

I think if what I am trying to do is see current information about a system user, then when using psutil.user() it shows the users and the user's pid @errant wigeon

errant wigeon
#

Ok that is outside of my wheelhouse, to even take a guess I'll need to read up a bit. Didn't know about the psutil library though, that's a nice one

#

#unix might have more people who know about it as a heads up

errant wigeon
elder crystal
# errant wigeon <@!494534945742520322> so on it's own, that's a huge project. You'll want to spl...

thanks for the answer ๐Ÿ™‚ at the moment I have a python audio scraper and some alarm code well underway. I have an UNO, but i'm thinking of getting a mega for the purposes of the alarm clock. Thanks for the link, it looks extremely useful! My main problem figuring out how to get the arduino to webscrape, as I have no experience whatsoever about connecting the arduino to the internet! I'm having doubts about whether I can run all this on the arduino, or whether I should make a computer part for it...

errant wigeon
#

More or less, the arduino won't be able to do that. (There's some major hand waving there, but it's generally true)

#

a raspberry pi would have an easier time doing it,

#

the difference is a raspberry pi and an "Embedded Linux" board, and an arduino is a "Microcontroller". There's hand waving, but one can do most of the things a personal computer can do, and the other is built for simpler tasks, like monitor a sensor or turn on and off lights

#

Now I said there's some major hand waving--and that's because there are boards with wifi and they can be made to crawl and scrape on the web, but due to memory limitations, they're usually only given a small set of things to go and fetch--like the weather

elder crystal
errant wigeon
#

Personally I can't say--I've never tried to do audio+bluetooth on arduino. But there's a ton of projects out there that try to do it, so you can get a sense by searching those and seeing what others were able to do

#

from the looks of it, it's possible, but not necessarily straight forward

#

adafruit is a great place to search for projects and learn guides on as well

elder crystal
errant wigeon
#

no problem! Building stuff is so much fun

crisp cliff
#

hi guys, i have a question that i hope someone can help me solve this problem.
I'm doing my capstone project, the project is about smart door lock using facial recognition. I have already built the API using Flask and OpenCV for capturing faces and training. After that, I don't know how to put the model to the Raspberry Pi for facial recognition. If you have any ideas, please let me know. Thanks for your help guys.

errant wigeon
#

is there any reason you can't just install opencv and flask onto the pi and run it there?

crisp cliff
#

If I turned off the Raspberry Pi so that I can not get the API request from my front-end website dashboard

#

So I separated it, the raspberry pi only to get the model for the facial recognition

errant wigeon
#

Ok. I need to get a mental picture of how you're designing the program. I assume you have something like [camera]-->[facial recognition]-->[lock] as a rough outline: is that correct?

crisp cliff
#

I already have an idea that after training the model, i will put the model to firebase storage.
The raspberry pi will download the model and load the model for facial recognition. But what if I add another person -> This is the problem and I don't know how to solve this

errant wigeon
#

Are you training the model to notice your face from others, or are you training a model that can notice and distinguish multiple faces?

crisp cliff
errant wigeon
#

awesome, give me a few minutes to scan through the docs, but it might output some profile array, and to add a new person to the system you might just be able to do something like have a list of all faces, and then the pi will check back in to see if it's list is up to date

crisp cliff
errant wigeon
#

so is there any reason you can't have the pi check the firebase storage for a new yaml?

errant wigeon
crisp cliff
errant wigeon
#

well how are you going to get the yaml from firebase to the pi in the first place?

#

it'll depend on that process

crisp cliff
#
def download_model():
    try:
        storage.child('model.yml').download('models/model.yml')
        print('Downloaded')
    except Exception as e:
        print(e)
crisp cliff
errant wigeon
#

awesome! So depending on how you want to handle it, you can do 'model_YYYYMMDDHHmm.yml' where that's a date string, or you could just increase the index 'model_i.yml' for each trained model

#

then before you download, you can have a second function

    try:
        # list files 
    except ...
#

when you get the list of files, check to see if the new file is more recent than the one you have, and if so, download the new one

crisp cliff
#
def download_model():
    try:
        storage.child('models/model.yml').download('model.yml')
        print('Downloaded')
        recognizer.read('trainer/trainer.yml')
    except Exception as e:
        print(e)


# download_model()


def get_user_by_rfid(rfid):
    all_users = db.child('Users').get()
    for user in all_users.each():
        if rfid == user.val()['rfid']:
            name = user.val()['name']
            return name


rfid = 0

cap = cv2.VideoCapture(0)
# cap.set(3, 640)
# cap.set(4, 480)

# minW = 0.1*cap.get(3)
# minH = 0.1*cap.get(4)

while True:
    ret, frame = cap.read()
    img = cv2.flip(frame, 1)
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    # faces = faceCascade.detectMultiScale(
    #     gray,
    #     scaleFactor=1.2,
    #     minNeighbors=5,
    #     minSize=(int(minW), int(minH))
    # )
    faces = faceCascade.detectMultiScale(gray, 1.3, 5)

    for (x, y, w, h) in faces:
        cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
        rfid, confidence = recognizer.predict(gray[y:y+h, x:x+w])

        print(str(rfid) + " => " + str(confidence))
        if (confidence < 80):
            name = get_user_by_rfid(str(rfid))
            print('name', name)
            confidence = " {0}".format(round(confidence))
            count_time = time.time()
        else:
            rfid = "unknown"
            confidence = " {0}".format(round(confidence))

        cv2.putText(img, str(rfid), (x + 5, y - 5),
                    font, 1, (255, 255, 255), 2)
        cv2.putText(img, str(confidence), (x + 5, y + h - 5),
                    font, 1, (255, 255, 0), 1)

    cv2.imshow("Camera", img)
    if(time.time() - count_time > 10):
        pass
    k = cv2.waitKey(10) & 0xff
    if k == 27:
        break

print("\nPress ESC to exit...")
cap.release()
cv2.destroyAllWindows()
#

@errant wigeon Can you review my code

#

But what if i run this application, i don't know how to download the model at the same time the application is running

errant wigeon
#

so this code runs on the pi?

crisp cliff
errant wigeon
#

and you run this infinitely (so long as you're running the demo at least?

crisp cliff
#

@errant wigeon yes i run this application infinitely

errant wigeon
#

ok, so in that while loop, you could have a check to see if so much time has passed, (like a minute, three minutes, five, etc: that time is how often you want to check for a new model and you want to make sure it's decently infrequent so you don't annoy firebase)

#

if that time has passed, run the "check for new model" function, and if it does, run the "download model" function, and then you'll need to make sure you update the recognizer with the new model

crisp cliff
errant wigeon
#

you should be able to ping me here without an issue

#

best of luck working through the design!

half wraith
#

do python libraries work with micropython

#

?

sudden aurora
#

hi guy im a dog and im gonna dead

sturdy ridge
half wraith
errant wigeon
#

micropython is an implementation of python 3 that is implemented on a bare metal level of a supported microcontroller. Python libraries aren't implemented the same way, so a lot of what they require isn't implemented or available in micropython

#

it aims to be as close to a standard version of python as possible, but you'll hardly ever have more than a few megabytes of space for all of the programs on a microcontroller, so you have to cut out some stuff

half wraith
#

python libs need dependencies that are built into python that micro doesnt have

#

?

errant wigeon
#

kinda.

#

It might be easier to think of it as micropython isn't python, it's a different programming language. So like you can't just import numpy with a java program, you can't import numpy with micropython

#

micropython just aims to be as close as possible to python--they follow the same syntax and program structure and execute more or less the same way

sturdy ridge
#

Microcontrollers are bare metal. You have nothing available for you until you implement it yourself, no memory allocation, no kernel, no nothing. Most python libraries will depend heavily on the existence of memory allocation and kernel/OS features provided by your operating system. Because a microcontroller doesn't support those, in general using a language on a microcontroller is vastly different from using it on a PC user level environment

errant wigeon
#

so if you want to run a while loop, both micropython and python would be written in the same way

i = 0
while i < 10:
    print(i)

but libraries aren't just simple code like that, so they don't 'drag and drop' into micropython like a simple script might

sturdy ridge
#

This is true for non python languages too. When you're using Rust, C++, and C, you won't automatically have available to you basic functions like printf and Mallocs and whatnot because they're heavily OS platform feature dependent

#

Even though unlike micropython they are the same language and implementation

gaunt bobcat
#

Hi,
I got an idea for a development and I may need 7 microcontrollers. Though I wonder what is the best way for doing that.

Here is the context and the idea:
We got six builings and one underground parking lot that are all newly built, and power may shut off at any time without notice.

The idea is to get 7 microcontrollers: one for each building and the parking lot (so 7 in total), that ping a server (may be PHP server and/or a Python-developed Discord bot), via WiFi.
Here is already a SPOF: WiFi routers may lose internet connection without notice either but still being powered, but I guess that if one router loses connection, the microcontroller would just have to connect to another router. The internet connection is reliable and uses FttH for everyone, but some router models are old and just need to be restarted manually once a month I would say.
When the servers are not pinged after 2 minutes, a webhook from the servers send a message on Discord, saying that power may have shut off.

So far I only know Python as a beginner. I began to learn about 3 month ago, and I just started discovering classes, though I code and improve the Discord bot almost everyday because it has a lot of APIs.

I wonder whether a microcontroller would be appropriate for that?

Here is what should be reckoned with:

  • The microcontroller should have WiFi. It will be connected to the ISP router of a neighbor.
  • It needs to be powered at all times, so we may need to acquire USB cables and power adapters.
  • It will be located in the technical duct of each building where there is a power socket. But that power socket may be used for other purposes, such as powering a vacuum cleaner. The power socket has a European format (French, type E).
    -> I am trying to estimate the cost of the project, so the cost can be borne by the home owner association.

Do you have any idea of appropriate hardware for that? can that idea be improved?
I do not know if an ESP32 can do the job? or a Pi Zero W?

gentle vapor
#

yeah I think an ESP32 board would do the job

#

you might want one with a good wifi antenna or the possibility of adding an external one, to make sure it has a chance to see a router

#

and you'll want fault-tolerant software that will recover from losing wifi and be able to switch networks

ashen dock
#

how do I listen to sound on my Pi4? I tried plugging in headphones, but I'm not sure which jack I should put it into, and if this is even possible. Any help?

gaunt bobcat
hallow igloo
#

Does anyone have a turtle bot? need help with a project

rotund swallow
hallow igloo
#

all the hardcore stuff

rotund swallow
#

where are you learning ROS from? I believe you are pursuing robotics?

#

@hallow igloo

olive totem
#

Not sure if Im asking in the right place, but Im looking for a hardware button that would allow for a half press

#

Not quite sure where or how to find one, I need it for a half press to trigger autofocus on my camera, and a full press to trigger the shutter release

errant wigeon
#

@olive totem this might help, but it might be far easier to make a design with two buttons unless you need the focus and shutter trigger on the same button

olive totem
#

Im taking hundreds of photos in a span of a few minutes, its for photogrammetry, so the focus and shutter need to be on the same button

#

Also, that design is currently what Im looking at with my own trigger, but its not a very good button, nor is it small enough to fit on my rig in a comfortable way

#

As an idea, I need a small button to fit on these side handles

#

Ive found some monetary push buttons on amazon, but I really have no clue if they will do what I want

errant wigeon
#

So unless I'm really reading that button wrong (which is possible) those are only one level push buttons

#

honestly, the adafruit's discord might be the better place to ask--you might be more likely to get someone who's done a project looking for a product like you are

#

there's a help channel, 'help-with-project' and I'd recommend you try asking there

storm carbon
#

yo i want to run a block of code randomly btween two midnight any suggestion?

hollow jackal
#

HELLOOOOOOOO has anyone made a micropython byte interpreter so I can have instructions as bytes and potentially store more instructions?

sturdy ridge
#

@olive totem Have you considered the apple approach? Instead of a real button, some sort of pressure sensor with a vibration motor?

#

Less pressure -> half press, more pressure -> full press?

olive totem
#

Sounds like way too much work

#

Its just a shutter release, super simple in design

errant wigeon
frail scroll
#

what would be the best bluetooth library for Raspberry Pi?
my test case needs to advertise the bluetooth and let the phone connect into it and send back information

vivid fossil
#

Hey there, I'm writing a Python wrapper to provide a simple API interface for talking with some hardware.
I'm seeking an opinion on if this is a good use case of @property decorators or an abuse.

The hardware are some pumps, and they can respond to some pre-defined commands and give back some ugly strings in the form of bytes. I'm trying to handle that encoding/decoding/parsing process behind the scenes in the wrapper.

I have some methods such as
get_solvent() and set_solvent(x) and I'm considering using @property and @<property>.setter decorators. However, the accessed/returned value isn't being stored on the object. A call to get_solvent() sends a command to the hardware, parses the response, and returns a value. This takes non-negligible time as there is a soft-coded minimum 15 ms delay between sending a command and getting the response.

Does using @property decorators for something like this constitute an 'anti-pattern'? If you used a library that had implemented properties in this way, would you find it smelly?

#

If this is better suited to a different channel I'll move it

sturdy ridge
errant wigeon
grave rapids
#

How can I communicate with a low power device (room thermometer) that emits a signal at 433ghz

errant wigeon
#

Are you sure it's 433ghz, not 433Mhz?

grave rapids
#

Yes youโ€™re right sorry

errant wigeon
#

Ok, I've never used them so I dug into it, and I have no idea

errant wigeon
#

it should be possible to figure out how it's encrypted and then use another module that just decodes it, and transmits in the correct for of encryption, but that'll require a bit of reverse engineering and it depends how into the weeds you're willing to get to figure that out

grave rapids
#

i did some more googling and apparently there is a community around โ€œlow power device transmitters and scannersโ€. On the 433 frequency is typically fobs and weather stations (which is the device that I have)

#

it looks like i will need an SDR receiver, and some open source software.

#

the receivers i've seen so far are too expensive (at least for this project).

#

but you're right @kindred sand i could use RadioHead along with Arduino & setup a cheap receiver

errant wigeon
#

That's good to hear, I wasn't sure what you were trying to talk to so I could only get so specific. The SDR is a great choice, there's a large and active sdr community out there, so if you go that route I'm sure there's folks who can help you out

#

And if you google the device name + arduino, or +SDR you might find a project someone else did that you can simple copy to help guide you

#

Best of luck regardless!

grave rapids
#

i'm trying to get data from my weather station device and create reports, check my indoor temperature from work, etc

errant wigeon
#

I'm going offline for a while so I won't be able to reply, but what kind of weather station do you have. That'll can help narrow in on what kind of radio and protocol they're using

grave rapids
#

its La Crosse Technology. cheap device it was like $12

#

thanks that would help

errant wigeon
grave rapids
#

for some reason links dont work

#

this is a cool article thanks

errant wigeon
#

which ones specifically?

grave rapids
#

i thought this video was pretty cool : https://www.youtube.com/watch?v=JdzVIjKA68o

US: https://www.amazon.com/shop/techminds
UK: https://www.amazon.co.uk/shop/techminds

Here we take a look at decoding some of the micro transmissions from Low Power Devices on the 433Mhz band using RTL433 software for Linux and Windows.

Github Source: https://github.com/merbanan/rtl_433

Windows Binary: https://cognito.me.uk/computing/windows/...

โ–ถ Play video
errant wigeon
#

Neat I'll have to take a look at it in a bit. You have a good one and best of luck on this project!

grave rapids
#

thanks cheers!

lost moss
#

damn this is pretty cool

honest prairie
#

@digital fossil sorry false alarm

digital fossil
#

false!!!!!

lost moss
#

guys I've been quite interested in this field and i just wonder where should i start

#

i have somewhat of an intermediate knowledge in python, currently getting used to java and am a cs student if that helps

errant wigeon
#

this offers plenty of different guides and tutorials

lost moss
#

well i dont specifically know but ill check that out

#

i just want to get a deeper insight tbh

#

i looked into basic projects like building drones and radio frequency stuffs

errant wigeon
#

start simple, writing code to blink an LED is a common starting point, and the joy of getting it to blink after a lot of time trying never goes away

lost moss
#

but like with microcontrollers its only smthn you look into when you need something specific no?

lost moss
errant wigeon
#

ehh yes and no, they're not like computers so they can't do anything and everything, but they can do a lot of types of tasks. They're just best for one (ish) task at a time

errant wigeon
lost moss
#

funny story a while back i did a bit of research and got my hands on a raspberry pi model 3b +

errant wigeon
#

that's an embedded linux device, not a micro controller. But it'll give you a chance to play with some level of circuitry using the GPIO pins

lost moss
#

i got an sd card and tried to get it to work but idk i kinda had some monitor connectivity issues

#

that or i went wrong downloading software

lost moss
#

its an atmega 32 or something which im pretty sure is a microcontroller

errant wigeon
#

Both the pi and arduino are solid ecosystems and solid choices, I'd also suggest the circuit playground express https://www.adafruit.com/product/3333 since it's got a lot of parts preloaded onto the board

lost moss
#

ah i do actually have some softwares that i've demoed with a few components and stuff

#

fritzing and this other one that was part of a 3d modelling thing

errant wigeon
#

nice! I say find a simple project that sounds interesting (like blinking LEDs or reading the temperature of the room) and work towards getting that up and running

lost moss
#

it's really also bc i have an a level course in electronics starting this sep so im quite excited

#

i feel like i dont know enough to be able to start a project tho ๐Ÿ˜

errant wigeon
#

then don't start a project just yet. First, try to blink an LED. Then, try to make it blink faster, slower, longer, or shorter

lost moss
#

ah ok

#

so i would use the arduino for this i presume?

errant wigeon
#

slowly build up to a project, but don't yet start on it. You'd be surprised how difficult blinking an led might be, but that you can do it. Then afterwards, you'd be surprised at how easy starting the project can be in contrast to the difficulty of blinking the LED

#

You can do it with an arduino, raspberry pi, or circuit playground express

lost moss
#

ah ok tysm!

errant wigeon
#

I think the circuit playground is a good board to get over the arduino if you don't already have breadboards, leds, resistors, etc

#

it has a bunch of stuff built into it so you don't need to worry about wiring just yet

lost moss
#

i will try it with the raspberry pi and just get a resistor and led

#

ah yes thats what i wanted to say

errant wigeon
#

Awesome! Good luck!

lost moss
#

i had a question

#

lol

lost moss
# errant wigeon Awesome! Good luck!

basically you see with soldering, i dont want to start yet but theres many different contradicting recommendations out there and i just wanted to know what you would recommend or use

errant wigeon
#

to avoid soldering, you can use a breadboard (a lot of people use breadboards while developing a circuit or testing components-I have two within arms reach of me right now, about four more scattered about my office)

#

it's a collection of sockets that you can plug wires into, and some of the rows are connected (the above guide explains it far better)

lost moss
#

oh i've actually heard of them before

#

but that wouldn't necessarily work with smd components right?

errant wigeon
#

you then can use jumper wires to jump one connection to another

errant wigeon
lost moss
#

ah ok

#

LEARNING CURVE ye boi

#

i normally watch greatscott vids

lost moss
#

im assuming a 1.5v cell?

errant wigeon
#

so as long as you don't have many components, you can power it from the microcontroller you're using

#

There's some handwaving there, but for blinking an LED and some other things, you won't need to worry about it yet

#

a lot of boards have a 3.3v or 5v pin that can supply some current, and most of their gpio pins can also output an amount of current (not as much as the power pins, but plenty to drive lower current devices

#

The raspberry pi 'blink an led' guide goes into more detail, and adafruit has learn guides explaining it as well

lost moss
#

oh ok thanks that is all for now

last yoke
#

hi i have this problem on my d1 mini (esp 8266)

#

it works on another sites

#

For server i am using fastapi (python) and d1 is running micropython

spiral sandal
#

@last yoke looks like you have a quite old version of urequests on the board

spiral sandal
#

maybe you should remove the "#" at line 82 to see what happens and tell us

last yoke
#

problem is i am using only screen command to interface with esp. Somehow i have problems with thonny (only program that i know for micropython), so idk how to edit it.

spiral sandal
#

then tbh you should learn about uart / ampy first before trying to debug remote code or you will hit a wall

#

dunno if remote debugger work with mp but it's maybe worth looking at it or adding it

gentle vapor
#

I don't know if Mu is a better choice for Micropython

#

I guess you have to try and see

last yoke
#

Okay everyone. Thank you very much for your help. Idk how, but thonny managed to connect today and i created new file with code from urequests github. Now it started working and i can get data from my server.

gentle vapor
#

the thing is the only connection to the board is the serial port, so sending files happens through the REPL too via raw mode, when using Thonny or ampy or other tools. That's why Thonny takes over the serial line and switches between interactive REPL and raw mode as needed, whether when managing files or clicking "run".
So if you are connected with screen, or sometimes if you left the REPL in a particular state, Thonny can't do its thing.

#

When I used ampy way back in the days that was a major pain to me, having to disconnect from the REPL to transmit every file, and reconnect afterwards. Circuitpython (and the ESP32-S2) was a relief in that regard.

hallow igloo
#

anyone knows why the data is the same number that the adress just one line above the data ? (I'm making a pc : 65c02) and sorry for my english ๐Ÿ˜‚ ๐Ÿ˜ญ

#

i'll give you an exmple

#

here i defined the adresses :

#

rom = bytearray([0xea]) * 32768

rom[0] = 0xa9
rom[1] = 0x42

rom[2] = 0x8d
rom[3] = 0x00
rom[4] = 0x60

rom[0x7ffc] = 0x00
rom[0x7ffd] = 0x80

with open("rom.bin", "wp") as out_file :
out_file.write(rom)

#

(it's an 32 bits rom)

#

and

#

it gives me that :

#

... data -> read -> 00 (adress)
... data -> read -> 60 (adress)
... 6000 -> read -> adress

#

u can see that at the third line i find again 00 60

#

annyone knows why ?

languid kite
#

any pyautogui channel

#

??

errant wigeon
#

there's a user interface channel, that probably would be the best fit

tight plinth
#

anyone ever used blunano??

hallow igloo
#

question: what can I do with micropython on the ESP32S

#

yes ik its dumb

#

actually nevermind i dont have any spare

#

and its hard

rustic grotto
#

Hey all, I'm using a pico running CircuitPython to emulate a mouse HID. Currently, it's showing up as a mouse, keyboard and controller (separate devices). I noticed this thread on the topic - https://github.com/adafruit/circuitpython/issues/1015

Does anyone know a workaround for hardcoding the microcontroller as a particular device? (Mouse in my case)

GitHub

A couple of forum posts recently have asked if HID or MSC could be disabled for security or device interference reasons. We need some kind of dynamic USB descriptors to do this. https://forums.adaf...

tiny tiger
#

is anybody familiar with micropython?

#

the line was initializing an I2C pin

#

I2C object

#

i2c = I2C(scl=Pin(22), sda=Pin(21)) which are the correct pins

#

what is the 'id' argument required supposed to be?

errant wigeon
#

I believe it should be the ID of the i2c object you're trying to connect to.

#

could you try i2c = I2C.init(scl=Pin(22), sda=Pin(21)) (this isn't my wheelhouse so bear with me)

#

And from the looks of it, you might already have the scl and sda pins defined in you board, (depending on the board you're using) and might simply be able to to initialize an i2c instance without needing to declare the slc and sda pins (assuming that those pins are defined as 22 and 21 for the board)

gentle vapor
#

I think it needs an id for which hardware I2C you are using

#

like: i2c=machine.I2C(0, sda=sda_pin, scl=scl_pin, freq=400000)

errant wigeon
#

does it allow you to initialize then scan:

i2c = I2C.init(scl=Pin(22), sda=Pin(21))
my_device = i2c.scan()

or does it absolutely need the id before you can run that init?

spiral sandal
#

the id is the number of the i2c bus , also do not use "id" it's a builtin function of Python

#

@tiny tiger some platform have hardware i2c and others software i2c so you would need to use the specific platform documentation (if any and up 2 date )

tiny tiger
#

I figured it out I think

#

@spiral sandal was right, 'id' is a builtin function and i needed to use machine.SoftI2C instead of the usual

errant wigeon
gentle vapor
#

here id is just the name of the first argument when you are creating a hardware I2C bus

errant wigeon
#

Do various hardware bus's have predefined names?

mild turret
#

is it possible to use vscode for python on rpi pico besides C ?

spiral sandal
#

@mild turret you mean micropython/circuitpython ?

gentle vapor
# mild turret yes

there is a Circuitpython plugin for vscode, I have tested it but I don't actually use it so I don't know the state of it, it should bring completion and a button for the REPL. I believe you need to open the CIRCUITPY drive in vscode, then there's stuff at the bottom right and autocompletion

#

I don't know about Micropython though

mild turret
#

@gentle vapor i mean there was only tutorial proclaiming to do rpi pico on vscode but it actually only did it for C

gentle vapor
#

ah

lone heron
#

can you use recursion in micro-controllers to perform daily tasks and is it viable?

#

I am curious

gentle vapor
lone heron
#

Like I said I am curious and just wanted to know

cloud wyvern
#

Hey guys I was wondering if you could help me. I'm trying to get both of my stepper motors to move clockwise and counter clockwise 1 full rotation. When I run the code I use it only moves one stepper motor. I get an error that the "channel is already in use, continuing anyway" which is why my second motor won't move. I don't get how its in use when i named it differently and am using different pins can anyone help?

spiral sandal
#

@cloud wyvern what type are your stepper drivers (and on which mcu), could it be they need to use separate pwm channels ?

cloud wyvern
#

@spiral sandal Iโ€™m using tb 6560 and itโ€™s on a raspberry pi 3b+

errant anvil
#

pi@raspberrypi:~/Documents/RPI_STuff/Code/Python_Code/12.1.1_Joystick $ python3 Joystick.py
Program is starting ...
Not found device in address 0x48
Not found device in address 0x4b
No correct I2C address found,
Please use command 'i2cdetect -y 1' to check the I2C address!
Program Exit.

#

not sure why im getting this

#

happened after i duel booted

stuck thicket
minor moth
#

Write down the mode 0 control words of 8255 for the following two cases:

(a) Port A = Input port, Port B = not used, Port CU = Input port and Port CL = Output port.

(b) Port A = Output port, Port B = Input port, Port C = Output port

#

does anyone know this ?

wheat loom
#

Sounds like you want to look up the datasheet and look for those words

#

It is on the pages 4 and 5

#

Should be quite simple

#

Feel free to ask if there is something you donโ€™t understand

grizzled creek
#

I want to learn hardware programming, but I don't know where to begin... Like serial ports, USB devices... I am a web developer, have any idea what I should work on first?

spiral sandal
#

@grizzled creek if you want to use python and web then maybe you could build a web simulator

ionic kindle
#

๐Ÿ‘€

elder crystal
#

Is it easy to make a raspi record audio?

#

And store it?

hasty zealotBOT
#

A Python library used to create text-based games with TkInter.

lean oracle
#

Can I run python on arduino uno

#

It is what I have and I can't buy a pyboard now cuz of the pandemic

spiral sandal
#

@lean oracle you'd better use micropython unix + rpc via serial, because uno can only run some bytecode as it does not have enough ram

#

it just need a very long usb cable ๐Ÿ˜„

lean oracle
#

Yeah true

#

Thanks

#

For

#

The

#

Help

spiral sandal
cursive anvil
#

Hello are there people here with experience in Arduino (or C/C++ libraries)? I'm trying to write my own class where I want to use another library's instance in that's automatically created on the #include. I haven't figured out how I can use that same instance in my own class.. The class type is IrSend with the instance IrSender, I would like to use IrSender.doStuff() in my library.

Right now I'm getting a ton of errors that say multiple definition of IRsend::functionX. I simply included the library in my custom class and call it like I would in the Arduino .ino file, where it works fine.

spiral sandal
#

you may need to copy C & H content of library (IRremote/src/*) you want to extend inside src folder of the one you are creating so IRremote .c does not get linked twice

hallow igloo
#

hello

#

does anyone know how to read pyserial data seperately if you don't mind helping

#

for example x and y axis data at the same time but take those two data as seperate variables in the serial communcation inputs

hallow igloo
#

Hiye
Anyone here know about arduino
cause i have a doubt
This is the code i wrote for a simple obstacle avoider...Im new to arduino and i dont have one yet ...Will this work ...If i connect it to an arduino and the included parts ?

and ignore if i have missed semicolons

#

And i have another doubt

#

Can i program an arduino with python without additional hardware

hallow igloo
gentle vapor
tacit swift
#

Hey

#

Anyone here know how I can get started with stm32 microcontrollers

#

I have two stm32 boards

#

One with stm32f103rct6 and another with stm32f103c8t6

sterile lily
harsh kelp
#

Anyone here got exp with Wasp-os?

hallow igloo
#

Oi

#

anyone can please help me or guide me on how to get serial data on arduino to python

#

I used pyseriala but I can I make the output's seprate and give them to to different variables ein the python script with x and y delcartions.

gentle vapor
viscid shoal
#

Hello, i'm looking for help with a medical sensor and micropython, can someone help me?

viscid shoal
#

here is the full question:
how can i program a sensor from i2c with micropython? i need help or guide about the creation of own libraries to this sensor, i didn't found basic information to this on google. the sensor is MAX30102 it's libraries are on Arduino and i didn't found micropython version.

errant wigeon
novel aurora
#

how can we code arduino with python

viscid shoal
#

@novel aurora just in case, are you talking about my question? Or something apart...

chilly niche
tacit swift
#

Hey
Anyone here know how I can get started with stm32 microcontrollers
I have two stm32 boards
One with stm32f103rct6 and another with stm32f103c8t6

#

Stm32 microcontrollers

#

Have you used one of those ?

#

Ok

#

I just want some resource to use them

graceful lily
#

This is the first time I have encountered a bug that requires another bug in order for the actual intention of the function to work

spiral sandal
astral cloak
#

I was having a lot of trouble connecting my Arduino Nano to my computer, and I'm not sure if this is the right place to ask for help. It was for a python based code, and a microcontroller, but I don't know.

static heart
#

Trying to use PySerial to write to a STM32F7 disco board, I've basically got a number of this max length '2.1785714285714284' and want to be able to write that serially through USB. I've read the API but am unsure how to implement and use it properly, has anyone got any experience doing this before?

hallow igloo
#

Yes

harsh kelp
#

been playing around with micropython for my smartwatch ๐Ÿ™‚ such cool stuff!

bright spade
#

wouldn't it be with that module @gaunt hemlock

bright spade
gaunt hemlock
#

I suggest you to go with Flask

#

So you can prototype it faster

bright spade
#

I do not prefer to use flask

#

django is simple and effective

gaunt hemlock
#

Oh ok

#

Do you think you're going to implement some ai?

gaunt hemlock
#

ok

bright spade
#

just receive and send data

gaunt hemlock
#

great

bright spade
#

By the way thank you for not using too many terms because I'm a little too young

tacit swift
#

Thank you @sudden rain

untold patio
#

Is micropython available for the ATSAMD51J20A chips?

#

I see circuitpython is

hushed cliff
#

Is Thonny good for MicroPython

tight plinth
#

witch is the best smartwatch to make programs to??

grave swan
#

hey

#

does anybody knows pyfirmata

#

i programmed Arduino using standard firmata but it works till it is plugged with my pc

#

but as i unplug it, it stops working

#

and can you recommend some cheap microcontrollers which can be programmed

#

using python

gentle vapor
#

my understanding is that firmata is a way to control your microcontroller from a PC, so of course it does not work when unplugged from the PC ? Unless I'm missing something, I'm not sure what you want to do ?

scenic pebble
gentle vapor
scenic pebble
#

Raspberry Pi is like a smol pc

#

you can run python on it

gentle vapor
#

I'm talking about the Raspberry pico, not the SBC raspberrys

scenic pebble
#

Its still Raspberry right?

#

:)

#

ohhh

gentle vapor
#

they have pretty much nothing in common in the way you program them, the name is just confusing

scenic pebble
#

oh

#

ok

gentle vapor
#

now sure there are ways to write the same code for both by using the Circuitpython Blinka layer for linux for example, and it certainly can do many of the same things

open meadow
#

is python's Curcuit lib is good to use to make drones, or will it have a bad reaction speed

#

since python is slow I have some doubts

leaden gazelle
#

why wont circuitpython stay downloaded on my pico

#

when i unplug it and plug it back in the circuitpython uf2 file disappears

gentle vapor
hallow igloo
#

hey, i have an esp32 with micropython installed on it and a mpu6050 sensor. im trying to read the data off of the mpu6050, but for some reason cant i2c.scan find the mpu6050 sensor.. the light of the sensor is on so i think the sensor is working

#

does someone here know how i can fix this? or help me set it up

vivid fossil
#

I have a question here -- looking for some feedback on unit tests I wrote for interfacing with some hardware (HPLC pumps)
#unit-testing message
Sorry for the x-post but I wasn't sure where would be the best place to ask, seemed applicable to both

hallow igloo
#

and I also have a question

I want to make a small 4dof robot arm that can harvest a hydroponic bin with the help of a camera
But even though I'm familiar with Python and machine learning, I've never tried training a robot arm by combining inverse kinematics, a camera and machine learning
So do any of you know a tutorial where i could start, or maybe some documentation?
thank you :))

errant wigeon
# open meadow is python's Curcuit lib is good to use to make drones, or will it have a bad rea...

If you google "circuit python/micro python for drones" there's a sizeable number of results. While I've not explored programming a drone, I think it should be functional for them. Now if you're exploring things like drone racing, it might be pushing the speed of the language, but I'd wager it's more than functional for what normal drone flight needs. (Since I'm not experience in drones with circuit python, I'm saying this based off of the results of a google search).

errant wigeon
errant wigeon
# vivid fossil I have a question here -- looking for some feedback on unit tests I wrote for in...

The feedback you got under the unit test channel is fantastic, (I gained some tips for future and ongoing projects). The only real suggestion I can offer is to test that certain return values raise errors: there are pressures that are basically impossible to achieve during functional operation and that kind of sensor awareness is really helpful. If a sensor is returning an impossible value, it frequently helps to flag it as erroneous. But honestly, that recommendation is built off of my own experience dealing with poorly reporting sensors, so maybe it doesn't apply in your instance. Other than that and what's already been recommended, the tests look alright when I looked them over

errant wigeon
# hallow igloo and I also have a question I want to make a small 4dof robot arm that can harve...

Having a hydropincs system myself, and knowing the roots of my plants get tangled, what are you looking for with respect to harvesting? Different 4dof arms will have different strengths, and might have trouble successfully picking what is ready for harvest. Ignoring that issue, my instinct is to recommend that you use an embedded linux device (or just a regular computer) for all of the machine learning/camera/computer vision stuff so you have access to the full python ecosystem, and then communicate the necessary actions to the arm itself. This approach would help you divide the project into a bunch of smaller steps: interfacing with the arm (the only part that might need a microcontroller), deciding how to move the arm (Which I think would involve a robotic arm simulation of some sort, such as https://github.com/srsanghavi/Robotic-arm-simulation), backprojecting or computing the 3d location of a pixel in a 2d image to figure out where the grabber of the arm needs to be (https://math.stackexchange.com/questions/2237994/back-projecting-pixel-to-3d-rays-in-world-coordinates-using-pseudoinverse-method, https://www.scratchapixel.com/lessons/3d-basic-rendering/computing-pixel-coordinates-of-3d-point/mathematics-computing-2d-coordinates-of-3d-points), and finally deciding the 'ready to pick' threshold of your crop (this is a huge area of investigation in agg research: https://academic.oup.com/jxb/article/67/11/3587/2197789, https://www.hackster.io/taifur/ripe-fruit-identification-9c8848, etc. The keyphrase I searched was, "opencv harvesting crops" as opencv is a great library that has a python extension for these kinds of projects). In short, it's a complex project, but by letting yourself use a computer for most of it, the only part of a microcontroller you need to worry about is how to controller the 4dof arm

hallow igloo
hallow igloo
errant wigeon
acoustic swift
#

Why does binary data being sent over USB data lines sometimes have to be encoded in base64? Like from the raspberry pi pico to the raspberry pi 3b+?

gentle vapor
#

I think I can hasard a guess that you are talking about maybe Micropython that would require it because the serial is the REPL console and so binary data could contain control characters that could have unintended effects, but pure serial in like arduino would not have that issue

hallow igloo
acoustic swift
acoustic swift
acoustic swift
steep dune
#

KeithTheEE--- can a raspi 3b+ handle OPENCV ? is there a distribution that has this already in its image from the start?

gentle vapor
#

I was even talking about that over there yesterday, as somebody was asking about outputing binary to serial and found it was coerced into string/unicode representation

#

Circuitpython is now including (in alpha) the option for a secondary, binary friendly, dedicated USB serial interface (as well as treat the REPL serial as binary). I don't know if Micropython can do that too though

#

maybe Micropython has a way to open the repl serial as a data stream/UART

acoustic swift
# gentle vapor I think I can hasard a guess that you are talking about maybe Micropython that w...

Question here, "Micropython that would require it because the serial is the REPL console and so binary data could contain control characters". How is serial data stored on the REPL console? Are you saying the REPL console can be used to retrieve the serial data being sent from the pico outward using some commands because I was reading this : https://www.raspberrypi.org/forums/viewtopic.php?t=306520
Then from there, reading that, I'd potentially see some control characters?

gentle vapor
#

ah you see, I didn't know sys.stdout.buffer.write would work ! existed

#

or is it sys.stdout.write ?

acoustic swift
#
while True:
     sys.stdout.buffer.write(a)

There's this example on the site so I'm pretty sure it is sys.stdout.buffer.write

gentle vapor
#

seems like it should work then

acoustic swift
#

And I'm a bit confused on the definition of a buffer and how it works here, I need to test this too when my pico comes through I got my raspberry pi 3b+ already

gentle vapor
#

that's a way to define a byte string, you can also use bytes([1, 0, 0xff])

#

you can create a buffer and write to it rather than allocate new ones

buf = bytearray(10)
buf[0:4] = b"beef"
buf[4:8] = "beef".encode()
buf[8:10] = b"\xbe\xef"
print(buf)
bytearray(b'beefbeef\xbe\xef')
#

sys.stdout.buffer.write(buf)

#

now as to sys.stdout.buffer

#

I think it's basically the way to access the binary underlying buffer of sys.stdout without string conversion

#

but I don't know more about that

acoustic swift
#

I saw this line of code to be run on the raspberry pi 3b+ which was ```python
ser = serial.Serial("/dev/ttyACM0")
while true:
line = ser.readline()

But there's a gap in my understanding to what ```sys.stdout.buffer.write``` does to pass data along its micro usb port, which will then be moved across to my raspberry pi 3b+ usb port via usb cable
gentle vapor
#

ah well the board presents itself to the computer as a USB-serial device, creating a serial port on the host (/dev/ttyACM0 on linux if no other port is present) and that's how you read the buffer from the host, by using pyserial a in that code, or anything that reads a serial port

#

now in the example it uses readline()

#

but you can use read(n) to read n bytes

#

if you output as binary, you don't want to use readline, that's more for strings

acoustic swift
#

I think I remember something about passing float data types or just numbers in general and converting them to string prior is better because of the character set or the lack of unicode support something like that with Micro python idk it was something a bit complicated

gentle vapor
#

ah no we were talking about sending as binary
if you're fine sending as strings you can just print

import time
while True:
  value = sensor.something()
  print(value)
  time.sleep(1) # not too fast !
ser = serial.Serial("/dev/ttyACM0")
while true:
  line = ser.readline()
  try:
    value = float(line)
  except ValueError:
    continue # ignore bad value
  # do something with the value
  print("Received",value)
acoustic swift
#

So printing automatically writes to a buffer

acoustic swift
gentle vapor
#

yeah there is no flush needed

#

by the way for binary something like that would probably work, not quite sure on the details, and I prefer using json in general to transmit data (unless maybe it has to be super fast, but then python might not be the bestest choice)

import time
import struct
while True:
  value = sensor.something()
  sys.stdout.buffer.write(struc.pack("f",value))
  time.sleep(1) # not too fast !
ser = serial.Serial("/dev/ttyACM0")
while True:
  line = ser.read(4)
  try:
    value = struct.unpack("f",line)[0]
  except ValueError:
    continue # ignore bad value
  # do something with the value
  print("Received",value)
gentle vapor
# acoustic swift You talked prior to there being the potential of multiple buffers here? Does rea...

I mentioned multiple serial ports, they would be completely independent from each other, like 2 separate files you write and read from, it would be /dev/ttyACM1 for example for the second one, the point is to be able to access the REPL to test and debug without interference with the serial data line, but I don't know how to do that in Micropython. The forum thread you linked mentioned it, and there's certainly the answer to that in that forum

#

(might need a recompile of micropython though)

acoustic swift
#

Also, there was something I wanted to understand as well it was identifying which of my components are in which port.
I had an idea to read from each serial port on my raspberry pi 3b+ and when I send serial data via my raspberry pi pico I would send the data in a string format with information such as "Component1-x".
With x just being the data collected from a component I'm sending and "Component1" being used when the data is picked up to identify whether the serial port I'm reading from is one of my components. Then from here it can handle the data.
Would this work?

#

Ah it should I assume, and it would just come down to me testing it first to see if it wouldn't

gentle vapor
#

I would use json:

import json
data = json.dumps({"component1" : value})
print(data)
data = json.loads(line)
if "component1" in data:
  print("Component 1 sent:",data["component1"])
#

it's all strings, but it can do structured data that easily translates to and from python, which is great

#

(some try/except might be needed in case the json data doesn't validate)

#

or you can send some fixed size identifier in the binary stream, and read the right number of bytes to test it

#

what kind of project is that for ?

acoustic swift
#

A environmental sensor. I'll have a casing and screen display for my raspberry pi 3b+. The display will have a pyqt5 window that displays data collected from the serial ports from attached raspberry pi pico components that will read data such as temperature, humidity / moisture, light intensity, etc. It's purpose is to help with gardening / farming

#

There will also be a casting for the raspberry pi pico attachable components to make the components need and safe guarded too *

steep dune
#

very cool

acoustic swift
#

Ty

#

And thank you @gentle vapor for the help as well, really appreciate it! ๐Ÿ˜„

#

Hopefully when I get the pico through the order I can test this and get it working well

#

Then order a couple more

steep dune
#

hmmm is there wifi on a pico?

gentle vapor
#

oh yeah collect data into a python dictionary, populating it as needed, and send that over in json, the pi can then update the display with whatever is available in the dict

#

no, for wifi you will likely want an ESP32 or ESP32-S2

steep dune
#

pico speaks python that makes it easier

gentle vapor
#

the ESP32 is a very good Micropython platform

steep dune
#

but does a pico have a user port thing for SPI chips

#

hmmm sensors are SPI and ??

gentle vapor
#

it has 2 hardware SPI and 2 hardware I2C

steep dune
#

i want to make a water analyser for hydroponics

#

measure PH , what else??

gentle vapor
#

(that can be used on a variety of pins, but read the pinout to know which)

steep dune
#

mmmm leds and optocouplers to the rescue

gentle vapor
#

there's a ton of ESP and pico projects out there to look up for inspiration, they are both quite popular

steep dune
#

pico = smart node

#

have your sensors for hydro - local = 3 feet away -- then send data via serial ? I2C ? .... wifi

#

then have a RP3B+ run 24/7 and do data logging and messaging( basement is flooding - ALERT )

#

ESP32 is the new version i guess

hallow igloo
#

hmmm

hallow igloo
#

which arduino kit is best for home automation/Ai?

steel folio
#

Can you giveaway Raspberry pi full kit

#

Or can I progam Arduino with python

atomic dawn
#

For interfacing with nodemcu is there any other dev enviroment other than Thorny?

harsh kelp
harsh kelp
errant wigeon
errant wigeon
# steep dune KeithTheEE--- can a raspi 3b+ handle OPENCV ? is there a distribution that has...

To my knowledge yes it'll run just fine. If you try to do some extreme computing the pi might lag, and if you don't keep track of your ram you could hit memory errors, but opencv has been compiled for the pi: https://towardsdatascience.com/installing-opencv-3-4-3-on-raspberry-pi-3-model-b-e9af08a9f1d9 (This was written in 2018 so I wouldn't worry about the opencv version they specify, you're probably fine going up to the lastest/default that installs)

steep dune
#

cool thanks

steel folio
harsh kelp
#

@steel folio you can get off brand ardino kits for realllly cheap just buy one of those

harsh kelp
#

Oh I can get a rpi zero for 5 bucks... lol

#

Either way it's generally frowned upon to go into groups like this and beg for people to buy things for you..

bronze light
#

Has anyone here much experience with a 3 x 4 matrix keypad, with the Raspberry Pi?

#

I have a matrix keypad which is connected to my Pi and is working perfectly as expected in terms of being able to talk to it, it's registering inputs absolutely fine. However I'm having some issues whereby if you hold the keypad button down for any length of time it is registering more than one input as the check is held inside a loop.

#

The loop part of the script is

#
if __name__ == '__main__':
    # Initialize the keypad class
    kp = keypad()

    # Loop forever
    while True:

        # Loop while waiting for a keypress
        digitPressed = None
        while digitPressed == None:
            digitPressed = kp.getKey()
        print(digitPressed)

        sleep(0.1)
#

Can provide the keypad class if needed.

gentle vapor
#

does it return one or a list of keys that are pressed ? what you want to do is remember if the key was already pressed by setting a variable and reset it when it's not pressed, and then you can chose to do whatever you want when the key is pressed or released.

spark robin
#

So, I have a question.
I want to start IoT.

where should I startโ€ฆ?
I have decent xp in Django and I have also made few projects using it and espโ€ฆ

harsh kelp
#

I'd start by picking a project and searching online for examples of how other people did it. After you do a few basic projects you should have a good enough understanding to make something original

spark robin
#

hmmm. IC @harsh kelp.
I have made some projects beforeโ€ฆ
can you suggest what should I give more weightage, networking or the hardwareโ€ฆ?

harsh kelp
#

I'm not sure what u mean by weight age.. but I'd say it's better to start with hardware and learn how drivers and such work. That way when you move onto networking its just a matter of connecting and sending signals

#

It's hard to say tho it really depends on what you want to do

hallow igloo
bronze light
bronze light
gentle vapor
# bronze light Your solution sounds like the best case scenario - do you have any pointers for ...

What happens if multiple keys are being pressed/held ?
Assuming only one is pressed at a time, you can do it like that.

wasPressed = None
while True:
    digitPressed = kp.getKey()
    if digitPressed and digitPressed != wasPressed:
        print(f"This was pressed: {digitPressed}")
    wasPressed = digitPressed
    # wait a time low enough for the reaction time the user expects
    sleep(0.1)

You might also want keypad to give you a set of what is currently on and do set maths, though if only one can be pressed at a time, you can have kp.getKeys() be set(kp.getKey())

wasPressed = set()
while True:
    pressed = kp.getKeys()
    for key in wasPressed - pressed:
        print("this little key went to the market") # key released
    for key in pressed & wasPressed:
        print("this little key is staying home") # key held down
    for key in pressed - wasPressed:
        print("this little key had roast beef") # key just pressed
    wasPressed = pressed
    # wait a time low enough for the reaction time the user expects
    time.sleep(0.1)
bronze light
#

Appreciate the response mate, I managed to get it working in the end ๐Ÿ™‚

#

I used this

#
previousKey = keypad.getKey() # Initialise a variable to store the last saved value

while True:
        sleep(0.1)

        # Obtain the current pressed key
        digit = keypad.getKey()

        # If a key is actually being pressed
        if digit != None:
            # Check if the key is different to the previous one
            if digit != previousKey:
                # Print the number
                print(digit)

        # Set the previous value
        previousKey = digit
gentle vapor
#

๐Ÿ‘

neat olive
#

can you use python for motor controllers? how does it compare to other languages for controlling hardware?

west bloom
#

Guys I am just about to start using the python in microcontrollers, So which library do you prefer and also which microcontroller should I buy so I can run it and use it in my daily life.

hasty zealotBOT
#

Hey @hallow igloo!

It looks like you tried to attach file type(s) that we do not allow (.rtf). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.

Feel free to ask in #community-meta if you think this is a mistake.

thin grotto
#

wow!

pure sinew
#

Hm, I've been thinking a lot about those USB wall adaptors, I've been extremely sceptical to the รผber cheap ones because I don't want to burn said mcu and/or my apartment down.
There are some that can be bought in local stores, but they tend to go for prices ranging from 5โ‚ฌ to 25โ‚ฌ roughly so..
The thing is I would actually love to buy a small bunch (10-20) as long as the price would be around $5 or less

lime bear
#

Best language to code microcontrollers is c++

dawn jacinth
#

if anybody could come help me out with a question in #help-popcorn that would be amazing

balmy osprey
#

Hey guys, I'm trying to make a box as an object in micropython and display it on an OLED. All other functions are working fine, oled works, tested the lot.

when I press run, this code freezes up and the screen remains blank. Can someone point me to what im doing wrong?

# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
import wif
from machine import Pin, I2C

import sh1106

import time

class box:
    def __init__(self,x,y):
        self.posx=x
        self.posy=y
        while True:
            time.sleep(2000)
            display.fill_rect(self.posx,self.posy,10,10,1)
            display.show()

    def movebox(self,tx,ty):
        self.posx = tx
        self.posx = ty
                
        


# ESP32 Pin assignment 
#i2c = I2C(-1, scl=Pin(14), sda=Pin(27))
i2c = I2C(scl=Pin(14), sda=Pin(27), freq=400000)
display = sh1106.SH1106_I2C(128, 64, i2c,Pin(16), 0x3c)
display.sleep(False)
display.fill(0)

r=box(15,15)

wif.wifi_connect()



#

note: import wif is just my wifi initialization

sly acorn
sly acorn
pure sinew
#

@sly acorn no, I'm talking about the same sort of adaptor as the one depicted in @hallow igloo 's post

hallow igloo
#

@pure sinew I wouldn't worry about it, the 25$ ones are 99% surely made in china too, you're just paying a premium for sake of giving money away

#

I can't say I've ever had any problems with articles from aliexpress

#

ofc you can buy higher power rated ones on aliexpress too, i believe 20W ones will come at around 3$ or so

#

the one i sent is rated for only 5W but that should be more than enough for raspberry pi

mortal plover
balmy osprey
#

@mortal plover I was toying around until another user pointed me to the fact that my "sleep" time was in seconds and not microseconds, so my box would take, according to my code above, 33 minutes before drawing the box. I'd slept and woken up to a box on my oled!

#

I'm having fresh new issues now, like moving a box from a to b

hasty zealotBOT
#

Hey @balmy osprey!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

balmy osprey
#

This is my new code, could someone look at my box class and see if i've done something wrong? The box class has a movebox function which is supposed to move the box to a given coordinate on my oled screen.

class box:
    def __init__(self,x,y):
        self.posx=x
        self.posy=y
        self.update()
        
    def update(self):
        display.fill_rect(self.posx,self.posy,10,10,1)
        display.show()
        

    def movebox(self,tx,ty):
        x=self.posx
        y=self.posy
        pathflag = 0
        if (x>tx&y>ty):
            pathflag=1
        elif(x<tx&y<ty):
            pathflag = 2
        elif(x<tx&y>ty):
            pathflag = 3
        elif(x>tx&y<ty):
            pathflag = 4
        elif(x==tx&y==ty):
            pathflag = 0
        
        while (pathflag == 1):
                display.fill_rect(self.posx,self.posy,10,10,0)
                self.posx = self.posx-1
                self.posy = self.posy-1
                self.update()
                
                
        while (pathflag == 2):
                display.fill_rect(self.posx,self.posy,10,10,0)
                self.posx = self.posx+1
                self.posy = self.posy+1
                self.update()
                
                
                
        while (pathflag == 3):
                display.fill_rect(self.posx,self.posy,10,10,0)
                self.posx = self.posx+1
                self.posy = self.posy-1
                self.update()
                
                
        while (pathflag == 4):
                display.fill_rect(self.posx,self.posy,10,10,0)
                self.posx = self.posx-1
                self.posy = self.posy+1
                self.update()
                
                
        if (self.posx==tx&self.posy==ty):
            pathflag=0
            display.fill_rect(self.posx,self.posy,10,10,1)
            display.show()
            ```
lime bear
mortal plover
balmy osprey
#

@mortal plover Thanks for checking it out! The final code was way simpler:

class box:
    def __init__(self,x,y):
        self.posx=x
        self.posy=y
        self.update()
        self.pathflag = 0
        
    def update(self):
        display.fill_rect(self.posx,self.posy,10,10,1)
        display.show()
        
    def movebox(self,endx,endy):
        
                 
        startx = self.posx
        starty = self.posy
                
        for i in range(1,21):     
        
            display.fill_rect(self.posx,self.posy,10,10,0)
            self.posx = int(startx + (endx - startx) * i/20)
            self.posy = int(starty + (endy - starty) * i/20)
            self.update()     
balmy osprey
balmy osprey
#

Hey guys, so I've added to my previous piece of code and have a wire attached to my esp32's touch sensor. Is there a way to use the two cores of the ESP32 and listen to touch events?

#

Or would that be overkill and can I add an event listener on the same core as an object?

#

I've been trying to port some of the code over from Keyboard and Keypad libraries

while True:  # making a loop
    try:  # used try so that if user pressed other than the given key error will not be shown
        if touch0.read():  # if touch is recorded
            print('You Pressed A Key!')
            break  # finishing the loop
    except:
        break

#

This was the init

from machine import Pin, I2C, TouchPad
touch0 = TouchPad(Pin(12))
touch0.config(500)
main ridge
#

anyone has block diagram for a frequency meter?

eager wasp
#

@scarlet owlxxin Maybe use an interrupt handler?

balmy osprey
#

@eager wasp Thanks! I'll take a look, looks promising

eager wasp
#

You're going to want to set a variable then exit quickly then let the main loop handle the input.

balmy osprey
#

@eager wasp Hey so I kinda got what you said, but my code isn't running properly, could you take a look?

button = Pin(10,Pin.IN)

button_press = False
global interrupt_pin
def handle_interrupt (pin):
    global button_press
    buttonpress = True
    global interrupt_pin
    interrupt_pin = pin
button.irq(trigger=Pin.IRQ_RISING, handler=handle_interrupt)
instance=[]
boxcount = 0
while True:
    if button_press:
        boxcount +=1
        instance.append(box(random.randint(1,128),random.randint(1,64),10,count))
eager wasp
#

You need to set button press to false after you read it.

#

while True:
if button_press:

balmy osprey
#

Oh i see

eager wasp
#

Also I'd just put like a sleep 10ms timer in your while True loop

balmy osprey
#

@eager wasp Could you check this if you have the time? https://pastebin.com/2r530uXZ It's my full code, I'm uploading what I learn to github https://github.com/theaxxxin/micropython-oled-boxes so that anyone in the future can make use of this

GitHub

Simple OOP to get started with micropython. Contribute to theaxxxin/micropython-oled-boxes development by creating an account on GitHub.

#

It's not working for some reason

#

(the pastebin code, not whats on github)

eager wasp
#

Put the sleep under the while True not in the if statement

#

buttonpress = True
\

#

typo

#

_

#

๐Ÿ™‚

balmy osprey
eager wasp
#

In the interrupt handler

balmy osprey
#
button = Pin(10,Pin.IN)

button_press = False
global interrupt_pin
def handle_interrupt (pin):
    global button_press
    button_press = True
    global interrupt_pin
    interrupt_pin = pin
button.irq(trigger=Pin.IRQ_RISING, handler=handle_interrupt)
instance=[]
boxcount = 0
while True:
    time.sleep(0.01)
    if button_press:
        boxcount +=1
        instance.append(box(random.randint(1,128),random.randint(1,64),10,str(count)))
        button_press = False
eager wasp
#

That looks reasonable.

balmy osprey
#

maybe it's a problem with my OOP

#

this is the edited code

eager wasp
#

I'm trying to remember if you have to reset the input pin after reading it.

balmy osprey
#

The code executes but nothing seems to happen when i press the button

#

further, in my pastebin, I've made a typo inside initializing my new box object on buttonpress, but the shell doesnt throw up any errors which leads me to believe that the button press code isn't being executed

#

however the system seems to be in a loop because the shell isn't receiving any input

#

says machine is busy

eager wasp
#

Yeah... That's the one problem with ISR's and for loops. They don't exiit.

#

At 10ms, if you count to 1500, that's 15 seconds?

#

Just change the while True loop into a for x in range(1500):

balmy osprey
#

hm okay

#

let me try

eager wasp
#

Then it should exit.

#

Give it 15 seconds then try again.

#

Also print() if you get in either if statement.

#

Also, are you sure it's rising? or falling?

balmy osprey
#

I used this kind of setup for the button

eager wasp
#

What is pin AO?

#

Oh.

balmy osprey
#

just for the button

#
boxcount = 0
for x in range(1500):
    time.sleep(0.01)
    if button_press:
        boxcount +=1
        print("buttonpress!")
        instance.append(box(random.randint(1,128),random.randint(1,64),10,str(boxcount)))
        button_press = False
eager wasp
#

Got it... I thought the pot was a button as well.

balmy osprey
balmy osprey
eager wasp
#

Does the pin actually match up in software?

balmy osprey
#

Yes, this is the board's pinout

eager wasp
#

That looks right to me.

balmy osprey
#

D34 --> Pin 10

eager wasp
#

Circuit looks right.

#

But is it pin 10 or something GPIO10?

balmy osprey
eager wasp
#

Pin 10 is GPIO25.

#

I would take a multimeter and find out where that pin goes.

#

According to that document it could also be GPIO34.

balmy osprey
#

okay, maybe I can try 34

#

brb

eager wasp
#

I think in Micropython pins represent the GPIO number.

#

It doesn't have a clue about how that board is layed out.

balmy osprey
#

Well, the screen wires up fine, had to set SDA and SCL pins

#

did that according to the diagram that i attached

eager wasp
#

I'm looking back over your code.

balmy osprey
#
from machine import Pin, I2C, TouchPad

import sh1106

import time
import random



# ESP32 Pin assignment for display (DONT IGNORE)
i2c = I2C(scl=Pin(14), sda=Pin(27), freq=400000)

# Display Init Sequence ---- 
display = sh1106.SH1106_I2C(128, 64, i2c,Pin(16), 0x3c)
display.sleep(False)
display.fill(0)
# ------
  

#Box Class

class box:
    def __init__(self,x,y,sz,name):
        self.posx=x
        self.posy=y
        self.size = sz
        self.name = name
        self.update()
       
        
    def update(self):
        display.fill_rect(self.posx,self.posy,self.size,self.size,1)
        display.text(self.name,self.posx+self.size+2,self.posy)
        display.show()
        
    def move(self,endx,endy):
        
                 
        startx = self.posx
        starty = self.posy
                
        for i in range(1,51):     
        
            display.fill_rect(self.posx,self.posy,self.size,self.size,0)
            display.text(self.name,self.posx+self.size+2,self.posy,0)
            self.posx = int(startx + (endx - startx) * i/50)
            self.posy = int(starty + (endy - starty) * i/50)
            self.update()     
a = box(10,10,10,"A")
button = Pin(34,Pin.IN)

button_press = False
global interrupt_pin
def handle_interrupt (pin):
    global button_press
    button_press = True
    global interrupt_pin
    interrupt_pin = pin
button.irq(trigger=Pin.IRQ_RISING, handler=handle_interrupt)
instance=[]

boxcount = 0
for x in range(1500):
    time.sleep(0.01)
    if button_press:
        boxcount +=1
        print("buttonpress!")
        instance.append(box(random.randint(1,128),random.randint(1,64),10,str(boxcount)))
        button_press = False
        

a = box(10,10,10,"A")
#

the whole thing

eager wasp
#

IO14 13 I/O
GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK,
SD_CLK, EMAC_TXD2

#

IO14 is SD_CLK

#

So your I2C scl is IO14 which is pin 13.

#

So I bet that's right.

#

Okay... I'm officially going back and forth between two data sheets now.

balmy osprey
#

Hold up, there are new boxes on my screen