Skip to content

Instantly share code, notes, and snippets.

View TakehikoShimojima's full-sized avatar

Takehiko Shimojima TakehikoShimojima

View GitHub Profile
/*
* M5StackとBME680をI2C接続し、温度、湿度、気圧を測定しプリントアプトする
*/
#include <M5Stack.h>
#include <Wire.h>
#include "Adafruit_BME680.h"
#include "Ambient.h"
#define PERIOD 60
#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の初期化
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...')
#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);
#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
#include <M5Stack.h>
HardwareSerial GPS_s(2);
void setup() {
M5.begin();
GPS_s.begin(9600);
}
void loop() {
#include <M5Stack.h>
#include <TinyGPS++.h>
HardwareSerial GPS_s(2);
TinyGPSPlus gps;
void setup() {
M5.begin();
GPS_s.begin(9600);
}
#include <M5Stack.h>
#define HR_pin 36 // 心拍センサーの信号線をGPIO36につなぐ
void setup(){
M5.begin();
dacWrite(25, 0); // Speaker OFF
Serial.println("Pulse sensor test");
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に戻して
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: