1234567891011121314151617181920212223242526272829303132333435363738 |
- #include <M5Stack.h>
- #include <Wire.h>
- void setup() {
- M5.begin();
- M5.Power.begin();
- M5.Lcd.setTextColor(WHITE);
- M5.Lcd.setTextSize(3);
- M5.Lcd.clear(BLACK);
- M5.Lcd.setCursor(120, 100);
- }
- uint16_t result;
- float temperature;
- void loop() {
- Wire.beginTransmission(0x5A);
- Wire.write(0x07);
- Wire.endTransmission(false);
- Wire.requestFrom(0x5A, 2);
- result = Wire.read();
- result |= Wire.read() << 8;
-
- temperature = result * 0.02 - 273.15;
-
- M5.Lcd.fillRect(120,100,120,100,BLACK);
- M5.Lcd.setCursor(120, 100);
-
- M5.Lcd.print(temperature);
- Serial.println(temperature);
- delay(500);
- M5.update();
- }
|