#microcontrollers

1 messages · Page 2 of 1

uneven hull
#

hey, reasking here because someone said yall might know.

i am trying to write UART commands to read a value from some hardware

so ive set these commands the best i can. these are the commands, and i will post the info from the datasheet in which im using

to note, i can send the test command and get a response, so i assume the hardware is all good

    ser.write(b'S')
    x = bin(0x44 | 0x01)
    ser.write(x.encode())
    ser.write(b'10')
    ser.write(b'P')

and here is the info from the datasheet, which im trying to accomplish

"The host issues the read command by sending an S character followed by an I2C-bus

target device address, and the total number of bytes to be read from the addressed I2C-
bus target. The frame is then terminated with a P character. Once the host issues this
command, SC18IM704 will access the I2C-bus target device, get the correct number of
bytes from the addressed I2C-bus target, and then return the data to the host.
Note that the second byte sent is the I2C-bus device target address. The least significant
bit (R) of this byte must be set to 1 to indicate this is an I2C-bus write command."

more info can be given if needed, but at base i am trying to write these commands and they do not seem to work, when the test commands do. so it must be the code, but i cant put my finger on what im missing

steady sky
#

like on a computer not the pico?

gentle vapor
#

I don't know micropython's wifi well, but could you be running the webrepl from boot.py ?

gentle vapor
uneven hull
uneven hull
#

this is quite the rabbit hole. im trying to make sense of 3 datasheets, to determine how this data is being sent and how i can receive it. but im coming up empty.

how do i turn this into usable data? where do i even start?

the hardware is

arduino mega as microcontroller

SC19IM704 uart to i2c-bus bridge

SHT30 temp sensor

uneven hull
#

so with that data im getting, ive written this

    temperature = (response[0] << 8 | response[1]) * 175 / 65535.0 - 45
    humidity = (response[3] << 8 | response[4]) * 100 / 65535.0

which gives me -45 temp, and 100 hum. the values never change no matter what i do to the sensor

gentle vapor
#

so what I expect is that you would need to first send a write command to tell the sensor the address you want to read, followed by a read command that will read the result.
Trying to read the datasheets I would guess something like that:

def uart_write(payload):
    ser.write(b"S" + bytes([addr<<1, len(payload)]) + payload + b"P")
def uart_read(length):
    ser.write(b"S" + bytes([(addr<<1)|1, length]) + b"P")
    return ser.read(length)

# tell the sensor to measure the temperature, highe repeatability, clock stretching enabled (page 10 table 9 of Datasheet_SHT3x_DIS.pdf)
uart_write(b"\x2C\x06")
# sleep for at least 1ms (maybe unnecessary)
time.sleep(0.001)
# read 6 bytes: 2 data, 1 CRC for each
data = uart_read(6)
# unpack
temperature, crc1, humidity, crc2 = struct.unpack(">HBHB", data)
temperature = temperature * 175 / 65535.0 - 45
humidity = humidity * 100 / 65535.0
valid oyster
#

Anybody have an Idea of how to fullscreen render a camera feed created by OpenCV using the Raspberry Pi's built in GPU by using (I'm guessing) OpenGl packaged with OpenCV

gentle vapor
uneven hull
gentle vapor
#

ah no I meant the functions defined above

uneven hull
gentle vapor
#

yep

uneven hull
#

so i wrote this up and got the error at the end

import serial
import time
import struct
# UART configuration
ser = serial.Serial(
    port='/dev/serial0',
    baudrate=115200,
    #parity=serial.PARITY_NONE,
    #stopbits=serial.STOPBITS_ONE,
    #bytesize=serial.EIGHTBITS,
    timeout=1
)

def uart_write(payload):
    ser.write(b"S" + bytes([addr<<1, len(payload)]) + payload + b"P")
def uart_read(length):
    ser.write(b"S" + bytes([(addr<<1)|1, length]) + b"P")
    return ser.read(length)

# tell the sensor to measure the temperature, highe repeatability, clock stretching enabled (page 10 table 9 of Datasheet_SHT3x_DIS.pdf)
uart_write(b"\x2C\x06")
# sleep for at least 1ms (maybe unnecessary)
time.sleep(0.001)
# read 6 bytes: 2 data, 1 CRC for each
data = uart_read(6)
# unpack
temperature, crc1, humidity, crc2 = struct.unpack(">HBHB", data)
temperature = temperature * 175 / 65535.0 - 45
humidity = humidity * 100 / 65535.0
print("temp: "+temperature+" Hum:"+humidity)

Traceback (most recent call last):
File "SM18-2.py", line 27, in <module>
temperature, crc1, humidity, crc2 = struct.unpack(">HBHB", data)
struct.error: unpack requires a buffer of 6 bytes

#

i also changed addr to 0x44, just missed it in the copy/paste

gentle vapor
#

yeah it probably times out before it gets data, you can try printing data and looping until it returns something
[bad code removed]

#

or increase the timeout

#

oh wait no

#

it's in the read that it must wait

def uart_read(length):
    ser.write(b"S" + bytes([(addr<<1)|1, length]) + b"P")
    while True:
        data = ser.read(length)
        print(data)
        if data:
            return data
#

