1
0

main.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "driver/gpio.h"
  5. #include "esp_log.h"
  6. #include <stdbool.h>
  7. #include "sdkconfig.h"
  8. #include "config.h"
  9. #include "wifi.h"
  10. #include "mqtt.h"
  11. #include "readTemps.h"
  12. #include "esp_chip_info.h"
  13. esp_chip_info_t chip_info;
  14. static void configure_led(void)
  15. {
  16. ESP_LOGI("LED", "Example configured to blink GPIO LED!");
  17. gpio_reset_pin(BLINK_GPIO);
  18. /* Set the GPIO as a push/pull output */
  19. gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
  20. }
  21. void getChipInfo(void) {
  22. esp_chip_info_t chip_info;
  23. esp_chip_info(&chip_info);
  24. ESP_LOGI("MAIN", "Model: %d = %s", chip_info.model,chip_info.model == CHIP_ESP32 ? "ESP32" : "Unknown");
  25. ESP_LOGI("MAIN", "Features: WiFi%s%s, %d cores",
  26. (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
  27. (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
  28. chip_info.cores);
  29. ESP_LOGI("MAIN", "Revision: %d", chip_info.revision);
  30. }
  31. void app_main(void)
  32. {
  33. getChipInfo();
  34. #ifdef WIFI_ENABLED
  35. initWifi(); // Init WIFI
  36. #endif
  37. #ifdef MQTT_ENABLED
  38. mqtt_init();
  39. #endif
  40. #ifdef ENABLE_DS18B20
  41. initTempReadings();
  42. #endif
  43. /* Configure the peripheral according to the LED type */
  44. configure_led();
  45. while(1) {
  46. gpio_set_level(BLINK_GPIO, 1); // Turn the LED on (1 is high)
  47. vTaskDelay(500 / portTICK_PERIOD_MS);
  48. gpio_set_level(BLINK_GPIO, 0); // Turn the LED off (0 is low)
  49. vTaskDelay(500 / portTICK_PERIOD_MS);
  50. }
  51. }