Hi,
I’m trying to set up the Grove - I2C High Accuracy Temperature Sensor - MCP9808 on a Seeeduino Wio Lite W600. Using the “MCP9808 Basic” example code, I am getting initialization failures. The code I’m using for setup is below:
#include “Seeed_MCP9808.h”
MCP9808 sensor;
void setup() {
SerialUSB.begin(9600);
delay(5000);
if (sensor.init()) {
SerialUSB.println(“sensor init failed!!”);
} else {
SerialUSB.println(“sensor init!!”);
}
}
Anyone have any ideas what would be causing the initialization to fail?
Thanks in advance!
Your code should not even compile. The line :
MCP9808_sensor;
Should not have an underscore in it. It should be:
MCP9808 sensor;
@Dennis_Mabrey, you are absolutely correct and my apologies. I added that underscore by mistake while I was trying a couple things I found online. I have removed it from the current code. It complies OK without the underscore and prints “sensor init failed!!”.
(I’ve updated the code in the original post to reflect this.)
Ok.
The first question is are you using the Grove Shield for WIO Lite to connect this? If so are you certain it is connected to the I2C port? That would be the port in the top row all the way to the right.
Second question is have you tried running the I2C scanner code on this device to see if it is detecting the sensor? This is what I have my students do when they cannot find an I2C device. You can download and run one from here: https://playground.arduino.cc/Main/I2cScanner/
The I2C address it returns should be 0x18 according to the code.
Hey @Dennis_Mabrey,
Thanks again for chiming in here!!!
First, yes, I am using the Grove Shield for Wio Lite and the sensor is in the correct port.
Second, the scanner shows the address is 0x01? According to the wiki it should be 0x18 as you mentioned… I changed this line in the library per the wiki to:
#define DEFAULT_IIC_ADDR 0X01
With that change in the library, I can compile, etc., but it is still failing initialization. Any follow up ideas?
As always thanks so much!
I would not go changing the I2C address to 0x01. That might be some other I2C device on the W600 (though I didn’t see any listed). If you perform an I2C scan without any sensor plugged in it should tell you if 0x01 is an internal device or not.
Do you have any other I2C devices? If so unplug the MCP9808 and plug in the other device. Then perform an I2C scan. If that gives a good value, you might have an issue with your MCP9808 sensor.
If you don’t get a good value back then you might have something wrong with the Grove Shield.
Looking at the pics of the shield the pins are exposed on the bottom. Make sure you are not putting the shield on a conductive surface (like a metal table).
1 Like