(that's for testing to see if you get a response, you might otherwise want a timeout on a loop like that)

#

you can also just make the read blocking, I think:

ser.timeout = None

and see if it ever receives something or not

uneven hull
#

two things from my tests

  1. it randomly returns /x00, which breaks the loop but gives no data

  2. it returns the data, but its that same data
    b'\x00\x00\x81\xff\xff\xff'
    temp: -45.0 Hum:100.0

and again, values do not change when i mess with the sensor

gentle vapor
#

hmmm

uneven hull
#

just tried it with different hardware and yielded the same result. is it possible this is a hardware issue?

either way, i unfortunately have to head off to the dentist. but i thank you greatly for helping, if theres anything u ever need please let me know

gentle vapor
#

I think there's something we are doing wrong, but I don't know, I don't have a SC18IM704 so it's hard to get how it really works

uneven hull
#

Thats fair, ill keep digging and try to find the answer. It seems like we're doing the right thing based on the datasheets tho

uneven hull
hot sand
#

hello I am pretty new to microcontrollers.
I want to start a project where I need to stream video wirelessly with a minimum of 30 fps.
does anyone have any advise for camera/controllers?

spiral sandal
valid oyster
hallow igloo
#

ice work guys

quiet sparrow
#

I need help on installing MineTest on my raspberry Pi, what I have done so far seems to not work

supple oxide
quiet sparrow
#

raspberry pi 4 and i have tried to download off the minetest website by copy pasting the code needed to download but i always get an error

supple oxide
quiet sparrow
#

this is what happens
nat@natsPi:~ $ sudo apt-get update && sudo apt-get install -y git build-essential libirrlicht-dev libgettextpo0 libfreetype6-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-openssl-dev libluajit-5.1-dev liblua5.1-0-dev && git clone --depth=1 https://github.com/minetest/minetest.git "$HOME/minetest" && cd "$HOME/minetest/games" && git clone --depth=1 https://github.com/minetest/minetest_game.git && cd .. && cmake . && make -j$(nproc) && sudo make install && minetest; echo -e "\n\n\e[1;33mYou can run Minetest again by typing "minetest" in a terminal or selecting it in an applications menu.\nYou can install mods in ~/.minetest/mods, too.\e[0m"
Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package libjpeg8-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libjpeg9-dev libjpeg62-turbo-dev

Package libpng12-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libpng12-dev' has no installation candidate
E: Package 'libjpeg8-dev' has no installation candidate

You can run Minetest again by typing "minetest" in a terminal or selecting it in an applications menu.
You can install mods in ~/.minetest/mods, too.

supple oxide
quiet sparrow
#

yes

#

i think

supple oxide
quiet sparrow
#

I just did some further reading and it says
NOTE: This script may not work immediately on Ubuntu 16.10 and 17.04. You may need to swap libpng and libjpeg for more recent versions, which have different package names. Consider the Minetest Flatpak as a simpler way to run latest Minetest versions, that doesn't require root rights as well.

quiet sparrow
#

if you need me to i can screen share

supple oxide
#

what happens if you type: apt show libjpeg8-dev libpng12-dev

quiet sparrow
#

this happens
nat@natsPi:~ $ apt show libjpeg8-dev libpng12-dev
Package: libjpeg8-dev
State: not a real package (virtual)
Package: libpng12-dev
State: not a real package (virtual)
N: Can't select candidate version from package libjpeg8-dev as it has no candidate
N: Can't select candidate version from package libpng12-dev as it has no candidate
N: Can't select versions from package 'libjpeg8-dev' as it is purely virtual
N: Can't select versions from package 'libpng12-dev' as it is purely virtual
N: No packages found

supple oxide
#

alr thats our issue, you don't have those in you package repo

quiet sparrow
#

ok

supple oxide
#

which version of rpi os is this

#

or is it even rpi-os? did you install ubuntu?

quiet sparrow
#

it is a raspberry pi os 32 bit not sure what version

supple oxide
#

nvm, its bullseye

#

replace libjpeg8-dev with libjpeg9-dev

quiet sparrow
#

which one of the 9s?

supple oxide
#

try running this: ```
sudo apt-get update && sudo apt-get install -y git build-essential libirrlicht-dev libgettextpo0 libfreetype6-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-openssl-dev libluajit-5.1-dev liblua5.1-0-dev && git clone --depth=1 https://github.com/minetest/minetest.git "$HOME/minetest" && cd "$HOME/minetest/games" && git clone --depth=1 https://github.com/minetest/minetest_game.git && cd .. && cmake . && make -j$(nproc) && sudo make install && minetest; echo -e "\n\n\e[1;33mYou can run Minetest again by typing "minetest" in a terminal or selecting it in an applications menu.\nYou can install mods in ~/.minetest/mods, too.\e[0m"

#

also, if you don't mind being on an old version (4.17), you could try sudo apt-get install minetest

hasty zealotBOT
#

Hey @quiet sparrow!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

quiet sparrow
#

Hit:1 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9).
git is already the newest version (1:2.30.2-1+deb11u1).
libfreetype6-dev is already the newest version (2.10.4+dfsg-1+deb11u1).
libpng-dev is already the newest version (1.6.37-3).
libpng-dev set to manually installed.
The following packages were automatically installed and are no longer required:
espeak-ng-data libespeak-ng1 libpcaudio0 libsonic0 raspinfo
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
autoconf automake autotools-dev bzip2-doc cmake-data libegl-dev libgl-dev
libgles-dev libglvnd-dev libglx-dev libirrlicht1.8 libjpeg62-turbo-dev
libjsoncpp24 libltdl-dev liblua5.1-0 libncurses-dev libopengl-dev libopengl0
libreadline-dev librhash0 libsigsegv2 libtool libtool-bin m4
x11proto-xf86vidmode-dev
Suggested packages:
autoconf-archive gnu-standards autoconf-doc gettext cmake-doc ninja-build
libcurl4-doc libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev
libssl-dev libirrlicht-doc libtool-doc ncurses-doc readline-doc sqlite3-doc
gfortran | fortran95-compiler gcj-jdk m4-doc

#

happens when typed the long code

supple oxide
#

looks good but what happened after?

quiet sparrow
#

there is more now

#

there was another error

  • Configuring incomplete, errors occurred!
    See also "/home/nat/minetest/CMakeFiles/CMakeOutput.log".
    CMake Error at CMakeLists.txt:108 (message):
    IrrlichtMt is required to build the client, but it was not found.
supple oxide
#

it looks like the script you used was much too old

quiet sparrow
#

ok

supple oxide
#

i found this script: ```
( echo ZZZZ Updating Apt-Get Repository List ; sudo apt-get update ; echo ZZZZ Installing Dependencies ; sudo apt -y install g++ make libc6-dev libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev ; echo ZZZZ Cloning Minetest Source ; git clone --depth 1 https://github.com/minetest/minetest.git ; echo ZZZZ Cloning Source of Minetests Fork of Irrlicht ; git clone https://github.com/minetest/irrlicht ; echo ZZZZ Entering Irrlicht Source dir ; cd irrlicht ; echo ZZZZ Generating Minetests Fork of Irrlicht Build Files ; cmake . -DBUILD_SHARED_LIBS=ON ; echo ZZZZ Compiling Minetests Fork of Irrlicht ; make -j$(nproc) ; echo ZZZZ Navigating to Parent Dir ; cd .. ; echo ZZZZ Navigating to Minetest Source Dir ; cd minetest ; echo ZZZZ Generating Minetest Build Files ; cmake . -DRUN_IN_PLACE=TRUE -DIRRLICHT_LIBRARY=../irrlicht/lib/Linux/libIrrlichtMt.so -DIRRLICHT_INCLUDE_DIR=../irrlicht/include/ ; echo ZZZZ Compiling Minetest ; make -j$(nproc) ; echo ZZZZ Cleaning up apt installs ; sudo apt clean ; echo ZZZZ Cleaning up apt-get installs ; sudo apt-get clean ; echo ZZZZ Launching Minetest ; /home/pi/minetest/bin/minetest ) > Minetest_install_output.txt

#

might work better

quiet sparrow
#

i got a warnnig bu the code is still running (i will try the old version after this try)
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

quiet sparrow
#

ended at directory not found

supple oxide
#

could you give the surrounding logs?

quiet sparrow
#

hold on the old version might work'

#

IT WORKED

#

thank you

supple oxide
#

if the old version works (as in does the job) for you

supple oxide
quiet sparrow
#

i works well

dreamy canyon
#

i have a doubt

random thicket
#

Hello every one I'm having trouble using a stepper motor with a raspberry pico, the motor spins just fine but if I double press the "spin button" it changes direction, I don't know why it is changing direction 😦

quiet sparrow
#

i might be able to help

#

@random thicket

random thicket
#

this is the test code
`import time
from machine import Pin

DIR = Pin(14, Pin.OUT)
STEP = Pin(15, Pin.OUT)

button = Pin(16, Pin.IN, Pin.PULL_UP)

def go_down():
DIR.value(1)
STEP.value(1)

time.sleep(0.001)

time.sleep_ms(1)
STEP.value(0)
pass

while True:
if not button.value():
go_down()
#print("PRESSED")`

quiet sparrow
#

What's happening is when you press it twice it doubles all of the values

#

@random thicket

random thicket
#

I'm not sure what you mean by that pithink
@quiet sparrow

quiet sparrow
#

here

def go_down():
DIR.value(1)
STEP.value(1)

time.sleep(0.001)

time.sleep_ms(1)
STEP.value(0)
pass
#

when you press the button twice

#

this runs twice

#

so it would double the values causing it to do the opposite

#

is the DIR direction?

#

@random thicket

#

because if it is, 1 equalls clockwise and so 2 should mean counter clock wise? right?

random thicket
#

that is correct 0 is counter clock wise and 1 is clockwise and 2 is ccw

#

I'm wrong values over 1 defaults to 1

quiet sparrow
#

change the dir value to 0 and run it then press the button twice'

random thicket
#

and if I check the value of DIR it does not change but the motor direction does

random thicket
quiet sparrow
#

did it start the other direction or was it exactly the same?

#

also for some context for me is this motor being used for an up/down motion?

random thicket
#

it seems a bit random even without the button, just running the go_down()

quiet sparrow
#

i think the motor will change direction any time it notices a change in value even if it stays the same

#

and just so you know i think you can start a help forum

random thicket
#

what if I take the DIR out of the code?

quiet sparrow
#

try that

random thicket
quiet sparrow
#

if for some reason it still changes with the DIR code removed' then i would think there is a problem with the motor not your code

random thicket
#

it does still change direction I guess I have to try with other components

#

Thank you for the help @quiet sparrow joe_salute

quiet sparrow
#

np

#

i hope you fix it

rain forge
#

hey there,
Is there someone with knowedge of dali commands? I can turn a light on and off, with help of logic analyzer, but I can dimm it. It would nice if I can figure out what the commands mean.
These are the on and off commands:
[1001010101010101100101010101010101]
[1001010101010101011001010101010101]

eternal carbon
#

Im trying to make the LED flash for x amount of times (rannum) but instead the LED is staying on for 0.1 per integer (rather than flashing for each). Where have I gone wrong? Using a pi pico W btw.

#

wait just realised what I did

#

I read it through, I never told it to delay turning the LED off so it just looked like it stayed on.

#

Oops.

final zodiac
#

hello anyone know pyfirmata for arduino ?

past fossil
#

Lately, I've been working on projects with the M5Stack Fire and Core 2 devices.

elder coyote
#

I'm new to development on an esp32, and i would like to use pycharm (and micro python)

When i try to follow basically any tutorial i end up with the same message during flashing.

Connecting to /dev/cu.usbserial-13210
Uploading files: 0% (0/1)
/Users/pythonical/Documents/repos/work/OCM/esp_mp/main.py -> main.py

I have the micro python plugin installed and my code is litterally just
print('hello world')

my physical setup is an m1 mac connected to an esp32-s3-DevKitC-1 over usb directly into the port that says uart. and if i go to the micro python tab i see .

I (71911) example: log -> UART
example: print -> stdout
example: print -> stderr

Any idea why the code does not flash? any tips on troubleshooting would be much appreciated

broken forge
#

Hi y'all, quick question:
Does anyone know if the arduino 16*2 lcd fits straight on top of an uno r3? or do I need a breadboard

kindred fern
#

If I want to transfer files to a Pi, do I have to burn it onto the sd card from a DIFFERENT pc, then plug it into the Pi, or can I add it via flashdrive

strange prairie
#

you need breadboard to do it

#

or use lcd adapters

torpid flare
#

a question regarding micropython, multicore (1 thread per core) on raspberry pico... obviously locks are required for shared collections, but how atomic are assignments?

#

that is, assignments to simple objects (numbers, booleans)

spiral sandal
torpid flare
#

you have no choice but to use thread to start on the second core

spiral sandal
#

sure but no one is forcing you to mess with values used by the other thread, hence the GIL to prevent that temptation

torpid flare
#

at some point your threads needs to communicate

#

GIL?

spiral sandal
torpid flare
#

from what I read there is no GIL on micropython/pico

spiral sandal
#

well even if there are failsafes, you should act like there aren't to avoid ruining your work

#

threads problems are extremely hard to fix and unpredictable

torpid flare
#

it's not exactly a new technology... you just have to be careful and ensure you don't do silly things 🙂

spiral sandal
#

famous last words 🙂

torpid flare
#

yeah when it comes to python, it may be an overstatement... 🙂

plucky light
#

Hello everyone !
I am not certain this is the right chan for my question so feel free to redirect me.
I want to connect a waveform generator (Agilent 33220A 20 MHz Function / Arbitrary Waveform Generator) to a computer with a USB cable, and use it in a code that I use to interface many experimental devices, and made with visual studio code (python langage). The code is already made and I am not the one who coded it, but it worked fine before. Then the devices were unplugged and replugged in a different configuration and now when I run the code, it shows the same visual interface as before, but the fonctionality I want to use does not respond and I think it is related to this specific waveform generator.

When I plug the waveform generator with the usb, the device manager tells me that I need to install the appropriate drivers. The probleme did not arise before the machine was unplugged so I tried to change the cable, change the USB port on which it was plugged on the computer, but it was the same.
So I looked up online for the users guide, they mention drivers on a CD-ROM which I have not and was probably lost. I then looked for drivers online and had a hard time finding a driver appropriate for python or visual studio code, as they often refer to labview or matlab. I found this driver and installed it :
https://www.keysight.com/us/en/lib/software-detail/driver/33210a-33220a-function--arbitrary-waveform-generator-ivi-and-matlab-instrument-drivers-1639528.html
But I had the same error.
**So my questions are : can I find a python appropriate driver ? Will it be relevant to the problem since the problem is at computer level and not code level ? Can the code work fine without the driver (and in this case do I need to look elsewhere to debug my code) ? **
Thanks 🙂

spiral sandal
#

ask vendor support for another windows driver cdrom ? You'll hardly find anything on a python on microcontroller related channel. Your problem is really at a OS level unless you use "libusb" from python

torpid flare
#

you probably still need a low level USB driver, but this seems to solve the python aspect

#

but I don't think this is the proper channel, as you'll use python on a computer and this channel is more specific to python running on microcontrollers

plucky light
#

Yeah you're right I misunderstood the channel's name, do you know where I should post it ?

torpid flare
#

no idea, I'm new around here... but if your problem is about locating a usb driver, I don't think it even has to do with python 🙂 you'll have more luck in a place where people have similar hardware

#

but maybe most agilent/GPIB devices are using the same low level drivers? check what you can download from agilent

gritty iron
#

hey all, is there a version of autopygui for micropython

steep dune
#

why bother using a GUI on a micro C

gritty iron
#

not on the micro c, to emulate a HID device

spiral sandal
tacit onyx
#

can u connect ev3 wit python without sd card?

#

maybe just via the pc cable or usb or bluetooth?

spiral sandal
quiet sparrow
#

i cant do anything with my termanal

#

i always get theses for errors
E: Conflicting values set for option Signed-By regarding source https://repo.steampowered.com/steam/ stable: /usr/share/keyrings/steam.gpg !=
E: The list of sources could not be read.
E: Conflicting values set for option Signed-By regarding source https://repo.steampowered.com/steam/ stable: /usr/share/keyrings/steam.gpg !=
E: The list of sources could not be read

#

i looked at the directory and it does not exsist

#

someone help

smoky dragon
#

Can I use my esp8266 cp2102 nodemcu v3 if smoke came out of it it still turns on. But I need to hold the reset button then it only turns on when I release the reset button it just turns off is there a fix?

errant wigeon
#

I would probably refrain from using it in that state just in case the part that burnt out is something that could harm the pc in its absence. Do you know which specific component blew up?

young swift
#

Ah k

valid oyster
remote oar
#

Not sure if this is the right spot but is there anyone here with experience using pcom for PLC communication?

young swift
#

You have the camera module right

karmic palm
#

Hello everyone, I am a 3rd year student of Applied Electronics and I would like to learn programming on microcontrollers, that is, the embedded part. Can you suggest some starter project ideas and some apps I can test? So Proteus and AVR studio would be good? I want you to work on this part with bits. Thank you and I look forward to any reply in private or here.

errant wigeon
karmic palm
errant wigeon
karmic palm
#

Thank you very much for sending your time to answer me. I try to search and learn in your links. I want to make project for bachelor degree. This project is an ambient sensor for 2 3 rooms, for example and all information are stored in main server. This serve is in Raspberry pi and the information is ttransmitted with ESP32.

tranquil robin
#

Jo, I want to install the driver for my pyboard but windows says something like "It's already has the best driver"

#

How can I force the install?

little cedar
errant wigeon
# little cedar i am looking for help in ESP32 CAM modules. does any project have that? like usi...

https://circuitpython.org/board/adafruit_esp32s2_camera/
Is it this camera?
To my knowledge it's support is still in development with respect to circuit python, so I'm not sure how capable it is in circuit python. That said I'm sure it's supported in c. Additionally, this project sounds overall fairly similar to that: https://learn.adafruit.com/cloud-cam-connected-raspberry-pi-security-camera
so it might be of some help

#

It's not a perfect analog but hopefully it's similar enough you can use it to help break down the problem

hallow igloo
#

hey anyone know what does this error mean?

#

trying to print a text on my SSD1306 display , using a pico

#

the oled shows just white dots

#

i have wired it up like that

little cedar
main bane
#

greetings all. i just installed thonny on windows 10. trying to do some python dev with my pi pico. it doesn't seem that i can install any libraries. they all end with an error similar to this: https://pastebin.mozilla.org/dSUAQWnM

balmy ravine
#

Looks scuffed but I am very happy with it

#

It is an arcade like games where you have to stop the light on the red one in the middle

#

I progressively gets harder as you win more

pliant epoch
#

Hi, I’m new to EE so I’m trying to make a project to get the hang of it. I’m trying to build a little machine where you basically talk to it and it replies back to you through text on an LCD. I have an Arduino and was wondering which speech recognition hardware is good for this. Lmk, thanks!

pliant epoch
slender ingot
#

Does someone wanna take a look a question at #unix ? Relates to buildroot and asus tinkerboard

steel forge
#

is anyone familiar with circuit python for raspberry pi pico w?

#

im using circuit python and by the documentation i should have the wifi module

#

as a core module

#

but when i try and import it

#

it logs this ```boot.py output:
Traceback (most recent call last):
File "boot.py", line 4, in <module>
File "wserver.py", line 2, in <module>
ImportError: no module named 'wifi'

radiant depot
#

Finally figured out how to make a voice app launcher for my diy wearable piglassv2 using whisper and gpt to go along with the graphical launcher

its a good thing im using gpt as error checking for whisper, this is the prompt


Maker Faire Cam```

Once I have the string from gpt I can get the index of it in my list and then use my existing run app selection function from the graphical launcher
radiant depot
hallow igloo
#

how do i protect a board from emp while shipping

errant wigeon
hallow igloo
#

already searched for that locally cant find it in my small town, any household alternatives?

#

ive read about tinfoil

errant wigeon
#

I do not know. That's outside my experience unfortunately

hallow igloo
#

thats fine, thanks for helping :)

errant wigeon
hallow igloo
#

so do i just wrap it, no precautions to take before?

#

my thinking process is that if there is still electricity board could it travel through the tinfoil and short something

errant wigeon
#

I'd make sure your ground plane is touching the foil for sure, but yeah kind of, it looks like it. It won't be a perfect solution, so be prepared for it to fail. That said it should work.
Oh yeah the board should have no power connected to it, and the caps shouldn't have charge otherwise you'll risk shorts because of the foil. If your board is powered/has a battery/can't be discharged, I'd say it might be prudent to ignore the foil wrap.

hallow igloo
#

it wont be powered and its an arduino uno r3 board

#

so just make sure that it touches GND pin?

hallow igloo
errant wigeon
#

Oh those have pretty good design and aren't overly sensitive, you could just throw it in a cardboard box and probably be fine

#

anti static bags are better, but those are some good boards

hallow igloo
#

awesome. one more question, im shipping like a kit -- there are capacitors LEDs and what not. do i need to individually wrap them as well?

#

included in there is also an LCD, i presume that its best to wrap it as well yeah?

errant wigeon
#

LCD definitely wrap, those can crack and break.
From a user experience point of view, caps and LEDs in their own bag is nice because its very easy to check and make sure no component is lost

hallow igloo
#

oh yeah i separated them in their own respective bags

#

thank you for helping :)

errant wigeon
#

No problem! Hope it ships well! It should be fine but there's always a risk with that sort of thing

wet pecan
#

I'm trying to use an Arduino mega to control a hexapod. I have already solved the inverse kinematics for one limb. I don't see how it will help in moving the robot. Is there any reference that i could use??

gaunt whale
#

does anyone know any mysql docker images that work on raspbian stretch 32 bit?

humble kraken
#

mariadb is FOSS version of oracle mysql

gaunt whale
#

aha, nice

tranquil grotto
#

Anyone knowing robotics willing to teach me

#

dm me pls

patent river
#

Hello there, I've started work on my project for bachelor's degree, still in planning phase but i want to confirm if my idea is feasible and practical before i confirm it

The project is simple we plan to use and esp32 board with bunch of sensors to monitor various parameters such as temp, humidity, pressure etc along with an RF ID reader, send email when reading go above a threshold, we also want to use micropython instead of arduino or C

We plan to send this data to some database, so it goes to a mosquito server on my pc then using node red it goes to influx db and blynk iot service

At influx db we plan to use grafana to create a dashboard and visualize it, the only reason for blynk iot is their mobile app

Is this feasible? Can micropython accomplish all of it? Is there a better way? Thanks!

gentle vapor
#

you better lookup existing library support before you choose your sensors, but there should be a large choice

somber pagoda
#

hi

#

does anyone here know how to fix rpi vnc connection?

fast pewter
#

IOT based weather monitoring system

#

Let's catch up on discord while working on it

patent river
patent river
balmy ravine
#

!code

hasty zealotBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

balmy ravine
#
import machine
import utime

