Skip to content

Instantly share code, notes, and snippets.

View ma2shita's full-sized avatar

Kohei MATSUSHITA ma2shita

View GitHub Profile
@ma2shita
ma2shita / extend-sinatra-app-skelton-db.diff
Created December 1, 2014 09:24
Extend Sinatra-App-Skelton for using DB(PostgreSQL)
diff --git Gemfile Gemfile
index a531c7c..2932ed2 100644
--- Gemfile
+++ Gemfile
@@ -4,6 +4,11 @@ gem "sinatra"
gem "grape"
gem "slim"
gem "sass"
+gem "activerecord"
+gem "sinatra-activerecord"
/*
Needs ENVs.
- AWSIOT_ENDPOINT (You see Management Console in AWS IoT setting)
- AWSIOT_TOPIC_PREFIX (any you set)
*/
// code from https://github.com/sigfox/npm-sensit
const SensitMsg = function(sigfoxFrame){
this.frame = Number(parseInt(sigfoxFrame, 16));
this.frameStr = sigfoxFrame;
@ma2shita
ma2shita / example_for_unashieldv2s_w_soracom_harvest.ino
Last active October 9, 2017 09:29
Example for "Sigfox Shield for Arduino (UnaShield V2S)" with SORACOM Harvest
/* Get temperature from on-board sensor, sending SORACOM Harvest via Sigfox */
#include "SIGFOX.h"
static UnaShieldV2S transceiver(COUNTRY_JP, false, "NOTUSED", true); /* ref: https://unabiz.github.io/unashield/ */
void setup() {
Serial.begin(9600);
if (!transceiver.begin()) stop(F("Unable to init SIGFOX module, may be missing"));
}
void loop() {
@ma2shita
ma2shita / dmsg_of_ms2131i-8.txt
Created November 7, 2017 03:29
dmsg of Huawei MS2131i-8 on Raspbian Stretch (linux 4.9)
usb 1-1.2: new high-speed USB device number 4 using dwc_otg
usb 1-1.2: New USB device found, idVendor=12d1, idProduct=14fe
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2: Product: HUAWEI Mobile
usb 1-1.2: Manufacturer: HUAWEI
usb 1-1.2: SerialNumber: FFFFFFFFFFFFFFFF
usb-storage 1-1.2:1.0: USB Mass Storage device detected
scsi host0: usb-storage 1-1.2:1.0
usb 1-1.2: USB disconnect, device number 4
usb 1-1.2: new high-speed USB device number 5 using dwc_otg
@ma2shita
ma2shita / wio-lte-sent-to-both-harvest-and-funnel.ino
Created December 4, 2017 05:13
wio-lte-sent-to-both-harvest-and-funnel
/* Send to both SORACOM Harvest and SORACOM Funnel */
#include <WioLTEforArduino.h>
#include <stdio.h>
#define INTERVAL (10000)
#define SENSOR_PIN (WIOLTE_D38)
WioLTE Wio;
@ma2shita
ma2shita / wio-lte-define-by-ota.ino
Created December 31, 2017 14:57
Define setting in Wio LTE by OTA (Tag of SORACOM Air SIM)
/*
Tag on SORACOM Air SIM
key=_conf
value={"working_mode":"uptime","loop_interval":5000,"send_cloud":true,"endpoint_host":"harvest.soracom.io","endpoint_port":8514}
(alt)value={"working_mode":"led","loop_interval":1000}
*/
#include <stdio.h>
#include <string.h>
#include <WioLTEforArduino.h>
WioLTE Wio;
@ma2shita
ma2shita / WioLTE_emit_IMEI_to_SORACOM_Harvest.ino
Created January 10, 2018 07:11
WioLTE emit IMEI to SORACOM Harvest
#include <stdio.h>
#include <WioLTEforArduino.h>
WioLTE Wio;
#define CLEAR 0
#define GRAY 90
#define RED 91
#define GREEN 92
#define YELLOW 93
#define BLUE 94
@ma2shita
ma2shita / multiple_sensortag.js
Last active January 19, 2018 23:20
Example code of read sensor data of multiple SensorTag (CC2541DK-SENSOR, CC2650STK) at same time by using node-sensortag
/*
* Example code of read sensor data of multiple SensorTag (CC2541DK-SENSOR, CC2650STK) at same time by using node-sensortag
*
* Node.js 0.10.36 or higher (4.4.2 ready)
*
* Usage;
* $ npm install sensortag async
* $ node multiple_sensortag.js
*
* e.g.)
@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"