Skip to content

Instantly share code, notes, and snippets.

View ma2shita's full-sized avatar

Kohei MATSUSHITA ma2shita

View GitHub Profile
@ma2shita
ma2shita / grove-ultrasonic-ranger_soracom-harvest.ino
Created February 7, 2018 13:51
Grove UltrasonicRanger plot to SORACOM Harvest (for CodeZine)
/* CodeZine: Grove IoT Starter Kit for SORACOM <grove-ultrasonic-ranger_soracom-harvest.ino> */
#include <stdio.h>
#include <WioLTEforArduino.h>
WioLTE Wio;
#include <Ultrasonic.h>
#define ULTRASONIC_PIN (WIOLTE_D38)
#define INTERVAL (3000)
#define RECEIVE_TIMEOUT (10000)
@ma2shita
ma2shita / grove-buzzer-with-mqtt-and-soracom-beam.ino
Last active February 10, 2018 04:29
Grove Buzzer Control via MQTT of PubNub and SORACOM Beam (for CodeZine)
/* CodeZine: Grove IoT Starter Kit for SORACOM <grove-buzzer-with-mqtt-and-soracom-beam.ino> */
#include <WioLTEforArduino.h>
#include <WioLTEClient.h>
#include <PubSubClient.h> // https://github.com/knolleary/pubsubclient
#include <stdio.h>
#define APN "soracom.io"
#define USERNAME "sora"
#define PASSWORD "sora"
/* TemperatureAndHumidity Class for DHT11 ==== */
class TemperatureAndHumidity
{
public:
TemperatureAndHumidity(int pin);
bool Read(float* temperature, float* humidity);
private:
int _pin;
void DHT11Init(int pin);
void DHT11Start(int pin);
"""
INPUT: API Gateway
required ENVs;
- OUTGOING_TOKEN: Slack's Outgoing Webhook Token
"""
import json
import logging
logger = logging.getLogger()
"""
`event` is;
{
"transition_wating_sec": <sec:Integer>,
"thing_name": <thingName:String>
}
"""
import json
import logging
@ma2shita
ma2shita / max1click-demo_JF2018_call.py
Last active November 7, 2018 14:25
See: https://qiita.com/ma2shita/items/8f1b4b12faa99dd17063 | SORACOM LTE-M Button (AWS IoT 1-Click) -> this function)
"""
required ENVs;
- INCOMING_WEBHOOK: Slack's Incoming Webhook URL
- PARSON_(SINGLE|DOUBLE|LONG): JSONfy String
{"name": <Display name and Thing name:String>,
"slack_id": <Slack member ID (see profile):String>}
e.g.) {"name":"max","slack_id":"UC0RVEWBZ"}
"""
import json
@ma2shita
ma2shita / call_monitor.html
Last active February 20, 2019 18:22
See: https://qiita.com/ma2shita/items/8f1b4b12faa99dd17063 | Monitoring ThingShadow in AWS IoT Core using Websocket
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Call monitor</title>
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/vue-i18n/dist/vue-i18n.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.404.0/aws-sdk.min.js"></script>
@ma2shita
ma2shita / awsiotcore-deviceshadow_via_soracom-beam.ino
Last active October 29, 2019 04:50
Using Device shadow of AWS IoT Core via SORACOM Beam
/*
* Copyright (c) 2019 Kohei "Max" MATSUSHITA (ma2shita+git@ma2shita.jp)
* Released under the MIT license
* https://opensource.org/licenses/mit-license.php
*/
#include <string.h>
#include <stdio.h>
#include <WioLTEforArduino.h>
WioLTE Wio;
#include <WioLTEClient.h>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MQTT console for AWS IoT Core with MQTT over WebSocket</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.404.0/aws-sdk.min.js" integrity="sha256-5j5NcghceMlKBa2qXSGw6l24mOkiXOsdi9sB21pBips=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.2/mqttws31.min.js" integrity="sha256-UplsBBNj5zR16Nyo1bVLLVd0ndtLYs0A5c4WrbK/etU=" crossorigin="anonymous"></script>
<script>/* from https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/protocols.html */
/**
@ma2shita
ma2shita / m5stack_informater_weather.ino
Last active July 1, 2019 01:49
Weather informater for M5Stack + 3G Ext. board
#include <M5Stack.h>
#include <string.h>
#define TINY_GSM_MODEM_UBLOX
#include <TinyGsmClient.h>
TinyGsm modem(Serial2); /* Serial2 is Modem of 3G Module */
TinyGsmClient ctx(modem);
void modem_enabler();
void print_bottom_menu();