led128 = machine.Pin(8, machine.Pin.OUT)
led64 = machine.Pin(9, machine.Pin.OUT)
led32 = machine.Pin(10, machine.Pin.OUT)
led16 = machine.Pin(11, machine.Pin.OUT)
led8 = machine.Pin(12, machine.Pin.OUT)
led4 = machine.Pin(13, machine.Pin.OUT)
led2 = machine.Pin(14, machine.Pin.OUT)
led1 = machine.Pin(15, machine.Pin.OUT)

number = 0

for i in range(255):
    
    number = i
    
    if number >= 128:
        number = number - 128
        led128.toggle()

    if number >= 64:
        number = number - 64
        led64.toggle()
        
    if number >= 32:
        number = number - 32
        led32.toggle()
        
    if number >= 16:
        number = number - 16
        led16.toggle()

    if number >= 8:
        number = number - 8
        led8.toggle()

    if number >= 4:
        number = number - 4
        led4.toggle()
        
    if number >= 2:
        number = number - 2
        led2.toggle()
        
    if number >= 1:
        number = number - 1
        led1.toggle()       
        
    utime.sleep_ms(500)
    
    if led1.value() == 1:
        led1.toggle()
        
    if led2.value() == 1:
        led2.toggle()
    
    if led4.value() == 1:
        led4.toggle()
    
    if led8.value() == 1:
        led8.toggle()
    
    if led16.value() == 1:
        led16.toggle()
    
    if led32.value() == 1:
        led32.toggle()
    
    if led64.value() == 1:
        led64.toggle()
    
    if led128.value() == 1:
        led128.toggle()
    
#

how could I optimise this??

gentle vapor
#

there might be an off-by-one error or not

wise needle
#

lmao people use python for embedded?

errant wigeon
#

Yup, it's really quite great for them if you need something to work right away or need to quickly get towards a final form of a build. In much the same way Python is heavily geared towards a rapid iteration cycle, Circuit Python and MicroPython make it easy to throw code on a microcontroller, deploy it, test it, and iterate on it.

steep dune
#

thats a very cool way of explaining that...

knotty pewter
#

It's RAD… }:)

peak flame
#

is there a sort of guide or roadmap to getting started with embedded systems development? not specifically python but any general direction would be a great help because i'm not sure what to purchase besides a breadboard and a few wires, i'm kinda liking this kit https://amzn.eu/d/7hCUm47, any opinions?

lofty cypress
# peak flame is there a sort of guide or roadmap to getting started with embedded systems dev...

If you are getting just started with arduino, the kit seems an overdo. I don't know what you want to specifically do but for like multiple inputs like a calculator, I would recommend an arduino uno mega(mega has more pins). If you plan to get a LCD I would recommend also getting a potentiometer to adjust the brightness of the LCD although you can also do it in the code itself but pair a resistor in the ckt so you don't blow the backlight of the LCD. You would also need male-to-male jumping wires to wire up the LCD with the arduino.

peak flame
#

and i'm not sure what i should buy besides a breadboard, led and arduino

lofty cypress
# peak flame and i'm not sure what i should buy besides a breadboard, led and arduino

Some arduino(s) like arduino uno, already come with a led, that lights up when a pin is read true iirc.

To summarizes my earlier message you would need:
For LCD:

  • Potentiometer or Resistor 1k Ohm
  • Male-to-Male jumping wires

Most of the arduino projects require an LCD if you are doing some hobbyist type project. Like an alarm clock or the chrome dinosaur game etc.

For most of these hobbyist projects you will need:

  • Push buttons
#

You can a buy 16x2 LCD but having a bigger display eases things alot.

peak flame
lofty cypress
lofty cypress
#
#

AHHH! I am currently on phone can't remove the embeds, sorry for the chat wall.

peak flame
#

god bless thanks fam

sharp idol
#

Can I ssh into a pi pico w?

gentle vapor
# sharp idol Can I ssh into a pi pico w?

nope, it's not running an operating system like that, but there are other options for controlling it by setting up a simple server that will interpret commands for example

past cloud
#

what knowledge/electrical stuff should i learn before diving into making gizmos and thingamabobs?

icy quarry
next basalt
#

Hey guys i have a relay what gives me some trouble i need help to write a program to switch it on and off i can figure out the rest but not working properly

trail vessel
#

anyone have ideas for what I should do with esp32's? I dont really want to get any more parts so

wet prism
cedar cave
#

hi

#

@fathom reef

#

i didnt really bought rn orange pi 4

#

but can u do tutorial in my dms? so i can check them in future and carefully follow them

past cloud
sharp idol
tidal bobcat
#

i h ave no clue what to do with my microcontroller its an arduino uno and i have a kit with a bread board an lcd and more components any suggestions?

lofty cypress
knotty pewter
#

My current project is to create a set of traffic lights (or rather railway signalling lights - so only a red and a green LED). Getting them turning on and off is a good starting point, and just a modification of the blink example program. I'm now working on adding some control via serial.

knotty pewter
#

On the back of that project "suggestion", I have my own question :D

If I have some serial handshaking between the Python script and the Arduino code (PC sends a character, Arduino responds), I seem to be able to get responses back from the Arduino. However, I can't seem to have the PC be a passive consumer of data (PC just reads the serial). Is this something I've forgotten about serial interfaces, or am I just missing something? It seems I need to send data in order to be able to receive data.

#

If I comment out 68-71 from the Arduino code and move the ser.write call outside the loop (for the initial handshaking), I don't appear to receive anything from the ser.readline() call.

knotty pewter
#

Hmmph. If I reduce it to just writing out on the serial every 1000ms, it seems to work :(

knotty pewter
#

Not entirely sure what the issue was; managed to get it working now. I do hate the debug route that gets the thing working, but doesn't elucidate what was previously wrong!

sick zodiac
#

hello, is there any way to make a real-time OCR program with libcamera instead of OpenCV? My raspberry's OS is Bullseye so I can't use openCV / Raspistill (legacy camera support disabled)

errant wigeon
whole locust
#

hi

#

I am making my own computer with esp32, and it has all the new features that a advanced linux machine has, I am using Tel-S CISW Operating System in the esp32 to control it, and that operating system is completely made by me, and I want some assistance regarding my software, as it is very complex and difficult featue that I am talking about. So, can someone help me in my personal window, (DM) becuase I can't leak the code for the software, and even I will not be able to upload it here becuz its 78000+ lines big code. The Problem: USB Host need for esp32, STA WiFi Mode Switiching problem, using a VGA Display with esp32 (USB Host Needed for Keyboard and Mouse Control) etc... I will provide the code and the main schematics for the computer in prsnl DM, also will provide all the equired libs.

#

Also, its in Arduino (C++) Language

wet prism
#

this sounds like a pretty impressive project, but i'm not sure somebody will have the time to read through 78000 lines of code

errant wigeon
whole locust
whole locust
errant wigeon
#

I mostly showed this to show his process so you could see what he used, why he used it, and what considerations he had to make for it. Since it's a linux kernel it won't be a perfect guide, but it might help walk you through a thought process on a similar design. Additionally he has a wealth of resources he links to in the writeup. In the absence of me being able to help in this project, I feel this might be a really helpful writeup that tackles problems similar to yours, albeit in a different fashion

whole locust
#

okie

#

btw, is there sm1 who knows a little abt arduino?

knotty pewter
#

You might just ask the question, then people would know how much "a little bit" means, and maybe just be able to answer :D

gentle vapor
#

only the ESP32-C3 and C6 (and upcoming ones) use RISC-V though, the other ESP32 are Xtensa.
for USB, only the S2 and S3 have a USB peripheral and there seems to be a low level USB host library by espressif

autumn pier
#

how can i program the esp8266 clock ?

sullen rune
#

Not mycrocontrollers !!!

#

MicroProcessors !!!

autumn pier
#

oh, Where I have to go

errant wigeon
errant wigeon
abstract imp
#

idk if this is the right channel or server to ask this, but is there anyone who could help me with verilog?

knotty pewter
#

It's been a long time since I looked at any, and I probably can't remember half of what I did know (which wasn't very much)…but it can't hurt to post and see :)

autumn pier
#

i want to run a python program in this watch : Clock Deauther ESP-12F

autumn pier
#

not cracking or scripting code

errant wigeon
#

Ah that looks like a project, not just an esp thing. For help with that I'd suggest you go to the project page and ask the developer there

errant wigeon
# abstract imp idk if this is the right channel or server to ask this, but is there anyone who ...

You might have better luck in the 1bitsquared discord which can be found through here: https://1bitsquared.com/pages/community
They have an fpga page and you might be able to ask there. That said I'm not active in that community so I'm not 100% sure how questions are managed, so be sure to read the community rules and guidelines ahead of posting.
And @knotty pewter is right, doesn't hurt to ask here too. No way of knowing otherwise

dusty harness
#

When it comes to powering a breadboard with 12V, can I just take a dc 12v adapter, cut the ends and plug it in?

sonic rock
#

hey

sharp arch
#

hello are there any teachers in this channel to teach me basics of micro python

sharp arch
#

i have to learn this core

#

within 2 weeks

steep dune
#

screen in the middle nice

valid sail
#

Anyone knows a good library for embedded systems?

sonic rock
#

pi pico ?

stark egret
#

Anyone familiar with arduino programming knows what does this lines say 👇 :

D425
D524
D623
D722

BSS to ground
RW to ground
RS to 12  
E to 11
first logic toggle to sixth AND first XOR input
second logic toggle to first AND second XOR input
third logic toggle to second AND third XOR input

fourth logic toggle to third XOR input
output the first,second, and third XOR TO seven,eight, and nine 

is this even a syntax ?

knotty pewter
#

That's just a set of wiring instructions, it looks. Not entirely sure what the first few lines are.

#

And the use of "AND" to mean "and", rather than the logic gate "AND" is a tad confusing.

hallow igloo
#
import utime
from machine import I2C, Pin
from ssd1306 import SSD1306_I2C
i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000)
oled = SSD1306_I2C(128, 32, i2c)
text = "abcdefghijklmnopqrstuvwxyz"
oled.fill(0)
oled.text(text, 0, 0)
oled.show()
while True:
    for i in range(len(text)*6):
        oled.scroll(-1, 0)
        oled.show()
        utime.sleep(0.05)

this only shows till 'p' on the display , anyone help please

sharp idol
#

Why does my code only run when plugged into a pc? Trying to automate lights using a pi pico w. Does it need the pc to connect to wifi?

gentle vapor
#

no, depends what you are running and what it's doing

knotty pewter
sharp idol
knotty pewter
#

I guess the thing to do would be to write something that shows the code's running on the Pi (it probably is - it's a Pi, so that's the usual mode of operation). Make it blink the on-board LED every second, say.

#

If that works, move it so the LED blinks when you run a given function…walk through the program debugging it by making the LED blink (it's the embedded equivalent of using print to debug a desktop script)

sharp idol
#

I am printing out the time, i guess i Can switch that to a led blink. I could also get an LCD and display the time on there. Start with each second and drop down to each minute once I confirm it’s doing what it needs to. Would also allow me to have some display to change the time for daylight savings if we’re still doing that in the US.

knotty pewter
#

The advantage of the on-board LED is precisely that it is onboard. You just need to toggle the appropriate line to get it to blink. Once you've demonstrated that it's working, you can then use other things to test. You can (probably!) set up ssh to run on the Pi, so you'd have a console you could output debug to without having it wired to the PC.

sharp idol
#

I get paid this week. I think I’ll get an lcd since I would like to have some interface for the garden to display temp and water levels anyway. I can print to that lol.

knotty pewter
#

You can…when you know it's working!

shrewd iron
#

trying to measure RPM on my raspberry pi which has a "hall sensor". I noticed that when I was trying to do floating calcs, the RPM reading can be extremely off. Should I try multithreading to help separate reads from outputs?

sonic rock
#

do you guys use pico

hasty zealotBOT
#

:incoming_envelope: :ok_hand: applied timeout to @cerulean galleon until <t:1680777021:f> (10 minutes) (reason: duplicates rule: sent 4 duplicated messages in 10s).

The <@&831776746206265384> have been alerted for review.

worthy shell
#

does anyone have solution for mediapipe not working on raspberry pi 4? I saw similar questions on raspb forums but no one is giving any answers...I tried most tutorials and scripts out there but nothing seems to work

#

anyone that could help?

severe bramble
#

I don't know much about it but I can advise you to turn to 1 thing I heard about : "pyserial" (communication python -> MCU PIC)
and a project that I could find : http://projectproto.blogspot.com/2009/12/python-for-pic-mcus.html (attention it's a link which is not protected)

hallow igloo
#

What is microcontroller?

glass tundra
#

Whats the difference between arduino uno and arduino zero and esp32 and m5stack

knotty pewter
#

A microcontroller is generally a smaller processor that's dedicated to some specific task. As opposed to a general purpose processor for which you have a OS installed before doing any tasks. (There's definitely a big grey area, though - Are Pis microcontrollers or not? :D )

knotty pewter
valid sail
#

A good library for programming them?

knotty pewter
#

Arduinos? You can just programme them in C with nothing more than the compiler you can get from their site.

valid sail
#

For C++ is there any microcontroller for creating embedded systems?

knotty pewter
#

I'm sure there's a C++ compiler out there. I can't recall if the basic Arduino one is just C or also supports C++

#

Apparently (and I should have known this, having worked for the company that builds the chips) you can use C++; I've only ever used C.

#

Yep, the IDE happily compiles class...

errant wigeon
#

I think it's kind of termed "arduino c or arduino c++" since it's a weird subset of the c++ language with its own quirks

knotty pewter
#

I think I saw something along those lines as I was skimming the docs just now looking for the answer

#

I wonder if it will handle a template ;)

errant wigeon
#

yeah, as a result I never know what to call it because it's just weird lol

#

shudders umm yeah, template I definitely don't avoid those at all costs

knotty pewter
#

Yeah, it allows templates... Let's see if it'll do packs }:)

#

Oh, seems to...

#

Up to C++11 (at least)

knotty pewter
#

I only know it as another microcontroller, no details. I've seen it used in home automation and other IoT-y projects

