12 votes

Control Hardware PWM frequency

According to this formula: pwmFrequency in Hz = 19.2e6 Hz / pwmClock / pwmRange We can set pwmClock=1920 and pwmRange=200 to get pwmFrequency=50Hz: 50 Hz = 19.2e6 Hz / 1920 / 200 I test it on ...
user avatar
  • 316
5 votes

How to read Wiegand card ID?

You can reliably read Wiegand devices with my pigpio library. There is C, C++, and Python example code at http://abyz.me.uk/rpi/pigpio/examples.html
user avatar
  • 66.5k
5 votes
Accepted

Using BCM GPIO pin numbers with wiringPi C library

To set a pin numbering scheme you use one of four Setup functions: int wiringPiSetup (void); int wiringPiSetupGpio (void); int wiringPiSetupPhys (void); int wiringPiSetupSys (void); To use BCM GPIO ...
user avatar
5 votes
Accepted

I2C using wiringPi or IOCTL in C, more than 2 bytes

I'm wondering, may understand that Raspberry Pi's I2C is in fact the SMBus version of I2C ? I don't think it is limited in that sense but that is the normative way to use it. There is no such ...
user avatar
  • 55.8k
5 votes
Accepted

WiringPi: change output of GPIO pins synchronously?

It's possible with a very minor caveat. When you set a GPIO high or low you write to one of two registers. A set register to set selected GPIOs high. A clear register to set selected GPIOs low. ...
user avatar
  • 66.5k
5 votes

WiringPi error etates I'm not Using an RPi

I ran into this same problem using Java with Raspbian on a Pi 3 and found a posting from the Pi4J development team indicating that the problem is that when Pi4J is automatically installed, a copy of ...
user avatar
5 votes

Is this behaviour of GPIO pins normal?

On many electronics boards, GPIO pins are set to a "floating voltage" (not on, not off, just somewhere in the middle) until the pin actually gets initialized or used for the first time. Remember, ...
user avatar
  • 3,312
5 votes

Is this behaviour of GPIO pins normal?

Most of the pins are configured as inputs. This is normal, and usually the safest option. All of these inputs are put into a defined state with either a pullup or pulldown. The normal values are ...
user avatar
  • 53.5k
5 votes
Accepted

Cross compiling for RPi - error while loading shared libraries

Shared or dynamic libraries are needed at run time. So you need the library not only on the build system but in on the target system, in this case on the PI. This is different from static libraries. ...
user avatar
  • 2,160
4 votes

Raspberry Pi to Arduino (Leonardo) avoiding latency

If you need low latency communication, know that interpreted code is always going to be relatively slow. Code compiled into CPU-native instructions, as C and C++ almost always are, will run much ...
user avatar
  • 141
4 votes

Can we determine the mode of a GPIO pin?

Yes you can. Use getAlt(int pin) method for that from libwiringPi.so (or wiringPi.h). It will give you direction of that pin.
user avatar
  • 196
4 votes
Accepted

WiringPi: using interrupts with Python

Interrupts are not supported in the python version of wiringPi2 because it's a wrapper of the original wiringPi C library. To quote the publisher of the module in issue 8 of it's github: ... I will ...
user avatar
  • 86
4 votes
Accepted

Using Wiringpi in crontab to control GPIO pins on RaspberryPi

The most common error in crontabs seems to be not giving the full paths to programs or data used. Use the which command to find where gpio is stored on your machine (probably /usr/local/bin/gpio) and ...
user avatar
  • 66.5k
4 votes

Output Accurate, Detailed PWM signal

The Pis with 40 pin expansion header (and the compute module) have two hardware PWM channels which you should be able to use with wiringPi. That would give you control of two ESCs. From the software ...
user avatar
  • 66.5k
4 votes
Accepted

WiringPi pin numbering for RPi 2B and 3B?

The side where your micro sd card is the upper side, the first number is your gpio pin number from the RPi itself (in ascending order) then there is the Broadcom number, and between the parenthesis as ...
user avatar
4 votes
Accepted

How do you force wiringPI library to use local time instead of UTC time?

