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
/* | |
* M5StackとBME680をI2C接続し、温度、湿度、気圧を測定しプリントアプトする | |
*/ | |
#include <M5Stack.h> | |
#include <Wire.h> | |
#include "Adafruit_BME680.h" | |
#include "Ambient.h" | |
#define PERIOD 60 |
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 "Ambient.h" // Ambientのヘッダーをインクルード | |
Ambient ambient; // Ambientオブジェクトを定義 | |
unsigned int channelId = 100; // AmbientのチャネルID | |
const char* writeKey = "writeKey"; // ライトキー | |
void setup() { | |
... | |
ambient.begin(channelId, writeKey, &client); // チャネルIDとライトキーを指定してAmbientの初期化 |
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
import machine | |
import utime | |
from m5stack import lcd | |
import bme280 | |
import ambient | |
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21)) | |
bme = bme280.BME280(i2c=i2c) | |
am = ambient.Ambient(100, '...writeKey...') |
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 <ESP8266WiFi.h> | |
#include <SoftwareSerial.h> | |
static const int RXPin = 2, TXPin = 12; // ソフトシリアルのピンの指定 | |
SoftwareSerial ss(RXPin, TXPin, false, 256); // ソフトシリアルのオブジェクト | |
void setup() | |
{ | |
Serial.begin(115200); | |
delay(20); |
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 <ArduinoJson.h> | |
#include <ESP8266HTTPClient.h> | |
#include <ESP8266WiFi.h> | |
#include <ESP8266WiFiMulti.h> | |
#include "Ambient.h" | |
const char* ssid = "ssid"; | |
const char* password = "password"; | |
unsigned int channelId = 100; // AmbientのチャネルID |
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 <M5Stack.h> | |
HardwareSerial GPS_s(2); | |
void setup() { | |
M5.begin(); | |
GPS_s.begin(9600); | |
} | |
void loop() { |
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 <M5Stack.h> | |
#include <TinyGPS++.h> | |
HardwareSerial GPS_s(2); | |
TinyGPSPlus gps; | |
void setup() { | |
M5.begin(); | |
GPS_s.begin(9600); | |
} |
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 <M5Stack.h> | |
#define HR_pin 36 // 心拍センサーの信号線をGPIO36につなぐ | |
void setup(){ | |
M5.begin(); | |
dacWrite(25, 0); // Speaker OFF | |
Serial.println("Pulse sensor test"); |
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
void loop() { | |
delay(REDRAW); // REDRAW時間(20ミリ秒)待つ | |
int y = pulseSensor.getLatestSample(); // 最新の心拍センサーの値を取得 | |
if (x > 0) { | |
M5.Lcd.drawLine(x - 1, lastY, x, y, WHITE); // LCDに描画 | |
lastY = y; | |
} | |
if (++x > LCD_WIDTH) { // LCD画面の最後まで描いたら | |
x = 0; // x軸を0に戻して |
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
class ScanDelegate(DefaultDelegate): | |
def __init__(self): | |
DefaultDelegate.__init__(self) | |
def handleDiscovery(self, dev, isNewDev, isNewData): # スキャンハンドラー | |
if isNewDev: # 新しいデバイスが見つかったら | |
print('found dev (%s)' % dev.addr) | |
scanner = Scanner().withDelegate(ScanDelegate()) | |
while True: |