#

The first hit on googling suggests that the main advantage is the ESP has on-board wifi, while it's an addon for Arduinos (even for the Zero…apparently)

glass tundra
#

Ty

knotty pewter
#

The other thing I guessed at - the Arduino infrastructure is a bit more mature.

glass tundra
#

Why does arduino have holes for pins but other microcontrollers have actual metal pins?

knotty pewter
#

There are bare boards, and there are boards that come with the pin adaptors attached.

#

Like this ^?

#

I still need to solder the pins on :)

glass tundra
#

Yeah

#

Like you thread it through and there are pins

glass tundra
knotty pewter
#

Some come pre-soldered.

glass tundra
#

Oh

#

Elegoo uno is the exact same as arduino uno right

knotty pewter
#

It may be an "Arduino compatible" board. But, yes, Arduino is an open-source specification, so there are lots of "compatible" boards that are not made by Arduino themselves.

glass tundra
#

got it

glass tundra
#

Whats the difference between 3.3v and 5v operating voltage?

#

is 3.3 harder and riskier to work with or something?

errant wigeon
#

That's the voltage the pins operate at. So if you put a 3.3v logic chip with a 5v logic item, it'll have a hard time working because 3.3v isn't enough. And if you instead put 5v into the chip that's 3.3v, you run the risk of frying it because you've put too much power into it when it's only rated for about 3.3v

glass tundra
#

Whats a logic item?

errant wigeon
#

Sensor, motor, LED+resistor

glass tundra
#

And which voltage should I use?

errant wigeon
#

I couldn't think of a better name

#

Up to you. A lot of products are moving towards 3.3v logic. The primary reason for this is that they use less power

glass tundra
#

I think I have a bunch of components from a UNO kit already, that means they all use 5v right

errant wigeon
#

Yup, and in that case, I'd stick with 5v

#

I have a good number of 5v logic products as well, you can do a lot with it

glass tundra
#

I guess that means I have to stick with arduino right

#

Esp32 seems to be 3.3 volt

errant wigeon
#

Eh yeah and nah, you're not buying into a single ecosystem, you can play around and then later of find a project you want to build out and buy parts for that

#

It's really not that big of a deal

#

there are even logic boosters that will take 3.3v and bump it to 5v (as long as you provide it with a 5v source). You just need to not plug 5v into 3.3 v inputs without some form of protection.

#

So I really wouldn't worry about it

glass tundra
#

Hm

#

Maybe ill get one of both

#

An arduino nano and some esp32 board

errant wigeon
#

Nice. Though after a point I'd suggest you just jump in. There's only so much you can plan for and planning doesn't capture the fun of building. Adafruit has some great guides to help you choose a project you're interested in: https://learn.adafruit.com/

glass tundra
#

What would be a good esp32 board to start with?

errant wigeon
#

I love the ESP32-S2 personally. Most of my projects the last two years have used that chip

#

This is a collection of boards which use that chip and can run circuit python.
That said you might not care about running circuit python

#

I think most if not all can use C or C++

glass tundra
#

Will I need to solder exposed pins on?

errant wigeon
#

Yes, but I think if you buy through adafruit there's usually an option to buy one with the pins presoldered

#

but it's not an option for all the boards, so it might vary

glass tundra
#

Kay

#

Thanks!

errant wigeon
glass tundra
#

The headers are included right

errant wigeon
#

I think I've gotten male headers with every board I've directly purchased from adafruit, and I think there's a blurb somewhere that states it, but I cannot find it at the moment

wooden cloak
#

What’s the best kit/tutorialsto get started with microcontrollers?

sonic rock
#

hey

final zodiac
#

@frozen oyster (sorry for the ping )

#

even after restarting vsc, pyfirmata is not recognized

frozen oyster
final zodiac
buoyant hornet
glass tundra
#

Is espressif esp32 and esp32 pico different things? Or is esp32 pico a subset of espressif esp32

errant wigeon
# buoyant hornet How do I connect this Display: https://joy-it.net/de/products/RB-TFT1.8 to a Ras...

https://joy-it.net/files/files/Produkte/RB-TFT1.8/RB-TFT1.8_Anleitung_2023-01-06.pdf
https://www.digikey.com/en/maker/projects/raspberry-pi-pico-rp2040-spi-example-with-micropython-and-cc/9706ea0cf3784ee98e35ff49188ee045
https://forums.raspberrypi.com/viewtopic.php?t=301247
The docs for the display show it has pins for spi that you can connect to. For the pico, you'll need to wire it and program it so it treats a selection of its pins as spi pins, which the digikey link shows and the raspberry pi forums link explains as well

gentle vapor
# glass tundra Is espressif esp32 and esp32 pico different things? Or is esp32 pico a subset of...

ESP32 is a chip, with some internal RAM and typically using external flash and optionally external PSRAM. There are many modules that use that chip with different options in external RAM and flash.
There are also variants of the chip where PSRAM and/or flash are inside the chip, which allows for smaller modules. The ESP32 pico is one (or a family) of those variants, and the name of modules using it like the "ESP32-pico-mini"

#

and then there are the ESP32-S2, S3, C3, C6, etc. which are different families of chips separate from the suffixless ESP32 which doesn't make everything more confusing

glass tundra
#

My esp32 s2 just arrived

#

Spent an hour researching how to print stuff on the screen

knotty pewter
#

Only an hour?

agile solstice
#

anyone use arduino here ?
I sucessfully made a LED controlling circuit using arduino; However, I don't want to use the entire arduino for this single project. I want to make it into a minimum single board IC . How can I do this ?

knotty pewter
#

What do you expect a single board integrated circuit to do?

hollow snow
gentle vapor
agile solstice
#

I'd hope to have a minimum IC to do this simple job

gentle vapor
#

something like a custom 328 board ? Maybe you should ask in places more related to Arduino, like their forum or discord. Adafruit has a "hardware design" channel (and more general channels), and many people with a lot of experience too

stone cloak
#

does someone know if its possible to communicate via radio with microbit and python?

rigid helm
#

if there is a will there is a way.

#

I'm sure you could figure it out but idk how easy that would be.

stone cloak
#

i think its a little bit hard

rigid helm
#

I looked it up and the micro bit should have a radio module that you can acess using python.

stone cloak
#

how?

rigid helm
#

To send data, you can use the "radio.send" function and to receive data, you can use the "radio.receive" function. Tho I think you would need to program both the transmitter and the receiver using Python code.

stone cloak
#

sorry, I forgot to say that I want to do this on Windows

rigid helm
#

so you want to make your computer transmit radio waves to your micro bit controller? or the other way around?

stone cloak
#

both

#

i already did it with Bluetooth LE, but it needs too much energy on the microbit

rigid helm
#

Oop. I was just abt to suggest bluetooth

stone cloak
#

xD

rigid helm
#

have you tried bluetooth ble?

stone cloak
#

yes

rigid helm
#

im stupid. you already said that. I fr didnt process the "le" you said 🤦‍♂️

stone cloak
#

no problem

rigid helm
#

yeah idk any alternatives tbh.

stone cloak
#

okay, thank you anyway

rigid helm
#

I googled some more and there might be a power saving mode on the micro bit. You could also lower the transmission intervals?

stone cloak
#

how would i do it?

rigid helm
#

i dont know! I'm getting this all off of google lol

stone cloak
#

okay

sullen crescent
#

Is a raspberry pi considered a micro controller?

knotty pewter
#

Yes and no. I'd say 'yes' because of its size and ability to talk directly to hardware devices. But I'd also say 'no' because it (generally) runs a full OS to do so. It's sort of in a grey area.

#

Somewhere above there was a discussion about what the definition of "microcontroller" is, iirc.

floral spruce
#

Hey, just wondering how I should mitigate noise produced by supplying servos with 5V.
I'm designing a PCB that'll cover the functions you can see in the rough diagram below, what I'm wondering is how much noise am I going to get by powering those servos via the 5V. Will the 3.3V lin reg stop this noise progressing into the rest of the PCB? Or is there some actions I should take to help reduce the noise. The buck will have some decoupling capacitors around it but past that I'm not too familiar with noise reduction methods, or if it's even necessary here

ancient merlin
#

Hardware designer/artist/ceo here who can't programme but is making automated machines for kitchens - anyone want to chat about working on the programming?

gaunt whale
#

what kind of analog feedback are you sending back btw?

floral spruce
#

Would placing those caps near the connectors on the PCB (that go to the servos) be sufficient as well? From what I've read it's not quite as effective, because then the noise still exists in the wires connecting to the servos, which basically just produces an antennae of sorts. Though I'm not sure if it'll be much of an issue, so long as I get that RFM95 chip as far away from those wires as I can, or if it'd even effect it

gaunt whale
#

that depends on how close the wires feeding each servo are to each other

floral spruce
gaunt whale
#

a good option, for example, is to put the caps at the connectors as you say, and then bundle up everything over a UTP cable to get noise cancellation

floral spruce
gaunt whale
#

if the wires run parallel to each other over long distances, they'll interfere

#

if the servo analog output is just a dc value, it can be worthwhile to also put a shunt cap on the analog feedback near the ic. the pwm signal will generate interference as well since they have high frequency components

floral spruce
#

alright cool, I'll keep that in mind, and I'll see what I can do about those cables, I can probably bundle them together and it split off to the two individual servos closer to where they're located

#

Or I can figure out some jank way to get those capacitors closer to the servos, but I'll worry about that if it ends up being an issue

gaunt whale
#

how many servos is it?

floral spruce
#

Just 2

gaunt whale
#

aha

floral spruce
#

Relatively low power as well

gaunt whale
#

then you can use an ethernet cable

#

the pairs are twisted in such a way to reduce interference

floral spruce
#

Also just on the note of shunt capacitors, can't say I'm familiar with them, know any sources that give a brief explanation?

gaunt whale
#

i don't think i have a good reference off the top of my head, but the term isn't very important here. i meant a capacitor between the analog feedback and ground with the purpose of providing a low impedance path to ground for high frequency signals. same as what you'd do between the 5v line and ground

floral spruce
#

oh gotcha, is it just another term for a decoupling capacitor? Or is this like a specific use of a decoupling capacitor or something?

gaunt whale
#

it depends on the application, i suppose. google likes suggesting capacitor banks for power factor correction if you look up shunt capacitors 😛 the configuration is the same, but they interpret it as changing the angle of the impedance

#

but in any case it'S more or less like "an alternative path through the circuit"

floral spruce
#

gotcha

#

Right, cheers for the help, time to speedrun this thing so I can get an order off as soon as possible 👀

wispy dagger
#

I need hep with simulating IDS on IoT devices, I already have the ANN model for anomaly detection

hallow igloo
#

hi all, new, wel kyna new in rasppery pi programing and theterin in electrkoniks in iceland

plush geode
#

Anyone have a link to a Discord channel for ESP32 programming?

placid torrent
#

hello guys, I'm not sure if this is the right place to ask this question but it is the closest topic I could find.
I have a pico W running a PID temp controller with a heater written in micropython. I would like to have a websocket server to retrieve the temperature real time, without interfering with the PID loop. I was able to build a server using Microdot but I can't find a way to have the PID loop independent from the request cycle. I'm not a python expert at all and I could not find much material online for such application, most of the things I found are basic examples or they keep the sensor readings inside the websocket loop. Any advice is very appreciated!

gentle vapor
placid torrent
hexed sage
#

@plush geodearduino discord has an esp32 channel

quartz pawn
#

Hi all! I'm working on a Rasp Pi project that uses a Waveshare EPD (E-Paper) display. I'm trying to take a photo from the Pi Camera to then convert to black&white and share on the e-Paper screen. The e-Paper display does work, shows an image I made on my pc. The camera does take a photo, I opened it on the Pi. I'm not sure what's causing the reference before assignment error and Google wasn't any help. Hope someone here can be! Thanks!

quartz pawn
knotty pewter
#

reference before assignment possibly suggests that there's a route through your code where you don't actually assign to that variable, and haven't given it any initial default value

astral cloak
#

Hi guys! I'm trying to get python to mesh with arduino and I have it working well so far. It can detect inputs and sent signals out too. I'm now trying to get it set up with a sensor that uses I2C protocol and I don't really know where to start with that. I'm using PyFirmata on an Arduino Nano.

hexed sage
#

@astral cloak so you don't have custom code running on the Arduino

astral cloak
#

No, I guess that would be necessary?

hexed sage
#

@astral cloak yes, unless pyfirmata has some sort of i2c sensor thing you can enable

astral cloak
#

Ok. Thanks!

hexed sage
#

@astral cloakif you use the pyfirmata library the arduino code it should work just fine ```arduino
import pyfirmata

Create a pyfirmata object.

firmata = pyfirmata.Arduino('/dev/ttyUSB0')

Set the I2C address of the sensor.

firmata.i2c.set_device_address(0x5A)

Write a value to the sensor.

firmata.i2c.write(0x01)

Read a value from the sensor.

value = firmata.i2c.read()

Print the value.

print(value)```

fossil bridge
fossil bridge
errant wigeon
sterile glade
#

anyone here got the nRF52840-Dongle? I want to make sure i am buying the right thing

errant wigeon
#

I don't know of that board, but what are you trying to figure out to make sure you're buying the right thing?

velvet marsh
#

I'm trying to make my Raspberry Pi 3B a time lapse camera, however it does not seem to want to write photos to my USB stick directly, which is necessary as I plan on making this fully automated & headless

plucky tapir
#

does anyone know a way to rotate a stepper motor continuously with a rasberry pi? is there a library i can download and use with this? thanks

errant wigeon
velvet marsh
#

The script also does have a provision for a date variable for the file name
So it has unique names to avoid overwriting the same file
If I leave out the date it has zero issues

#

copypaste from another server I've been working thru

errant wigeon
errant wigeon
velvet marsh
#

yes

errant wigeon
#

what is the error?

velvet marsh
#

it doesn't want to write the file

#

says something along the lines of "can't open file"

errant wigeon
#

could you get the full error, it's hard to say without that unfortunately

velvet marsh
#

alas it's packed up rn as we're doing the test fit today

#

but I can get it back this evening

