QTPy ESP32-S2 not finding sensor

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Bwts
 
Posts: 4
Joined: Wed Jan 18, 2023 7:46 am

QTPy ESP32-S2 not finding sensor

Post by Bwts »

Arduinio 2.0 IDE, QTPy ESP32-S2, Adafruit MCP9808 temperature sensor, STEMMA connected.
Green LED lit on sensor, no LEDs lit on board.

I'm using the following example code from the Adafruit MCP9808 library,

Code: Select all

#include <Wire.h>
#include "Adafruit_MCP9808.h"

// Create the MCP9808 temperature sensor object
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();

void setup() {
  Serial.begin(9600);
  while (!Serial); //waits for serial terminal to be open, necessary in newer arduino boards.
  Serial.println("MCP9808 demo");
  
  // Make sure the sensor is found, you can also pass in a different i2c
  // address with tempsensor.begin(0x19) for example, also can be left in blank for default address use
  // Also there is a table with all addres possible for this sensor, you can connect multiple sensors
  // to the same i2c bus, just configure each sensor with a different address and define multiple objects for that
  //  A2 A1 A0 address
  //  0  0  0   0x18  this is the default address
  //  0  0  1   0x19
  //  0  1  0   0x1A
  //  0  1  1   0x1B
  //  1  0  0   0x1C
  //  1  0  1   0x1D
  //  1  1  0   0x1E
  //  1  1  1   0x1F
  if (!tempsensor.begin(0x18)) {
    Serial.println("Couldn't find MCP9808! Check your connections and verify the address is correct.");
    while (1);
  }
    
   Serial.println("Found MCP9808!");

  tempsensor.setResolution(3); // sets the resolution mode of reading, the modes are defined in the table bellow:
  // Mode Resolution SampleTime
  //  0    0.5°C       30 ms
  //  1    0.25°C      65 ms
  //  2    0.125°C     130 ms
  //  3    0.0625°C    250 ms
}

void loop() {
  Serial.println("wake up MCP9808.... "); // wake up MCP9808 - power consumption ~200 mikro Ampere
  tempsensor.wake();   // wake up, ready to read!

  // Read and print out the temperature, also shows the resolution mode used for reading.
  Serial.print("Resolution in mode: ");
  Serial.println (tempsensor.getResolution());
  float c = tempsensor.readTempC();
  float f = tempsensor.readTempF();
  Serial.print("Temp: "); 
  Serial.print(c, 4); Serial.print("*C\t and "); 
  Serial.print(f, 4); Serial.println("*F.");
  
  delay(2000);
  Serial.println("Shutdown MCP9808.... ");
  tempsensor.shutdown_wake(1); // shutdown MSP9808 - power consumption ~0.1 mikro Ampere, stops temperature sampling
  Serial.println("");
  delay(200);
}
Compiles fine and when first run I got the following message in the serial monitor,
Couldn't find MCP9808! Check your connections and verify the address is correct.
Note, it never printed
MCP9808 demo
So I unplugged everything, plugged it all back in but now nothing appears in the monitor.

Anyone know what's going on here?

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: QTPy ESP32-S2 not finding sensor

Post by dastels »

The STEMMA-QT connector is connected to the second I2C port. I.e. Wire1, not Wire. See https://learn.adafruit.com/adafruit-qt- ... -scan-test.

In setup() use

Code: Select all

if (!tempsensor.begin(&Wire1)) {
instead of

Code: Select all

if (!tempsensor.begin(0x18)) {
You don't need to pass the address since it's the default. If you do change the address, pass it to begin as a second argument, e.g.

Code: Select all

if (!tempsensor.begin(&Wire1, 0x19)) {
Dave

User avatar
Bwts
 
Posts: 4
Joined: Wed Jan 18, 2023 7:46 am

Re: QTPy ESP32-S2 not finding sensor

Post by Bwts »

Thanks Dave but now I'm not getting anything back in the Serial Monitor, so no idea if it worked.

User avatar
Bwts
 
Posts: 4
Joined: Wed Jan 18, 2023 7:46 am

Re: QTPy ESP32-S2 not finding sensor

Post by Bwts »

Ahh sorted I removed

Code: Select all

while (!Serial); 
Thanks again.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”