The Raspberry Pi has traditionally been programmed using Python. Although this is a very powerful language, many programmers may not be familiar with it. C on the other hand is perhaps the most commonly used programming language and all embedded microcontrollers can be programmed using it.
----------------------------------------
The C language is taught in most technical colleges and universities and almost all engineering students are familiar with using it with their projects. This book is about using the Raspberry Pi with C to develop a range of hardware-based projects. Two of the most popular C libraries, wiringPi and pigpio are used.
------------------------------------------
The book starts with an introduction to C and most students and newcomers will find this chapter invaluable. Many projects are provided in the book, including using Wi-Fi and Bluetooth to establish communication with smartphones.
Many sensor and hardware-based projects are included. Both wiringPi and pigpio libraries are used in all projects. Complete program listings are given with full explanations. All projects have been fully tested and work.
------------------------------------------
The following hardware-based projects are provided in the book:
- Using sensors
- Using LCDs
- I²C and SPI buses
- Serial communication
- Multitasking
- External and timer interrupts
- Using Wi-Fi
- Webservers
- Communicating with smartphones
- Using Bluetooth
- Sending data to the cloud
--------------------------------------
Program listings of all Raspberry Pi projects developed in this book are available on the Elektor website. Readers can download and use these programs in their projects. Alternatively, they can customize them to suit their applications.
Author(s): Dogan Ibrahim
Edition: 1
Publisher: Elector
Year: 2021
Language: English
Pages: 376
Tags: c c17 raspberry pi embedded iot 2022
Chapter 1 ● Installing the Operating System on Raspberry Pi
1.1 ● Overview
1.2 ● Raspbian Buster installation steps on Raspberry Pi 4
1.3 ● Using networked connection
1.4 ● Remote access
1.5 ● Using Putty
1.5.1 ● Configuring Putty
1.6 ● Remote access of the Desktop
1.7 ● Static IP address
1.8 ● Summary
Chapter 2 ● Raspberry Pi Program Development
2.1 ● Overview
2.2 ● The nano text editor
2.3 ● Example project
2.4 ● Creating and running a Python program on Raspberry Pi
2.5 ● Creating and running a C program on Raspberry Pi
2.6 ● Summary
Chapter 3 ● C Programming for Raspberry Pi
3.1 ● Overview
3.2 ● The C Language
3.2.1 ● Variables
3.2.2 ● Screen output and keyboard input
3.2.3 ● Comparison
3.2.4 ● Operators
3.2.5 ● Auto increment/decrement operators
3.2.6 ● Logical operators
3.2.7 ● Flow control
3.2.8 ● Arrays
3.2.9 ● String variables
3.2.10 ● Arithmetic functions
3.2.11 ● String functions
3.2.12 ● Character macros
3.2.13 ● Alternative numeric input
3.2.14 ● User functions
3.2.15 ● File processing
3.2.16 ● Structures
3.2.17 ● Unions
3.2.18 ● Pointers
3.3 ● Summary
Chapter 4 ● Hardware Programming using C
4.1 ● Overview
4.2 ● The general purpose input-output ports (GPIO)
4.3 ● Interfacing with GPIO
4.3.1 ● Loads requiring small currents
4.3.2 ● Loads requiring higher currents
4.3.3 ● Using relays
4.4 ● Project 1: Flashing LED - compilers available
4.4.1 ● Using the pigpio library
4.4.2 ● Using the wiringPi library
4.4.3 ● Other C libraries/compilers for Raspberry Pi
4.5 ● Using the Geany editor
4.6 ● The hardware
4.7 ● Summary
Chapter 5 ● Hardware Projects using C
5.1 ● Overview
5.2 ● Project 1 - Rotating LEDs
5.3 ● Project 2 - Christmas lights
5.4 ● Project 3 - Binary up counter with LEDs
5.5 ● Project 4 - Binary up/down counter with LEDs
5.6 ● Project 5 - LED dice
5.7 ● Project 6 - LED colour wand
5.8 ● Project 7 - Changing the brightness of an LED
5.9 ● Project 8 - Generating random sounds using a buzzer
5.10 ● Project 9 - Display temperature and relative humidity
5.11 ● Project 10 - ON/OFF temperature controller
5.12 ● Summary
Chapter 6 ● LCD Projects
6.1 ● Overview
6.2 ● HD44780 LCD module
6.3 ● Project 1 - Displaying text
6.4 ● Project 2 - Second counter
6.5 ● Project 3 - Creating a custom character
6.6 ● Project 4 - Creating multiple custom characters
6.7 ● Project 5 - Displaying current date and time
6.8 ● Project 6 - Displaying the temperature and humidity
6.9 ● Summary
Chapter 7 ● I2C Bus Interface
7.1 ● Overview
7.2 ● The I2C Bus
7.3 ● Project 1 - Port expander
7.4 ● Project 2 - EEPROM memory
7.5 ● Project 3 - TMP102 temperature display
7.6 ● Project 4 - I2C LCD
7.7 ● Project 5 - Using the pigpio library with I2C - TMP102 temperature display
7.8 ● Summary
Chapter 8 ● SPI Bus Interface
8.1 ● Overview
8.2 ● Raspberry Pi SPI pins
8.3 ● Project 1 - Port expander
8.4 ● Summary
Chapter 9 ● Using Analogue-to-Digital Converters (ADCs)
9.1 ● Overview
9.2 ● Project 1 - Analogue temperature sensor thermometer
9.3 ● Summary
Chapter 10 ● Using Digital-to-Analogue Converters (DACs)
10.1 ● Overview
10.2 ● The MCP4921 DAC
10.3 ● Project 1 - Generating square wave signal with any peak voltage
10.4 ● Project 2 - Generating sawtooth wave signal
10.5 ● Summary
Chapter 11 ● Using Serial Communication
11.1 ● Overview
11.2 ● Raspberry Pi serial port
11.3 ● Project 1 - Serial communication between Raspberry Pi and Arduino Uno
11.4 ● Summary
Chapter 12 ● Other Useful Functions wiringPi
12.1 ● Overview
12.2 ● Project 1 - Using external interrupts - event counter
12.3 ● Project 2 - Using the tone library - generating 1kHz signal
12.4 ● Project 3 - Using the tone library - sweep frequency tone generation
12.5 ● Project 4 - Using the tone library - reading the frequency from the keyboard
12.6 ● Project 5 - Using the tone library - melody maker
12.7 ● Timing library
12.8 ● Multitasking threads
12.9 ● Project 6 - Multi-threading - flashing 3 LEDs at different rates
12.10 ● Project 7 - Multi-threading - Two-digit 7-segment LED counter
12.11 ● Hardware PWM
12.12 ● GPIO utility
12.13 ● Support for other chips and add-on boards
12.14 ● Summary
Chapter 13 ● Other Useful Functions - pigpio
13.1 ● Overview
13.2 ● Project 1 - Using external interrupts - event counter
13.3 ● Timing
13.4 ● Timer interrupts
13.5 ● Project 2 - Using timer interrupts - flashing LED
13.6 ● Project 3 - Using timer interrupts - 2 digit 7-segment LED counter
13.7 ● Project 4 - Multi-threading - flashing 3 LEDs at different rates
13.8 ● Project 5 - Hardware PWM- generate 1kHz PWM wave with hardware
13.9 ● File handling
13.10 ● Waves
13.11 ● picscope
13.12 ● pigpiod
13.13 ● Summary
Chapter 14 ● Communication over Wi-Fi
14.1 ● Overview
14.2 ● UDP and TCP/IP
14.3 ● UDP communication
14.4 ● Project 1 - Communicating with an Android smartphone using UDP (Raspberry Pi is the server)
14.5 ● Project 2 - Sending temperature readings to Android smartphone (Raspberry Pi is the server)
14.6 ● Project 3 - Communicating with an Android smartphone using UDP (Raspberry Pi is the client)
14.7 ● Project 4 - Sending time-stamped temperature readings to Android smartphone (Raspberry Pi is
14.8 ● Project 5 - Web Server application - controlling two LEDs
14.9 ● Summary
Chapter 15 ● Bluetooth Communication
15.1 ● Overview
15.2 ● Project 1 - Bluetooth communication with a smartphone - sending and receiving text messages
15.3 ● Project 2 - Bluetooth communication with a smartphone - controlling two LEDs
Chapter 16 ● Automatically Running Programs on Startup
16.1 ● Overview
16.2 ● Scheduling a program to run at specified times
Chapter 17 ● Sending Data to the Cloud
17.1 ● Overview
17.2 ● Project - Sending temperature and humidity data to the cloud
● Index