Go to advanced search

by ghp
Fri Jun 18, 2021 6:32 am
Forum: Python
Topic: Initializing variables in a class
Replies: 10
Views: 214

Re: Initializing variables in a class

Python classes provide an __init__ method which is the 'constructor'. See https://docs.python.org/3/reference/datamodel.html#object.__init__ For your code, it could look like this: class LEDStrip: def __init__(self, pin, numPixels, brightness=0.2): self.numPixels = numPixels self.brightness = bright...
by ghp
Thu Jun 17, 2021 2:25 pm
Forum: Automation, sensing and robotics
Topic: Raspberry Pi and sensors in a PCB using Easyeda
Replies: 11
Views: 424

Re: Raspberry Pi and sensors in a PCB using Easyeda

fritzing has an option to design PCB from the breadboard sketch. See https://fritzing.org/learning/tutorials/designing-pcb/ Instead of using the Pi, use a 'generic shrouded pin header' with 40 pin (where you solder a pin header later which is attached to pi). Use the 'fritzing fab', pay some money a...
by ghp
Wed Jun 16, 2021 6:07 pm
Forum: Python
Topic: SparkFun Qwiic Single Relay GUI
Replies: 2
Views: 151

Re: SparkFun Qwiic Single Relay GUI

You need a frontend (aka GUI) and a backend (aka hardware interface). Unlikely you find exactly this combination. For the frontend, you can use a simple GPIO on/off think like https://www.raspberrypi.org/forums/viewtopic.php?t=261675 The backend is I2C, there are example available https://github.com...
by ghp
Wed Jun 16, 2021 6:14 am
Forum: Python
Topic: Storing Motor DutyCycle so I can increase and decrease
Replies: 2
Views: 167

Re: Storing Motor DutyCycle so I can increase and decrease

Simple solution: a variable named motor1_current_dutycycle on global scope and refer to it with "global motor1_current_dutycycle" in the code. motor1_current_dutycycle = 50 def a_method(): global motor1_current_dutycycle motor1_current_dutycycle += 20 Drawback is that you have the checks f...
by ghp
Mon Jun 14, 2021 5:40 pm
Forum: Automation, sensing and robotics
Topic: Running Ultrasonic Sensor on RP4 with MCP3008
Replies: 11
Views: 460

Re: Running Ultrasonic Sensor on RP4 with MCP3008

The sensor supports a min and max set potentiometer. Try to change their settings. Perhaps the current set range is too narrow. There is also a remark in the datasheet "Mounting Consideration:The performance of this sensor can be influenced by direct metal contact.This zone is12mm/.50"meas...
by ghp
Sun Jun 13, 2021 4:44 pm
Forum: Python
Topic: Python omx wrapper while true /closes after a few hours
Replies: 1
Views: 148

Re: Python omx wrapper while true /closes after a few hours

Modified the script a bit and have it running here on a pi4 since 24h. Basic change is to add a small delay which limits the DBUS polling rate to 5Hz. And tried to make it polite and paused the video before setting new position(although I think this is not root cause of the problem). #!/usr/bin/env ...
by ghp
Sat Jun 12, 2021 10:01 am
Forum: Python
Topic: Flask: How to make this page not reloading?
Replies: 6
Views: 318

Re: Flask: How to make this page not reloading?

Add REST API for switching the LED to the flask app. Many tutorials, e.g https://pythonbasics.org/flask-rest-api/ Add the REST API calls to your web page, this requires javascript. Many tutorials, e.g. https://stackoverflow.com/questions/36975619/how-to-call-a-rest-web-service-api-from-javascript or...
by ghp
Fri Jun 11, 2021 9:50 pm
Forum: Automation, sensing and robotics
Topic: Running Ultrasonic Sensor on RP4 with MCP3008
Replies: 11
Views: 460

Re: Running Ultrasonic Sensor on RP4 with MCP3008

Connect all GND together: GND-Sensor (from the 24V) ------ GND Voltage divider ------ AGND ADC pin 14 ------- DGND ADC pin 9 ------- GND Pi First approach is: just connect them together. Second approach: when you worry about sub-millivolt, the ultimate bit of performance, noise, thermal effects, dri...
by ghp
Fri Jun 11, 2021 7:43 pm
Forum: Automation, sensing and robotics
Topic: Running Ultrasonic Sensor on RP4 with MCP3008
Replies: 11
Views: 460

Re: Running Ultrasonic Sensor on RP4 with MCP3008

The values of 22, 10 Ohm are far too low. The datasheet says min 500 Ohm (meaning more is possible) for the total load. In the sketch a proposal. And I think you missed the GND connection. The voltage divider, ADC and PI have a common GND line. Double check the voltage divider resistors that GND is ...
by ghp
Fri Jun 11, 2021 5:20 pm
Forum: Automation, sensing and robotics
Topic: Running Ultrasonic Sensor on RP4 with MCP3008
Replies: 11
Views: 460

Re: Running Ultrasonic Sensor on RP4 with MCP3008

How do you connect the sensor to the ADC chip ? Sketch and photo is helpful. How do you scale down the Sensor voltage output (0..10V) to (0..3.3V) for the ADC ? Does the voltage across the sensor (0..10V, load resistor 500Ohm or more) correlate with distance ? In the datasheet there is a remark abou...
by ghp
Thu Jun 10, 2021 4:19 am
Forum: Automation, sensing and robotics
Topic: Audio sensing
Replies: 3
Views: 264

Re: Audio sensing