errant wigeon
#

sounds good, when you have it back please post the error 🙂

velvet marsh
#

this is one piece of a larger project doing atmospheric data collection

#

I've got a DHT11 Thermometer/Hygrometer and BMP180 barometer both working perfectly

#

all running thru one python script that launches on boot

errant wigeon
#

Awesome, that sounds like a nifty project

velvet marsh
#

it's for my junior design course

#

it's part of a rover project

#

the pi is handling data collection inside a small deployable module, then there's an arduino uno running the main rover

#

which takes in signals from an HC-06 BT module over the native serial port and runs four motors thru an L293D chip as well as an electromagnet that acts as a "hitch" for connecting and disconnecting the module with the pi

#

the Pi was chosen for the task as I had one kicking around that I'd originally had as a retropie

errant wigeon
#

very nice, sounds like a fun project overall

velvet marsh
#

it's been frustrating, but rewarding

#

we lost almost two weeks of work trying to troubleshoot what ultimately ended up being a dead L293D

#

because my teammate who was working on the motors sent 18V up the 5V logic rail 💀

errant wigeon
#

Ah that's a right of passage kind of mistake. Gotta christen projects with a bit of that magic blue smoke

velvet marsh
#

oh for sure

#

I'm glad I read the datasheet

errant wigeon
#

They're amazingly helpful when you have a good one.
Anyways I've got to get back to work, good luck with the test fit! I'll check back in later to look at the error if someone else hasn't answered your question already. Cheers!

velvet marsh
#

I'll hopefully have a screencap for you this evening

plucky tapir
#

the step, direction and enable is connected to gpio pins

#

as well as 5v and ground, then stepper is powered by external 12v source

#

like that

errant wigeon
plucky tapir
#

a4988

#

but yea thats the website I used

#

it only shows how to test the stepper motor, not continuous motion

#

I'm trying to control my stepper motor via buttons (when I hold down one button it will continuously rotate until I let go, and other btuton for the same but in the other direction). I've seen this done on arduino but not rpi so i'm not sure

#

i'm assuming theres a way to do this with my current setup, I just haven't found out how yet

errant wigeon
#

Are you able to share the code you're currently using?

plucky tapir
#

uhh yes with pictures, let me power up my rpi rq

errant wigeon
#

Please avoid posting pictures of code if that's alright

plucky tapir
#

oh ok

#

uhh

#

not sure how to transfer the text from rpi to my computer

#

give me a few minutes

#
import RPi.GPIO as GPIO
from RpiMotorLib import RpiMotorLib
import time

GPIO.setmode(GPIO.BCM)

direction= 22 # Direction (DIR) GPIO Pin
step = 23 # Step GPIO Pin
EN_pin = 24 # enable pin (LOW to enable)
buttonPinR=26
buttonPinL=16

mymotortest = RpiMotorLib.A4988Nema(direction, step, (21,21,21), "A4988")

GPIO.setup(buttonPinL, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(buttonPinR, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(EN_pin,GPIO.OUT)

while True:
    buttonStateL = GPIO.input(buttonPinL)
    if buttonStateL == False:
        print('hi')
        GPIO.output(EN_pin,GPIO.LOW) # pull enable to low to enable motor
        mymotortest.motor_go(True, # True=Clockwise, False=Counter-Clockwise
            "Full" , # Step type (Full,Half,1/4,1/8,1/16,1/32)
            800, # number of steps
            .0005, # step delay [sec]
            False, # True = print verbose output 
            .05) # initial delay [sec]
                  
    buttonStateR = GPIO.input(buttonPinR)
    if buttonStateR == False:
        print('bye')
        GPIO.output(EN_pin,GPIO.LOW) # pull enable to low to enable motor
        mymotortest.motor_go(False, # True=Clockwise, False=Counter-Clockwise
            "Full" , # Step type (Full,Half,1/4,1/8,1/16,1/32)
            800, # number of steps
            .0005, # step delay [sec]
            False, # True = print verbose output
            .05) # initial delay [sec]
          ```
#

I know that my current code is only for moving the motor a certain amount at a time

if my code sucks its because im new to coding lmao

errant wigeon
#

No worries about the quality, I can read it
I probably wont be able to dig into this until tomorrow or sunday just because it'll require me to read a lot of documentation. But thank you for posting the code in a text block rather than an image, that'll make this easier to review. Additionally it's possible someone else is able to answer your issue before I can

plucky tapir
#

thank you! i'll keep looking to, but if you find something if you can ping me that would be awesome, thanks

knotty pewter
plucky tapir
#

like set my enable pin to high?

#

right now my enable pin is plugged into a ground pin

#

if i plug it anywhere else it doesnt work with another software im using for some reason...

knotty pewter
#

If you need to pull it low to enable the motor, you're going to need to pull it high to reset it. If you tell the Pi to pull it low, it's not going to change that until you tell it otherwise.

plucky tapir
#

wouldnt it complete its movement first before putting enable to high

#

or will it immediately just turn off

#

im not good at explaining

#

ill test it out and find out

knotty pewter
#

You might want some button debounce, but if you are only setting it high when neither button is pressed, it should turn off when you aren't pressing a button.

plucky tapir
#

ok 👍

plucky tapir
plucky tapir
#

ALRIGHT

#

I figured it out

#

used pwm signals

plucky tapir
hallow igloo
#

Based

thorny cobalt
#

that is a step motor?

smoky wharf
#

Any of yall understand raspberry pis?
if it doesn't have any internet usage for a long period of time (6-7 hours) I can no longer SSH to it. Power management is off, and I can fix it by cutting power to the pi and then restarting it. Is there a fix for this or do i just take this massive L? I also can't ping it at all.

knotty pewter
#

Probably something to do with the Linux network config, but I can't think off the top of my head what might cause that. If you can't ping it, that suggests it's disconnected from your wifi/network (and the inability to ssh is caused by that)

split hollow
#

Basic requirements for running python in pico

#

Raspberry pi pico

#

Or can I run discord also

smoky wharf
#

probably maybe might work

errant wigeon
smoky wharf
#

LED is solid red

#

5V per port

errant wigeon
smoky wharf
#

Yeah, we'll see

#

I'm suspect of the router kicking it off the network, as others have mentioned in several threads

errant wigeon
#

Yeah that's another really likely candidate. Everyone's suggestions for debugging issues like these are born from their own debugging experience. Bad power supplies killed a few of my projects in the past, so I always start there. But networking might be the real issue. The ping script might solve it completely

smoky wharf
#

though, if its a bad power supply, shouldn't the RPi just restart?

smoky wharf
errant wigeon
#

That probably means you're right and it's more to do with the router than the power.
And brownouts are weird. Infuriatingly so. My thought was your pi's power dropping low enough it couldn't maintain communication with the router but not so low it completely shuts down and reboots.

smoky wharf
#

That's goofy as all get out

#

Do you happen to know anything about tmux? Is there anyway to create a tmux session and run this script in it from the rc.local file? I'd really like to be able to check on the status of the script if I ever need to.

errant wigeon
#

It's delightful when you're a week into debugging code only to learn that the issue isn't a bug but a power supply
No, I've never used tmux unfortunately

#

the #unix channel might have some knowledge there though. Or someone else here might

smoky wharf
#

well, before I get into all that, I'll just test the script now

split hollow
errant wigeon
# split hollow Please tell

A raspberry pi pico is an embedded device, and doesn't have an operating system. As such, it doesn't run CPython (aka what most folks know as Python), so instead you have to run a version of python that tries to keep a lot of 'python' present, but fits on the small device. That means Circuit Python or Micro Python. A lot of things like discord aren't ported to those versions of python so you can't do like you could in normal cpython. The pinned message in this channel has a lot more details explaining the difference
Additionally, here's a couple of links about the pico
https://www.raspberrypi.com/documentation/microcontrollers/micropython.html
https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/overview

smoky wharf
#

Smarter arduino?

smoky wharf
gentle vapor
#

compared to the "classic" Arduino AVR 8bit chips you can consider it sensibly more powerful

smoky wharf
#

in terms of RPi os (debian?) is there a difference between logout and exit?

knotty pewter
#

Yes. If you exit, you leave the current process. If you logout you terminate this user's session. You could have multiple processes; exit will just end the current one. logout would end your current login session (processes you started may continue to run, depending on how they're set up).

meager obsidian
#

Hey, how lightweight is a python class instance that declares no variables? Is it reasonable that I can load up a class with tons of methods, and when I instance that class, its no bigger than a class with only a few methods?

#

ok, i was able to test it using sizeof() on instances, the answer is that hwoever many methods the class has, there's no impact on the size of its instances

#

edit: sizeof doesn't actually seem to work - when i add a var to my class, it doesnt change the instance size - so sizeof is ignoring the actual contents of the item and just reporting the size of the pointer to the instance maybe - so i still need to find out if having more methods on a class increases the instance size

#

using sys.getsizeof doesn't seem to do better, it returns a larger size (48 as opposed to 32 from sizeof) but whether the instance has more vars/methods or not its always 48

#

basically, im going to have a few hundred objects on my microcontroller that need some management - im trying to understand how much overhead my management code will have - because it would be easier to code it as an object that gets instanced once per thing its managing - so a few hundred managers

#

if instances are expensive in memory, then i have a monolith that manages everything via lists internally

#

if instances are not expensive, then each object gets its own handle and methods to call, and operates descentralized

velvet marsh
#

Should I be running the command as sudo?

errant wigeon
#

No worries

#

Hmmm

#

let me review the thread--might be a bit, my brain is wrapped in another project

errant wigeon
velvet marsh
#

Still doesn't work

#

Path exists

errant wigeon
#

in the terminal can you type in ls /media/luna/Micron/Ph and then hit the tab keep to see if it autofills in the rest of "photos"

velvet marsh
#

Yes it does

#

The P is capitalized

#

But yes

#

Let me pull up the script I'm trying to run

errant wigeon
velvet marsh
errant wigeon
#

and I assume adding Photos/tes then hitting tab fills in "test.jpeg"

velvet marsh
#

No, it doesn't write to test.jpeg

errant wigeon
#

oohh

velvet marsh
#

It won't create that file

errant wigeon
#

ok that helps me clue in on the issue--slowly returning to the topic after all

#

ugh bash is not my wheelhouse

velvet marsh
#

Ah

#

Yeah it's not mine either

#

The good news is my Python script for logging data to the same drive works perfectly

errant wigeon
#

Is there a reason you're taking the picture via bash and not the python script?

velvet marsh
#

Python can't figure it out

#

Unless I'm missing something entirely

#

Because I'd love for it to be all in one

#

Since I got crontab to cooperate with that script

errant wigeon
velvet marsh
#

Yeah I'm on bullseye

errant wigeon
#

have you reenabled the legacy camera stuff?

velvet marsh
#

I just did

#

It's not gonna become a time lapse video, I just need it to take photos on interval

#

I'm gonna reboot then try the first link

#

the first link is pretty outdated

errant wigeon
#

yeah, pyimagesearch was my goto when I made a timelapse project
"raspberry pi opencv take picture"
was how I found it originally, and that might be a good way to figure out how to take pictures with bullseye nowadays.

#

That's why I found the second link
is it still not successfully taking a picture with the pythonscript?

#

I'm probably going to need to sign off for the night soon--do you have a minimalist block of code in python to take pictures?
Or a minimalist block that doesn't work? I'll give it a shot over the next couple of days on my setup to see if I can see what isn't working on my end

velvet marsh
#

I actually think I'm pretty close

#

I just can't get the PiCamera library loaded

errant wigeon
velvet marsh
#

It's taken photos before

errant wigeon
#

What operating system are you using? Bullseye?

#

Do you have Glamor graphic acceleration enabled? It's under raspi-config -> advanced options

velvet marsh
#

Yes

#

I don't think so

errant wigeon
#

give that a shot and then reboot

#

I could be following the wrong tips

velvet marsh
#

Enable glamor?

#

@errant wigeon

errant wigeon
velvet marsh
#

Gotcha

#

Thanks a ton

#

I think the issue is the tutorial relies on deprecated libraries

errant wigeon
velvet marsh
#

I'm a 64-bit user

#

And I'd hate to scrap this install

errant wigeon
#

this *may* be a workaround

velvet marsh
#

Cool I'll keep tryin

smoky wharf
#

Alright team, need your assistance on this. My raspberry pi suddenly won't let me ssh into it anymore. I can connect via teamviewer, power management is off, it has full connection to the internet, both are on the same network, and ssh has been enabled. My router's settings hasn't been changed recently. My main can't ping the pi, and the pi can't ping me

#

Then suddenly, it all works again. No changes

#

this is agonizing

velvet marsh
#

Thank you so much for your help!

smoky wharf
#

and now its broke again

#

bruh

tired laurel
#

does anyone kow why I am getting s impto error?

#

ImportError: no module named 'machine.Pin'

cloud hinge
#

how to get scale to store target data on micro sd module card so when arduino restarted it reads and uses target data and does not go back to default? i made a code with cgpt but doesnt seem to retrieve data once restarted so i dont think its saving either

ember sequoia
#

What is the best software to make a 3d design of smallscale micrcontroller projects?

smoky wharf
#

SSH makes me want to drive head first into a meat grinder

proud elk
#

Hi guys, currently working on a system where a bunch of esp32 are communicating using mqttc with a raspberry pi, I am observing some interesting behavior when I send the esp32 to sleep (its not deepsleep, just normal time sleep()) for a set amount of time, that they actually wake up before the set time. Anyone every observed something similar?

hallow igloo
#

can someone help me with my pybadge lc

#

i cannot get a single input to register

knotty pewter
#

You may need to provide a lot more information than that. Can't say I can help, but without more info, I doubt others can, either!

winged chasm
#

Hey, I have a short question. I want to build a device that detects the humidity and sends this data to a home server. I do that with Sockets. Should I encrypt it or is it already encrypted? And if by any cause, somebody should know how it is in Java, I would prefer that answer.

Thanks a lot 😄

humble kraken
#

Unless you are using a TLS socket it is not encrypted

#

you can make your own TLS backed public server if you want, for instance an MQTT server which has a TLS cert

#

or you can do private encryption where you bake in the key to both server and client

#

@winged chasm ^

#

just googling "tls mqtt" gets me a lot of hits. BTW MQTT is a message passing protocol, which is great for IOT things where clients want to pass on a message into a 'holding server' that you can later use, like passing humidity numbers

#

https://nacl.cr.yp.to/ NACL is a nice little library that comes with a "fully built cryptosystem" (i.e if you just use it in the standard way, it is very very hard to make any noob security mistakes) for doing private encryption

#

or libsodium is also built off it

minor monolith
#

anybody can help me?

knotty pewter
#

We have no idea

arctic zephyr
#

Has anyone tried connecting the arduino com port to a python server?
There is a code with the main server and a code with a com port to open the lock. When they connect, the server starts to slow down.

knotty pewter
arctic zephyr
sullen hamlet
sullen hamlet
arctic zephyr
#

I also found a bug in the code. When I forcibly stop the code, the light is on even after the code has run, but if it works completely, it immediately goes out.

#

import serial

ser = serial.Serial('COM4', 9600)
ser.baudrate = 9600
ser.port = 'COM4'

port_status = ser.is_open
print(f"статус порта {port_status}")

a = 1

while a < 10000:
ser.write('1'. encode())
print ('отправлено на СOM порт')
a = a+1
ser.close()

sullen hamlet
#

That tells me very little. So your code just streams a large buffer of 1's? Also why send it at 0's and 1's and not just the data you want? Using a byte per bit feels a little strange?

arctic zephyr
sullen hamlet
#

your code does not appear to do that function?

arctic zephyr
sullen hamlet
#

that code to me is just sending the character 1, 10000 times over the serial port, it never reads anything?

arctic zephyr
#

It reads, but the light bulb still goes out at the end

sullen hamlet
#

after 10 seconds?

#

say when you close the serial port?

arctic zephyr
#

after the loop

sullen hamlet
#

so stepping back, how do you want the code to behave, if you intend to close the serial port, I'm unclear if that would reboot your microcontroller or not

arctic zephyr
#

That is, when the port is closed, the microcontroller can reboot?

sullen hamlet
#

try this code for a start,

import time

ser = serial.Serial('COM4', 9600)

port_status = ser.is_open
print(f"статус порта {port_status}")

ser.write('1'.encode())
print('отправлено на СOM порт')

time.sleep(10)  # Wait for 10 seconds before closing the serial port

ser.close()```
sullen hamlet
#

some fit a capacitor between reset and ground to stop this, but its a starting point as I'm not quite sure what your using

arctic zephyr
#

But there is no way to solve it programmatically?

sullen hamlet
#

this code is to test that out, if it behaves the exact same, it means you cant disconnect, and may need to change your implementation on the python side a little if you don't want to change the hardware,

arctic zephyr
#

the code works the same and I do not understand how I can revise the implementation in python

sullen hamlet
#

what this means is its the disconnection that is stopping the micro, so the fault may lie in your micros code or needing a capacitor for a reset pin

next part is, why does the script need to stop after 10 seconds, what would it usually do after those 10 seconds?

arctic zephyr
#

The light bulb must stay on

sullen hamlet
#

then your either going to need to leave the script sleeping forever, investigate your micros code to see if its checking if a serial connection is connected, or addressing the possible reset in hardware, your currently stuck with 1 of these 3

arctic zephyr
#

thanks, i wiil try to decide it

arctic zephyr
plucky wagon
#

Hi i need help with the usage of the RPLCD lib, Im using it to create a menu, but the menu is just broken af. Although it should work, I think that the buffer gets filled with crap and then it starts do display random characters. Is there some way to fix it?

Here is code:

lcd.cursor_mode = "hide"
lcd.clear()
lcd.close(clear=True)

class Menu():
    def __init__(self, lcd):
        self.rows = 4
        self.columns = 20
        self.line = 0
        self.lcd = lcd
    
    def dsiplay_menu(self):
        lcd.cursor_pos = (0,0)
        lcd.write_string(">")
        
        time.sleep(0.1)
        
        lcd.cursor_pos = (0,1)
        lcd.write_string("Info panel")
        
        time.sleep(0.1)
        
        lcd.cursor_pos = (1,1)
        lcd.write_string("Manual mode")
        
        time.sleep(0.1)
        
        lcd.cursor_pos = (2,1)
        lcd.write_string("Auto mode")
        
        time.sleep(0.1)
        
        lcd.cursor_pos = (3,1)
        lcd.write_string("Bordel")
        
        lcd.home()
    
    def update(self):
        lcd.cursor_pos = (self.line - 1, 0)
        lcd.write_string(" ")
        lcd.cursor_pos = (self.line, 0)
        lcd.write_string(">")
        
        lcd.cursor_pos = (0,1)
        lcd.write_string("Info panel")
        
        lcd.cursor_pos = (1,1)
        lcd.write_string("Manual mode")
        
        lcd.cursor_pos = (2,1)
        lcd.write_string("Auto mode")
        
        lcd.cursor_pos = (3,1)
        lcd.write_string("Bordel")
        
    
    def moove(self, line):
        self.line = line 
        self.update()


menu = Menu(lcd)
menu.dsiplay_menu()

time.sleep(2)

menu.moove(1)
hallow igloo
#

hi group, looking for help with code using interstate75w and matrix 64x32

steep dune
#

such nice clean coding

knotty pewter
#

!code

hasty zealotBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

knotty pewter
#

Or, in this case, ```c
<the code>
```

cloud hinge
sullen hamlet
#

give me a bit, just reading over it

cloud hinge
#
#include "HX711.h"
#include <SD.h>
#include <SPI.h>

#define DEBUG_HX711

// calibration parameter from calibrating code with known values
#define CALIBRATION_FACTOR 400000

// file name for target weight
const char* targetWeightFile = "target_weight.txt";

// Create the lcd object address 0x3F and 20 columns x 4 rows 
LiquidCrystal_I2C lcd (0x27, 20, 4);

// data pin and clock pin
byte pinData = 3;
byte pinClk = 2;

// pump pin
byte pinPump = 4;
byte pinRelay = 4; // define relay pin

// define HX711
HX711 scale;

// variable to keep track of pump state
bool isPumpOn = false;

// define pins for buttons
int buttonUp = 5;
int buttonDown = 6;

#
int targetWeight = 200;

void setup() {
  lcd.init();
  lcd.backlight();

  // Initialize micro SD card
  Serial.begin(9600);
  while (!Serial) {}

  if (!SD.begin(4)) {
    Serial.println("SD card initialization failed!");
    return;
  }
  Serial.println("SD card initialized.");

  // Read target weight from file
  File file = SD.open(targetWeightFile);
  if (file) {
    targetWeight = file.parseInt();
    file.close();
  } else {
    Serial.println("Failed to open target weight file.");
  }

  lcd.setCursor(0, 0);
  lcd.print("    Target");
  lcd.setCursor(14, 0);
  lcd.print(targetWeight);
  lcd.print(" g");

  pinMode(pinPump, OUTPUT);
  pinMode(pinRelay, OUTPUT); // initialize relay pin as output
  pinMode(buttonUp, INPUT_PULLUP);
  pinMode(buttonDown, INPUT_PULLUP);

#ifdef DEBUG_HX711
  // Initialize serial communication
  Serial.begin(9600);
  Serial.println("[HX7] Sensor start HX711");
#endif

  //Initializing sensor
  scale.begin(pinData, pinClk);
  // apply the calibration value
  scale.set_scale(CALIBRATION_FACTOR);
  // Initialize the tare
  //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale.tare();
}
#
  float weight = scale.get_units() * 1000; // convert to grams and round to nearest gram

#ifdef DEBUG_HX711
  Serial.print("[HX7] Reading: ");
  Serial.print(weight);
  Serial.print(" g");
  Serial.println();
#endif

  lcd.setCursor(0, 1);
  lcd.print("    Weight: ");
  lcd.print(round(weight));
  lcd.print(" g  ");

  // check button presses
  if(digitalRead(buttonUp) == LOW){
    targetWeight += 1;
  }
  if(digitalRead(buttonDown) == LOW){
    targetWeight -= 1;
  }

  if ((weight >= targetWeight) || (weight >= -100 && weight <= 75)) {
    digitalWrite(pinPump, LOW); // stop pump
    digitalWrite(pinRelay, LOW); // turn off relay
    isPumpOn = false; // update pump state

    lcd.setCursor(0, 2);
    lcd.print("    Pump stopped   ");

    lcd.setCursor(14, 0);
    lcd.print(targetWeight);
    lcd.print(" g");

    // update the weight on the screen until the scale is reset
    while ((weight >= targetWeight) || (weight >= -100 && weight <= 75)) {
      weight = scale.get_units() * 1000;
      lcd.setCursor(0, 1);
      lcd.print("    Weight: ");
      lcd.print(round(weight));
      lcd.print(" g  ");
    }
  } else {
    digitalWrite(pinPump, HIGH); // run pump
    digitalWrite(pinRelay, HIGH); // turn on relay
    isPumpOn = true; // update pump state

    lcd.setCursor(0, 2);
    lcd.print("    Pump running   ");
  }

  // check if pump state has changed and update relay accordingly
  if (isPumpOn) {
    digitalWrite(pinRelay, HIGH);
  } else {
    digitalWrite(pinRelay, LOW);
  }
  
  delay(1000);
}
#

thats the one that does not work and lcd displays just black bars @sullen hamlet

sullen hamlet
#

first thing that stands out to me is you have the relay pin defined twice, still working through it

cloud hinge
#
#include "HX711.h"

#define DEBUG_HX711

// calibration parameter from calibrating code with known values
#define CALIBRATION_FACTOR 400000
// Create the lcd object address 0x3F and 20 columns x 4 rows 
LiquidCrystal_I2C lcd (0x27, 20, 4);

// data pin and clock pin
byte pinData = 3;
byte pinClk = 2;

// pump pin
byte pinPump = 4;
byte pinRelay = 4; // define relay pin

// define HX711
HX711 scale;

// variable to keep track of pump state
bool isPumpOn = true; // set initial state to on

// define pins for buttons
int buttonUp = 5;
int buttonDown = 6;

// target weight
int targetWeight = 200;

void setup() {
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0, 0);
  lcd.print("     PLANT SCALE");

  pinMode(pinPump, OUTPUT);
  pinMode(pinRelay, OUTPUT); // initialize relay pin as output
  pinMode(buttonUp, INPUT_PULLUP);
  pinMode(buttonDown, INPUT_PULLUP);

#ifdef DEBUG_HX711
  // Initialize serial communication
  Serial.begin(9600);
  Serial.println("[HX7] Sensor start HX711");
#endif

  //Initializing sensor
  scale.begin(pinData, pinClk);
  // apply the calibration value
  scale.set_scale(CALIBRATION_FACTOR);
  // Initialize the tare
  //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale.tare();
}

