Skip to content

Instantly share code, notes, and snippets.

@ksasao
Last active September 21, 2020 09:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksasao/cf601184691e59297fd464af910966b4 to your computer and use it in GitHub Desktop.
Save ksasao/cf601184691e59297fd464af910966b4 to your computer and use it in GitHub Desktop.
M5Atom で ENV II Unit を動かすサンプルです。
// ENVII Read test for M5Atom
// 2020/5/22 @ksasao
// see https://twitter.com/ksasao/status/1263830103819055104
/*Please install the < Adafruit BMP280 Library > (https://github.com/adafruit/Adafruit_BMP280_Library)
* from the library manager before use.
*This code will display the temperature, humidity and air pressure information on the screen*/
#include <M5Atom.h>
#include <Wire.h>
#include "Adafruit_Sensor.h"
#include <Adafruit_BMP280.h>
#include "SHT3X.h"
SHT3X sht30;
Adafruit_BMP280 bme;
float tmp = 0.0;
float hum = 0.0;
float pressure = 0.0;
void setup() {
M5.begin(true, false, true);
Wire.begin(26,32);
Serial.println(F("ENV Unit(SHT30 and BMP280) test..."));
while (!bme.begin(0x76)){
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
}
}
void loop() {
pressure = bme.readPressure();
if(sht30.get()==0){
tmp = sht30.cTemp;
hum = sht30.humidity;
}
Serial.printf("Temperatura: %2.2f*C Humedad: %0.2f%% Pressure: %0.2fPa\r\n", tmp, hum, pressure);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment