Book Image

Internet of Things Projects with ESP32

By : Agus Kurniawan
Book Image

Internet of Things Projects with ESP32

By: Agus Kurniawan

Overview of this book

ESP32 is a low-cost MCU with integrated Wi-Fi and BLE. Various modules and development boards-based on ESP32 are available for building IoT applications easily. Wi-Fi and BLE are a common network stack in the Internet of Things application. These network modules can leverage your business and projects needs for cost-effective benefits. This book will serve as a fundamental guide for developing an ESP32 program. We will start with GPIO programming involving some sensor devices. Then we will study ESP32 development by building a number of IoT projects, such as weather stations, sensor loggers, smart homes, Wi-Fi cams and Wi-Fi wardriving. Lastly, we will enable ESP32 boards to execute interactions with mobile applications and cloud servers such as AWS. By the end of this book, you will be up and running with various IoT project-based ESP32 chip.
Table of Contents (12 chapters)

Storing sensor data on a microSD card

Technically, we can store any data of a certain file type on an SD card and microSD card. We can also store sensor data in external storage.

For demo purposes, we sense temperature and humidity with the DHT sensor. We use the same wiring from the dhtdemo project in Chapter 2, Making Visual Data and Animation on an LCD. Our scenario is to sense temperature and humidity and then store them in microSD storage.

We clone our previous project, sdcard. Then, we change to a new project by naming it sdcarddht. We should then rename the main program file sdcard.c to sdcarddht.c. We modify codes on file operations to read temperature and humidity from DHT by calling the dht_read_data() function. After obtaining sensor data, we store it into a file named sensor.txt:

        ESP_LOGE(TAG, "Reading sensor data");

if (dht_read_data(sensor_type...