SHT20 I2C an ESP32 S2 Mini nicht nutzbar

Hallo, ich erhalte den 998 Fehler im SerialMonitor und kann den SHT20 folglich nicht nutzen.
Das heißt, der Sketch unter DFRobot_SHT20 > getHumidityAndTemperature.ino gibt aus:
Time:287635 Temperature:998.0C Humidity:998.0%
Sensor wird also nicht erkannt.
Modul Wemos S2 Mini
Modul SHT20

Idealerweise funktioniert dieser aber mit einem Arduino Mega einwandfrei!
Ein baugleiches SHT20 Modul verhält sich identisch. Ein weiterer Wemos S2 Mini ebenso. Toll.

Pins laut Schema des Herstellers:
SDA GPIO33 und SCL GPIO35

SDA und SCL in variants/esp32s2/pins_arduino.h folglich manuell eingestellt:
static const uint8_t SDA = 33;
static const uint8_t SCL = 35;

Hier stand standardmäßig
static const uint8_t SDA = 8;
static const uint8_t SCL = 9;
drin, auch diese Pins habe ich getestet und natürlich auch umgesteckt.

Es ist nichts anderes angeschlossen.
SDA geht an Pin 33 des ESP32S2 und SCL an Pin 35
VCC ist bei Arduino und ESP32 jeweils 3.3V gewesen.
Ich habe keinerlei experimente mit Widerständen gemacht.

gewähltes Modul in Arduino IDE 1.8.19: "ESP32S2 Dev Module".
Wird erkannt als:
BN: ESP32S2 Dev Module
VID: 303a
PID: 0002
SN: 0
installierte Boardversion ESP32 2.0.11

Ich habe den ganzen Tag vergeudet, habe viel rumprobiert und gegoogelt und keine Lösung gefunden. Denn die Einträge in der variants/esp32s2/pins_arduino.h habe ich ja schon angepasst.
Wie bekomme ich den SHT20 mit dem Wemos S2 Mini zur Zusammenarbeit bewegt?

Sketch:

#include "DFRobot_SHT20.h"

/**
 * Hardware Connections:
 * -VCC = 3.3V
 * -GND = GND
 * -SDA = A4 (use inline 330 ohm resistor if your board is 5V)
 * -SCL = A5 (use inline 330 ohm resistor if your board is 5V)
 */
DFRobot_SHT20 sht20(&Wire, SHT20_I2C_ADDR);

void setup()
{
  Wire.begin(33, 35);
  Serial.begin(115200);
  
  // Init SHT20 Sensor
  sht20.initSHT20();
  delay(100);
  Serial.println("Sensor init finish!");

  /**
   * Check the current status information of SHT20
   * Status information: End of battery, Heater enabled, Disable OTP reload
   * Check result: yes, no
   */
  sht20.checkSHT20();
}

void loop()
{
  /**
   * Read the measured data of air humidity
   * Return the measured air humidity data of float type, unit: %
   */
  float humd = sht20.readHumidity();

  /**
   * Read the measured temp data
   * Return the measured temp data of float type, unit: C
   */
  float temp = sht20.readTemperature();

  Serial.print("Time:");
  Serial.print(millis());   // Get the system time from Arduino
  Serial.print(" Temperature:");
  Serial.print(temp, 1);   // Only print one decimal place
  Serial.print("C");
  Serial.print(" Humidity:");
  Serial.print(humd, 1);   // Only print one decimal place
  Serial.print("%");
  Serial.println();

  delay(1000);
}

Wenn ich Wire > WireScan ausführe, bekomme ich:
Scanning for I2C devices ...
Error 5 at address 0x01
Error 5 at address 0x02
Error 5 at address 0x03
Error 5 at address 0x04
Error 5 at address 0x05
Error 5 at address 0x06
Error 5 at address 0x07
Error 5 at address 0x08
Error 5 at address 0x09
Error 5 at address 0x0A
Error 5 at address 0x0B
...
was so viel wie IC2 busy bedeutet, meine ich. Aha.

