Last active
December 3, 2020 02:59
-
-
Save TakehikoShimojima/fe4c3e9f360f419aa0835d4176b032a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <M5StickC.h> | |
#include <Wire.h> | |
#include "Adafruit_Sensor.h" | |
#include <Adafruit_BMP280.h> | |
#include "SHT3X.h" | |
#include "Ambient.h" | |
SHT3X sht30; | |
Adafruit_BMP280 bme; | |
WiFiClient client; | |
Ambient ambient; | |
const char* ssid = "ssid"; | |
const char* password = "password"; | |
unsigned int channelId = 100; // AmbientのチャネルID | |
const char* writeKey = "writeKey"; // ライトキー | |
float tmp = 0.0; | |
float hum = 0.0; | |
float pressure = 0.0; | |
void setup() { | |
M5.begin(); | |
Wire.begin(); | |
M5.Lcd.setTextSize(2); | |
M5.Lcd.setRotation(3); | |
M5.Lcd.fillScreen(BLACK); | |
while (!bme.begin(0x76)){ | |
M5.Lcd.println("Could not find a valid BMP280 sensor, check wiring!"); | |
} | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
M5.Lcd.print("."); | |
} | |
M5.Lcd.print("WiFi connected\r\nIP address: "); | |
M5.Lcd.println(WiFi.localIP()); | |
ambient.begin(channelId, writeKey, &client); | |
} | |
void loop() { | |
pressure = bme.readPressure() / 100; | |
if(sht30.get()==0){ | |
tmp = sht30.cTemp; | |
hum = sht30.humidity; | |
} | |
M5.Lcd.fillScreen(BLACK); | |
M5.Lcd.setCursor(0, 0); | |
M5.Lcd.printf("Temp: %2.1f\r\n", tmp); | |
M5.Lcd.printf("Humi: %2.0f%%\r\n", hum); | |
M5.Lcd.printf("Press:%2.0fhPa\r\n", pressure); | |
ambient.set(1, tmp); | |
ambient.set(2, hum); | |
ambient.set(3, pressure); | |
ambient.send(); | |
delay(60 * 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment