Skip to main content
11 votes
Accepted

Controlling Raspberry Pi GPIO with c and Python

The BCM2711 SOC in the Pi4 has a new Peripheral implementation (all previous SOC had the same Peripheral implementation) which provides additional functionality. This includes the original ...
Milliways's user avatar
  • 60.5k
5 votes

How to enable SPI1 and SPI0 at the same time?

In order to use the spi1 port of the Raspberry Pi, you need to set the dtoverlay=spi1-1cs in /boot/config.txt. By default this will use the pins (https://pinout.xyz/pinout/spi): MOSI - pin 38 MISO - ...
steviethecat's user avatar
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. ...
RalfFriedl's user avatar
  • 2,188
5 votes
Accepted

Pi locking up trying to use rising/falling edge detection

Solution: Add: dtoverlay=gpio-no-irq to /boot/config.txt. Previously the kernel would automatically disable interrupts when you set one of rising/falling edge detection methods but that apparently ...
Nick's user avatar
  • 195
5 votes

WiFi packet sniffer for RPi in c++

Sniffing other WiFi networks you are not associated must be supported by the WiFi chip, called monitor mode. If you look at the chip configuration on the RasPi with: rpi ~$ iw list Wiphy phy0 --- ...
Ingo's user avatar
  • 42.2k
5 votes
Accepted

Shutdown from C program

Call system(): #include <stdlib.h> ... system("sudo shutdown now");
Joep's user avatar
  • 111
4 votes
Accepted

How do I read just the Pi's serial number with a program coded in C?

You will have to do something along the following lines. #include <stdio.h> #include <stdint.h> uint64_t getSerial(void) { static uint64_t serial = 0; FILE *filp; char buf[512];...
joan's user avatar
  • 71.2k
4 votes
Accepted

DHT11 or GPIO Library to Use in C

For the GPIO libraries available on the Pi see http://elinux.org/RPi_GPIO_Code_Samples For C the usual choices are wiringPi bcm2835 pigpio (github)
joan's user avatar
  • 71.2k
4 votes

Raspberry Pi Baremetal Programming

Well, maybe you forgot to put "break" into your switch block case? switch (mode) { case GPIO_OUTPUT: *GPFSEL |= (1 << gpio_bit); break; case GPIO_INPUT: ...
NameNotFound's user avatar
4 votes
Accepted

Imprecise result after bitwise operation on GPIO registers

You have misunderstood the usage of the set and clear registers. If bit x is 1 in the set register then GPIO x is set high. If bit x is 0 then the level of GPIO x is not affected (i.e. if high it ...
joan's user avatar
  • 71.2k
4 votes
Accepted

Errors compiling C program with time.h library

This type of "clock" support isn't C99 but POSIX. Try removing -std=c99 from your compilation command and compile your code. If that doesn't work, Add #define _POSIX_C_SOURCE 199309L to your code ...
karan's user avatar
  • 116
4 votes

What if I flash the ARM processor with some random firmware

No, that won't be possible. As such, ARM CPUs inside the Raspberry pi SoC are slaves to the videocore. They cannot even go out of reset until the videocore executes the right firmware which allows ...
Dmitry Grigoryev's user avatar
4 votes

How do I implement an interrupt service routine on Raspberry Pi?

wiringPi uses interrupts, e.g. with the wiringPiISR function. pigpio uses interrupts, e.g. with the gpioSetISRFunc function. lgpio uses interrupts. e.g. with the gGpioSetAlertsFunc function. None of ...
joan's user avatar
  • 71.2k
3 votes

Interfaces besides sysfs for GPIO programing in C

The sysfs system filesystem access to the GPIO is all that is provided as a standard library from Linux. There are dozens of third party libraries. See http://elinux.org/RPi_GPIO_Code_Samples for ...
joan's user avatar
  • 71.2k
3 votes

python library to generate pulse frequency of "n" hz

Actually the pigpio Python module can do this quite easily for a single stepper. You would use the wave functions in combination with wave chains. Say you want a ramp of 20ms, 10ms, 5ms, 2ms, 1ms. ...
joan's user avatar
  • 71.2k
3 votes

pigpio servo control

The only problem I can see with the code is that it terminates straight away. When the program ends the pigpio library will shut down so servo pulses will stop. I suggest you add a time_sleep(10) or ...
joan's user avatar
  • 71.2k
3 votes
Accepted

PN532 NFC module not working on Pi 3

Steps to install NFC PN532 The Raspberry pi 3 has changed things around a bit: ttyAMA0 now refers to the serial port that is connected to the bluetooth. The old serial port is now called ttyS0. So if ...
Bruno A. Klein's user avatar
3 votes
Accepted

System Calls From C Code

If you need to provide input for a command, you should do it via input substitution or pipes, like this: system("echo 123456 | gpg --passphrase-fd 0 gpgTest.py.gpg"); system("gpg --passphrase-fd 0 ...
Dmitry Grigoryev's user avatar
3 votes

UART interrupt in Raspberry PI with c or c++

The linux UART API (really, the POSIX termios API, but you should use the system man pages for implementation specifics; everything is mostly in man 3 termios) creates a file descriptor that can be ...
goldilocks's user avatar
  • 59.3k
3 votes

How to run a persistent program at boot which prints to console?

If you want the output printed to console, you are going to have to set that up. There are lots of things started at boot, and they can't all print to console or it would be an interleaved mess. So, ...
goldilocks's user avatar
  • 59.3k
3 votes
Accepted

Does select/multithreading make sense when dealing with multiple DS18B20 and GPIO reads simultaneously?

For asynchronous or polling access, the better approach is to serialize your hardware access into a single thread for a given bus. This thread should run at relatively high priority and establish the ...
crasic's user avatar
  • 3,003
3 votes
Accepted

How to access to I2C software with wiringpi library-

As you say in your comment just use the wiringPiI2CSetupInterface function. This function is actually called by wiringPiI2CSetup. E.g. rather than fd = wiringPiI2CSetup(0x31); Use fd = ...
joan's user avatar
  • 71.2k
3 votes

Print the amount of vibration on the screen in C

The Raspberry Pi does not have any analog input PINs. Thus you will not be able to interpret analog input signals without some additional hardware. In order to be able to read not only HIGH or LOW ...
oh.dae.su's user avatar
  • 934
3 votes
Accepted

popen() vs netcat

I bet it has to do with buffering you're doing on streams. man popen has this line Note that output popen() streams are block buffered by default. You'll have to increase the buffer size to ...
Dmitry Grigoryev's user avatar
3 votes
Accepted

How do I implement an interrupt service routine on Raspberry Pi?

There is no way to call userspace code from an ISR. Unlike system calls which run on the stack of the userspace program, interrupt handlers use internal kernel memory for the stack. Since that memory ...
Dmitry Grigoryev's user avatar
3 votes

Communication Raspberry Pico and 3B+

It is unrealistic to expect a "tenfold" increase. There are many ways of communicating with the Pico (all the usual suspects in fact). You may be interested in Pico as a computer peripheral.
Milliways's user avatar
  • 60.5k
3 votes

Pi Pico: Software Reset using the C SDK?

I don't see another way than using the watchdog. The example in the SDK documentation looks similar to this: void software_reset() { watchdog_enable(1, 1); while(1); } This busy waits 1ms ...
user141389's user avatar
2 votes

Write an OS for Raspberry Pi in C

Try this instead: http://www.valvers.com/open-software/raspberry-pi/step01-bare-metal-programming-in-cpt1/ Also, the x86 experience is a bit different. It may be applicable to general ARM bare ...
Dennis Ng's user avatar
  • 121
2 votes

Create a Terminal Menu GUI in C

You could alternatively use this library called Termbox.
tprk77's user avatar
  • 121
2 votes

C Program compilation problem

The problem is with your printf line. printf(hello world; you are missing the closing parenthesis ")", You are also missing quotes around the text "Hello World" change that line to: printf("hello ...
Steve Robillard's user avatar

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