Go to advanced search

by njh
Sat Mar 28, 2020 1:28 pm
Forum: Troubleshooting
Topic: Calculating resistors smd leds and GPIO button input. Minimum or maximum voltage / current
Replies: 15
Views: 458

Re: Calculating resistors smd leds and GPIO button input. Minimum or maximum voltage / current

LED forward voltage varies with current, and also from device to device. When it's close to 3.3V then it's difficult to regulate the current with just a resistor, so use the 5V supply with a transistor as Bob shows. The current you want for the calculation is the smallest of what the circuit can sou...
by njh
Mon Mar 23, 2020 12:36 pm
Forum: Troubleshooting
Topic: Strange WS2801 LED stripe behaviour
Replies: 8
Views: 347

Re: Strange WS2801 LED stripe behaviour

Hi. If you want to try it without a buffer/levelshifter (it might work) try this: https://tutorials-raspberrypi.de/wp-content/uploads/2016/10/Raspberry-Pi-WS2801B-RGB-LED-Stripe-Schaltplatine.png Note the way both GNDs connect together (just connect both black wires to the same terminal on the LED s...
by njh
Tue Mar 17, 2020 10:19 am
Forum: Troubleshooting
Topic: Strange WS2801 LED stripe behaviour
Replies: 8
Views: 347

Re: Strange WS2801 LED stripe behaviour

Yes, all GNDs should connect to a common point. But try not to make loops. If you use the 74AHCT125, pin 14 should be connected to the LED power supply, so it produces the correct voltages for the LEDs. If you have separate power supplies, don't connect anything to the Pi's 5V header pins. You'll ne...
by njh
Tue Mar 17, 2020 9:25 am
Forum: Troubleshooting
Topic: Strange WS2801 LED stripe behaviour
Replies: 8
Views: 347

Re: Strange WS2801 LED stripe behaviour

Unfortunately the only clear example I can find on the web is for WS2812B, which is not quite the same . But to adapt it for WS2801, the pinout for the 74AHCT125 would be 1 - GND 2 - SCLK 3 - CI (to LEDs) 4 - GND 5 - MOSI 6 - DI (to LEDs) 7 - GND (common) 14 - 5V (LED supply) basically using pins 4,...
by njh
Mon Mar 16, 2020 1:10 pm
Forum: Troubleshooting
Topic: Strange WS2801 LED stripe behaviour
Replies: 8
Views: 347

Re: Strange WS2801 LED stripe behaviour

