Change read_raw_i2c_temp to return temp and humidity #419

Merged
qtemp merged 4 commits from master into master 2021-10-13 18:37:01 +01:00
qtemp commented 2021-05-05 02:04:44 +01:00 (Migrated from github.com)

Change read_raw_i2c_temp to read one or two float values from slave; one for temperature and the other for humidity.

Modified get_sensor_data to populate temp & hum based on the sensor type:

  • When the sensor type is "temp_raw_i2c" the resulting assignment is temp followed by hum.

  • When the sensor type is "hum_raw_i2c" the resulting assignment is hum followed by temp.

Added hum_raw_i2c and temp_raw_i2c to list of humdityCapableSensor's.

Arduino code for sending two float values:

    float data[2];
    data[0] = (float) t1; // Temp
    data[1] = (float) h1; // Humidity
    Wire.write((uint8_t*) data, sizeof(data));

Arduino code for sending a single float value:

    float data[1];
    data[0] = (float) t1; // Temp
    Wire.write((uint8_t*) data, sizeof(data));

or

union floatBytes
{
  uint8_t bytes[4];
  float value;
} floatContainer;

    floatContainer.value = t1;
    Wire.write(floatContainer.bytes, sizeof(float));

Change read_raw_i2c_temp to read one or two float values from slave; one for temperature and the other for humidity. Modified get_sensor_data to populate temp & hum based on the sensor type: - When the sensor type is "temp_raw_i2c" the resulting assignment is temp followed by hum. - When the sensor type is "hum_raw_i2c" the resulting assignment is hum followed by temp. Added hum_raw_i2c and temp_raw_i2c to list of humdityCapableSensor's. Arduino code for sending two float values: ``` float data[2]; data[0] = (float) t1; // Temp data[1] = (float) h1; // Humidity Wire.write((uint8_t*) data, sizeof(data)); ``` Arduino code for sending a single float value: ``` float data[1]; data[0] = (float) t1; // Temp Wire.write((uint8_t*) data, sizeof(data)); ``` or ``` union floatBytes { uint8_t bytes[4]; float value; } floatContainer; floatContainer.value = t1; Wire.write(floatContainer.bytes, sizeof(float)); ```
vitormhenrique commented 2021-10-13 18:37:16 +01:00 (Migrated from github.com)

We probably need to add this to the readme and wiki as well.

We probably need to add this to the readme and wiki as well.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#419