#include "Wire.h"

void setup() {
  Serial.begin(115200);
  Wire.begin(33, 35);
}

void loop() {
  byte error, address;
  int nDevices = 0;

  delay(5000);

  Serial.println("Scanning for I2C devices ...");
  for(address = 0x01; address < 0x7f; address++){
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0){
      Serial.printf("I2C device found at address 0x%02X\n", address);
      nDevices++;
    } else if(error != 2){
      Serial.printf("Error %d at address 0x%02X\n", error, address);
    }
  }
  if (nDevices == 0){
    Serial.println("No I2C devices found");
  }
}

Habe den mit der im Sketch gezeigter Lib fehlerfrei kompiliert.
Mit der DFRobot habe mall Probleme gehabt.

//
//    FILE: SHT2x_demo_ESP32.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: demo
//     URL: https://github.com/RobTillaart/SHT2x


#include "Wire.h"
#include "SHT2x.h"

uint32_t start;
uint32_t stop;

SHT2x sht;


void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("SHT2x_LIB_VERSION: \t");
  Serial.println(SHT2x_LIB_VERSION);

  Wire.begin(12, 13);
  sht.begin();

  uint8_t stat = sht.getStatus();
  Serial.print(stat, HEX);
  Serial.println();
}


void loop()
{
  start = micros();
  sht.read();
  stop = micros();

  Serial.print("\t");
  Serial.print(stop - start);
  Serial.print("\t");
  Serial.print(sht.getTemperature(), 1);
  Serial.print("\t");
  Serial.println(sht.getHumidity(), 1);
  delay(1000);
}


//  -- END OF FILE --

hast du es mal mit anderen IO-pins probiert?

Der ESP32-S2 hat mehr IO-pins als ein ESP32__

Möglicherweise ist es aber trotzdem so dass just an die IO-pins 33,35 ebenfalls nur als Input genutzt werden können oder der Flash oder PSRAM-chip an den Pins hängt.

Ich habe mal kurz gegoogelt ob es für den ESP32-S2 auch so eonen Bericht wie für den ESP32__

"which IO-pins to use"

gibt
ich bin aber für den ESP32-S2 nicht fündig geworden.

vgs

Frage zeig mall link zu dem ESP, auf welschen Pins ist der SHT drauf?

Sehe ich im Sketch des TO nicht... Braucht das der ESP nicht?

Manch mall wird in der Lib Aufgerufen. Könne die DF nicht.
Habe reingeschaut in die .h

#include <Arduino.h>
#include <Wire.h>

Hallo,
Pullup Widerstande für den Bus sind verwendet ?

https://learn.adafruit.com/working-with-i2c-devices/pull-up-resistors

Was für SHT ist das?
PullUp Widerstände dran?

link zum ESP:

link zum SHT20
https://aliexpress.com/item/32800566636.html

aber
da stehen die pins

Ja dann teste es doch mal mit pullup-widerständen

Wen die was auf dem Link dann sind welsche drauf(10K), und wie immer falsche angaben es ist ein 3,3V Modul nix mit 5V wie in der Beschreibung.

Bringt mir im serialmonitor leider als Ausgabe:
2175203 -46.8 -6.0
fortlaufend selbe Werte.

PullUps sind welche mit 10k gemessen auf dem sht20 drauf, ja.

Im Datasheet des Herstellers steht ab Seite 12 die Pinbeschreibung.
Welche Pins wären demnach die richtigen SDA und SCL? Sind es dort nicht Pin34+Pin36? ....... auch wenn jeder GPIO für I2C programmierbar sein soll......

Ich habe nun an den im Schema empfohlenen Pins 33 und 35 einen GY-85 3-Achsen-Sensor angeschlossen und er wird ohne Umbauten erkannt.

Versuch die Lib aus #2.

Nach der Beschreibung der Pin sollten alle funktionieren. Versuch kostet nix😊

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.