0%

A practical guide to building PIC and STM32 microcontroller board applications with C and C++ programming

Key Features

  • Discover how to apply microcontroller boards in real life to create interesting IoT projects
  • Create innovative solutions to help improve the lives of people affected by the COVID-19 pandemic
  • Design, build, program, and test microcontroller-based projects with the C and C++ programming language

Book Description

We live in a world surrounded by electronic devices, and microcontrollers are the brains of these devices. Microcontroller programming is an essential skill in the era of the Internet of Things (IoT), and this book helps you to get up to speed with it by working through projects for designing and developing embedded apps with microcontroller boards.

DIY Microcontroller Projects for Hobbyists are filled with microcontroller programming C and C++ language constructs. You'll discover how to use the Blue Pill (containing a type of STM32 microcontroller) and Curiosity Nano (containing a type of PIC microcontroller) boards for executing your projects as PIC is a beginner-level board and STM-32 is an ARM Cortex-based board. Later, you'll explore the fundamentals of digital electronics and microcontroller board programming. The book uses examples such as measuring humidity and temperature in an environment to help you gain hands-on project experience. You'll build on your knowledge as you create IoT projects by applying more complex sensors. Finally, you'll find out how to plan for a microcontroller-based project and troubleshoot it.

By the end of this book, you'll have developed a firm foundation in electronics and practical PIC and STM32 microcontroller programming and interfacing, adding valuable skills to your professional portfolio.

What you will learn

  • Get to grips with the basics of digital and analog electronics
  • Design, build, program, and test a microcontroller-based system
  • Understand the importance and applications of STM32 and PIC microcontrollers
  • Discover how to connect sensors to microcontroller boards
  • Find out how to obtain sensor data via coding
  • Use microcontroller boards in real life and practical projects

Who this book is for

This STM32 PIC microcontroller book is for students, hobbyists, and engineers who want to explore the world of embedded systems and microcontroller programming. Beginners, as well as more experienced users of digital electronics and microcontrollers, will also find this book useful. Basic knowledge of digital circuits and C and C++ programming will be helpful but not necessary.