void loop() {
  float weight = scale.get_units() * 1000; // convert to grams and round to nearest gram

#ifdef DEBUG_HX711
  Serial.print("[HX7] Reading: ");
  Serial.print(weight);
  Serial.print(" g");
  Serial.println();
#endif

#

  lcd.setCursor(0, 1);
  lcd.print("    Weight: ");
  lcd.print(round(weight));
  lcd.print(" g  ");

  if(digitalRead(buttonUp) == LOW){
    targetWeight += 1;
    lcd.setCursor(14, 0);
    lcd.print("   "); // clear previous target weight
    lcd.setCursor(14, 0);
    lcd.print(targetWeight);
    lcd.print(" g");
  }
  if(digitalRead(buttonDown) == LOW){
    targetWeight -= 1;
    lcd.setCursor(14, 0);
    lcd.print("   "); // clear previous target weight
    lcd.setCursor(14, 0);
    lcd.print(targetWeight);
    lcd.print(" g");
  }

  if ((weight >= targetWeight) || (weight >= -100 && weight <= 75)) {
    digitalWrite(pinPump, HIGH); // stop pump (reverse of original code)
    digitalWrite(pinRelay, HIGH); // turn off relay (reverse of original code)
    isPumpOn = false; // update pump state

    lcd.setCursor(0, 2);
    lcd.print("    Pump stopped   ");

    lcd.setCursor(14, 0);
    lcd.print(targetWeight);
    lcd.print(" g");

    // update the weight on the screen until the scale is reset
    while ((weight >= targetWeight) || (weight >= -100 && weight <= 75)) {
      weight= scale.get_units() * 1000;
      lcd.setCursor(0, 1);
      lcd.print("    Weight: ");
      lcd.print(round(weight));      lcd.print(" g  ");
    }
  } else {
    digitalWrite(pinPump, HIGH); // run pump
    digitalWrite(pinRelay, HIGH); // turn on relay
    isPumpOn = true; // update pump state

    lcd.setCursor(0, 2);
    lcd.print("    Pump running   ");
  }

  // check if pump state has changed and update relay accordingly
  if (isPumpOn) {
    digitalWrite(pinRelay, HIGH);
  } else {
    digitalWrite(pinRelay, LOW);
  }
  
  delay(1000);
}
#

here is th good code, the last code the relays might have been backward, i had updated it to switch the on and off possisions on this code

sullen hamlet
#

lets focus on the small bits for now,

// pump pin
byte pinPump = 4;
byte pinRelay = 4; // define relay pin

why are both the same?

#

I'm getting to the LCD stuff, but reading library documentation takes a moment

cloud hinge
#

relay turns on pump on and off

sullen hamlet
#

then pump it is, contnuing

cloud hinge
sullen hamlet
#

first part cleaned up, still working on the loop

#include <LiquidCrystal_I2C.h>
#include "HX711.h"
#include <SD.h>
#include <SPI.h>

// UI
unsigned long lastLcdUpdate = 0;
unsigned long buttonPressTime = 0;
bool buttonPressed = false;
unsigned long buttonHoldTime = 0;
bool buttonHeld = false;

// SD Card
const char* targetWeightFile = "target_weight.txt";

// LCD
LiquidCrystal_I2C lcd (0x27, 20, 4);
byte pinData = 3, pinClk = 2,