The use of UTC time seems to be hardcoded in ds1302 utility. Note the following line: gmtime_r (&now, &t) ; This converts your system time to UTC, before writing it to the DS1302 chip. When ...
user avatar
4 votes

Is this behaviour of GPIO pins normal?

The programmable pins (General Purpose Input/Output) can be used in a variety of ways - but not all at the same time. Before the point where power is applied to the RPi's Systen-on-Chip (Soc) AND it ...
user avatar
  • 3,583
4 votes
Accepted

how to read output of gpio readall

The ALTx signifies the alternate functions of a pin. See this for a better understanding. BCM is the pin number when using GPIO (aka BCM) numbering scheme, and wPi is the pin number when using the ...
user avatar
  • 1,456
4 votes

Wiring Pi - Root not required?

wiringPi was modified to allow the use of /dev/gpiomem rather than /dev/mem to access the GPIO. To access the GPIO via /dev/mem requires root privileges. By default /dev/gpiomem can be accessed by ...
user avatar
  • 66.5k
4 votes
Accepted

Why is WiringiPi unable to find hardware revision?

WiringPi is not supported on any other operating systems than Raspbian - so its likely this feature is not supported in Ubuntu. WiringPi is developed directly on a Raspberry Pi running 32-bit ...
user avatar
  • 6,161
4 votes

GPIO pins not changing state

You are confusing wiringiPi numbers with GPIO numbers. The sysfs interface uses GPIO numbers. The highlighted GPIO is GPIO 26 (wiringPi 25). GPIO 25 is connected to pin 22. See https://pinout.xyz/
user avatar
  • 66.5k
4 votes
Accepted

multiple UARTs on the 40-pin

so where was one big misunderstandings. thanks to @joan for pointing to the docs and @tlfong01 for their link to their article: https://penzu.com/public/b94e6b30 essentially, on the raspberry 4, there ...
user avatar
  • 151
3 votes

How can I use a usb barcode reader with my raspberry pi

Your card reader is a usb card reader that acs like a keyboard and spits out the value as if keys were being pressed. It looks as if you should be able to use the fgetc()function in php to get ...
user avatar
3 votes

pwm fan on pin 18 help!

Your fan probably has a voltage drop that is too high for the Pi's GPIO to power it. The GPIO pins only output 3.3v 50ma MAX.
user avatar
  • 6,185
3 votes

How to run 2 servos with wiringpi2 on Raspberry pi 2

Lucky to see this question, I just spent weeks on controlling two servo (SG90) using WiringPi and programming in C, there're three things that I recommend. 1.Using BCM GPIO instead of WiringPi Pin ...
user avatar
  • 31
3 votes

Can we determine the mode of a GPIO pin?

Yes, you can determine the current mode of a gpio. You'd have to search the wiringPi documentation and source code to see if a method is implemented by wiringPi. My pigpio library provides the C I/F ...
user avatar
  • 66.5k
3 votes

Raspberry Pi to Arduino (Leonardo) avoiding latency

Between a Raspberry Pi and an Arduino, using UART is the best option. I know because this is my 3rd project doing so. (And also USB is impossible) You should run the UART at 1000000 baud. Default ...
user avatar
  • 391
3 votes

I2C using wiringPi or IOCTL in C, more than 2 bytes

It's a limitation of wiringPi. It only implements a couple of SMBus commands. As you say using SMBus commands you are limited to 32 bytes. Using the raw device you can send hundreds at a time. I'm ...
user avatar
  • 66.5k
3 votes
Accepted

How to address gpio pins

There are several different GPIO numbering schemes. You need to ensure that the software you are using is using the numbering scheme you expect. See https://pinout.xyz/ for the gory details. The ...
user avatar
  • 66.5k
3 votes
Accepted

How to read gpio current mode in shell or wiringpi

pigpio offers a method to read the GPIO mode from C, Python, and the shell. C http://abyz.me.uk/rpi/pigpio/cif.html#gpioGetMode Python http://abyz.me.uk/rpi/pigpio/python.html#get_mode shell http://...
user avatar
  • 66.5k

Only top scored, non community-wiki answers of a minimum length are eligible