source code migrating from gitlab

This commit is contained in:
2026-05-15 15:51:41 -04:00
commit 6cf9a21574
28 changed files with 2960 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(temp-humidity)
+2
View File
@@ -0,0 +1,2 @@
idf_component_register(SRCS "temp-humidity.c"
INCLUDE_DIRS ".")
+18
View File
@@ -0,0 +1,18 @@
## IDF Component Manager Manifest File
dependencies:
## Required IDF version
idf:
version: '>=4.1.0'
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
zorxx/dht: ^1.0.1
panigrah/esp32-idf-hd44780: ^0.0.3
+57
View File
@@ -0,0 +1,57 @@
#include "HD44780.h"
#include "dht.h"
#include <esp_err.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdint.h>
#include <stdio.h>
#define DHT_PIN 25
#define LCD_ADDR 0x27
#define SDA_PIN 21
#define SCL_PIN 22
#define LCD_ROWS 16
#define LCD_COLS 2
float convertValue(int16_t val);
float converTemp(int16_t celsius);
void app_main(void) {
const char *tag = "TEMP_HUMID";
int16_t temp, humid;
char tempStr[32], humidStr[32];
ESP_LOGI(tag, "Starting our temp/humidity readings");
LCD_init(LCD_ADDR, SDA_PIN, SCL_PIN, LCD_COLS, LCD_ROWS);
while (1) {
LCD_clearScreen();
esp_err_t err = dht_read_data(DHT_TYPE_AM2301, DHT_PIN, &humid, &temp);
if (err != ESP_OK) {
ESP_LOGE(tag, "Error: could not read DHT22 Sensor");
} else {
// printf("Temp: %d.%d C\n", temp / 10, temp % 10);
// printf("Humidity: %d.%d%%\n", humid / 10, humid % 10);
//
float celsius = convertValue(temp);
float humidity = convertValue(humid);
float fahrenheit = converTemp(celsius);
sprintf(tempStr, "T: %.1fC / %.1fF", celsius, fahrenheit);
sprintf(humidStr, "Humidity: %.1f%%", humidity);
LCD_writeStr(tempStr);
LCD_setCursor(0, 1);
LCD_writeStr(humidStr);
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
float convertValue(int16_t val) { return val / 10.0f; }
float converTemp(int16_t celsius) { return celsius * (9.0f / 5.0f) + 32.0f; }