1
0

main.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. esp_chip_info_t chip_info;
  13. static void configure_led(void)
  14. {
  15. ESP_LOGI("LED", "Example configured to blink GPIO LED!");
  16. gpio_reset_pin(BLINK_GPIO);
  17. /* Set the GPIO as a push/pull output */
  18. gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
  19. }
  20. void getChipInfo(void) {
  21. esp_chip_info_t chip_info;
  22. esp_chip_info(&chip_info);
  23. ESP_LOGI("MAIN", "Model: %d = %s", chip_info.model,chip_info.model == CHIP_ESP32 ? "ESP32" : "Unknown");
  24. ESP_LOGI("MAIN", "Features: WiFi%s%s, %d cores",
  25. (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
  26. (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
  27. chip_info.cores);
  28. ESP_LOGI("MAIN", "Revision: %d", chip_info.revision);
  29. }
  30. void app_main(void)
  31. {
  32. getChipInfo();
  33. #ifdef WIFI_ENABLED
  34. initWifi(); // Init WIFI
  35. #endif
  36. #ifdef MQTT_ENABLED
  37. mqtt_init();
  38. #endif
  39. #ifdef ENABLE_DS18B20
  40. initTempReadings();
  41. #endif
  42. /* Configure the peripheral according to the LED type */
  43. configure_led();
  44. while(1) {
  45. gpio_set_level(BLINK_GPIO, 1); // Turn the LED on (1 is high)
  46. vTaskDelay(500 / portTICK_PERIOD_MS);
  47. gpio_set_level(BLINK_GPIO, 0); // Turn the LED off (0 is low)
  48. vTaskDelay(500 / portTICK_PERIOD_MS);
  49. }
  50. }