From 94a4869aede234aafc2f524356b0aebb51b5bcf7 Mon Sep 17 00:00:00 2001 From: ms34me <10122657+ms34me@users.noreply.github.com> Date: Wed, 26 Jul 2017 19:45:20 -0700 Subject: [PATCH 1/2] send configuration settings in testConnection() send configuration settings in testConnection() --- MCP342X.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MCP342X.cpp b/MCP342X.cpp index f0390f1..e84db8e 100644 --- a/MCP342X.cpp +++ b/MCP342X.cpp @@ -70,6 +70,7 @@ MCP342X::MCP342X(uint8_t address) { */ bool MCP342X::testConnection() { Wire.beginTransmission(devAddr); + Wire.write(configRegShdw | MCP342X_RDY); return (Wire.endTransmission() == 0); } From ee46111cc845410a9fe6cf23e843483b65acbde9 Mon Sep 17 00:00:00 2001 From: ms34me <10122657+ms34me@users.noreply.github.com> Date: Wed, 26 Jul 2017 19:48:18 -0700 Subject: [PATCH 2/2] updated example testConnection() now sends config settings. So, it had to be moved to AFTER the setup of ConfigRegShdw --- Examples/ReadLoop/ReadLoop.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples/ReadLoop/ReadLoop.ino b/Examples/ReadLoop/ReadLoop.ino index 47099e9..93e0a25 100644 --- a/Examples/ReadLoop/ReadLoop.ino +++ b/Examples/ReadLoop/ReadLoop.ino @@ -14,15 +14,17 @@ void setup() { while (!Serial) {} // wait for Serial comms to become ready Serial.println("Starting up"); Serial.println("Testing device connection..."); - Serial.println(myADC.testConnection() ? "MCP342X connection successful" : "MCP342X connection failed"); - + myADC.configure( MCP342X_MODE_CONTINUOUS | MCP342X_CHANNEL_1 | MCP342X_SIZE_16BIT | MCP342X_GAIN_1X ); - - Serial.println(myADC.getConfigRegShdw(), HEX); + + Serial.print("ConfigRegShdw: 0b"); + Serial.println(myADC.getConfigRegShdw(), BIN); // verify the settings + + Serial.println(myADC.testConnection() ? "MCP342X connection successful" : "MCP342X connection failed"); } // End of setup()