Issue with Env-iii hat.
-
Having an issue running the following code with the env-iii hat. Any help would be appreciated.
#include <M5StickCPlus.h> #include "M5_ENV.h" SHT3X sht30; QMP6988 qmp6988; float tmp = 0.0; float hum = 0.0; float pressure = 0.0; int status; void setup() { M5.begin(); //M5.Axp.ScreenBreath(8); M5.Lcd.setRotation(3); Wire.begin(0,26); qmp6988.init(); } void loop() { pressure = qmp6988.calcPressure(); status = sht30.get(); tmp = sht30.cTemp; hum = sht30.humidity; M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(0, 0); M5.Lcd.printf("Temp: %2.1f\r\nHumi: %2.0f%%\r\nPressure:%2.0fPa\r\nStatus: %d", tmp, hum, pressure, status); delay(4000); }04:49:47.756 -> [ 2][I][esp32-hal-i2c.c:75] i2cIni��): Initialising I2C Master: sda=32 scl=33 freq=100000
04:49:47.756 -> [ 5][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
04:49:47.796 -> M5StickCPlus initializing...[ 78][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
04:49:48.391 -> OK
04:49:48.391 -> E (645) ledc: freq_hz=0 duty_resolution=13
04:49:48.391 -> [ 649][E][esp32-hal-ledc.c:75] ledcSetup(): ledc setup failed!
04:49:48.391 -> [ 649][W][Wire.cpp:301] begin(): Bus already started in Master Mode.
04:49:48.391 -> [ 653][W][Wire.cpp:301] begin(): Bus already started in Master Mode.
04:49:49.506 -> [ 1760][E][Wire.cpp:513] requestFrom(): i2cRead returned Error 263
04:49:50.512 -> [ 2761][E][Wire.cpp:513] requestFrom(): i2cRead returned Error 263 -
Hello @goochiecobbler
not sure, what is going wrong. But the Arduino Wire library has changed in the past and has broken some previously working examples.
There is a hint in the log about 'Bus already started in Master Mode' so you could try adding a
Wire.end();before theWire.begin(0, 26);and see if that helps.Thanks
Felix -
That did fix it, thank you so much. <3
I did notice that error, just still familiarizing myself with arduino and wasn't sure how to go about it.Working code follows for anyone wondering.
#include <M5StickCPlus.h> #include "M5_ENV.h" SHT3X sht30; QMP6988 qmp6988; float tmp = 0.0; float hum = 0.0; float pressure = 0.0; void setup() { M5.begin(); M5.Lcd.setRotation(3); Wire.end(); Wire.begin(0,26); qmp6988.init(); } void loop() { pressure = qmp6988.calcPressure(); sht30.get(); tmp = sht30.cTemp; hum = sht30.humidity; M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(0, 0); M5.Lcd.printf("Temp: %2.1f\r\nHumi: %2.0f%%\r\nPressure:%2.0fPa\r\n", tmp, hum, pressure); delay(1000); } -
Hello @goochiecobbler
I am happy to hear it worked. And thank you for reporting back and posting the working code.
Thanks
Felix
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login