mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Internal temperature: Support Beken platform (#6491)
This commit is contained in:
		| @@ -14,6 +14,11 @@ uint8_t temprature_sens_read(); | ||||
| #ifdef USE_RP2040 | ||||
| #include "Arduino.h" | ||||
| #endif  // USE_RP2040 | ||||
| #ifdef USE_BK72XX | ||||
| extern "C" { | ||||
| uint32_t temp_single_get_current_temperature(uint32_t *temp_value); | ||||
| } | ||||
| #endif  // USE_BK72XX | ||||
|  | ||||
| namespace esphome { | ||||
| namespace internal_temperature { | ||||
| @@ -46,6 +51,16 @@ void InternalTemperatureSensor::update() { | ||||
|   temperature = analogReadTemp(); | ||||
|   success = (temperature != 0.0f); | ||||
| #endif  // USE_RP2040 | ||||
| #ifdef USE_BK72XX | ||||
|   uint32_t raw, result; | ||||
|   result = temp_single_get_current_temperature(&raw); | ||||
|   success = (result == 0); | ||||
| #ifdef USE_LIBRETINY_VARIANT_BK7231T | ||||
|   temperature = raw * 0.04f; | ||||
| #else | ||||
|   temperature = raw * 0.128f; | ||||
| #endif  // USE_LIBRETINY_VARIANT_BK7231T | ||||
| #endif  // USE_BK72XX | ||||
|   if (success && std::isfinite(temperature)) { | ||||
|     this->publish_state(temperature); | ||||
|   } else { | ||||
|   | ||||
| @@ -14,6 +14,7 @@ from esphome.const import ( | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
|     PLATFORM_ESP32, | ||||
|     PLATFORM_RP2040, | ||||
|     PLATFORM_BK72XX, | ||||
| ) | ||||
| from esphome.core import CORE | ||||
|  | ||||
| @@ -51,7 +52,7 @@ CONFIG_SCHEMA = cv.All( | ||||
|         state_class=STATE_CLASS_MEASUREMENT, | ||||
|         entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||||
|     ).extend(cv.polling_component_schema("60s")), | ||||
|     cv.only_on([PLATFORM_ESP32, PLATFORM_RP2040]), | ||||
|     cv.only_on([PLATFORM_ESP32, PLATFORM_RP2040, PLATFORM_BK72XX]), | ||||
|     validate_config, | ||||
| ) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user