Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(matter): Changes Matter Temperature Sensor to report Celsius #10759

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s
// Simulate a temperature sensor - add your preferred temperature sensor library code here
float getSimulatedTemperature() {
// The Endpoint implementation keeps an int16_t as internal value information,
// which stores data in 1/100th of any temperature unit
// which stores data in 1/100th Celsius.
static float simulatedTempHWSensor = -10.0;

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

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

// Matter beginning - Last step, after all EndPoints are initialized
Expand Down Expand Up @@ -102,7 +102,7 @@ void loop() {
// Print the current temperature value every 5s
if (!(timeCounter++ % 10)) { // delaying for 500ms x 10 = 5s
// Print the current temperature value
Serial.printf("Current Temperature is %.02f <Temperature Units>\r\n", SimulatedTemperatureSensor.getTemperature());
Serial.printf("Current Temperature is %.02fC\r\n", SimulatedTemperatureSensor.getTemperature());
// Update Temperature from the (Simulated) Hardware Sensor
// Matter APP shall display the updated temperature percent
SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) {
}
rawTemperature = _rawTemperature;
}
log_v("Temperature Sensor set to %.02f Degrees", (float)_rawTemperature / 100.00);
log_v("Temperature Sensor set to %.02fC", (float)_rawTemperature / 100.00);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MatterTemperatureSensor : public MatterEndPoint {
public:
MatterTemperatureSensor();
~MatterTemperatureSensor();
// begin Matter Temperature Sensor endpoint with initial float temperature
// begin Matter Temperature Sensor endpoint with initial float temperature in Celsius
bool begin(double temperature = 0.00) {
return begin(static_cast<int16_t>(temperature * 100.0f));
}
Expand All @@ -32,11 +32,11 @@ class MatterTemperatureSensor : public MatterEndPoint {

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

protected:
bool started = false;
// implementation keeps temperature in 1/100th of a degree, any temperature unit
// implementation keeps temperature in 1/100th Celsius x 100 (int16_t) normalized value
int16_t rawTemperature = 0;
// internal function to set the raw temperature value (Matter Cluster)
bool setRawTemperature(int16_t _rawTemperature);
Expand Down
Loading