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

setAmbientResolution() #13

Merged
merged 5 commits into from
Oct 30, 2024
Merged

Conversation

mikeysklar
Copy link
Contributor

@mikeysklar mikeysklar commented Oct 22, 2024

Tested on MCP9600. Added setAmbientResolution() and included minimal example code. Runs well as expected with higher resolution Ambient readings.

Original example code unmodified also still runs correctly with lower resolution ambient readings.

Test with:
Arduino IDE 2.3.3
Feather RP2040
MCP9600

This came out of a forum request for controlling the resolution for the ambient temperature to match the resolution with the thermocouple. I didn't think it would be a big deal, but it took me a day to realize the datasheet had high / low resolution logic flipped.

mcp9600-resolution

#include <Adafruit_MCP9600.h>

Adafruit_MCP9600 mcp;

// New variables for resolutions
Ambient_Resolution ambientRes = RES_ZERO_POINT_0625;
Thermocouple_Resolution thermocoupleRes = RES_14_BIT;

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);

  if (!mcp.begin(0x67)) {
    Serial.println("Failed to find MCP9600 chip");
    while (1) { delay(10); }
  }

  // Set the resolutions
  mcp.setAmbientResolution(ambientRes);
  mcp.setThermocoupleResolution(thermocoupleRes);

  Serial.println("MCP9600 ready.");
}

void loop() {
  float ambientTemp = mcp.readAmbient();
  float thermocoupleTemp = mcp.readThermocouple();

  Serial.print("Ambient Temp: ");
  Serial.print(ambientTemp, 2);
  Serial.print(" C, Thermocouple Temp: ");
  Serial.print(thermocoupleTemp, 2);
  Serial.println(" C");

  delay(1000);
}

@ladyada

Tested on MCP9600. Added setAmbientResolution() and included minimal example code.
@mikeysklar
Copy link
Contributor Author

@ladyada - The CircuitPython version did not need a setAmbientResolution() interface since the bits can easily be twiddled from user code. The original forum issue was a request for setAmbientResolution() for Arduino library which I have added. @alian35 and I have both tested this and found it to be working as expected.

@ladyada
Copy link
Member

ladyada commented Oct 28, 2024

yah wanna add it as a commented out (or not commented out) line in the exmaples so folks know its there?

@mikeysklar
Copy link
Contributor Author

Good point.

I added ambient resolution to the example sketch. Same format as the ADC settings.

Tested on Feather RP2040 with MCP9600.

I can order a MCP9601 to add equivalent there if you think that is a good idea.

@ladyada ladyada merged commit 6ea508e into adafruit:master Oct 30, 2024
1 check passed
@ladyada
Copy link
Member

ladyada commented Oct 30, 2024

good idea to get the 9601 they are both annoyuing chips

@mikeysklar
Copy link
Contributor Author

I ordered a 9601. I can update this PR or start a fresh one with the 9601 update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants