Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5aaccd8

Browse filesBrowse files
authored
feat(matter): fixes matter temperature sensor endpoint to indicate celsius as measure unit (espressif#10759)
1 parent 10d0bf8 commit 5aaccd8
Copy full SHA for 5aaccd8

File tree

Expand file treeCollapse file tree

3 files changed

+8
-8
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+8
-8
lines changed

‎libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino

Copy file name to clipboardExpand all lines: libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s
4242
// Simulate a temperature sensor - add your preferred temperature sensor library code here
4343
float getSimulatedTemperature() {
4444
// The Endpoint implementation keeps an int16_t as internal value information,
45-
// which stores data in 1/100th of any temperature unit
45+
// which stores data in 1/100th Celsius.
4646
static float simulatedTempHWSensor = -10.0;
4747

4848
// it will increase from -10C to 10C in 0.5C steps to simulate a temperature sensor
@@ -70,7 +70,7 @@ void setup() {
7070
Serial.println();
7171

7272
// set initial temperature sensor measurement
73-
// Simulated Sensor - it shall initially print -25 degrees and then move to the -10 to 10 range
73+
// Simulated Sensor - it shall initially print -25C and then move to the -10C to 10C range
7474
SimulatedTemperatureSensor.begin(-25.00);
7575

7676
// Matter beginning - Last step, after all EndPoints are initialized
@@ -102,7 +102,7 @@ void loop() {
102102
// Print the current temperature value every 5s
103103
if (!(timeCounter++ % 10)) { // delaying for 500ms x 10 = 5s
104104
// Print the current temperature value
105-
Serial.printf("Current Temperature is %.02f <Temperature Units>\r\n", SimulatedTemperatureSensor.getTemperature());
105+
Serial.printf("Current Temperature is %.02fC\r\n", SimulatedTemperatureSensor.getTemperature());
106106
// Update Temperature from the (Simulated) Hardware Sensor
107107
// Matter APP shall display the updated temperature percent
108108
SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature());

‎libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp

Copy file name to clipboardExpand all lines: libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) {
9696
}
9797
rawTemperature = _rawTemperature;
9898
}
99-
log_v("Temperature Sensor set to %.02f Degrees", (float)_rawTemperature / 100.00);
99+
log_v("Temperature Sensor set to %.02fC", (float)_rawTemperature / 100.00);
100100

101101
return true;
102102
}

‎libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h

Copy file name to clipboardExpand all lines: libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MatterTemperatureSensor : public MatterEndPoint {
2323
public:
2424
MatterTemperatureSensor();
2525
~MatterTemperatureSensor();
26-
// begin Matter Temperature Sensor endpoint with initial float temperature
26+
// begin Matter Temperature Sensor endpoint with initial float temperature in Celsius
2727
bool begin(double temperature = 0.00) {
2828
return begin(static_cast<int16_t>(temperature * 100.0f));
2929
}
@@ -32,11 +32,11 @@ class MatterTemperatureSensor : public MatterEndPoint {
3232

3333
// set the reported raw temperature
3434
bool setTemperature(double temperature) {
35-
// stores up to 1/100th of a degree precision
35+
// stores up to 1/100th Celsius precision
3636
int16_t rawValue = static_cast<int16_t>(temperature * 100.0f);
3737
return setRawTemperature(rawValue);
3838
}
39-
// returns the reported float temperature with 1/100th of a degree precision
39+
// returns the reported float temperature with 1/100th Celsius precision
4040
double getTemperature() {
4141
return (double)rawTemperature / 100.0;
4242
}
@@ -55,7 +55,7 @@ class MatterTemperatureSensor : public MatterEndPoint {
5555

5656
protected:
5757
bool started = false;
58-
// implementation keeps temperature in 1/100th of a degree, any temperature unit
58+
// implementation keeps temperature in 1/100th Celsius x 100 (int16_t) normalized value
5959
int16_t rawTemperature = 0;
6060
// internal function to set the raw temperature value (Matter Cluster)
6161
bool setRawTemperature(int16_t _rawTemperature);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.