// IO
byte pinPump = 4, buttonUp = 5, buttonDown = 6;
bool isPumpOn = false;

// Scale
HX711 scale;
#define CALIBRATION_FACTOR 400000
#define DEBUG_HX711
int targetWeight = 200;

void setup() {
  // LCD setup
  lcd.init(); lcd.backlight();
  lcd.setCursor(0, 0);  lcd.print("     PLANT SCALE");
  
  // Pump and buttons setup
  pinMode(pinPump, OUTPUT); pinMode(buttonUp, INPUT_PULLUP); pinMode(buttonDown, INPUT_PULLUP);

  #ifdef DEBUG_HX711
  Serial.begin(9600); 
  Serial.println("[HX7] Sensor start HX711");
  #endif
  
  // Weight scale setup
  scale.begin(pinData, pinClk); scale.set_scale(CALIBRATION_FACTOR); scale.tare();
}```
cloud hinge
#

@sullen hamlet the only reason i need sd card working is cause when i power off arduino the save state goes back to its coded number right now at 200grams. need target weight to save to sd card . power down then power up with last target wieght by reading card upon start up

sullen hamlet
#

your micro has an eeprom?

#

you generally have atleast 256 bytes to play with

cloud hinge
sullen hamlet
#

the inline lcd stuff is sometimes frowned upon, e.g. you don't really need that set cursor, as you can just send a longer string the first time to move the cursor there

#

ah sorry haven't gotten to that bit yet

cloud hinge
#

one other issue was i cant change target wieght with buttons unless pump is on. i tryed a lot of ways but no luck. not a issue really though

cloud hinge
#

The wiring.........

sullen hamlet
#
  // Reading weight
  float weight = scale.get_units() * 1000;

#ifdef DEBUG_HX711
  Serial.print("[HX7] Reading: ");
  Serial.print(weight);
  Serial.println(" g");
#endif

  // Update LCD 4 times a second
  if (millis() - lastLcdUpdate >= 250) {
  
    // Display weight and target weight
    
    lcd.setCursor(0, 0); lcd.print("    Target:   "); lcd.print(targetWeight); lcd.print(" g");
    lcd.setCursor(0, 1); lcd.print("    Weight: ");   lcd.print(round(weight)); lcd.print(" g  ");

    lastLcdUpdate = millis();
  }

  // Button presses and hold
  bool upPressed = digitalRead(buttonUp) == LOW;
  bool downPressed = digitalRead(buttonDown) == LOW;

  if (upPressed || downPressed) {
    if (!buttonPressed) {
      buttonPressTime = millis(); 
      buttonPressed = true;
    }

    if (millis() - buttonPressTime >= 80 && !buttonHeld) {
      targetWeight += upPressed ? 1 : -1;
      buttonHoldTime = millis();
      buttonHeld = true;
    }

    if (buttonHeld && millis() - buttonHoldTime >= 500) {
      targetWeight += upPressed ? 1 : -1;
      buttonHoldTime = millis();
    }
  } else {
    buttonPressed = false;
    buttonHeld = false;
  }

  // Pump control
  if ((weight >= targetWeight) || (weight >= -100 && weight <= 75)) {
    if (!isPumpOn) {
      digitalWrite(pinPump, LOW);
      isPumpOn = true;
      lcd.setCursor(0, 2);  lcd.print("    Pump Stopped   ");
    }
  } else {
    if (isPumpOn) {
      digitalWrite(pinPump, HIGH);
      isPumpOn = false;
      lcd.setCursor(0, 2);  lcd.print("    Pump Running   ");
    }
  }
}```

This bit is harder to tidy up, I also added some UI stuff to the earlier bit
#

@cloud hinge I have not made sure it compiles, but see if that gets you closer, at minimum it seems like it should be fine if its wired right?

#

In reality I would probably go further and just replace isPumpOn with a digitalRead of the output, save the risk of things getting out of state

cloud hinge
sullen hamlet
#

probably because your trying to send a large amount of text instead of only the relevant bits?

cloud hinge
sullen hamlet
cloud hinge
sullen hamlet
#

I'm at a bus stop, so I'm just cleaning it up on my phones text editor 😄

cloud hinge
#

@sullen hamlet i added the two codes u sent together and compiled, wasnt sure if that code was completed or i need to add some old code back in

sullen hamlet
#

nah that should have been complete unless I missed much

#

worst case leave loop empty as a test, your doing a print in the setup

cloud hinge
#

gpt said this ``` Change the line that declares the variables pinPump, buttonUp, and buttonDown to the following:

arduino

uint8_t pinPump = 4, buttonUp = 5, buttonDown = 6;

In the setup() function, change the line that initializes the pins to the following:

pinMode(pinPump, OUTPUT); pinMode(buttonUp, INPUT_PULLUP); pinMode(buttonDown, INPUT_PULLUP);

In the loop() function, change the lines that check the button states to the following:

arduino

bool upPressed = digitalRead(buttonUp) == LOW;
bool downPressed = digitalRead(buttonDown) == LOW;

Declare the isPumpOn variable at the beginning of the code, before the setup() function, like this:

arduino

bool isPumpOn = false;

After making these changes, the code should compile and run without errors.

sullen hamlet
#

the first part with the variables was my error, I've updated, the other variable is declared before?

cloud hinge
sullen hamlet
#

uint8_t pinPump = 4, buttonUp = 5, buttonDown = 6; this was a valid error,

cloud hinge
sullen hamlet
#

you are safe to replace the entire setup part,

cloud hinge
# sullen hamlet you are safe to replace the entire setup part,

i think im gonna have to crash out, 3:18 here, may i add you as a friend to chat more later? super greatful for your help. i will continue more in the morning. would love to show u the whole project if your interested. i have another version im gonna be working on soon when i get another scale

cloud hinge
# sullen hamlet you are safe to replace the entire setup part,

i was able to get it to compile afer a gpt fix but it looks like got is correct in stating that there is no save function. " Based on the code provided, it seems that the SD card library is included but no code is written to actually save or read data from the SD card." on a super cool note the buttons are able to update target wieght weather pump on or off now, super happy about that man, cant thank you enough

sullen hamlet
cloud hinge
cloud hinge
sullen hamlet
#

Sure in about 7 hours

cloud hinge
cloud hinge
#

got the eeprom workingincident_actioned , was thinking it will still be nice to get sd card module working for additional backup combine with eeprom or separate for reliability. i hear heat is a factor on eeprom reliability but for this is seems perfect, also future sd module features in the future like storing environmental or sensor data. pretty cool how i can leave it plugged in and only uses if i need the code. but for now im super stoked, cant thank you enough. i can show you the code later when u have some time.

sullen hamlet
#

(Seeing as you tare on power loss there is a risk of it adding say 200g of water in such a case so you may want to instead store the tare offset somewhere 😄 )

cloud hinge
# sullen hamlet (Seeing as you tare on power loss there is a risk of it adding say 200g of water...

my idea is to make lift that auto lifts and drops plant on scale when starting system so it auto tars.stars. would be much more reliable if the lift is reliable. The scales can have a drift from multiple factors that are not reliable in long run and if plant is on scale when starts up it will auto tar and if old wieght is used It wont be accurate cause of plant drinking water and evaporation . So im gonna use some actuators, hydraulic lift or something of that nature. Maybe 2 or 4. All this for a solo cup but IIf It works then I can make a bigger scale and bigger lifts. I think ai would be ideal for measuring plant biomass to make self adjustments in futures. Way overkill I know but i figure it hasn't been done maybe or maybe not there will be possible advantages. Also have idea for robots to select plants to pick up and put on scale and take them off after so another plant could be weighed and watered. Erlither robots or a automation system

sullen hamlet
#

Plant weight also drifts with development and watering amounts change based on tenperature if you want to get fancy 🙂 ill go iver the reat later

cloud hinge
# sullen hamlet Plant weight also drifts with development and watering amounts change based on t...

ok. Gonna boot my computer so I can text and share better.. yeah i realize the drift will be from plant gaining weight but that's where the human eye comes in. Can add a few grams or what not with reprogramming for now. The way i have it set up its it's a pain to remove arduino cause its powered by power module . I dont think I can plug USB for programming while power supply hooked up. I'll soon find a fix but for now its it's working lol. i have 3 temperature sensors. not sure how id implement them based on watering from temps with this setup. maybe if i had a clock to keep track of time and temps to reduce or add more water to target weight. thats a very good point on drinking amount based on temps

cloud hinge
#

@sullen hamlet ```// Libraries
#include <LiquidCrystal_I2C.h>
#include <HX711.h>
#include <EEPROM.h>

// UI
unsigned long lastLcdUpdate = 0;
unsigned long buttonPressTime = 0;
bool buttonPressed = false;
unsigned long buttonHoldTime = 0;
bool buttonHeld = false;

// LCD
LiquidCrystal_I2C lcd (0x27, 20, 4);
uint8_t pinData = 3, pinClk = 2;

// IO
uint8_t pinPump = 4, buttonUp = 5, buttonDown = 6;
bool isPumpOn = false;

// Scale
HX711 scale;
const float CALIBRATION_FACTOR = 400000;
const bool DEBUG_HX711 = true;
int targetWeight = 200;

void saveTargetWeightToEEPROM() {
EEPROM.put(0, targetWeight);
}

void loadTargetWeightFromEEPROM() {
EEPROM.get(0, targetWeight);
}

void setup() {
// LCD setup
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(" PLANT SCALE");

// Load target weight from EEPROM
loadTargetWeightFromEEPROM();

// Pump and buttons setup
pinMode(pinPump, OUTPUT);
pinMode(buttonUp, INPUT_PULLUP);
pinMode(buttonDown, INPUT_PULLUP);

#ifdef DEBUG_HX711
Serial.begin(9600);
Serial.println("[HX7] Sensor start HX711");
#endif

// Weight scale setup
scale.begin(pinData, pinClk);
scale.set_scale(CALIBRATION_FACTOR);
scale.tare();
}

void loop() {
// Reading weight
float weight = scale.get_units() * 1000;

#ifdef DEBUG_HX711
Serial.print("[HX7] Reading: ");
Serial.print(weight);
Serial.println(" g");
#endif ```

#
  if (millis() - lastLcdUpdate >= 250) {
    lcd.setCursor(0, 0); 
    lcd.print("    Target:   "); 
    lcd.print(targetWeight); 
    lcd.print(" g");
    
    lcd.setCursor(0, 1); 
    lcd.print("    Weight: ");   
    lcd.print(round(weight)); 
    lcd.print(" g  ");

    lastLcdUpdate = millis();
  }

  // Button presses and hold
  bool upPressed = digitalRead(buttonUp) == LOW;
  bool downPressed = digitalRead(buttonDown) == LOW;

  if (upPressed || downPressed) {
    if (!buttonPressed) {
      buttonPressTime = millis(); 
      buttonPressed = true;
    }

    if (millis() - buttonPressTime >= 80 && !buttonHeld) {
      targetWeight += upPressed ? 1 : -1;
      buttonHoldTime = millis();
      buttonHeld = true;
    }

    if (buttonHeld && millis() - buttonHoldTime >= 500) {
      targetWeight += upPressed ? 1 : -1;
      buttonHoldTime = millis();
    }
  } else {
    buttonPressed = false;
    buttonHeld = false;
  }

  // Save target weight to EEPROM and control pump
  saveTargetWeightToEEPROM();

// Control pump
if (weight >= 75 && weight < targetWeight) {
if (!isPumpOn) {
digitalWrite(pinPump, HIGH); // turn on pump
isPumpOn = true;
lcd.setCursor(0, 2);
lcd.print(" Pump Running ");
}
} else {
if (isPumpOn) {
digitalWrite(pinPump, LOW); // turn off pump
isPumpOn = false;
lcd.setCursor(0, 2);
lcd.print(" Pump Stopped ");
}
}

if (weight < -1000) {
digitalWrite(pinPump, LOW);
isPumpOn = false;
lcd.setCursor(0, 2);
lcd.print(" Negative Grams ");
}

// Update target weight if it goes below zero
if (targetWeight < 0) {
targetWeight = 0;
}

// Save target weight to EEPROM
saveTargetWeightToEEPROM();
} ```
sullen hamlet
# cloud hinge <@368938019790520320> ```// Libraries #include <LiquidCrystal_I2C.h> #include <H...

you have a clock of sorts, you know how long your micro has been running 😄 as for where to expand on the code, for your earlier requirements its mostly good, just odd that you removed the print statements on if the pump is on or off,
should probably also implement some filtering on the weight and some hysteresis so it stays on or off with some margin required to change it, e.g. so the weight of the water in your tubing doesnt make it oscillate 🙂

hallow igloo
#

cool haf fun

cloud hinge
# hallow igloo cool haf fun

cool name, you must love voltage as much as i do or more, may i ask why you chose that name? my old name was 5v

hallow igloo
#

🙂

cloud hinge
# sullen hamlet you have a clock of sorts, you know how long your micro has been running 😄 as f...

i dont have a clock atm but hopefully one day. it was got that removed it but the puump started and pump stoped and relay seem to work with lcd once its triggered. i definatatly need to make a setting where it does not water after completing the target weight for x amount or time, times a day, once a day or ect.. for the weight drift the only thing i know of is to twist the wires and keep the short. seems twisting has the biggest influence, i had a wire coil going around the scale that seemed to stop drift but im not 100% sure if thats what made it steady without drift. the contraption i have keeps the tubing above the place where its watering to not interfere with weight calculations. i made the pump pump as slow as possible for slow dripings

cloud hinge
hallow igloo
#

😄

cloud hinge
# hallow igloo 😄

been learning about common ground lately, very interesting they all have to tie in to one. i recently learned that there can be noise from multiple ground tie in sources and a copper bus bar is a way to minimize noise or noise cancelling capacitors.

hallow igloo
#

yes it dose

cloud hinge
# hallow igloo yes it dose

i get voltage drop on my 20 x 4 lcd panel when relay kicks in, any idea how to avoid that? it seems to dim lcd slightly when relay triggered. i think power module is limited to 500ma so maybe thats part of it. i think lcd is only like 40ma

hallow igloo
#

what is you powersorses?

