M5Stack 및 BME280 센서로 환경 데이터 얻기
소개
M5Stack이라는 ESP32 기판의 마이크로 컴퓨터 보드에 환경 센서를 연결하고 온도, 습도, 압력 정보를 M5Stack의 LCD 화면에 표시해 보았습니다.
작업 내용
BME280 보드를 준비합니다. 센서 라이브러리가 충실한 이유로 Adafruit의 제품을 구입합니다.
M5Stack 본체 과 확장 보드 를 준비합니다.
사진 1. M5Stack 본체의 내부 ESP32가 보입니다.
사진 2. M5Stack용 확장 보드에 BME280을 설치했습니다. 중앙부에 MPU-9250이라고 하는 9축 센서도 설치했습니다만, 이번은 설명 대상외입니다.
실행 결과
프로그램을 업로드합니다.
잘 시작했습니다. 했어!
요약
1. M5Stack이라는 마이크로 컴퓨터 보드에 BME280 환경 센서를 설치하여 동작을 확인했습니다.
눈치채다
마이컴 보드에 LCD 화면이 탑재되어 있으면, 활용도가 오르네요. 디자인도 귀엽기 때문에, M5Stack로 해도 좋았다고 생각합니다.
ESP32와 가까운 위치에 온도 센서를 설치했기 때문에 실온보다 3-5℃ 높은 수치를 나타냅니다.
업데이트
M5Stack+BME280으로부터 취득한 데이터를 클라우드 업로드해, 가시화한 내용을 게재했습니다.
M5Stack과 BME280 센서로 획득한 환경 데이터를 클라우드에서 시각화
참고 자료
1. M5Stack이라는 마이크로 컴퓨터 보드에 BME280 환경 센서를 설치하여 동작을 확인했습니다.
눈치채다
마이컴 보드에 LCD 화면이 탑재되어 있으면, 활용도가 오르네요. 디자인도 귀엽기 때문에, M5Stack로 해도 좋았다고 생각합니다.
ESP32와 가까운 위치에 온도 센서를 설치했기 때문에 실온보다 3-5℃ 높은 수치를 나타냅니다.
업데이트
M5Stack+BME280으로부터 취득한 데이터를 클라우드 업로드해, 가시화한 내용을 게재했습니다.
M5Stack과 BME280 센서로 획득한 환경 데이터를 클라우드에서 시각화
참고 자료
IoT 시각화 서비스 Ambinet 사의 시모무라씨가 쓴 책을 참고로 했습니다.
M5Stack, ESP32 일반에 관한 정보를 알기 쉽게 정리했으므로, M5Stack 유저에게는 절대 추천합니다.
프로그램 코드
M5Stack_BME280.ino/
#include <Wire.h> //IC2 Library
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <M5Stack.h>
#define SEALEVELPRESSURE_HPA (1013.25) //Ambient Pressure
Adafruit_BME280 bme; // I2C Instance
unsigned long delayTime;
void setup() {
//M5Stack Setup
M5.begin();
M5.lcd.setTextSize(3);
Serial.begin(115200);
while(!Serial); // time to get serial running
Serial.println(F("BME280 test"));
unsigned status;
// default settings
status = bme.begin();
// You can also pass in a Wire library object like &Wire2
// status = bme.begin(0x76, &Wire2)
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1) delay(10);
}
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
}
void loop() {
M5printValues();
printValues();
delay(delayTime);
}
void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
void M5printValues() {
float temp = bme.readTemperature();
float pres = bme.readPressure()/1000.0F; //[kPa]
float humid = bme.readHumidity();
M5.Lcd.setCursor(20,40);
M5.Lcd.print("Temp: ");
M5.Lcd.print(temp,1);
M5.Lcd.print("degC");
M5.Lcd.setCursor(20,100);
M5.Lcd.print("Pressure: ");
M5.Lcd.print(pres,1);
M5.Lcd.print("kPa");
M5.Lcd.setCursor(20,160);
M5.Lcd.print("Humidity: ");
M5.Lcd.print(humid,1);
M5.Lcd.print("%RH");
}
Reference
이 문제에 관하여(M5Stack 및 BME280 센서로 환경 데이터 얻기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kotai2003/items/80fe919b20640a86bace
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
/
#include <Wire.h> //IC2 Library
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <M5Stack.h>
#define SEALEVELPRESSURE_HPA (1013.25) //Ambient Pressure
Adafruit_BME280 bme; // I2C Instance
unsigned long delayTime;
void setup() {
//M5Stack Setup
M5.begin();
M5.lcd.setTextSize(3);
Serial.begin(115200);
while(!Serial); // time to get serial running
Serial.println(F("BME280 test"));
unsigned status;
// default settings
status = bme.begin();
// You can also pass in a Wire library object like &Wire2
// status = bme.begin(0x76, &Wire2)
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1) delay(10);
}
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
}
void loop() {
M5printValues();
printValues();
delay(delayTime);
}
void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
void M5printValues() {
float temp = bme.readTemperature();
float pres = bme.readPressure()/1000.0F; //[kPa]
float humid = bme.readHumidity();
M5.Lcd.setCursor(20,40);
M5.Lcd.print("Temp: ");
M5.Lcd.print(temp,1);
M5.Lcd.print("degC");
M5.Lcd.setCursor(20,100);
M5.Lcd.print("Pressure: ");
M5.Lcd.print(pres,1);
M5.Lcd.print("kPa");
M5.Lcd.setCursor(20,160);
M5.Lcd.print("Humidity: ");
M5.Lcd.print(humid,1);
M5.Lcd.print("%RH");
}
Reference
이 문제에 관하여(M5Stack 및 BME280 센서로 환경 데이터 얻기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kotai2003/items/80fe919b20640a86bace텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)