Skip to content

Instantly share code, notes, and snippets.

View ma2shita's full-sized avatar

Kohei MATSUSHITA ma2shita

View GitHub Profile
@ma2shita
ma2shita / m5stack_rainradar.ino
Last active March 15, 2024 09:59
RainRadar by YOLP for M5Stack
/*
* Copyright (c) 2019 Kohei "Max" MATSUSHITA
* Released under the MIT license
* https://opensource.org/licenses/mit-license.php
*/
#include <M5Stack.h>
#define CONSOLE Serial
#define MODEM Serial2 /* Serial2 is Modem of 3G Module */
#include <string.h>
import os
import json
import urllib.request
import urllib.parse
SLACK_CHANNEL_ID = os.environ['SLACK_CHANNEL_ID']
def lambda_handler(event, _):
print(f'{event=}')
btn = event['deviceEvent']['buttonClicked']['clickType']
text = f'ボタンが「{btn}」で押されました。<@UC0RVEWBZ> 仕組み: https://ma2shita.s3.ap-northeast-1.amazonaws.com/awssummittokyo2023a/AWS+Summit+Tokyo+2023.png'
@ma2shita
ma2shita / m5stack_tof_ranger2.ino
Last active January 13, 2023 06:56
ToF ranger with 3G ext. board and SORACOM UnifiedEndpoint for M5Stack / See: https://soracom.github.io/iot-recipes/poka-yoke-for-coffee-dispenser-by-m5stack/
/*
* Copyright (c) 2022 SORACOM, INC.
* Released under the MIT license
* https://opensource.org/licenses/mit-license.php
*/
#include <M5Stack.h>
#include <numeric>
#include <HTTPClient.h> // Why? see https://qiita.com/ma2shita/items/97bf1a0c3158b848019a
#define SerialMon Serial
# Using:
# .\export_images.ps1 7CxxxxxxxxCF "2022/10/18 7:00:00" [LOOP_COUNT:19] -Verbose
# #=> 001.jpg(+2:00) ~ 019.jpg(+38:00)
# Copyright (c) 2022 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
# Released under the MIT license
# https://opensource.org/licenses/mit-license.php
[CmdletBinding()]
Param(
# Using:
# bash export_images.bash 7CxxxxxxxxCF "2022/10/18 7:00:00" [LOOP_COUNT:19]
# #=> 001.jpg(+2:00) ~ 019.jpg(+38:00)
# Copyright (c) 2022 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
# Released under the MIT license
# https://opensource.org/licenses/mit-license.php
DEVICE_ID=$1
START_DATETIME=$2
# Copyright (c) 2022 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
# Released under the MIT license
# https://opensource.org/licenses/mit-license.php
import sys
# Params for sin()
hz = 1.0
length_sec = 4.1
sampling_frequency = 10
# Generate
@ma2shita
ma2shita / m5stack_deviceshadow_3gextboard_soracombeam_example.ino
Last active March 18, 2022 15:45
AWS IoT Core's Device shadow implementation using SORACOM Beam on M5Stack Basic/Gray + 3G ext. board
/*
Example | AWS IoT Core's Device shadow implementation using SORACOM Beam on M5Stack Basic/Gray + 3G ext. board
Copyright (c) 2022 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
Released under the MIT license
https://opensource.org/licenses/mit-license.php
*/
#define _VERSION_ "0.9"
#define THING_NAME "mcu1"
#define SHADOW_NAME "peripheral"
/*
* Copyright (c) 2021 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
* Released under the MIT license
* https://opensource.org/licenses/mit-license.php
*/
#define __VERSION__ "0.999"
#define SerialMon SerialUSB
#define LOOP_INTERVAL_MS 100
/*
* Copyright (c) 2021 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
* Released under the MIT license
* https://opensource.org/licenses/mit-license.php
*/
#define __VERSION__ "0.999"
#define SerialMon SerialUSB
#define LOOP_INTERVAL_MS (100)
@ma2shita
ma2shita / gpio6_shooting.bash
Last active December 29, 2021 03:32
Let's try IoT Prototyping / Fixed point camera with RPi (gpio6 / implementation)
#!/bin/bash
BCM_PIN=6
trap 'exit 0' 1 2 3 15
function _gpio_read() {
# $1 = reading GPIO pin (number of BMC pin)
raspi-gpio get $1 | awk -v RS=" " -F "=" -v k="level" '$1==k {print $2}'
}