Open MiguelGomesEstevao opened 1 year ago
how can I "send" that data
Please look here: https://github.com/jakubdybczak/esp32-arduino-matter-builder/blob/master/lib_files/examples/Light/Light.ino
I think that attribute::update
is the method that you searching for
Second is, how do I get the QR code to make the connection?
When you compile the example file that I linked in previous response, you will see a link do QR code printed in your console.
Thanks for the help! I was able to run that code on my ESP and connect it to my Google Home APP after creating a certification in the Development Console.
I'm trying to create a temperature measurement endpoint so I can send data from my temperature sensor to the application. I tried to use that example and I found the TemperatureMeasurement Cluster.
I tried this code to setup the Temperature Endpoint: `// Setup Temperature endpoint with default values TemperatureMeasurement::TemperatureMeasurementClusterAttributesStruct temperature_config; temperature_config.MeasuredValue.value = 25.0; // Set temperature attribute to 25.0°C by default endpoint_t *temperature_endpoint = TemperatureMeasurement::create(node, &temperature_config, ENDPOINT_FLAG_NONE, NULL);
// Save temperature attribute reference. It will be used to update attribute value later. temperature_attribute_ref = attribute::get(cluster::get(temperature_endpoint, TemperatureMeasurement::Id), TemperatureMeasurement::Attributes::MeasuredValue::Id);`
But it gives me an error saying 'TemperatureMeasurementClusterAttributesStruct' is not a member of 'chip::app::Clusters::TemperatureMeasurement'.
Do you have any idea/example of how to fix it? I've been looking for a guide but I can't find any.
Thank you in advance
Hi I am setting up a device with temperature measurement runnig from battery. It is running on esp32. I can send a temperature and can see it in google home app, but I want to send the battery percentage to the google home app too, but with no luck till now. How can I do that? Can you tell me some info about reporting battery state from matter device?
Thank you in advance.
Hi I am setting up a device with temperature measurement runnig from battery. It is running on esp32. I can send a temperature and can see it in google home app, but I want to send the battery percentage to the google home app too, but with no luck till now. How can I do that? Can you tell me some info about reporting battery state from matter device?
Thank you in advance.
@norberthidas
I've been trying to get the temperature reporting working. Could you share your temperature code?
Thanks!
Hello. Here is an example of how to send a value.
using namespace chip; using namespace chip::app::Clusters; using namespace esp_matter; using namespace esp_matter::endpoint;
// Cluster and attribute ID used by Matter Temperature device const uint32_t CLUSTER_ID_TEMP = TemperatureMeasurement::Id; const uint32_t ATTRIBUTE_ID_TEMP = TemperatureMeasurement::Attributes::MeasuredValue::Id;
/** This program presents many Matter devices and should be used only for debug purposes (for example checking which devices types are supported in Matter controller).
Keep in mind that it IS NOT POSSIBLE to run all those endpoints due to out of memory. There is need to manually comment out endpoints! Running about 4 endpoints at the same time should work. */
static void on_device_event(const ChipDeviceEvent event, intptr_t arg) {} static esp_err_t on_identification(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant, void priv_data) { return ESP_OK; }
static esp_err_t on_attribute_update(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t val, void priv_data) { if (type == attribute::PRE_UPDATE) { Serial.print("Update on endpoint: "); Serial.print(endpoint_id); Serial.print(" cluster: "); Serial.print(cluster_id); Serial.print(" attribute: "); Serial.println(attribute_id); } return ESP_OK; }
void print_endpoint_info(String clusterName, endpoint_t *endpoint) { uint16_t endpoint_id = endpoint::get_id(endpoint); Serial.print(clusterName); Serial.print(" has endpoint: "); Serial.println(endpoint_id); }
// Sets temperature attribute value void Set_temp_Attribute_Value(esp_matter_attr_val_t *temperature) { attribute::update(temperature_endpoint_id, CLUSTER_ID_TEMP, ATTRIBUTE_ID_TEMP, temperature);
}
void setup() { Serial.begin(115200);
esp_log_level_set("*", ESP_LOG_DEBUG);
node::config_t node_config; node_t *node = node::create(&node_config, on_attribute_update, on_identification);
endpoint_t endpoint; cluster_t cluster;
temperature_sensor::config_t temperature_sensor_config; temperature_sensor_config.temperature_measurement.measured_value = 22; endpoint = temperature_sensor::create(node, &temperature_sensor_config, ENDPOINT_FLAG_NONE, NULL); print_endpoint_info("temperature_sensor", endpoint);
// Setup DAC (this is good place to also set custom commission data, passcodes etc.) esp_matter::set_custom_dac_provider(chip::Credentials::Examples::GetExampleDACProvider());
esp_matter::start(on_device_event);
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); }
void loop() {
int16_t Temper = 23 * 100; //example of a measured value esp_matter_attr_val_t temperature = esp_matter_int16(Temper); Set_temp_Attribute_Value(&temperature); delay(5000); }
Hello. Here is an example of how to send a value.
include "Matter.h" #include <app/server/OnboardingCodesUtil.h> #include <credentials/examples/DeviceAttestationCredsExample.h> using namespace chip; using namespace chip::app::Clusters; using namespace esp_matter; using namespace esp_matter::endpoint;
// Cluster and attribute ID used by Matter Temperature device const uint32_t CLUSTER_ID_TEMP = TemperatureMeasurement::Id; const uint32_t ATTRIBUTE_ID_TEMP = TemperatureMeasurement::Attributes::MeasuredValue::Id;
/** This program presents many Matter devices and should be used only for debug purposes (for example checking which devices types are supported in Matter controller).
Keep in mind that it IS NOT POSSIBLE to run all those endpoints due to out of memory. There is need to manually comment out endpoints! Running about 4 endpoints at the same time should work. */
static void on_device_event(const ChipDeviceEvent event, intptr_t arg) {} static esp_err_t on_identification(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant, void priv_data) { return ESP_OK; }
static esp_err_t on_attribute_update(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t val, void priv_data) { if (type == attribute::PRE_UPDATE) { Serial.print("Update on endpoint: "); Serial.print(endpoint_id); Serial.print(" cluster: "); Serial.print(cluster_id); Serial.print(" attribute: "); Serial.println(attribute_id); } return ESP_OK; }
void print_endpoint_info(String clusterName, endpoint_t *endpoint) { uint16_t endpoint_id = endpoint::get_id(endpoint); Serial.print(clusterName); Serial.print(" has endpoint: "); Serial.println(endpoint_id); }
// Sets temperature attribute value void Set_temp_Attribute_Value(esp_matter_attr_val_t *temperature) { attribute::update(temperature_endpoint_id, CLUSTER_ID_TEMP, ATTRIBUTE_ID_TEMP, temperature);
}
void setup() { Serial.begin(115200);
esp_log_level_set("*", ESP_LOG_DEBUG);
node::config_t node_config; node_t *node = node::create(&node_config, on_attribute_update, on_identification);
endpoint_t endpoint; cluster_t cluster;
temperature_sensor::config_t temperature_sensor_config; temperature_sensor_config.temperature_measurement.measured_value = 22; endpoint = temperature_sensor::create(node, &temperature_sensor_config, ENDPOINT_FLAG_NONE, NULL); print_endpoint_info("temperature_sensor", endpoint);
// Setup DAC (this is good place to also set custom commission data, passcodes etc.) esp_matter::set_custom_dac_provider(chip::Credentials::Examples::GetExampleDACProvider());
esp_matter::start(on_device_event);
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); }
void loop() {
int16_t Temper = 23 * 100; //example of a measured value esp_matter_attr_val_t temperature = esp_matter_int16(Temper); Set_temp_Attribute_Value(&temperature); delay(5000); }
Hello, thank you for your support. Is this working on your ESP32? I'm trying to make it work, but it doesn't. Please let me know.
Hello. Here is an example of how to send a value.
include "Matter.h" #include <app/server/OnboardingCodesUtil.h> #include <credentials/examples/DeviceAttestationCredsExample.h> using namespace chip; using namespace chip::app::Clusters; using namespace esp_matter; using namespace esp_matter::endpoint;
// Cluster and attribute ID used by Matter Temperature device const uint32_t CLUSTER_ID_TEMP = TemperatureMeasurement::Id; const uint32_t ATTRIBUTE_ID_TEMP = TemperatureMeasurement::Attributes::MeasuredValue::Id; /* This program presents many Matter devices and should be used only for debug purposes (for example checking which devices types are supported in Matter controller). Keep in mind that it IS NOT POSSIBLE to run all those endpoints due to out of memory. There is need to manually comment out endpoints! Running about 4 endpoints at the same time should work. / static void on_device_event(const ChipDeviceEvent event, intptr_t arg) {} static esp_err_t on_identification(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant, void priv_data) { return ESP_OK; } static esp_err_t on_attribute_update(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t val, void priv_data) { if (type == attribute::PRE_UPDATE) { Serial.print("Update on endpoint: "); Serial.print(endpoint_id); Serial.print(" cluster: "); Serial.print(cluster_id); Serial.print(" attribute: "); Serial.println(attribute_id); } return ESP_OK; } void print_endpoint_info(String clusterName, endpoint_t endpoint) { uint16_t endpoint_id = endpoint::get_id(endpoint); Serial.print(clusterName); Serial.print(" has endpoint: "); Serial.println(endpoint_id); } // Sets temperature attribute value void Set_temp_Attribute_Value(esp_matter_attr_val_t temperature) { attribute::update(temperature_endpoint_id, CLUSTER_ID_TEMP, ATTRIBUTE_ID_TEMP, temperature); } void setup() { Serial.begin(115200); esp_log_level_set("", ESP_LOG_DEBUG); node::config_t node_config; node_t node = node::create(&node_config, on_attribute_update, on_identification); endpoint_t endpoint; cluster_t cluster; temperature_sensor::config_t temperature_sensor_config; temperature_sensor_config.temperature_measurement.measured_value = 22; endpoint = temperature_sensor::create(node, &temperature_sensor_config, ENDPOINT_FLAG_NONE, NULL); print_endpoint_info("temperature_sensor", endpoint); // Setup DAC (this is good place to also set custom commission data, passcodes etc.) esp_matter::set_custom_dac_provider(chip::Credentials::Examples::GetExampleDACProvider()); esp_matter::start(on_device_event); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); } void loop() { int16_t Temper = 23 * 100; //example of a measured value esp_matter_attr_val_t temperature = esp_matter_int16(Temper); Set_temp_Attribute_Value(&temperature); delay(5000); }
Hello, thank you for your support. Is this working on your ESP32? I'm trying to make it work, but it doesn't. Please let me know.
You didn't give much information here but try adding #include "Arduino.h"
and
uint16_t temperature_endpoint_id = 1;
Hey Guys!! It's my first time using this library! (Btw, awesome library, and very helpful).
I need help with two things: First is, I'm developing a device capable of reading temperature from a sensor and somehow I wanna make that data available so I can see it in my Google Home App. I saw some examples for button events etc but how can I "send" that data so it can be acessed? Second is, how do I get the QR code to make the connection?
Sorry if some of this questions are kinda weird. It's my first time seeing this and I'm starting to explore and I'm kinda lost with all this information.