Perhaps it is a voltage level problem? The Pi GPIOs work at 3.3V which is slightly out of spec for WS2801 inputs. If so you might need a 2-channel level shifter or buffer (for instance use a 74AHCT125. If you roll your own circuit, it should be non-inverting; Make sure it won't source any current ba...
by njh
Mon Mar 16, 2020 12:30 pm
Forum: Beginners
Topic: bss138 with LED strip python
Replies: 1
Views: 120

Re: bss138 with LED strip python

I'm guessing you have a discrete bidirectional level shifter made using BSS138 transistors, and perhaps a WS2812B based LED strip? If so: On the Low Voltage (LV or VDD1) side, connect the Pi to the level shifter: GND to GND, 3.3V to LV, and GPIO18 (say) to one of the level shifter's data pins (you o...
by njh
Fri Mar 13, 2020 9:50 am
Forum: C/C++
Topic: Toggle 1st gpio on every Nth 2nd gpio falling edge, more elegant pigpio solution?
Replies: 18
Views: 641

Re: Toggle 1st gpio on every Nth 2nd gpio falling edge, more elegant pigpio solution?

FWIW, I thought your first version was clearer. There's little point worrying about the relative costs of "if" and "%"; or of "1-" versus "1^" in this case. The bigger inefficiency is the busy-polling loops -- instead of which, why not use a callback? Something like: static void cb(int gpio, int lev...
by njh
Wed Mar 04, 2020 3:04 pm
Forum: Beginners
Topic: No. of GPIO pins required for my project
Replies: 3
Views: 226

Re: No. of GPIO pins required for my project

1. It's looking tight! There are 26 usable GPIOs (some pins have special functions like PWM or I2C, but those can be emulated in software on any pin at slightly lower speed), which is exactly(?) the number you need, with none to spare. I'd suggest using an expander to drive the "direction" outputs. ...
by njh
Wed Mar 04, 2020 11:36 am
Forum: Networking and servers
Topic: How to write JSON data on HTTP with Python?
Replies: 7
Views: 353

Re: How to write JSON data on HTTP with Python?

What happens if you try on the server

Code: Select all

    var latest_temperature = req.body.temperature;
    var latest_humidity = req.body.humidity;
by njh
Tue Mar 03, 2020 12:16 pm
Forum: Networking and servers
Topic: How to write JSON data on HTTP with Python?
Replies: 7
Views: 353

Re: How to write JSON data on HTTP with Python?

Your example code seems to be incomplete: You didn't show the part where you make the request. Also can you explain why there are two different IP numbers mentioned in your message? Which one are you connecting to? But if you're getting a 404 response, it probably does mean the URL is wrong. Maybe t...
by njh
Mon Mar 02, 2020 12:08 pm
Forum: Beginners
Topic: Current flow in bi-directional level shifter?
Replies: 4
Views: 285

Re: Current flow in bi-directional level shifter?

Thanks for your answer. Can I know why your solution only works if the shifter is not used bi-directionally? Is it because the series resistor will drop the signal voltage on the Uno end, so only the Pi can understand the Uno but not the other way around? In that case does it help to place the resi...
by njh
Fri Feb 28, 2020 11:07 am
Forum: Beginners
Topic: Current flow in bi-directional level shifter?
Replies: 4
Views: 285

Re: Current flow in bi-directional level shifter?

The MOSFET in the level shifter includes a built-in diode which will conduct whenever the Pi side (normally 3.3V) of either signal is more positive than the Arduino side (normally 5V). So a current can flow into the Arduino's I/O pins, and then through its protection circuitry to its power supply wh...
by njh
Wed Feb 26, 2020 2:37 pm
Forum: Troubleshooting
Topic: Relay turns on when RPi boots
Replies: 2
Views: 104

Re: Relay turns on when RPi boots

Also, note that pins 3,5 (GPIO2,3) have onboard pull-ups to 3.3V (for a 5V device this might register as either high or low, depending how it works; with Bob's corrected circuit it will register as high). Better use a different GPIO pin if that's not what you want.
by njh
Tue Feb 25, 2020 11:24 am
Forum: General discussion
Topic: Can a 12v relay be run using inputs from a different sensor.
Replies: 6
Views: 231

Re: Can a 12v relay be run using inputs from a different sensor.

Yes, it can all be done! As always, try to find out as much as possible about the components and modules you will be using. Relay modules vary. Many 12V ones will work from 5V, but it would be better to use a 5V relay. Important : Make sure the relay can be controlled from a 3.3V signal without dang...
by njh
Thu Feb 20, 2020 3:43 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: Flying Fish sensor / LM393 / GPIO problem
Replies: 1
Views: 177

Re: Flying Fish sensor / LM393 / GPIO problem

If you are willing to bodge the comparator module, you could maybe try adding hysteresis in the form of a large (say, 3.3M) resistor between the OUT and AC signals (pins 1 and 3 of the LM393, or various other places on the PCB), which might settle the oscillations. I'm surprised they didn't do that ...
by njh
Wed Feb 19, 2020 1:37 pm
Forum: Troubleshooting
Topic: 5v relay controlling with Raspberry Pi
Replies: 7
Views: 231

Re: 5v relay controlling with Raspberry Pi

I've checked the schematic, the power for the relays can't be separated from the optocoupler, unlike those fairly common arduino 4-relay boards. Sure it can - just remove the link between COM and GND (not that the OP needs to) and the input are completely isolated. https://www.velleman.eu/downloads...
by njh
Wed Feb 19, 2020 10:38 am
Forum: Troubleshooting
Topic: 5v relay controlling with Raspberry Pi
Replies: 7
Views: 231

Re: 5v relay controlling with Raspberry Pi

Hmm. Let's have a look. Ah. That one seems to be common GND. So ignore everything I just said. It should be safe. But you might have another problem - if it was designed for 5v-12v, it might not operate reliably with 3.3v signals? I expect it will be fine in this case, but if it doesn't work, the qu...
by njh
Tue Feb 18, 2020 8:05 pm
Forum: Troubleshooting
Topic: 5v relay controlling with Raspberry Pi
Replies: 7
Views: 231

Re: 5v relay controlling with Raspberry Pi

As you noticed, this has been covered many times. https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=83372&p=1225448#p1225448 It's not safe. You need a transistor because the opto-isolators (which contain LEDs) are typically connected in series with a resistor between the input and 5v. So they ...
by njh
Mon Feb 17, 2020 2:18 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: Minimize time between I2C sensor readings
Replies: 2
Views: 190

Re: Minimize time between I2C sensor readings

Some minor suggestions, if you haven't tried them already: If your device supports it, try increasing i2c_arm_baudrate to 400000 If your device supports it, try multi-byte read (read_i2c_block_data(addr,reg,2) or read_word_data) to see if you get both bytes in one go Printing to the terminal can tak...
by njh
Mon Feb 17, 2020 10:47 am
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: mpu6050 Stationary state value problem
Replies: 1
Views: 136

Re: mpu6050 Stationary state value problem

Can you explain
- What software have you used
- What readings are you getting
- What is wrong?

An XYZ accelerometer should not read all zeroes unless it is in free-fall.
by njh
Fri Feb 14, 2020 10:48 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: Wiring help for R701 Stepper Motor Driver
Replies: 6
Views: 272

Re: Wiring help for R701 Stepper Motor Driver

Yes, I would defintely use a transistor, otherwise there's a real risk of pulling the GPIOs above 3.3v and it takes little or no current to damage them! I hope that has not happened already. A ground connection shouldn't be needed if I understood that diagram in the pdf. It's hard to debug this stuf...
by njh
Fri Feb 14, 2020 12:54 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: Wiring help for R701 Stepper Motor Driver
Replies: 6
Views: 272

Re: Wiring help for R701 Stepper Motor Driver

From a quick look at that datasheet, it appears to be driven through opto-isolators that expect a common 5V rail, and current sink control signals (this is not unlike many kinds of relay driver boards). There are 2 control signals per motor (direction, step). But the Pi uses 3.3V logic levels on its...
by njh
Mon Feb 03, 2020 7:21 pm
Forum: C/C++
Topic: Math Calculations Are Slightly Off
Replies: 3
Views: 807

Re: Math Calculations Are Slightly Off

How wrong are the results? If the differences are tiny, it might not be wrong at all. Many math.h functions are not covered by the IEEE standard and won't always give the same answer on different platforms (though the Pi's accuracy should not be uniformly worse than a x86 PC). There are also compile...
by njh
Wed Jan 29, 2020 11:39 am
Forum: Other projects
Topic: Connected motorcycle helmet
Replies: 1
Views: 288

Re: Connected motorcycle helmet

If the GSM/GPS card uses all the pins then you can't add another Hat. But you might be able to gain access to some I2C pins either by design or by bodging wires onto the card or the Pi, then use an I2C-connected accelerometer. Alternatively if the card has a Compass/magnetometer function, it might a...
by njh
Wed Jan 29, 2020 10:46 am
Forum: General discussion
Topic: 6V lock solenoid with battery
Replies: 3
Views: 302

Re: 6V lock solenoid with battery

Agree with the above. People like MOSFETs because they seem easy to understand, can be very power-efficient, and work well with 5V logic levels; but not all of them work well at 3.3V and high currents. In some cases a Darlington device like TIP121 might be better (remember the diode and a base resis...

Go to advanced search