#

the relay tak a lott of amper so what is you power sourse?

cloud hinge
hallow igloo
#

using 5V for relay is to small, i wude use transistor to power what yu ar powering and the maby using other powersubley to drive the relay

cloud hinge
# hallow igloo using 5V for relay is to small, i wude use transistor to power what yu ar poweri...

ok, i havnt used a transistor before but need to learn, maybe i can use the same power source as the separate one that powers the pump. i dont quite grasp how trasistors give more amps from a low amp power source, i been struggling to grasp the concept for a while. i think thats how there used, maybe my terminology is incorrect. it just seems like magic to me thats possible, maybe i dont understand the tradeoffs from when its happening. its a 5v powered relay so i think thats the max it can handle from arduino side. i do have a 12v relay i havnt tried yet but i think it needs a trasistor or something to make it compatible with arduino nano. honestly the change lcd dimming is not that bad so i can live with it maybe for now, i really appreciate the info. been looking into alternatives to the lcd for something maybe like the nextion display or possibly even a the smallest oled 126 x 64. the 20 x 4 lcd does seem easy to work with though

cloud hinge
#

@sullen hamlet ``` EEPROM.put(0, targetWeight);
}

void loadTargetWeightFromEEPROM() {
EEPROM.get(0, targetWeight);
}

void setup() {
// LCD setup
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(" PLANT SCALE");

// Load target weight from EEPROM
loadTargetWeightFromEEPROM();

// Pump and buttons setup
pinMode(pinPump, OUTPUT);
pinMode(buttonUp, INPUT_PULLUP);
pinMode(buttonDown, INPUT_PULLUP);

#ifdef DEBUG_HX711
Serial.begin(9600);
Serial.println("[HX7] Sensor start HX711");
#endif

// Weight scale setup
scale.begin(pinData, pinClk);
scale.set_scale(CALIBRATION_FACTOR);
scale.tare();
}

void loop() {
// Reading weight
float weight = scale.get_units() * 1000;

#ifdef DEBUG_HX711
Serial.print("[HX7] Reading: ");
Serial.print(weight);
Serial.println(" g");
#endif

// Update LCD 4 times a second
if (millis() - lastLcdUpdate >= 250) {
lcd.setCursor(0, 0);
lcd.print(" Target: ");
lcd.print(targetWeight);
lcd.print(" g");
```

#
    lcd.print("    Weight: ");   
    lcd.print(round(weight)); 
    lcd.print(" g  ");

    lastLcdUpdate = millis();
  }

  // Button presses and hold
  bool upPressed = digitalRead(buttonUp) == LOW;
  bool downPressed = digitalRead(buttonDown) == LOW;

  if (upPressed || downPressed) {
    if (!buttonPressed) {
      buttonPressTime = millis(); 
      buttonPressed = true;
    }

    if (millis() - buttonPressTime >= 80 && !buttonHeld) {
      targetWeight += upPressed ? 1 : -1;
      buttonHoldTime = millis();
      buttonHeld = true;
    }

    if (buttonHeld && millis() - buttonHoldTime >= 500) {
      targetWeight += upPressed ? 1 : -1;
      buttonHoldTime = millis();
    }
  } else {
    buttonPressed = false;
    buttonHeld = false;
  }

  // Save target weight to EEPROM and control pump
  saveTargetWeightToEEPROM();

// Control pump
if (weight < 75 || weight >= targetWeight) {
  if (!isPumpOn) {
    digitalWrite(pinPump, HIGH); // turn on pump
    isPumpOn = true;
    lcd.setCursor(0, 2);
    lcd.print("    Pump Stopped ");
  }
} else {
  if (isPumpOn) {
    digitalWrite(pinPump, LOW); // turn off pump
    isPumpOn = false;
    lcd.setCursor(0, 2);
    lcd.print("    Pump Running ");
  }
}

if (weight < -1000) {
digitalWrite(pinPump, LOW);
isPumpOn = false;
lcd.setCursor(0, 2);
lcd.print(" Negative Grams ");
}

// Update target weight if it goes below zero
if (targetWeight < 0) {
targetWeight = 0;
}

// Save target weight to EEPROM
saveTargetWeightToEEPROM();
}```
#

this code is pretty good but for some reason the pump turns on for 1.5 seconds aprox upon first time powering up. also would be nice to put in a delay after reaching target weight at least 30seconds. i tried but it didnt work out so great.

fresh quarry
#

if you're using arduino I think there's a few options

cloud hinge
fresh quarry
#

for example, imagine if someone pressed down a key for less than buttonPressTime but it was still a valid input after debouncing

#

you want to be able to identify whether an input has been pressed both as fast as possible, and with high accuracy. the issue is that connections for buttons often will oscillate for the first few microseconds

#

your solution would detect the input much later than 30ms, but if you used a debounce library you could get close to that latency

#

without a debounce library you would be detecting each individual peak of the input signal as a separate button press, or you have to have a timeout like buttonPressTime

#

the timeout is normally used to get past that initial bouncing period

cloud hinge
fresh quarry
#

it's mostly plug-n-play

cloud hinge
fresh quarry
#

there is a decent probability that the buttons you're using might not even support fast enough sample rates to be able to identify super short keypresses

cloud hinge
fresh quarry
#

and then plug those into an arduino library

cloud hinge
fresh quarry
fresh quarry
#

you shouldn't worry much about latency though because the vast majority of inputs are fast enough you wouldn't notice

#

just need debounce to immediately receive the inputs as opposed to sampling it over time

cloud hinge
#

@fresh quarry can a breadboard power module be plugged into nano via 5v line and and have usb plugged in specifically for uploading sketch? maybe disconecting breadboard power module would work but nano cant power things without those extra ma

fresh quarry
#

You would probably need to plug it into the individual components that need the extra power

#

You could fry your arduino if you put too much voltage into the power port

cloud hinge
fresh quarry
cloud hinge
fresh quarry
cloud hinge
cloud hinge
fresh quarry
cloud hinge
#

if i only had a accurate program to measure biomass in almost real time . not sure what camera would be the best. ive seen a few ways to measure it but there mostly measureing canopies from far away. i would like one that measures close and 99.9% acuracy

fresh quarry
#

biomass like in a forest? or on a person?

cloud hinge
fresh quarry
fresh quarry
#

basically just divides the image into discrete areas that should roughly correspond to objects in frame

#

you could segment and then count the area of all segments with an average color that looks green etc

cloud hinge
fresh quarry
#

I'm pretty sure someone has already done that

cloud hinge
fresh quarry
#

it's also important to use the right keywords, you probably want to use "(CNN, DNN, segmentation, classification)"

cloud hinge
fresh quarry
#

GPT4 is pretty decent but it will annoy with warnings about how the algorithms you're searching for aren't good for production

cloud hinge
fresh quarry
#

and there are a lot lol

#

it did help me find some super amazing stuff I wouldn't find otherwise, like did y'all know that Berlekamp from the Berlekamp-Massey algorithm has an entire book dedicated to solving go?

fresh quarry
fresh quarry
# cloud hinge wow what a trip!

binary finite field arithmetic is so cool IMO, and it also is somewhat relevant to microcontrollers because it often uses hardware-dependent intrinsics to calculate these things super fast

cloud hinge
fresh quarry
cloud hinge
#

i been digging the old terminator compter and the newer versions with similar lcds

cloud hinge
#

i did a bunch of research on these type of computers cause i like the fact that there power is minimal and batteries last forever and u can see them in daylight good suposedly

fresh quarry
cloud hinge
fresh quarry
fresh quarry
cloud hinge
fresh quarry
fresh quarry
cloud hinge
cloud hinge
fresh quarry
#

yeah pdas are insane for battery life

#

I feel like e-ink displays are the modern version of that

#

they're getting pretty decent

#

5mhz processor 😮

cloud hinge
# fresh quarry I feel like e-ink displays are the modern version of that

this one is a upgrade from portfolio with bigger screen and backlite. https://www.youtube.com/watch?v=KCaEhYbKUxI

A quick video demo of my HP 320LX. There don't seem to be any decent videos on here with older Windows CE devices. Its got a funky digitizer, some of the taps don't register in the right place on the left hand side, so I use the keyboard a lot in this video.

The specs are:

Hitatchi SH3 at 44MHz
4MB RAM (split 2MB storage, 2MB system RAM)
640x...

▶ Play video
fresh quarry
#

haha that reminds me of those windows computers that allowed you to write on the touchscreen

#

but it was such a bad implementation you would end up with horrible looking writing

cloud hinge
fresh quarry
cloud hinge
cloud hinge
#

then again lcd pins are not straight forward by any means

fresh quarry
cloud hinge
sullen hamlet
#

Well AI creates a fun little issue. Its non copywritablr content 😄

fresh quarry
#

I can't wait for the first XXX v. OpenAI in US District Court #Y

sullen hamlet
#

So the more people use it. The harder it is to protect it. But vice versa the easier it is to take some of your code to your next job 😄

fresh quarry
#

the problem is that if an AI company tried to claim your code created with their model as their own IP, they would also have to demonstrate the sources of their model

#

which would mean compensating all the people who provided training data

#

which they're never gonna do

cloud hinge
#

singularity ?

sullen hamlet
#

AI being trained on copywrited content means its output must be treated as uncopywritable otherwise it would need to be treated as a derivite work

fresh quarry
#

well some AIs like copilot allow you to only get suggestions from public code

#

but yeah

#

it's a very thorny issue for copyright in general

cloud hinge
fresh quarry
#

like most things in the US it will be settled by whoever has the most money for lawyers

#

see DMCA, etc

cloud hinge
#

what if u have code thats rewritten 60% is it stil l uncopywrittable?

sullen hamlet
#

Its fun for me. It lowers the bar on derivite works.

It also can serve as proof of independant development if your crafty to get around some patent trolls 😄

fresh quarry
cloud hinge
sullen hamlet
#

Why im a little bitter is, a network analyser i got as a highschooler had some bugs in its roms that I patched. I released the patch methods and got a cease and desist despite the company that originally made it closing down in the 70s, but the new IP's owner was spiteful (no roms jist where to patch)

cloud hinge
sullen hamlet
#

Nah it was 2 years back,

#

I just needed a network anaylser that could be used in an automated test situation. But needed to patch some of its command parser

cloud hinge
# sullen hamlet I just needed a network anaylser that could be used in an automated test situati...

thats incredible u can do that. glad you were able to get it doing what was needed. i had a compuer admin at a comunity college get super mad at me for downloading wrapster files from napster once. he was pointing at me saying we got a napster user here making a big deal. when the teacher left he said it was all good lol. i used to download on my 128mb sony memory stick straight onto my camera via usb

#

i watched hackers 2 and 3 recentally. watching those movies gave me great insight into the times

#

@sullen hamlet what are your favorite top 5 hacker movies?

sullen hamlet
#

Probably summer wars. Its stupid but its fun

cloud hinge
#

@sullen hamlet do u know why the code i posted earlier starts the pump when arduino powered up for first time? maybe its cause its not reading arduino yet. plant scale is displayed on screen then it gets its data and displays on screen rest of info then pump stops

#

sumer wars definataly looks interesting indeed

sullen hamlet
cloud hinge
sullen hamlet
#

Add a function where holding both buttons tares the sensor

cloud hinge
sullen hamlet
#

You can mess with it. You might say assume your at target when you first power up.

#

And either button hold or large negative value for a number of readings as a sign to tare

cloud hinge
sullen hamlet
#

You can. But when does the pump then activate? This was why earlier i suggested maybe storing the tare offset for the next power on

#

Yes it will drift. But thats long term assuming its a decent scale

cloud hinge
fresh quarry
fresh quarry
#

but yeah it's funny even google admitted in their recent leaked memos that open source is the best way to capture a market

cloud hinge
fresh quarry
#

but all of them basically say: this is just an emulator, if you want games you have to go to other websites ;) ;)

cloud hinge
cloud hinge
#

@fresh quarry sometimes my computer freezes or and hd wont work and memory only does so much when i turn on my regular ac fan connected to same power line, is that dirty power or a type of bounce happening that causes the glitch, seems kinda like a volt injection or something. sometimes ill even here a random sound that is the same as plugging in usb but no hardware changes i see at that time . do u know about this subjuct by chance?

fresh quarry
cloud hinge
# fresh quarry sounds like a power supply issue probs

i got way too much connected to one ac source but yeah prob has something to do with that. its had other issues in past i think. curious what your interests are lately with coding micro controllers ect, i think i found this discord a while ago but dint see much activity. glad i stayed around to meet you guys. not every day i find like minded folks to chat with

#

i think this lcd mod has potential if it could be hooked to vga for arduino or esp for ultra low power use if u used your own type of backlighting or something of tht nature. https://hackaday.com/2015/10/10/what-to-do-with-old-lcd-screens-hack-your-own-electrochromatic-glass/

There’s something decidedly science fiction-like about electrochromatic glass. A wave of a hand or a voice command and the window goes dark (or goes transparent). You can get glass like this …

#

i just cant get over how the old screen are better than the new ones in size and quality of the new ones, did we go bassacwards in time for this technology?

fresh quarry
cloud hinge
# fresh quarry to be fair PDAs of yore were pretty luxury items, most people attempting to recr...

i was thinking that too, found that semi large normally 50$ and one on ebay for 10$ shipped. not sure if that one is convertable but its at a decent price point. i guess the thing would be if a good old version was to be found and hacked to work would they be available for very long to people that wanted them. i guess its maybe more of a nostalgia thing or maybe there is something to it. i dont think i have the know how but the idea facinates me for some reason becasue there is no other way https://www.denshi-jisho.com/CASIO-EX-word-XD-SP6600-Japanese-English-Electronic-Dictionary.html

cloud hinge
#

@sullen hamlet i havnt had much luck with stopping the pump upon power up. so weird cause i never noticed it before but then again i had relay backwards i think all set up in code and wiring. tried about five different ways but each way gpt offered made other things weird or acting up. using a peristaltic pump so its not a lot. if all else fails maybe ill have to use a motor controller that can switch backward so start up is backwards to begin with. main thing is not to get scale wet

sullen hamlet