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");
}
}