Skip to content

Instantly share code, notes, and snippets.

Avatar

Kohei MATSUSHITA ma2shita

View GitHub Profile
@ma2shita
ma2shita / extend-sinatra-app-skelton-db.diff
Created Dec 1, 2014
Extend Sinatra-App-Skelton for using DB(PostgreSQL)
View extend-sinatra-app-skelton-db.diff
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"
View extract_sigfox_sensit_repub_to_awsiot.js
/*
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 Oct 9, 2017
Example for "Sigfox Shield for Arduino (UnaShield V2S)" with SORACOM Harvest
View example_for_unashieldv2s_w_soracom_harvest.ino
/* 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 Nov 7, 2017
dmsg of Huawei MS2131i-8 on Raspbian Stretch (linux 4.9)
View dmsg_of_ms2131i-8.txt
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 Dec 4, 2017
wio-lte-sent-to-both-harvest-and-funnel
View wio-lte-sent-to-both-harvest-and-funnel.ino
/* 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 Dec 31, 2017
Define setting in Wio LTE by OTA (Tag of SORACOM Air SIM)
View wio-lte-define-by-ota.ino
/*
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 Jan 10, 2018
WioLTE emit IMEI to SORACOM Harvest
View WioLTE_emit_IMEI_to_SORACOM_Harvest.ino
#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 Jan 19, 2018
Example code of read sensor data of multiple SensorTag (CC2541DK-SENSOR, CC2650STK) at same time by using node-sensortag
View multiple_sensortag.js
/*
* 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 Feb 7, 2018
Grove UltrasonicRanger plot to SORACOM Harvest (for CodeZine)
View grove-ultrasonic-ranger_soracom-harvest.ino
/* 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 Feb 10, 2018
Grove Buzzer Control via MQTT of PubNub and SORACOM Beam (for CodeZine)
View grove-buzzer-with-mqtt-and-soracom-beam.ino
/* 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"