GPIO, I2C, SPI and Serial with Raspberry Pi 4

  Переглядів 7,649

NA5Y

NA5Y

День тому

In this video I do some playing around with the GPIO pins on a pi4.
My github repo
github.com/thaaraak/gpio
BCM2835 Library and Book
www.airspayce.com/mikem/bcm2835/
www.amazon.com/gp/product/187...
WiringPi
github.com/WiringPi/WiringPi
BCM2711 Datasheet
datasheets.raspberrypi.org/bc...
Pi 4 GPIO Header layout
www.raspberrypi.org/documenta...
My earlier MAX7219 example with STM
• GPS Clock - Part 2 LSE...
0:00 Intro
1:50 Pi hardware notes
2:20 GPIO Pins layout
6:02 Basic GPIO Access methods
9:46 The wiringPi and BCM2835 libraries
12:10 GPIO Output - Simple Blink Program
19:32 GPIO Input - Input processing
24:57 Raspberry Pi IoT book
25:31 I2C Example with ADS1115 ADC
35:00 SPI example with MAX7219 8 digit LED driver
41:22 Reading serial with a GPS receiver
43:13 Python serial example
44:28 C serial example with wiring Pi

КОМЕНТАРІ: 18
@LuisAngelFuentesAlvarez
@LuisAngelFuentesAlvarez 9 місяців тому
Oh man!! Thanks!! Saludos desde méxico :D
@na5y
@na5y 9 місяців тому
Thank you Luis!
@Russel4973
@Russel4973 2 роки тому
Great video! So, the bcm2835_init you showed was your modifications to the original lib? What I see on GitLab (Mike McCauley's) is different. It doesn't inspect /proc/device-tree/soc/ranges.
@na5y
@na5y 2 роки тому
I didn't modify the bcm2835 library at all (at least that I recall - it was a while ago ;) ). The copy I have was from a while back and must have changed since I took it. The library seemed to work pretty well although I didn't go through it exhaustively. Thank you for the comment!
@Russel4973
@Russel4973 2 роки тому
@@na5y Thanks for responding. The BCM2835 in Github is different. I must be looking at a different one.
@na5y
@na5y 2 роки тому
@@Russel4973 Just checked - Version 1.68 of bcm2835 was the version I used (its up to 1.71 I see now)
@qzorn4440
@qzorn4440 11 місяців тому
Great RPi GPIO information. I am trying to find a GPIO PWM example using OPi-GPIO on the Orange Pi-5 SBC Debian-Bullseye. Do you have a simple servo Pan/Tilt example? Thank you.
@na5y
@na5y 11 місяців тому
WiringPI has support for PWM - although I haven't tried it myself. There's this link out there that might be of interest. www.electronicwings.com/raspberry-pi/raspberry-pi-pwm-generation-using-python-and-c I suppose I should have included servos being an RC enthusiast! Thank you for the comment
@qzorn4440
@qzorn4440 11 місяців тому
@@na5y This looks very interesting. I am learning more about GPIO design as where Raspberry Pi software works nicely. Thank you so much.
@Atonix99
@Atonix99 2 роки тому
I need help with a project I am developing for my college degree... I am trying to connect 2 sensors (they need 5V and 170mA each) to my Raspberry Pi via SPI. They are both energised, and connected to the same miso, mosi and clock, as they should be. The problem comes with connecting the SS. I need two more wires for each radar: 1 for the SlaveSelect and another one for PinTurnOn. Is it mandatory that I use GPIO 24 and GPIO26 as SlaveSelect? Or I can use any I want? The thing is I am using any GPIO (free of course) I want at this moment and the radars work ONLY when the other radar is DISconnected. If I connect both, the screen just doesnt show anything, but as soon as I unplug one of them, the other one starts working... Any idea? I can give more dets if you were willing to help, thank you very much for your attention.
@na5y
@na5y 2 роки тому
There's nothing special about SS (also referred to as CS - Chip Select). You can use any GPIO for CS duties - and usually the code library will have allowance for that (some code libraries fix MOSI, MISO and CLK to specific pins). You'll definitely have to have one GPIO/CS pin allocated per device you have attached and then you just have to bring it low on the device you want to use and keep it low throughout the SPI transaction. Once the transaction is done bring it high. I hope this helps. Debugging SPI can be a bit of a pain at times - have a look at this video for a separate SPI example: ukposts.info/have/v-deo/kJOIeoB_omuc1X0.html
@na5y
@na5y 2 роки тому
I had to remind myself of the bcm2835 code and they do fix CS to 24 and 26 bcm2835_gpio_fsel(RPI_GPIO_P1_26, BCM2835_GPIO_FSEL_ALT0); /* CE1 */ bcm2835_gpio_fsel(RPI_GPIO_P1_24, BCM2835_GPIO_FSEL_ALT0); /* CE0 */ So it looks like you have to use those pins for CS if you are using that library
@na5y
@na5y 2 роки тому
Edit: Never mind - I found it - you call this function void bcm2835_spi_chipSelect(uint8_t cs) Before the SPI transaction to set the relevant SPI CS pin Looking at the bcm2835 library code I don't see how it lets you control the two different CS pins. You might have to look into using bcm2835_aux_spi_begin(void) - which uses a separate set of SPI pins bcm2835_gpio_fsel(RPI_V2_GPIO_P1_36, BCM2835_GPIO_FSEL_ALT4); /* SPI1_CE2_N */ bcm2835_gpio_fsel(RPI_V2_GPIO_P1_35, BCM2835_GPIO_FSEL_ALT4); /* SPI1_MISO */ bcm2835_gpio_fsel(RPI_V2_GPIO_P1_38, BCM2835_GPIO_FSEL_ALT4); /* SPI1_MOSI */ bcm2835_gpio_fsel(RPI_V2_GPIO_P1_40, BCM2835_GPIO_FSEL_ALT4); /* SPI1_SCLK */
@serefbal
@serefbal 2 роки тому
I need to send multiple data like rpi 4 7-8 bytes from arduino. How can I do this with i2c? I can send and receive single bytes of data, but have trouble reading multiple data.
@na5y
@na5y 2 роки тому
While there is certainly support I didn't try multi-byte I2C reads with the bcm library. You are reading on the RPi correct? What is your arduino hardware? Have you tried upgrading the board firmware on the arduino side? Sorry I can't be of much more help - but there's lots of potential causes for the problem.
@serefbal
@serefbal 2 роки тому
My Arduino board is UNO. yes, the single byte of data I sent from arduino and received from rpi 4 is correct. I am using smbus library in rpi 4 and master is working. Arduino is working as a slave. Thank you for your attention.
@na5y
@na5y 2 роки тому
I am sorry - I have no experience using the smbus library - I assume you are using the latest. Can you try a test I2C program using the bcm library? If that also doesn't work it would point to the Uno (of course if it *does* work it points to SMBUS). It can be tough debugging these sorts of things without an oscilloscope to see what is going on.
@dalesmith8666
@dalesmith8666 3 місяці тому
Thank GOD no bloody Python! ( not for me, only C, C++) By the way I'll be sending you an EM. (from QRZ). We have things in common. SDR, Programming. etc.73's Dale
Raspberry Pi GPIO - Getting Started with gpiozero
48:40
DroneBot Workshop
Переглядів 428 тис.
Arduino vs Pico - Which is the Best Microcontroller For You?
20:38
Gary Explains
Переглядів 277 тис.
Артем Пивоваров х Klavdia Petrivna - Барабан
03:16
Artem Pivovarov
Переглядів 3,8 млн
ЧТО ДЕЛАТЬ, ЕСЛИ НЕ ХВАТАЕТ ДЕНЕГ НА ВОССТАНОВЛЕНИЕ ТАЧКИ?
47:52
I PUT MY ARMOR ON (Creeper) (PG Version)
00:19
Sam Green
Переглядів 5 млн
This keyboard is a $100 computer!!! - Raspberry Pi 400
15:23
ShortCircuit
Переглядів 1,9 млн
PROTOCOLS: UART - I2C - SPI - Serial communications #001
11:58
Electronoobs
Переглядів 1,3 млн
#372 How to use the two Cores of the Pi Pico? And how fast are Interrupts?
14:25
Raspberry Pi & Python I2C Deep Dive with TonyD! @adafruit LIVE
1:03:12
Adafruit Industries
Переглядів 44 тис.
Easy Raspberry Pi Projects for 2023!
10:03
Crosstalk Solutions
Переглядів 794 тис.
#369 Definitive Guide to Attaching Sensors to the Raspberry Pi (Tutorial)
13:22
Vortex Cannon vs Drone
20:44
Mark Rober
Переглядів 12 млн
''Бесплатные умные'' домофоны для глупых людей. За чей счет банкет?
12:48
Вадим Шегалов.Оккультные игры элиты
Переглядів 29 тис.
Первый рабочий день HappyPC Старый Оскол! 🔥
9:51
Герасимов Live
Переглядів 19 тис.
Infrared Soldering Iron from Cigarette Lighter
0:58
ALABAYCHIC
Переглядів 1,8 млн
ЭТОТ МОНСТР ОТ INFINIX КРУЧЕ ЛЮБОГО XIAOMI! Я в шоке…
13:01
Thebox - о технике и гаджетах
Переглядів 19 тис.