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");