Table of Contents

  1. DIY Microcontroller Projects for Hobbyists
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Code in Action
    6. Download the color images
    7. Conventions used
    8. Get in touch
    9. Share Your Thoughts
  6. Chapter 1: Introduction to Microcontrollers and Microcontroller Boards
    1. Technical requirements
    2. Introduction to microcontrollers
    3. Microcontroller boards
    4. An overview of analog and digital electronics necessary for carrying out the book's projects
    5. Basic electronic components
    6. The diode
    7. The solderless breadboard
    8. Description of the Blue Pill and Curiosity Nano microcontroller boards
    9. Installing the IDEs
    10. Your first project – a blinking LED
    11. Running the blinking LED example with the Blue Pill board
    12. Running the blinking LED example on the Curiosity Nano board
    13. Summary
    14. Further reading
  7. Chapter 2: Software Setup and C Programming for Microcontroller Boards
    1. Technical requirements
    2. Introducing the C programming language
    3. The basic structure of the C language
    4. Introducing Curiosity Nano microcontroller board programming
    5. Introducing Blue Pill microcontroller board programming
    6. Example – Programming and using the microcontroller board's internal LED
    7. Programming the Blue Pill's internal LED
    8. Summary
    9. Further reading
  8. Chapter 3: Turning an LED On or Off Using a Push Button
    1. Technical requirements
    2. Introducing push buttons
    3. Understanding electrical noise from push buttons
    4. Debouncing a push button via hardware
    5. Debouncing a push button via software
    6. Connecting an LED to a microcontroller board port and using an internal pull-up resistor
    7. Debouncing a push button via software connected to the Blue Pill
    8. Turning an LED on or off with a push button on the Curiosity Nano
    9. Testing out the push button
    10. Summary
    11. Further reading
  9. Chapter 4: Measuring the Amount of Light with a Photoresistor
    1. Technical requirements
    2. Understanding sensors
    3. Defining sensors
    4. What are sensor modules?
    5. Introducing photoresistors
    6. Connecting a photoresistor to a microcontroller board port
    7. Connecting a photoresistor to a Blue Pill board
    8. Coding the photoresistor values and setting up ports
    9. Connecting a photoresistor to a Curiosity Nano board
    10. Connecting a photoresistor sensor module to the microcontroller boards
    11. Testing out the photoresistor
    12. Summary
    13. Further reading
  10. Chapter 5: Humidity and Temperature Measurement
    1. Technical requirements
    2. Introducing the DHT11 humidity and temperature sensor module
    3. What is relative humidity?
    4. The DHT11 pins and their values
    5. Connecting a DHT11 sensor module to the microcontroller boards
    6. Connecting the DHT11 to the Blue Pill board
    7. Connecting an LCD to the Blue Pill
    8. Connecting an LM35 temperature sensor to the Curiosity Nano board
    9. Coding to get data from the sensor module
    10. Programming the DHT11 sensor for the Blue Pill board
    11. Coding the sensor module and the 1602 LCD
    12. Programming the LM35 sensor on the Curiosity Nano board
    13. Showing the humidity and temperature data results on the serial port monitor
    14. Plotting the data
    15. Summary
    16. Further reading
  11. Chapter 6: Morse Code SOS Visual Alarm with a Bright LED
    1. Technical requirements
    2. Understanding Morse code and the SOS message
    3. Introducing super-bright LEDs and calculating their necessary resistors
    4. Connecting the resistor and the super-bright LED to the microcontroller board
    5. Connecting the super-bright LED to the Curiosity Nano
    6. Coding the SOS Morse code signal
    7. The SOS message code for the Curiosity Nano
    8. Testing the visual alarm
    9. Summary
    10. Further reading
  12. Chapter 7: Creating a Clap Switch
    1. Technical requirements
    2. Connecting a microphone to a microcontroller board port
    3. Understanding the electret microphone module
    4. Connecting the components
    5. Coding your clap switch sketch
    6. Coding a clap switch with two clapping sounds
    7. Coding a clap switch with a timer between claps
    8. Improving the project performance
    9. Summary
    10. Further reading
  13. Chapter 8: Gas Sensor
    1. Technical requirements
    2. Introducing the MQ-2 gas sensor
    3. Connecting a gas sensor to the STM32 microcontroller board
    4. Interfacing for digital reading
    5. Interfacing for analog reading
    6. Writing a program to read the gas concentration over the sensor board
    7. Coding for digital reading
    8. Coding for analog reading
    9. Testing the system
    10. Summary
    11. Further reading
  14. Chapter 9: IoT Temperature-Logging System
    1. Technical requirements
    2. Connecting a temperature sensor to the Blue Pill board
    3. Introducing the DS18B20 temperature sensor module
    4. Connecting the components
    5. Coding a temperature reading system
    6. Learning to connect the ESP8266 module
    7. An introduction to the ESP8266 Wi-Fi module
    8. Connecting an ESP8266 Wi-Fi module
    9. Coding a program to send the sensed temperature to the internet
    10. Connecting the STM32 Blue Pill board to the internet
    11. Summary
    12. Further reading
  15. Chapter 10: IoT Plant Pot Moisture Sensor
    1. Technical requirements
    2. Connecting a soil moisture sensor to the Blue Pill board
    3. Introducing soil moisture sensors
    4. Connecting the components
    5. Reading data from the soil moisture sensor module
    6. Coding a program to send the sensed data to the internet
    7. Showing sensor data results over the internet
    8. Summary
    9. Further reading
  16. Chapter 11: IoT Solar Energy (Voltage) Measurement
    1. Technical requirements
    2. Connecting a solar panel to the Blue Pill board
    3. Introducing the solar panel
    4. The B25 voltage sensor
    5. Connecting the components
    6. Reading data from a voltage sensor module
    7. Coding a program to send the sensed data to the internet
    8. Showing sensor data results over the internet
    9. Summary
    10. Further reading
  17. Chapter 12: COVID-19 Digital Body Temperature Measurement (Thermometer)
    1. Technical requirements
    2. Programming the I2C interface
    3. The I2C protocol
    4. I2C coding
    5. Coding the Arduino Uno software (peripheral)
    6. Coding the Blue Pill software (controller)
    7. Connecting an IR temperature sensor to the microcontroller board
    8. The MLX90614 IR sensor
    9. The GY-906 sensor module
    10. Connection of the IR sensor to an Arduino Uno
    11. Connecting the Blue Pill to the Arduino Uno
    12. Showing the temperature on an LCD
    13. Testing the thermometer
    14. Summary
    15. Further reading
  18. Chapter 13: COVID-19 Social-Distancing Alert
    1. Technical requirements
    2. Programming a piezoelectric buzzer
    3. Connecting the components
    4. Connecting an ultrasonic sensor to the microcontroller board
    5. Connecting the components
    6. Writing a program for getting data from the ultrasonic sensor
    7. Testing the distance meter
    8. Summary
    9. Further reading
  19. Chapter 14: COVID-19 20-Second Hand Washing Timer
    1. Technical requirements
    2. Programming the counter (timer)
    3. Showing the timer on an LCD
    4. Connecting an ultrasonic sensor to the microcontroller board
    5. What is an ultrasonic sensor?
    6. How does an ultrasonic sensor work?
    7. Putting everything together – think of a protective case for the project!
    8. Testing the timer
    9. Summary
    10. Further reading
    11. Why subscribe?
  20. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
3.238.233.189