Audio sensing is difficult.
Level sensing can be done with capacitive sensors.
Large scale https://www.instructables.com/Capacitiv ... el-Sensor/
Small scale: https://www.adafruit.com/product/4026
by ghp
Thu Jun 10, 2021 3:53 am
Forum: Python
Topic: Need help with finding library to generate tones via I2S mono amp and speaker
Replies: 4
Views: 236

Re: Need help with finding library to generate tones via I2S mono amp and speaker

Some years ago I used sonic-pi with an OSC interface. python-osc library is available. Did not check if the OSC api still exists. From my scratchClient code, here an untested snippet which you could use as a starting point: import socket try: import pythonosc import pythonosc.osc_message_builder exc...
by ghp
Wed Jun 09, 2021 7:47 am
Forum: Other projects
Topic: Inputting DMX to Raspberry Pi
Replies: 1
Views: 124

Re: Inputting DMX to Raspberry Pi

There is an arduino library for DMX, client and server. This can be a starting point for your code. The physical layer is identical to RS485. There are rs485 breakout for 3.3V available. The pi will be an end device, so you need to use a terminal resistor of 120 Ohm, most breakout board already cont...
by ghp
Wed Jun 09, 2021 7:39 am
Forum: Other projects
Topic: PI Zero W - Hottub Controller - Help needed
Replies: 9
Views: 314

Re: PI Zero W - Hottub Controller - Help needed

Think the GND connection of ULN to PI is missing in your description. (1) you need to connect GND of ULN2003 to GND of PI. Do not break this connection while system in operation. Best case use a soldered connection. (2) the relay current will flow through this wire. 70mA * 8, so ensure it is not too...
by ghp
Mon Jun 07, 2021 6:13 am
Forum: Python
Topic: Parse a text field with spaces into tkinter combobox
Replies: 2
Views: 126

Re: Parse a text field with spaces into tkinter combobox

Here a sample which seems to work. I use a list to collect the values and set this list into the combobox. # simulate a result from df command data = """Mounted on / /dev /dev/shm /run /run/lock /sys/fs/cgroup /boot /run/user/A B C """ import io buf = io.StringIO(data) ...
by ghp
Sun Jun 06, 2021 10:11 pm
Forum: Other projects
Topic: Excavator bucket position
Replies: 8
Views: 371

Re: Excavator bucket position

Build a small scale model (from plywood, broomstick or other cheap material), using RC servo to move the parts. Attach the sensors and check your algorithms whether you achieve the precision you need when the model is moving. As already discussed do not use magnetometer, will not work when steel is ...
by ghp
Fri Jun 04, 2021 10:49 am
Forum: Python
Topic: Get data from motionsensor with long cable
Replies: 1
Views: 80

Re: Get data from motionsensor with long cable

hall_connection.png The spec of this sensor is 5 to 15V, so I propose a separate power supply of 12V, a simple, low current 12V wall adapter is good for this. Current on hall output is prox 10mA. There are no data given for the sensor, but usually this should be possible. Use an optocoupler to isol...
by ghp
Thu Jun 03, 2021 8:17 pm
Forum: Automation, sensing and robotics
Topic: GPIO inputs lockout
Replies: 5
Views: 261

Re: GPIO inputs lockout

Some measures to protect inputs are in the following text (of course use 3.3V instead of 5V) https://www.digikey.de/en/articles/protecting-inputs-in-digital-electronics Optical isolation helps in difficult situations. Look for PLC input stage designs. E.g. https://www.edn.com/product-how-to-isolated...
by ghp
Mon May 31, 2021 5:54 am
Forum: Python
Topic: open 20 .py in one command ?
Replies: 7
Views: 466

Re: open 20 .py in one command ?

This find command (whether executed from ssh or local) looks for py files and executes one after the other. This is the simple thing. You can find this out yourself: write a bunch of py files, each printing out a distinct text, wait some time and print out text again. for i in range(10): with open(&...
by ghp
Mon May 31, 2021 5:21 am
Forum: Python
Topic: Trying to remove some elements from JSON data
Replies: 5
Views: 247

Re: Trying to remove some elements from JSON data

When you parse json, you get a nested python object, consisting of array and/or dict, nested in many levels if needed. Then it is up to the python code to navigate along the specific structure of the 'thing'. There is no 'select' method available as you know it in databases. import json response = &...
by ghp
Thu May 27, 2021 4:30 pm
Forum: Automation, sensing and robotics
Topic: Please HELP. How to connect anemometer and weather vane (rs485)?
Replies: 2
Views: 211

Re: Please HELP. How to connect anemometer and weather vane (rs485)?

You need a RS485 adapter. There are many, e.g. https://www.waveshare.com/rs485-board-3.3v.htm Connect Tx, Rx from pi to DI, RO from adapter. RSE can be left open when only receiving data. Then you need a power source of 24V, connection to sensor is simple, do not forget to connect GND of PI to GND o...
by ghp
Thu May 27, 2021 3:19 pm
Forum: Automation, sensing and robotics
Topic: Connecting a 433mhz transmitter to a 9v battery or 12v adapter
Replies: 3
Views: 236

Re: Connecting a 433mhz transmitter to a 9v battery or 12v adapter

If you use external supply, connect the GND together

GND-PI -------- GND-Transmitter ------ GND_EXTERNAL
by ghp
Thu May 27, 2021 5:29 am
Forum: Automation, sensing and robotics
Topic: Programming for a ship model
Replies: 52
Views: 4851

Re: Programming for a ship model

Could it be that the stepper motor controller tries to control it as a bipolar motor while I'm using a unipolar motor? Many things are possible, can't say for sure. Did you check this setup on the lab bench before putting it in place ? What are the possible problems - power supply for the motor shi...

Go to advanced search