Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0
j3tm0t0 / room-monitor.ino
Last active December 8, 2020 06:26
room-monitor for dragino w/Air Quality Sensor
/*
* send_multiple_sensor_data_with_soracom.ino
* Multiple sensor value send to Cloud via Unified Endpoint of SORACOM
*
* Copyright (c) 2020 SORACOM, INC.
* This software is released under the MIT License.
* http://opensource.org/licenses/mit-license.php
*/
#define CONSOLE Serial
@j3tm0t0
j3tm0t0 / soracom-harvest-location.ino
Created April 27, 2018 00:56
send location data to harvest based on cell tower
#include <WioLTEforArduino.h>
#include <stdio.h>
#define INTERVAL (60000)
#define RECEIVE_TIMEOUT (10000)
// uncomment following line to use Temperature & Humidity sensor
// #define SENSOR_PIN (WIOLTE_D38)
WioLTE Wio;
@j3tm0t0
j3tm0t0 / status.sh
Last active March 5, 2018 08:53
status display / reboot & shutdown script for MESH Status board
#!/bin/bash
# PIN assign
BUTTON=2
LAN=3
INTERNET=4
NG=14
OK=15
# Command for button
PUSH="sudo reboot"
@j3tm0t0
j3tm0t0 / AK-020_setup.sh
Last active May 16, 2016 06:33
run as root to configure your raspbian to use AK-020 with SORACOM Air SIM
#!/bin/bash
# install required packages
apt-get install -y eject wvdial
# add wvdial config
cat << EOF > /etc/wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = AT+CFUN=1
Init3 = AT+CGDCONT=1,"IP","soracom.io"
@j3tm0t0
j3tm0t0 / put_metrics.sh
Last active November 12, 2015 18:12
put on-board temperature and CPU usage as JSON on Raspberry Pi
#!/bin/bash
json=$(
awk '{printf "{\"temperature\":%3.1f,", $1/1000}' /sys/class/thermal/thermal_zone0/temp
top -b -n 2 | grep %Cpu | tail -1 |a awk '{printf "\"CPU\":%.1f}\n", $2+$4+$6+$10+$12+$14}'
)
echo $json
@j3tm0t0
j3tm0t0 / Beam_to_AWSIoT.rb
Last active May 2, 2019 01:36
2015/10/16 SORACOM Developer Conference LT : brew install mdp && mdp LT.md で見れます
#!/usr/bin/env ruby
require 'soracom'
require 'json'
if ARGV.length < 3
puts <<EOS
usage: #{$PROGRAM_NAME}" key.pem cert.pem ca.pem [ group-id ]
If 'group-id' is provided, this program will set Beam config to access AWS IoT.
If 'group-id' is not provided, this program will generate JSON to use with CLI.
@j3tm0t0
j3tm0t0 / connect_air.sh
Last active April 13, 2018 15:53
SORACOM Air + FS01BU or AK-020 を、Raspberry Pi や Intel Edison (debianインストール&USB-OTGケーブルで接続) で使用するための接続スクリプト(要: wvdial / usb-modeswitch)と、init用スクリプト by dietposter
#!/bin/bash
init_fs01bu()
{
usb_modeswitch -t <<EOF
DefaultVendor= 0x$1
DefaultProduct= 0x$2
TargetVendor= 0x$3
TargetProduct= 0x$4
MessageEndpoint= not set
MessageContent="55534243123456780000000080000606f50402527000000000000000000000"
@j3tm0t0
j3tm0t0 / periodiic.json
Last active May 9, 2016 22:33
periodic sns alarm by itself (for cron-like lambda execution)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"period": {
"Default": 3300,
"Description": "SQS message lifetime. SNS events will be kicked every (300 + this value) seconds",
"Type": "Number"
}
},
"Resources": {
@j3tm0t0
j3tm0t0 / app.zip
Last active October 30, 2020 10:01 — forked from supinf/s3-invalidation.js
CloudFront Invalidation using Lambda via SNS
@j3tm0t0
j3tm0t0 / lambda2cw.coffee
Last active August 29, 2015 14:10
lambda2cw - analyze S3 log files and put custom metric data to CloudWatch
console.log 'lambda2cw Started'
aws = require 'aws-sdk'
s3 = new aws.S3
apiVersion: '2006-03-01'
cw = new aws.CloudWatch
apiVersion: '2010-08-01'
putMetrics = (metrics,namespace,callback) ->
metricdata=metrics.splice(0,20) # Max 20 metric data per request