You might begin by verifying the pin numbers. WiringPi uses a numbering system that is different from other libraries. A good source for wiringpi pin numbers is the Raspberry Pi Pinout website. Clicking on a pin - for example GPIO 4 will reveal the numbering system specific to the wiringpi library. You should also take a look at the documentation for the ...
Let's keep it short. Your scripts could be failing for so many reasons. If you had a stack trace or an error message of some sort, we could at least speculate on what is going wrong but we have nothing.
This code is not optimal nor robust. Two things are lacking right now:
This is all the more important when your scripts are running ...
The easiest way is to find or create your own adapter cable. If the pi is in a case/housing, run the wires through a hole in the case and tie a knot in the cable so the cable can't be pulled through and disconnected from the Pi easily.
I personally get an Adafruit Perma-Proto HAT for Pi as well as the GPIO Header and you could solder directly to that your ...
You can't reassign the hardware functions of those GPIO.
You will have to physically swap the wiring.
If your application is low speed you could consider bit banging SPI in software. That would allow you to use any pin for any purpose (albeit with a large performance hit).
When a callback is running all other callbacks and the main program are blocked.
You have while loops in the callbacks which means they are blocked for periods of times.
I suggest you redesign and do the minimum amount of processing in each callback. I suggest setting flags only, no while loops.
If you think you have damaged one or more GPIO you can carry out a diagnostic test.
The test is a bash (command line) script called gpiotest.
The test requires the services of the pigpio library (pigpio may be preinstalled).
For the duration of the test nothing must be connected to the GPIO (no LEDs, wires, ribbon cables etc.).
The test ...
The Pi is a 3V3 device, most Arduinos are 5V.
It is not safe to feed a 5V signal into a Pi GPIO.
The Pi only works as a SPI bus master, it controls the clock.
This means that the SPI signals are:
Clock (SCLK) from Pi to Arduino.
Master Out Serial In (MOSI) from Pi to Arduino
Master In Serial Out (MISO) from Arduino to Pi
Chip Select (CS) from Pi to Arduino
I have no reason to doubt that your tests are correct for the RPi.GPIO Python module.
If you need to have more events queued you could use the pigpio Python module. It will queue up hundreds of events.
Just wanted to add that it's not normal for a sensor with specified 4.5 - 5.5V voltage range to be this sensitive to supply voltage. In fact, now that you "fixed" this by using a different power supply there is no guarantee that the new (more stable) value you're reading is any closer to actual CO2 level.
Good gas sensors are expensive, and cheap ...
There should be minimal processing in any interrupt service routine. Set a flag and exit is best.
Any system call is likely to screw the system. Don't sleep, don't call printf.
Debounce is not trivial.
See picod debounce
You have a while loop for each condition. That means the program flow stops at that position until the condition is removed.
I suggest you change those while to if. That should do what you seem to want.
E.g. rather than
while GPIO.input(37) == 0:
if GPIO.input(37) == 0:
You need to look at the .c source code. The .h file is included into the .c source code to make the program.
Using the Pico PIO is an advanced topic. If you are intending to learn how to program I suggest you start by using the Pico GPIO block to generate your waveform. If you are not intending to learn how to program you need to hire a programmer ...
By default, Raspberry Pi installations do not normally enable the SPI functions. Without SPI being enabled, the /dev/spidev0.0 inode is not created. This procedure is taken from https://pimylifeup.com/raspberry-pi-spi/, to which all credit is due.
The procedure outlined above uses the raspi-config tool to enable SPI. In case the link breaks, I've summarized ...