Book Image

Learning C for Arduino

By : Syed Omar Faruk Towaha
Book Image

Learning C for Arduino

By: Syed Omar Faruk Towaha

Overview of this book

This book will start with the fundamentals of C programming and programming topics, such data types, functions, decision making, program loops, pointers, and structures, with the help of an Arduino board. Then you will get acquainted with Arduino interactions with sensors, LEDs, and autonomous systems and setting up the Arduino environment. Moving on you will also learn how to work on the digital and analog I/O, establish serial communications with autonomous systems, and integrate with electronic devices. By the end of the book, you will be able to make basic projects such as LED cube and smart weather system that leverages C.
Table of Contents (17 chapters)
Learning C for Arduino
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Smart weather system


A weather system can determine a lot of variables and parameters related to the environment. In this section, we will stick to a few sensors to build a Smart Weather System that will measure air temperature, air pressure, and air humidity. You will need the following things:

  • Humidity and Temperature Sensor

  • Pressure Sensor

  • A 16x2 LCD Display

  • Arduino Board

  • Jumper wires

The Humidity and Temperature sensor we will use here is a common sensor (DHT11 or DHT22). The following image shows a DHT11 sensor:

We will use a pressure sensor (BMP180). The following image shows a BMP180 pressure sensor:

We already know how we can connect the LCD board. So let's skip this part for now. We will connect the other two sensors to the Arduino board.

The DHT11 has three pins, GND, VCC, and DAT.

Connect the GND pin to the Arduino GND pin, the VCC pin to the 5V pin, and the DAT pin to the digital pin 3 (or any digital pin you want). See the following figure for clarification:

To get data from the...