* Reference Source
- https://www.thingiverse.com/thing:2849398
- https://www.thingiverse.com/thing:2849369
- https://www.thingiverse.com/thing:2853257
- https://www.thingiverse.com/thing:2851040
- https://www.thingiverse.com/thing:2933140
- https://www.thingiverse.com/thing:4042873
- https://www.thingiverse.com/thing:4196820
- https://www.thingiverse.com/thing:4115425
- https://www.thingiverse.com/thing:2791919
- https://www.thingiverse.com/thing:2749146
- https://www.thingiverse.com/thing:2773037
- https://www.thingiverse.com/thing:2347090
- https://www.thingiverse.com/thing:2648038
- https://www.thingiverse.com/thing:3392612
- https://www.thingiverse.com/thing:3181792
- https://www.thingiverse.com/thing:4247453
DynamoDB Stream + Amazon ES (ElasticSearch, Kibana) [P024]
* Parts
- Raspberry Pi
- AWS Lambda Java Project in Ecplise
* Contents
1. Upload sensor data to json file using the Amazon S3 Rest API
- Pi4J + Amazon S3 REST API + Amazon Athena [P019]
2. Amazon Lambda S3 Trigger (node.js) : S3toDynamoDB
- source code : https://github.com/rdiot/rdiot-p022/blob/master/S3toDynamoDB/index.js
'use strict';
console.log('RDIoT S3toDynamoDB Loading post function');
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var dynamo = new AWS.DynamoDB.DocumentClient();
exports.handler = function(event, context, callback) {
console.log('Received event:', JSON.stringify(event, null, 2));
var bucket = event.Records[0]['s3']['bucket']['name'];
var en = event.Records[0]['eventName'];
var et = event.Records[0]['eventTime'];
var key = event.Records[0]['s3']['object']['key'];
var sip = event.Records[0]['requestParameters']['sourceIPAddress'];
var params1 = {Bucket: bucket, Key: key};
s3.getObject( params1, function(err,data) {
if(err) {
console.log(err.stack);
callback(err);
} else {
var value = data.Body.toString('ascii')
console.log(data);
console.log("Raw text:\n" + value);
var params2 = {
TableName: "pi-sensor",
Item:{
"id": et,
"event" : en,
"bucket": bucket,
"key" : key,
"sip": sip,
"value" : value
}
};
console.log("Gettings IoT device details...");
//S3 to DynamoDB
dynamo.put(params2, function(err, data) {
if(err) {
console.error("Unable to post devices. Error JSON:", JSON.stringify(err, null, 2));
context.fail();
} else {
console.log("keepet data:", JSON.stringify(data, null, 2));
context.succeed('success post');
}
});
}
});
}
3. AWS DynamoDB Monitoring
4. Create IAM Role
- It must have basic Amazon ES, DynamoDB, and Lambda execution permissions
- create custom role name : LambdaDynamoDBtoES
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"es:ESHttpPost",
"es:ESHttpPut",
"dynamodb:DescribeStream",
"dynamodb:GetRecords",
"dynamodb:GetShardIterator",
"dynamodb:ListStreams",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
5. Setup Amazon ES (Elasticsearch + Kibana)
- Define domain
- Configure cluster
- Set up access
- Review
- Service dashboard
6. Amazon Lambda DynamoDB Stream Trigger (java) : DynamoDBtoES
7. Develop AWS Lambda Java Project in Eclipse
- New Project : AWS Lambda Java Project
- New AWS Maven Project : awsLambdaDynamoDBStreamtoAmazonES
: Class Name: LambdaFunctionHandler
: Input Type : Dynamodb Event
- Check the items of DynamoDB when running pi4j
- Check the insert event message in the Cloud Watch Log
: public Integer handleRequest(DynamodbEvent event, Context context) {
context.getLogger().log("Received event: " + event);
{ApproximateCreationDateTime: Mon Aug 13 12:07:00 UTC 2018,Keys: {id={S: 2018-08-13T12:07:12.024Z,}},NewImage: {bucket={S: rdiot-test,}, id={S: 2018-08-13T12:07:12.024Z,}, sip={S: 211.245.211.252,}, event={S: ObjectCreated:Put,}, value={S: {"name":"temperature","value":33.0},}, key={S: pi_dht11_2018813079.json,}},SequenceNumber: 187352800000000003101012958,SizeBytes: 175,StreamViewType: NEW_AND_OLD_IMAGES}
https://docs.amazonaws.cn/en_us/elasticsearch-service/latest/developerguide/es-aws-integrations.html#es-aws-integrations-dynamodb-es
https://docs.aws.amazon.com/ko_kr/elasticsearch-service/latest/developerguide/aes-dg.pdf
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023] (0) | 2018.10.17 |
---|---|
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022] (0) | 2018.06.17 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021] (0) | 2018.06.15 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019] (0) | 2018.04.11 |
Amazon Polly + Google Home + Sonoff wifi [P018] (0) | 2018.04.04 |
Bluetooth Audio Receiver Board [B210]
https://www.youtube.com/watch?v=k3NmiGb3d9E
* Specs
Audio input mode:Bluetooth receiver
USB decode and play
TF card decoding playback
Support Playback Format: MP3,WMA,WAV,FLAC
Power Supply: DC 5V (original phone charger can power small USB plug)
Board Size:50 x 40mm
Preamp output can be directly promote the headset and also can be followed
by the use of the power amp
* Contents
- Connect
- Sample
Serial MP3 Music Player Module for Arduino (YX5300) [B208] (0) | 2018.12.18 |
---|---|
MP3 Format Decoder Board Amplifier [B120] (0) | 2016.09.29 |
Bluetooth 4.0 MP3 Decoding Board Module [B147] (0) | 2016.09.29 |
Remote Music USB MP3 Decoder Module [B124] (0) | 2016.09.29 |
Infrared distance sensor (GP2Y0A21YK0F) [S036]
https://www.youtube.com/watch?v=GhNwmtpVTY4
*GitHub : https://github.com/rdiot/rdiot-s036.git
* Specs
operating voltage: 4.5 V to 5.5 V
average current consumption: 30 mA (typical)
distance measuring range: 10 cm to 80 cm (4" to 32")
output type: analog voltage
output voltage differential over distance range: 1.9 V (typical)
response time: 38 ± 10 ms
package size: 29.5×13.0×13.5 mm (1.16×0.5×0.53")
weight: 3.5 g (0.12 oz)
* Contents
- DataSheet : http://www.sparkfun.com/datasheets/Components/GP2Y0A21YK.pdf
- Connect
Yellow ----- A0
Black ----- GND
Red ----- 5V
- Key Code
int pin = A0;
int I = analogRead(pin);
int value = (6762 /(I-9)) -(4);
lcd.print("distance=" + (String)value + "CM ");
Ultrasonic Ranging Module (HC-SR04) [S011] (0) | 2016.09.08 |
---|
Serial MP3 Music Player Module for Arduino (YX5300) [B208]
https://www.youtube.com/watch?v=D9rsBf1b3CM
GitHub : https://github.com/rdiot/rdiot-b208
* Specs
The module is a kind of simple MP3 player device which is based on a high-quality MP3 audio chip---YX5300. It can support 8k Hz ~ 48k Hz sampling frequency MP3 and WAV file formats.
There is a TF card socket on board, so you can plug the micro SD card that stores audio files. MCU can control the MP3 playback state by sending commands to the module via UART port, such as
switch songs, change the volume and play mode and so on. You can also debug the module via USB
to UART module. It is compatible with Arduino / AVR / ARM / PIC.
Features:
1. Support sampling frequency (kHz): 8 / 11.025 / 12 / 16 / 22.05 / 24 / 32 / 44.1 / 48
2. High quality
3. Support file format: MP3 / WAV
4. Support Micro SD card, Micro SDHC Card
5. 30 class adjustable volume
6. UART TTL serial control playback mode, baud rate is 9600bps
7. Power supply can be 3.2 ~ 5.2VDC
8. Control logic interface can be 3.3V / 5V TTL
9. Compatible with Arduino UNO / Leonardo / Mega2560 / DUE
* Contents
- interface
- Connect
Serial MP3 Player - Arduino
GND - GND
VCC - 5V
TX - D5
RX - D6
- Commonly Command bytes Descriptions
- tested source code
: https://github.com/rdiot/rdiot-b208/blob/master/SerialMp3PlayerControl.ino.ino
- Key Code
#include <SoftwareSerial.h>
#define ARDUINO_RX 5 // TX - Arduino RX
#define ARDUINO_TX 6 // RX - Arduino TX
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);
unsigned char playmode = 1;
#define PLAY 1
#define PAUSE 0
static int8_t Send_buf[8] = {0} ;
/************Command byte**************************/
#define CMD_NEXT_SONG 0X01
#define CMD_PREV_SONG 0X02
#define CMD_PLAY_W_INDEX 0X03
#define CMD_VOLUME_UP 0X04
#define CMD_VOLUME_DOWN 0X05
#define CMD_SET_VOLUME 0X06
#define CMD_SINGLE_CYCLE_PLAY 0X08
#define CMD_SEL_DEV 0X09
#define DEV_TF 0X02
#define CMD_SLEEP_MODE 0X0A
#define CMD_WAKE_UP 0X0B
#define CMD_RESET 0X0C
#define CMD_PLAY 0X0D
#define CMD_PAUSE 0X0E
#define CMD_PLAY_FOLDER_FILE 0X0F
#define CMD_STOP_PLAY 0X16
#define CMD_FOLDER_CYCLE 0X17
#define CMD_SET_SINGLE_CYCLE 0X19
#define SINGLE_CYCLE_ON 0X00
#define SINGLE_CYCLE_OFF 0X01
#define CMD_SET_DAC 0X1A
#define DAC_ON 0X00
#define DAC_OFF 0X01
#define CMD_PLAY_W_VOL 0X22
/*********************************************************************/
#define ROTARY_ANGLE_SENSOR A0
#define ADC_REF 5//reference voltage of ADC is 5v
#define VCC 5 //the default value of VCC of the control interface is 5v
#define FULL_ANGLE 280//full value of the rotary angle is 280 degrees
void setup()
{
//pinMode(2, INPUT); // Button - Paluse&Play
Serial.begin(9600);
mySerial.begin(9600);
delay(500);
attachInterrupt(0, playOrPause, RISING);//pin2 -> INT0, and the Touch Sensor
//is connected with pin2 of Arduino
sendCommand(CMD_SEL_DEV, DEV_TF);
delay(200);
sendCommand(CMD_PLAY_W_VOL, 0X0F01);
}
static int8_t pre_vol = 0x0f;
void loop()
{
int degrees;
degrees = getDegree();
int8_t volume;
/*The degrees is 0~280, should be converted to be 0~255 to control the*/
/*brightness of LED */
volume = map(degrees, 0, 280, 30, 0);
if(volume != pre_vol)
{
sendCommand(CMD_SET_VOLUME, volume);
pre_vol = volume;
}
delay(100);
}
void sendCommand(int8_t command, int16_t dat)
{
delay(20);
Send_buf[0] = 0x7e; //
Send_buf[1] = 0xff; //
Send_buf[2] = 0x06; //
Send_buf[3] = command; //
Send_buf[4] = 0x00;//
Send_buf[5] = (int8_t)(dat >> 8);//datah
Send_buf[6] = (int8_t)(dat); //datal
Send_buf[7] = 0xef; //
for(uint8_t i=0; i<8; i++)//
{
mySerial.write(Send_buf[i]);
}
}
int getDegree()
{
int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
float voltage;
voltage = (float)sensor_value*ADC_REF/1023;
float degrees = (voltage*FULL_ANGLE)/VCC;
return degrees;
}
/*Interrupt service routine*/
void playOrPause()
{
cli();
if(playmode == PLAY)
{
playmode = PAUSE;
sendCommand(CMD_PAUSE,0);
}
else
{
playmode = PLAY;
sendCommand(CMD_PLAY,0);
}
sei();
}
- Reference
CATALEX Serial MP3 Player manual version v1.0.1
: https://github.com/rdiot/rdiot-b208/blob/master/Serial%20MP3%20Player%20v1.0%20Manual.pdf
Serial Debug tool - SSCOM32
: https://github.com/rdiot/rdiot-b208/blob/master/Serial%20Debug%20tool%20-%20SSCOM32.zip
Serial MP3 Player Demo Code
: https://github.com/rdiot/rdiot-b208/blob/master/SerialMP3PlayerDemoCode%20for%20Arduino-1.0.zip
Bluetooth Audio Receiver Board [B210] (0) | 2019.02.25 |
---|---|
MP3 Format Decoder Board Amplifier [B120] (0) | 2016.09.29 |
Bluetooth 4.0 MP3 Decoding Board Module [B147] (0) | 2016.09.29 |
Remote Music USB MP3 Decoder Module [B124] (0) | 2016.09.29 |
LW-101 LED Display Water Temperature Meter Monitor [B209]
https://www.youtube.com/watch?v=1FiPwYkkRFg
* Specs
Features:
No batteries required - The device harvests its energy from the water flow Quick and easy installation without any tools - fits with handheld showerhead Materials approved for drinking water
Newest innovated technology to upgrade and modernize your bath room;
self powered battery free thermometer to monitor your shower temperature.
As home essential Needed - to serve and surprise your husband, wife or kids.
(Especially for families having toddlers or babies)
High-precision temperature sensor 360°rotatable waterproof led screen for better viewing.
Specification:
Material : ABS, PC
Size : connect to standard 1/2inch hose or shower head;
Temperate Range : 32-212 ℉, 0-100℃
Weight : 80g
* Contents
- Connect
Call server API for multiple sensor information [P002] (0) | 2017.05.24 |
---|---|
12V Thermostat Temperature Controller with NTC Sensor [S238] (0) | 2016.12.19 |
Temperature and humidity DHT22 (DHT22) [S063] (0) | 2016.09.07 |
MAX6675 Module + K Type Thermocouple Thermocouple Sensor (MAX6675) [S080] (0) | 2016.09.07 |
Infrared Thermometer MLX90614 (GY-906) [S034] (0) | 2016.09.07 |
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023]
https://www.youtube.com/watch?v=37gl-tkUa3M
GitHub : https://github.com/rdiot/rdiot-p023
* Parts
- Pi4J + Amazon S3 REST API + Amazon Athena [P019]
- Raspberry Pi2
- Temperature and humidity DHT11 sensor module (KY-015) [S008]
* Contents
1. Create custom role : AWS Lambda required acess to your resources
- Create a new IAM Role
- Role Name : LambdaSQSRole
- Attach policy : AmazonSQSFullAccess
2. S3 Lambda Trigger : Create function
- Function Name : S3toSQS
- Runtime : Node.js 6.10
- full body
- SQS Receiver : https://github.com/rdiot/rdiot-p023/blob/master/sparkReceiver/src/main/java/com/rdiot/sparkReceiver/receiver/SQSReceiver.java
- SQS Receiver with Delete : https://github.com/rdiot/rdiot-p023/blob/master/sparkReceiver/src/main/java/com/rdiot/sparkReceiver/SQSWithDelete.java
- SQS Receiver without Delete : https://github.com/rdiot/rdiot-p023/blob/master/sparkReceiver/src/main/java/com/rdiot/sparkReceiver/SQSWithoutDelete.java
- s3 event word count source : https://github.com/rdiot/rdiot-p023/blob/master/sparkReceiver/src/main/java/com/rdiot/sparkReceiver/sample/SQSWordCount.java
package com.rdiot.sparkReceiver.sample;
import java.util.Arrays;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.spark.SparkConf;
import org.apache.spark.streaming.Duration;
import org.apache.spark.streaming.Durations;
import org.apache.spark.streaming.api.java.JavaDStream;
import org.apache.spark.streaming.api.java.JavaPairDStream;
import org.apache.spark.streaming.api.java.JavaReceiverInputDStream;
import org.apache.spark.streaming.api.java.JavaStreamingContext;
import com.amazonaws.regions.Regions;
import com.rdiot.sparkReceiver.SQSWithoutDelete;
import com.rdiot.sparkReceiver.receiver.SQSReceiver;
import scala.Tuple2;
public class SQSWordCount {
private static Logger logger = Logger.getLogger(SQSWithoutDelete.class);
final static String appName = "sparkSQSReceiver";
final static String master = "local[2]";
final static String queueName = "jobQueue";
final static Duration batchDuration = Durations.seconds(5); // Batch Duration
final static Duration windowDuration = Durations.seconds(5); // TBD
final static Duration slideDuration = Durations.seconds(3); // TBD
public static void main(String[] args) throws InterruptedException {
Logger.getLogger("org").setLevel(Level.OFF);
//Spark Config
SparkConf conf = new SparkConf().setMaster(master).setAppName(appName);
conf.set("spark.testing.memory", "2147480000"); // if you face any memory issues
try (JavaStreamingContext jssc = new JavaStreamingContext(conf, batchDuration)) {
SQSReceiver javaSQSReceiver = new SQSReceiver(queueName) // 메시지큐 즉시 삭제
.with(Regions.AP_NORTHEAST_2);
System.out.println("# Spark Streaming Start");
JavaReceiverInputDStream<String> input = jssc.receiverStream(javaSQSReceiver);
// SQS Messages
/*
input.foreachRDD(rdd->{
rdd.foreach(w->{
System.out.println(w);
});
});
*/
// Word Count
JavaDStream<String> words = input.flatMap(x -> Arrays.asList(x.split(" ")).iterator());
JavaPairDStream<String, Integer> pairs = words.mapToPair(s -> new Tuple2<>(s, 1));
JavaPairDStream<String, Integer> wordCounts = pairs.reduceByKey((i1, i2) -> i1 + i2);
wordCounts.print();
jssc.start();
jssc.awaitTermination();
} finally {
logger.info("Exiting the Application");
}
}
}
7. Result
- SQS Message
- Word Count : split ':'
* Reference
- AWS Lambda Permissions Model : https://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html
- AWS SQS JS : https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html
- Spark Streaming Custom Receiver : http://spark.apache.org/docs/latest/streaming-custom-receivers.html
DynamoDB Stream + Amazon ES (ElasticSearch, Kibana) [P024] (0) | 2019.04.02 |
---|---|
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022] (0) | 2018.06.17 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021] (0) | 2018.06.15 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019] (0) | 2018.04.11 |
Amazon Polly + Google Home + Sonoff wifi [P018] (0) | 2018.04.04 |
TDA7492P Bluetooth 4.0 Amplifier Board 8-25V 50W (TDA7492P) [D091]
https://www.youtube.com/watch?v=bO7p7wcF7wA
* Specs
- Description
TDA7492P digital amplifier chip, designed to optimize the circuit layout, the sound quality is very good, with big power.
DIP switches can be more easily direcly adjusted after-class amplifier gain, to better promote the impedance larger speakers.
- Specs
Net weight: approx. 33g
Product size: approx.80*50*15mm/3.14*1.96*0.59''
Power: 2.1 interface DC 8~25V power supply
Audio input: stereo input various versions of the Bluetooth connection, using CSP8635 Bluetooth chip, Bluetooth V4.0, high software compatibility.
Output Impedance: 8 ohms Best(4,6,8,16 ohm impedance can drive speakers)
Output power: Add pre-5532 output foot(powered 25V, 6-ohm impedance output 2 X 50W, 8ohm impedance output 2 X 40W dual-channel)
DC 5V Amplifier Board 3W+3W Class D (PAM8403) [B122] (0) | 2016.09.28 |
---|---|
5V Digital Amplifier Module 5W+5W (PAM8406) [D064] (0) | 2016.09.28 |
TDA7297 Audio Amplifier Module DC6-18V 10-50W (TDA7297) [B155] (0) | 2016.09.28 |
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022]
https://www.youtube.com/watch?v=LHZBQmybbqc
GitHub : https://github.com/rdiot/rdiot-p022
* Parts
- Pi4J + Amazon S3 REST API + Amazon Athena [P019]
- Raspberry Pi2
- Temperature and humidity DHT11 sensor module (KY-015) [S008]
* Contents
1. S3 Upload
- Reference : Pi4J + Amazon S3 REST API + Amazon Athena [P019]
2. Run Java Application (pi4j)
- Source :
$ java -Dpi4j.linking=dynamic -jar pi4j_s3rest-0.0.1-SNAPSHOT.jar
3. S3 Storage Monitoring
4. AWS Lambda Monitoring
5. AWS DynamoDB Monitoring
6. AWS Lambda Source (node.js) : S3toDynamoDB
- source code : https://github.com/rdiot/rdiot-p022/blob/master/S3toDynamoDB/index.js
'use strict';
console.log('RDIoT S3toDynamoDB Loading post function');
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var dynamo = new AWS.DynamoDB.DocumentClient();
exports.handler = function(event, context, callback) {
console.log('Received event:', JSON.stringify(event, null, 2));
var bucket = event.Records[0]['s3']['bucket']['name'];
var en = event.Records[0]['eventName'];
var et = event.Records[0]['eventTime'];
var key = event.Records[0]['s3']['object']['key'];
var sip = event.Records[0]['requestParameters']['sourceIPAddress'];
var params1 = {Bucket: bucket, Key: key};
s3.getObject( params1, function(err,data) {
if(err) {
console.log(err.stack);
callback(err);
} else {
var value = data.Body.toString('ascii')
console.log(data);
console.log("Raw text:\n" + value);
var params2 = {
TableName: "pi-sensor",
Item:{
"id": et,
"event" : en,
"bucket": bucket,
"key" : key,
"sip": sip,
"value" : value
}
};
console.log("Gettings IoT device details...");
//S3 to DynamoDB
dynamo.put(params2, function(err, data) {
if(err) {
console.error("Unable to post devices. Error JSON:", JSON.stringify(err, null, 2));
context.fail();
} else {
console.log("keepet data:", JSON.stringify(data, null, 2));
context.succeed('success post');
}
});
}
});
}
7. Lambda : s3 put event sample
8. Lambda : Context Sample
9. Lambda : S3 Object GET Data Sample
DynamoDB Stream + Amazon ES (ElasticSearch, Kibana) [P024] (0) | 2019.04.02 |
---|---|
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023] (0) | 2018.10.17 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021] (0) | 2018.06.15 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019] (0) | 2018.04.11 |
Amazon Polly + Google Home + Sonoff wifi [P018] (0) | 2018.04.04 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021]
https://www.youtube.com/watch?v=xhVIT6XJ01s
GitHub : https://github.com/rdiot/rdiot-p021
* Parts
- Raspberry Pi2
- Temperature and humidity DHT11 sensor module (KY-015) [S008]
* Contents
1. Sample Test (basic publish)
- install maven3 in pi
- download maven3 : https://fossies.org/linux/misc/apache-maven-3.5.3-bin.tar.gz/
$ tar zxvf apache-maven-3.5.3-bin.tar.gz
$ export PATH=/home/pi/AWSIoT/apache-maven-3.5.3/bin:$PATH
- com.amazonaws.services.iot.client.sample.pubSub.PublishSubscribeSample
- download root ca certificate and install aws device sdk for java
- run pub/sub sample
$ unzip http://connect_device_package.zip
$ ./start.sh
mvn exec:java -pl aws-iot-device-sdk-java-samples -Dexec.mainClass="com.amazonaws.services.iot.client.sample.pubSub.PublishSubscribeSample" -Dexec.args="-clientEndpoint <prefix>.iot.<region>.amazonaws.com -clientId <unique client id> -certificateFile <certificate file> -privateKeyFile <private key file>"
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:15 min
[INFO] Finished at: 2018-06-01T13:43:37Z
[INFO] ------------------------------------------------------------------------
Running pub/sub sample application...
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO] ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO]
[INFO] -----------< com.amazonaws:aws-iot-device-sdk-java-samples >------------
[INFO] Building aws-iot-device-sdk-java-samples 1.1.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ aws-iot-device-sdk-java-samples ---
Cert file:../RaspberryPi.cert.pem Private key: ../RaspberryPi.private.key
Jun 01, 2018 1:43:59 PM com.amazonaws.services.iot.client.core.AwsIotConnection onConnectionSuccess
INFO: Connection successfully established
Jun 01, 2018 1:43:59 PM com.amazonaws.services.iot.client.core.AbstractAwsIotClient onConnectionSuccess
INFO: Client connection active: sdk-java
1527860639952: >>> hello from blocking publisher - 1
1527860639952: >>> hello from non-blocking publisher - 1
1527860639973: <<< hello from blocking publisher - 1
1527860639989: <<< hello from non-blocking publisher - 1
1527860640953: >>> hello from non-blocking publisher - 2
1527860640964: >>> hello from blocking publisher - 2
1527860640995: <<< hello from non-blocking publisher - 2
1527860641042: <<< hello from blocking publisher - 2
1527860641953: >>> hello from non-blocking publisher - 3
1527860641979: <<< hello from non-blocking publisher - 3
2. Develop
- Requirements : +java1.7, aws-iot-device-sdk-java 1.1.1, Jackson 2.x, Paho MQTT client for Java 1.1.x, pi4j
- Install the SDK using Maven
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
<version>1.1.1</version>
</dependency>
- source : https://github.com/rdiot/rdiot-p021/blob/master/src/main/java/com/rdiot/awsiot/App.java
3. Setup AWS IoT Core
4. Package Download
5. AWS IoT Rule Setup
- Rule Name : email_notification
- Description : when temperature is over 30 degrees.
- Rule Query : SELECT temperature as t, humidity as h FROM 'sensor/dht11' WHERE temperature > 30
- Actions
1) SNS : sendEmail
2) Republish : sensor/dht11/over30
6. run application
$ java -Dpi4j.linking=dynamic -jar awsiot-0.0.1-SNAPSHOT.jar (run.sh)
7. Monitoring
8. Action Check over 30 degrees
- republish to sensor/dht11/over30
- notification sns : email
- Reference
GitHub AWS IoT Device SDK for Java : https://github.com/aws/aws-iot-device-sdk-java/blob/master/README.md
API Document : http://aws-iot-device-sdk-java-docs.s3-website-us-east-1.amazonaws.com/
Sample Code : https://github.com/aws/aws-iot-device-sdk-java/blob/master/aws-iot-device-sdk-java-samples/src/main/java/com/amazonaws/services/iot/client/sample/pubSub/PublishSubscribeSample.java
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023] (0) | 2018.10.17 |
---|---|
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022] (0) | 2018.06.17 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019] (0) | 2018.04.11 |
Amazon Polly + Google Home + Sonoff wifi [P018] (0) | 2018.04.04 |
Amazon Polly TTS(Text to Speech) [P017] (0) | 2018.03.30 |
RGB LED Controller Dimmer 3 Channel DC12V - 24V 9A [B206]
https://www.youtube.com/watch?v=tsadcDA8O5M
* Specs
This LED Dimmer/RGB Controller can be used as a 3 channels LED single color strip light dimmer a LED RGB module / Flexible LED Strips as a static color controller.
Universal Red/Green/Blue(RGB) dimmer-konbs can be used to adjust Red, Green and Blue from 0 to 100 percent for full range color creation. Endless RGB color combinations.
Installation is quite easy, power up the unit with 12 to 24V DC power source and connect 3 output connection to RGB LED strip light or a Solid Color LED strip light. Electric wires and cables are easily connected to the unit through screw down connectors, which makes 100% secure connections.
Applications:
For RGB LED strip controlling and dimming each color independently.
For solid color LED strip with 3 independent channels
For dynamic White LED strip, controlling color temprature
For RGB modules
Input voltage: DC12V-24V, 108W (12V )/ 316W (24V)
Output: 3 channel
Max load current: 3 Amps/channel (9 Amps total)
IP rating: IP-55
Size:5.12*2.62*2 inches
* Contents
- LEFT Connect
+ - 12V
- - GND
- RIGHT Connect
COM - +
R - R
G - G
B - B
12V LED Strip SMD5630 Warm White Waterproof (SMD5630) [D041] (0) | 2016.09.21 |
---|---|
12V RGB LED Strip SMD5050 (SMD5050) [D031] (0) | 2016.09.21 |
12V RGB LED SMD3528 + Key IR (SMD3528,KeyIR) [D030] (0) | 2016.09.21 |
Samsung SmartThings Home Monitoring Kit [P020]
https://www.youtube.com/watch?v=d8WQEuLjbC0
* Parts
Samsung SmartThings Hub (STH-ETH-250) [B195]
Samsung SmartThings Multipurpose Sensor (F-MLT-US-2) [S254]
Samsung SmartThings Motion Sensor (F-IRM-US-2) [S255]
Samsung SmartThings Dimming Outlet (F-CEN-DIM-1) [S256]
* Contents
1. SmartThings Classic Mobile App > Automation > Add a SmartApp
2. Configure Smart Lighting Automations
3. Automation Routines : "Door Open"
Samsung SmartThings Dimming Outlet (F-CEN-DIM-1) [S256] (0) | 2018.04.24 |
---|---|
Samsung SmartThings Motion Sensor (F-IRM-US-2) [S255] (0) | 2018.04.24 |
Samsung SmartThings Multipurpose Sensor (F-MLT-US-2) [S254] (0) | 2018.04.24 |
Samsung SmartThings Hub (STH-ETH-250) [B195] (0) | 2018.04.19 |
Samsung SmartThings Dimming Outlet (F-CEN-DIM-1) [S256]
https://www.youtube.com/watch?v=gzb1YHhziaM
* Specs
- Description
Dim your lights to fit your mood.
Control standard plug-in lamps and other plug-in lighting devices.
Requires a SmartThings Hub or a compatible device with SmartThings Hub functionality.
Control your SmartThings Outlet and other connected devices with the SmartThings app for iPhone or Android.
Automate your SmartThings Outlet and set it to turn on or off when doors are opened, when there’s activity in your home, and much more.
Manage your SmartThings Outlet and other connected devices with SmartThings Routines for Good Morning, Goodbye, Good Night, and more.
Control your SmartThings Outlet with voice commands using SmartThings and the Google Assistant or Amazon Alexa.
- Specs
Model number: F-CEN-DIM-1
Power source: Wall-Powered
Weight: 0.25 lb
Dimensions: 2" x 2" x 2.5"
Protocol: ZigBee
* Contents
1. Reset the Outlet Sensor and then Add a Thing
2. Added the Outlet Sensor
3. Select the Outlet Sensor
4. Setup Automation > SmartApps
5.Add a SmartApps > SmartThings Recommends
6. SmartThings Recommends > Smart Lights
7. Select : Which devices do you want to control?
8. Setting : When Mode Changes to Night, Turn On the Outlet Sensor.
9. Good Night Routine : Mode Change to Night
Goodbye! Routine : Mode Change to Away
- Reference
https://shop.smartthings.com/products/samsung-smartthings-dimming-outlet/631
https://www.samsung.com/us/smart-home/smartthings/
https://www.samsung.com/us/smart-home/smartthings/kits/
Samsung SmartThings Home Monitoring Kit [P020] (0) | 2018.04.30 |
---|---|
Samsung SmartThings Motion Sensor (F-IRM-US-2) [S255] (0) | 2018.04.24 |
Samsung SmartThings Multipurpose Sensor (F-MLT-US-2) [S254] (0) | 2018.04.24 |
Samsung SmartThings Hub (STH-ETH-250) [B195] (0) | 2018.04.19 |
Samsung SmartThings Motion Sensor (F-IRM-US-2) [S255]
https://www.youtube.com/watch?v=v-EWr0Zb34M
* Specs
- Description
Add a little smartness to your things
Monitor motion and temperature.
Requires a SmartThings Hub or a compatible device with SmartThings Hub functionality.
Monitor your Motion Sensor and other connected devices with the SmartThings app for iPhone or Android.
Receive alerts from SmartThings if your Motion Sensor detects movement, or if the temperature changes.
Automate connected devices with SmartThings and set them to turn on or off if your Motion Sensor detects movement, or if the temperature changes.
- Specs
Model number: F-IRM-US-2
Power source: Battery : CR2450
Color: White
Weight: 0.08 lb
Dimensions: 0.8" x 2" x 2"
Protocol: ZigBee
Battery type: CR-2477
* Contents
- Connect
1. Add Thing : Motion Sensor
2. added Motion Sensor
3. when click the motion sensor : status
4. Add Automation Routine
5. Add a Routine : name is "who"
6. Setting : Change the mode to "home"
7. Automatically perform "who" : select "Things start happening"
8. Perform : Which : Motion Sensor
9. Successfully added Things Start Happening
10. Notification
- Reference
https://shop.smartthings.com/products/samsung-smartthings-motion-sensor
https://www.samsung.com/us/smart-home/smartthings/
https://www.samsung.com/us/smart-home/smartthings/kits/
Samsung SmartThings Home Monitoring Kit [P020] (0) | 2018.04.30 |
---|---|
Samsung SmartThings Dimming Outlet (F-CEN-DIM-1) [S256] (0) | 2018.04.24 |
Samsung SmartThings Multipurpose Sensor (F-MLT-US-2) [S254] (0) | 2018.04.24 |
Samsung SmartThings Hub (STH-ETH-250) [B195] (0) | 2018.04.19 |
Samsung SmartThings Multipurpose Sensor (F-MLT-US-2) [S254]
https://www.youtube.com/watch?v=v7Lrxuk4FL8
* Specs
- Description
Add a little smartness to your things.
Monitor doors and windows.
Monitor temperature and orientation.
Requires a SmartThings Hub or a compatible device with SmartThings Hub functionality.
Monitor your Multipurpose Sensor and other connected devices with the SmartThings app for iPhone or Android.
Receive alerts from SmartThings if your Multipurpose Sensor detects that doors and windows have been opened or left open, or if the temperature changes.
Automate connected devices with SmartThings and set them to turn on or off if your Multipurpose Sensor detects that doors and windows have been opened or left open, or if the temperature changes.
- Specs
Model number: F-MLT-US-2
Power source: Battery
Color: White
Weight: 0.1 lb
Dimensions: 0.57" x 1.35" x 1.9"
Protocol: ZigBee
Battery type: CR-2450 battery
* Contents
1. Add a Things : Multipurpose Sensor
- If your device doesn't connect, Then press the Connect Button.
2. Devices found and then Save : Multipurpose Sensor
3. You can see the Multipurpose Sensor Thing
4. Add a Routine to get push notification when open and close
- write the routine name : Door Open
- Change the mode : home
- Additional settings : Automatically perform "Door Open"
: Select "Something Opens or Closes"
- Advanced Options : Don't automatically do this if I am in one of these modes : none
- On the push notification
added "Door Open" Routine
5. When the multipurpose sensor is open or close
- Reference
https://www.samsung.com/us/smart-home/smartthings/
https://www.samsung.com/us/smart-home/smartthings/kits/
https://shop.smartthings.com/products/samsung-smartthings-multipurpose-sensor
Samsung SmartThings Home Monitoring Kit [P020] (0) | 2018.04.30 |
---|---|
Samsung SmartThings Dimming Outlet (F-CEN-DIM-1) [S256] (0) | 2018.04.24 |
Samsung SmartThings Motion Sensor (F-IRM-US-2) [S255] (0) | 2018.04.24 |
Samsung SmartThings Hub (STH-ETH-250) [B195] (0) | 2018.04.19 |
Samsung SmartThings Hub (STH-ETH-250) [B195]
https://www.youtube.com/watch?v=ERabX0zL7ag
* Specs
- Description
The brain of your smart home.
Connect wirelessly with a wide range of smart devices and make them work together.
Monitor and control connected devices in your home using a single SmartThings app for iPhone or Android.
Receive alerts from connected devices when there’s unexpected activity in your home.
Automate connected devices in your home and set them to turn on or off when doors are opened, as people come and go, and much more.
Manage connected devices in your home with SmartThings Routines for Good Morning, Goodbye, Good Night, and more.
Control connected devices in your home with voice commands using SmartThings and Amazon Alexa or Google Home.
Requires an internet-connected Wi-Fi router with an available ethernet port, plus the free SmartThings app for Android (4.1 or later) or iPhone (iOS 9.0 or later).
- Specs
Model number: STH-ETH-250
Power source: Battery, Wall-Powered
Color: White
Weight: 7.68 oz
Dimensions: 4.2" x 4.9" x 1.3"
Protocol: ZigBee, Z-Wave, Cloud-to-Cloud, LAN
Battery type: 4 AA batteries
* Contents
1. Install SmartThings Hub
- It needs welcome code (6 digit)
- power : AA battery 4ea or AC
2. Connect to SmartThings Hub and SmartThings Classic Mobile App
- add new SmartThings User
- create Samsung Account
- After login, Confirm your country
- Enter Code for activate your SmartThings secure Code.
- Connect your Hub
- Setup your location
- Setting up your hub
- Setup success!
- Adjust Battery Settings
- Finished
- Status Check : Hub is Online in menu
- Reference
https://shop.smartthings.com/products/samsung-smartthings-hub
Samsung SmartThings Home Monitoring Kit [P020] (0) | 2018.04.30 |
---|---|
Samsung SmartThings Dimming Outlet (F-CEN-DIM-1) [S256] (0) | 2018.04.24 |
Samsung SmartThings Motion Sensor (F-IRM-US-2) [S255] (0) | 2018.04.24 |
Samsung SmartThings Multipurpose Sensor (F-MLT-US-2) [S254] (0) | 2018.04.24 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019]
https://www.youtube.com/watch?v=G-Ot7oh4_jk
GitHub : https://github.com/rdiot/rdiot-p019.git
* Parts
- Raspberry Pi2
- Temperature and humidity DHT11 sensor module (KY-015) [S008]
* Contents
- Connect
S - Signal GPIO3
middle - VCC
- - GND
1. Getting sensor value by Pi4J (Java I/O library for the Raspberry Pi) and then upload to amazon s3.
: Run the java application
$ java -Dpi4j.linking=dynamic -jar pi4j_s3rest-0.0.1-SNAPSHOT.jar
2. Check the upload status in the amazon console. (s3)
3. Setup Amazon Athena .
- add database : pisensor
- add table : temperature
- DDL (add table)
CREATE EXTERNAL TABLE IF NOT EXISTS piSensor.temperature (
`name` string,
`value` float
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = '1'
) LOCATION 's3://rdkim-test/'
TBLPROPERTIES ('has_encrypted_data'='false');
4. SQL Query in the Amazon Athena
example : SELECT * FROM "pisensor"."temperature" limit 10;
- Pi4J Java Maven
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.1</version>
</dependency>
- project maven pom.xml
: https://github.com/rdiot/rdiot-p019/blob/master/pom.xml
- source : main : https://github.com/rdiot/rdiot-p019/blob/master/pi4j_s3rest/App.java
- source : pi4j : https://github.com/rdiot/rdiot-p019/blob/master/pi4j/dht11.java
- source : s3 rest api header aws sig4 : https://github.com/rdiot/rdiot-p019/blob/master/s3rest/auth/AWS4SignerForAuthorizationHeader.java
- Key Code
dht11 dht = new dht11();
for (int i=0; i<10; i++) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
objectContent = dht.getTemperature();
if(objectContent != null) {
System.out.println(objectContent);
putS3Object(bucketName, regionName, awsAccessKey, awsSecretKey);
break;
}
}
- Reference
: Pi4J Project : http://pi4j.com
: Pi4J GitHub : https://github.com/Pi4J/pi4j
: get dht11 : https://stackoverflow.com/questions/28486159/read-temperature-from-dht11-using-pi4j
: Amazon S3 Rest API : https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023] (0) | 2018.10.17 |
---|---|
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022] (0) | 2018.06.17 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021] (0) | 2018.06.15 |
Amazon Polly + Google Home + Sonoff wifi [P018] (0) | 2018.04.04 |
Amazon Polly TTS(Text to Speech) [P017] (0) | 2018.03.30 |
Amazon Polly + Google Home + Sonoff wifi [P018]
https://www.youtube.com/watch?v=IX2mUb73he8
GitHub : https://github.com/rdiot/rdiot-p018.git
* Parts
- Google Home AI Speaker [B187]
- Sonoff ITEAD WiFi Switch Module (ESP8266) [S198]
* Contents
- Install AWS CLI in Raspberry Pi
$ wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
$ unzip awscli-bundle.zip
$ sudo ./install -i /usr/local/aws -b /usr/local/bin/aws
- Config AWS CLI
$ aws configure
- Java amazon polly development
: maven : pom.xml : https://github.com/rdiot/rdiot-p018/blob/master/pom.xml
: Source : https://github.com/rdiot/rdiot-p018/blob/master/PollyDemo.java
: Binary : polly_sonoff.tar.gz
: command.txt : ON or OFF
- Sonoff Work with Google Home
- How to connect Sonoff smart ewelink to Google Assistant
1) Tap Home control in Googlt Home App Menu
2) Uner Devices, tap the + icon in the bootom right. (add devices)
3) Tap Smart We Link
4) Enter Your eWeLink account email/phone number. (need countrycode and account, password)
5) After Logging in successfully, it will display the device.
- Run java amazon polly application
$ java - jar polly-0.0.1-SNAPSHOT.jar
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023] (0) | 2018.10.17 |
---|---|
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022] (0) | 2018.06.17 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021] (0) | 2018.06.15 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019] (0) | 2018.04.11 |
Amazon Polly TTS(Text to Speech) [P017] (0) | 2018.03.30 |
Raspberry Pi Camera 5MP Night Version (SEN0184) [S280]
https://www.youtube.com/watch?v=HhDAtAHRuQ8
* Specs
Camera: 5 million pixels
Photosensitive Module: OV5647
Camera Parameters:
CCD size: 1/4 inches
Aperture (f): 1.8
Focal Length: 3.6MM (adjustable)
Diagonal: 75.7 degrees
Sensor best PIX: 1080p
4 Screw Holes
Can be used in a fixed position
3.3V external power supplies
Supports access to the infrared light or fill light
Dimension: 25mm x 24mm
* Contents
- Capture still image
$ raspistill -t 30000 -o rdiot.jpg
- Capture video
$ raspivid -t 10000 -o video.h264
- Capture Night Test
- Capture Day Test
- Download Capture File Sample :
- Reference
: RASPICAM COMMANDS : https://www.raspberrypi.org/documentation/usage/camera/raspicam/README.md
UVC Camera Movie Monitoring [P006] (0) | 2017.03.03 |
---|---|
UVC Camera Servo Motor Control [P006.1] (0) | 2017.01.07 |
Logitech HD WebCam C310 (C310) [S084] (0) | 2016.09.13 |
Samsung ARTIK 10 USB Camera [P010.7] (0) | 2016.08.31 |
Amazon Polly TTS(Text to Speech) [P017]
https://www.youtube.com/watch?v=1ehU_bueWdQ
GitHub : https://github.com/rdiot/rdiot-p017.git
* Specs
Amazon Polly is a service that turns text into lifelike speech, allowing you to create applications that talk, and build entirely new categories of speech-enabled products. Amazon Polly is a Text-to-Speech service that uses advanced deep learning technologies to synthesize speech that sounds like a human voice.
With dozens of lifelike voices across a variety of languages, you can select the ideal voice and build speech-enabled applications that work in many different countries.
* Contents
- Install AWS CLI in Raspberry Pi
$ wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
$ unzip awscli-bundle.zip
$ sudo ./install -i /usr/local/aws -b /usr/local/bin/aws
- config AWS CLI
$ aws configure
- java amazon polly library and text file
- run amazon polly application
- binary library download : polly.tar.gz
- maven dependency
: https://github.com/rdiot/rdiot-p017/blob/master/pom.xml
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-polly</artifactId>
<version>1.11.77</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.soundlibs/jlayer -->
<dependency>
<groupId>com.googlecode.soundlibs</groupId>
<artifactId>jlayer</artifactId>
<version>1.0.1-1</version>
</dependency>
- Souce Code
: https://github.com/rdiot/rdiot-p017/blob/master/PollyDemo.java
package com.rdiot.polly;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.polly.AmazonPollyClient;
import com.amazonaws.services.polly.model.DescribeVoicesRequest;
import com.amazonaws.services.polly.model.DescribeVoicesResult;
import com.amazonaws.services.polly.model.OutputFormat;
import com.amazonaws.services.polly.model.SynthesizeSpeechRequest;
import com.amazonaws.services.polly.model.SynthesizeSpeechResult;
import com.amazonaws.services.polly.model.Voice;
import javazoom.jl.player.advanced.AdvancedPlayer;
import javazoom.jl.player.advanced.PlaybackEvent;
import javazoom.jl.player.advanced.PlaybackListener;
public class PollyDemo {
private final AmazonPollyClient polly;
private final Voice voice;
//private static final String SAMPLE = "Polly Test";
private static String SAMPLE;
public PollyDemo(Region region) {
// create an Amazon Polly client in a specific region
polly = new AmazonPollyClient(new DefaultAWSCredentialsProviderChain(),
new ClientConfiguration());
polly.setRegion(region);
// Create describe voices request.
DescribeVoicesRequest describeVoicesRequest = new DescribeVoicesRequest().withLanguageCode("en-US");
// Synchronously ask Amazon Polly to describe available TTS voices.
DescribeVoicesResult describeVoicesResult = polly.describeVoices(describeVoicesRequest);
voice = describeVoicesResult.getVoices().get(0);
}
public static String roadLocalFile(String filepath) {
String readFile= "";
try {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filepath),"UTF-8"));
String s;
while ((s = in.readLine()) != null) {
readFile+= s;
}
in.close();
} catch (IOException e) {
System.err.println(e);
System.exit(1);
}
return readFile;
}
public InputStream synthesize(String text, OutputFormat format) throws IOException {
SynthesizeSpeechRequest synthReq =
new SynthesizeSpeechRequest().withText(text).withVoiceId(voice.getId())
.withOutputFormat(format);
SynthesizeSpeechResult synthRes = polly.synthesizeSpeech(synthReq);
return synthRes.getAudioStream();
}
public static void main(String args[]) throws Exception {
SAMPLE = roadLocalFile("./text.txt");
//create the test class
PollyDemo helloWorld = new PollyDemo(Region.getRegion(Regions.AP_NORTHEAST_2));
//get the audio stream
InputStream speechStream = helloWorld.synthesize(SAMPLE, OutputFormat.Mp3);
//create an MP3 player
AdvancedPlayer player = new AdvancedPlayer(speechStream,
javazoom.jl.player.FactoryRegistry.systemRegistry().createAudioDevice());
player.setPlayBackListener(new PlaybackListener() {
@Override
public void playbackStarted(PlaybackEvent evt) {
System.out.println("#################################################################");
System.out.println("RD IoT Amazon Polly TTS");
System.out.println("#################################################################");
System.out.println("Playback started");
System.out.println("-----------------------------------------------------------------");
System.out.println("TTS : " + SAMPLE);
}
@Override
public void playbackFinished(PlaybackEvent evt) {
System.out.println("-----------------------------------------------------------------");
System.out.println("Playback finished");
System.out.println("#################################################################");
}
});
// play it!
player.play();
}
}
S3 Lambda Trigger + Amazon SQS + SQSReceiver + SparkStreaming [P023] (0) | 2018.10.17 |
---|---|
Pi4J + Amazon S3 REST API + S3 Lambda Trigger + DynamoDB [P022] (0) | 2018.06.17 |
AWS IoT Core + Raspberry Pi + AWS IoT Device SDK for Java [P021] (0) | 2018.06.15 |
Pi4J + Amazon S3 REST API + Amazon Athena [P019] (0) | 2018.04.11 |
Amazon Polly + Google Home + Sonoff wifi [P018] (0) | 2018.04.04 |
USB Microphone [S281]
https://www.youtube.com/watch?v=ChITet6OuxM
* Specs
Product parameters:
The sensitivity: - 47 db + 4 db
Lower sensitivity: - 3 db at 1.5 V
Working voltage: 4.5 V
The frequency response: 100 to 16 KHZ
SNR: wining - 67 db
Line length: 0.7 to 0.9 M
* Contents
- Check Device
$ lsusb
$ dmesg
- Setup
$ sudo vi /usr/share/alsa/alsa.conf
defaults.ctl.card 0 => 1
defaults,pcm, card 0 => 1
- Setup Volume
$ alsamixer
- Recording
$ arecord -D plughw:1,0 -c 1 -f S16_LE -r 44100 test.wav
- Play
$ aplay test.wav
USB 2.0 Microphone Speech MIC Audio Adapter Driver [S278] (0) | 2018.03.26 |
---|---|
Sound recordable module 10sec [S191] (0) | 2016.09.17 |
Sound Control LED Lamp Module [S175] (0) | 2016.09.17 |
ISD 1820 Voice Recording Module (ISD1820) [S082] (0) | 2016.09.17 |
Small Sound Detection Module (KY-038) [S053] (0) | 2016.09.17 |
USB 2.0 Microphone Speech MIC Audio Adapter Driver [S278]
https://www.youtube.com/watch?v=Zw0uAvTD8n0
* Specs
Brand Name: ANBES
Set Type: Single Microphone
Communication: Wireless
Transducer: Condenser Microphone
Use: Computer Microphone
Model Number: USB Microphone
Polar Patterns: Omnidirectional
Package: No
Style: Computer Microphone
Item Name: Computer Microphone
* Contents
- Check Device
$ lsusb
$ dmesg
- Setup
$ sudo vi /usr/share/alsa/alsa.conf
defaults.ctl.card 0 => 1
defaults,pcm, card 0 => 1
- Setup Volume
$ alsamixer
- Recording
$ arecord -D plughw:1,0 -c 1 -f S16_LE -r 44100 test.wav
- Play
$ aplay test.wav
USB Microphone [S281] (0) | 2018.03.27 |
---|---|
Sound recordable module 10sec [S191] (0) | 2016.09.17 |
Sound Control LED Lamp Module [S175] (0) | 2016.09.17 |
ISD 1820 Voice Recording Module (ISD1820) [S082] (0) | 2016.09.17 |
Small Sound Detection Module (KY-038) [S053] (0) | 2016.09.17 |
Xiaomi Yeelight Candle Light [D090]
https://www.youtube.com/watch?v=qxB2_IPN0Ws
* Specs
- Description
Candela is the world's only smart candlelight using the latest Bluetooth (BLE) Mesh technology, combining the warm comfort of candlelight with the convenience and control of smart technology. The BLE Mesh technology allows up to 30,000 units Candelas to communicate with each other.
Control your candela and other YEELIGHT smart lights with our Android or iOS apps
The built-in 2100Mah battery allows for up to 8 hours of continuous use on a single charge. The portability lets candela fits in any moment of your life
Visual comfort light, the candela holds an 1800K Color temperature, which is the same Color temperature as candlelight, with adjustable brightness, leading to the warm familiar Copper of candlelight
Distinctive Design, Candela’s final design was the sum effort of 4 months collaboration with multinational design teams
Top quality materials, we want to fully load the lamp, offering a timeless piece with minimalist design components while using top quality materials to bring you the luxury product experience
Multiple lights, countless displays
A warm candle light for a heart-warming feeling
Your remote to a beautiful candlelit night
Intricately designed, a touchable artwork
Built-in rechargeable battery for a long-lasting life
- Specs
Brand YEELIGHT
Model Candela, LED Candle light,
Item Weight 1.4 pounds
Product Dimensions 4 x 4 x 10 inches
Item model number YLFW01YL
UPC 608887786279
Batteries: 1 Lithium Metal batteries required. (included)
Color Gold
Style Modern
Material Aluminum
Shape Circular
Power Source battery-powered
Item Package Quantity 1
Batteries Included? Yes
Batteries Required? Yes
Battery Cell Type Lithium Metal
Cover Included Candela, USB Cable
Bulb Type LED
Voltage 5 volts
Wattage 5 watts
* Contents
- yeelight app : https://play.google.com/store/apps/details?id=com.yeelight.cherry
- yeelight cancle ble advertise before pairing
Google Home AI Speaker [B187]
https://www.youtube.com/watch?v=swZtIL98IKY
* Specs
Dimensions
Diameter: 3.79 in (9B6.4 mm)
Height: 5.62 in (142.8 mm)
Power cable: 70.8 in (1.8 m)
Weight
Device: 1.05 lbs (477 g)
Power adapter: 4.58 oz (130 g)
Colors
Body: White
Base: Standard base is slate fabric.
Supported Audio Formats
HE-AAC, LC-AAC+, MP3, Vorbis, WAV (LPCM), FLAC with support for high-resolution streams
Wireless network
802.11b/g/n/ac (2.4GHz/5Ghz) Wi-Fi for high-performance streaming
Note: WPA2-Enterprise is not supported.
Speaker
High excursion speaker with 2" driver + dual 2" passive radiators delivers clear highs and rich bass
Far-field voice recognition supports hands-free use
Power
Required 16.5V, 2A included
Power Adapter
100-240V-1.1A 50-60Hz
Ports & Connectors
DC power jack
Micro-USB port (for service only)
Supported Operating Systems
Android 4.1 and higher
iOS 8.0 and higher
* Contents
https://madeby.google.com/home/
Home Improvement Home Automation Smart Home Kits and Hubs
Powered by your very own Google assistant, Google Home is designed to help streamline your life and manage your everyday tasks. On hectic mornings, get your daily schedule, traffic, and flight info, or set an alarm by saying, Ok Google, wake me up tomorrow at 6:30am. Simplify your shopping duties by telling Google to add things to your shopping list, or use it to set a timer to keep you on track. And there's more ? you can ask it questions, tell it to do things, and use it to stream entertainment to your TV with Chromecast. It's your own Google, always ready to help. Just start by saying, "Ok Google."
Google Home:
Enjoy your music
With a simple voice command, play tunes from services like YouTube Music and Google Play Music. Enjoy even more compatible audio services by streaming directly from your phone to Google Home.
Get answers from Google
Get answers to things you want to know including the latest on weather, traffic, finance, sports and more. Plus, get information to help you do things in your world. Ask "What is the nearest pharmacy" and follow it up with "When does it close"
Manage your everyday tasks
With your permission, Google Home can help you with things like your commute, flight information and more. Plus it's a whiz at setting alarms, starting timers and adding items to your shopping list.
Control compatible smart devices
Simply ask Google Home to stream videos to your TV with Chromecast or to turn up your Nest thermostat.
Get superior sound and voice technology
Google Home's high excursion speaker delivers HiFi sound quality. It can also hear you reliably thanks to far-field microphones.
- Control by TTS (Amazon Polly)
- Reference
google home : https://madeby.google.com/home/
google home help : https://support.google.com/googlehome/topic/7196250?hl=en&ref_topic=7029677,7029097,7029808,
SKT NUGU AI Speaker Ordering Pizza [B186.1] (0) | 2016.12.10 |
---|---|
SKT NUGU AI Speaker [B186] (0) | 2016.11.28 |
NRF24L01 2.4Ghz Wireless Module (NRF24L01) [S275]
https://www.youtube.com/watch?v=CVfX8fmW6Bk
GitHub : https://github.com/rdiot/rdiot-s275.git
* Specs
nRF24L01 is a single chip radio transceiver for the world wide 2.4 - 2.5 GHz ISM band.
The transceiver consists of a fully integrated frequency synthesizer, a power amplifier, a crystal oscillator, a demodulator, modulator and Enhanced ShockBurst? protocol engine.
Output power, frequency channels, and protocol setup are easily.
programmable through a SPI interface.
Current consumption is very low, only 9.0mA at an output power of -6dBm and 12.3mA in RX mode.
Built-in Power Down and Standby modes makes power saving easily realizable.
Maximum operating speeds up to 2Mbps, GFSK modulation efficiency, Anti-interference ability, Particularly suitable for industrial control applications.
125 Communications channels, Multi-point communication and frequency hopping to meet the communication needs.
Built-in hardware CRC error detection, Multipoint communication address control.
Low-power 1.9 ~ 3.6V, only 1uA on Power down mode.
Built-in 2.4Ghz antenna.
Available software to set the address, only received local Address when output data(Provide interrupt instruction), can be directly connected to a variety of microcontrollers, Software programming is very convenient.
Support 6 Data channels of data reception.
Standard DIP Pitch Interface for embedded applications.
* Contents
- Connect
VCC - 3.3V
CSN - D8
MOSI - D11
IRQ - NONE
GND - GND
CE - D7
SCK - D13
MISO - D12
- parts
Rotary Encoder Module (KY-040) [S120]
- Library : https://github.com/nRF24/RF24
- Tested Library Download : RF24-master.zip
- Key Code
- RF24_TX : https://github.com/rdiot/rdiot-s275/blob/master/RF24_TX.ino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display
RF24 radio(7, 8); // SPI Bus CE, CSN
const byte address[6] = "00001"; // RX = TX same address
int pin = A0; // Rotary Encoder Module (KY-040) [S120] : http://rdiot.tistory.com/126 [RDIoT Demo]
void setup() {
pinMode(pin, INPUT);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN); // Power Level : accoding to distance : RF24_PA_MIN / RF24_PA_LOW / RF24_PA_HIGH / RF24_PA_MAX
radio.stopListening(); // TX
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print("start LCD1602");
delay(1000);
lcd.clear();
}
void loop() {
lcd.setCursor(0,0);
lcd.print("S275:RF24L01 TX");
int readVal = analogRead(pin);
readVal = map(readVal, 0, 1023, 0, 179);
Serial.println(readVal);
lcd.setCursor(0, 1);
lcd.print("msg=>" + String(readVal) + " ");
char buf[4];
itoa(readVal, buf, 10);
radio.write(&buf, sizeof(buf)); //send messages to RX
delay(10);
}
- RX24_RX : https://github.com/rdiot/rdiot-s275/blob/master/RF24_RX.ino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display
RF24 radio(7, 8); // SPI Bus CE, CSN
const byte address[6] = "00001"; // TX = RX same address
Servo myservo;
int servoPin = 4;
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN); // Power Level : accoding to distance : RF24_PA_MIN / RF24_PA_LOW / RF24_PA_HIGH / RF24_PA_MAX
radio.startListening(); // RX
myservo.attach(servoPin);
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print("start LCD1602");
delay(1000);
lcd.clear();
}
void loop() {
lcd.setCursor(0,0);
lcd.print("S275:RF24L01 RX");
lcd.setCursor(0, 1);
if (radio.available()) {
char text[4] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
lcd.print("rcv=>" + String(text) + " ");
int value = atoi(text);
myservo.write(180-value);
}
delay(10);
}
- how to debug radio details
#include <printf.h>
printf_begin();
radio.printDetails();
3DR Radio 915Mhz Telemetry Kit [S211] (0) | 2016.09.17 |
---|---|
433Mhz Super-regenerative module (FS1000A,MX-JS-05V) [S081] (0) | 2016.09.17 |
315Mhz 4Channel Remote Control Kit (PT2262/PT2272) [S054] (1) | 2016.09.17 |
nRF905 Wireless Module 433,868,915Mhz (NRF905) [S117]
https://www.youtube.com/watch?v=IgzJsUzVhBk
GitHub : https://github.com/rdiot/rdiot-s117.git
* Specs
Tri-band transceiver operating frequency for the international ISM band 433/868/915MHz GMSK modulation, anti-interference ability, especially for industrial control applications using the DSS + PLL frequency synthesizer technology, excellent frequency stability, high sensitivity, to achieve - 100dBm low operating voltage (2.7V), low power consumption, standby only 1uA maximum transmit power of +10 dBm with multiple channels (up to more than 170) meet the requirements for low-power devices, in particular, to meet the needs of multi-channel work of special occasions, the work rate up to 76.8 Kbps
External components of at least (10), the basic need to debug. Low transmit power and high receive sensitivity of the design, the use of the license required to apply for open use at distances up to 1000m and the specific use of the environment and component parameters.
Electrical Characteristics:
NRF905 work band: 433/868/915MHz
Channel number: 170
Function: transmitter / receiver
Frequency stabilization method: PLL
Modulation mode: the FSK / GMSK
Maximum output power: +10 dBm
Sensitivity:-100dBm
Maximum operating rate: 76.8Kbit / s
Working voltage :2.7 - 3 .3 V
Application areas:
Vehicle monitoring, remote control, telemetry, small wireless network, wireless meter reading, access control systems, residential paging, industrial data acquisition systems, wireless tags, identification, non-contact RF smart cards, small wireless data terminals, security, fire systems, wireless remote control system, bio-signal acquisition, hydrological and meteorological monitoring, robot control, wireless 232 data communications, wireless 485/422 data communications, digital audio, digital image transmission.
* Contents
- Connect
VCC ---- Power supply.
TXE ---- RF module mode selecting.
CE ---- Enable RF module for transmit and receive.
PWR ---- Power up chip.
CLK ---- Output clock, divided crystal oscillator full swing clock.
CD ---- Carrier detect.
AM ---- Address matched.
DR ---- Receive and transmit ready.
MISO ---- SPI master input slave output.
MOSI ---- SPI mater output slave input.
SCK ---- SPI clock.
CSN ---- SPI enable.
GND ---- Ground
GND ---- Ground
- KOR : 919.7Mhz, 921.7Mhz, 923.1Mhz
- Reference Source : http://www.electrodragon.com/wp-content/uploads/2011/11/NRF905-for-arduino.zip
- Changed Code Library
PROGMEM unsigned const int freq_tab[10] = {
- TX Source : https://github.com/rdiot/rdiot-s117/blob/master/nRF905_TX.ino
#include <NRF905.h>
#include <SPI.h>
#define BUF_LEN 32
#define CONF_LEN 10
#define NRF905_CSN 10
unsigned char tx_buf[BUF_LEN]= "RDIoT TX CNT: \r\n";
unsigned char read_config_buf[CONF_LEN];
byte tx_address[4]= {0xcc,0xcc,0xcc,0xcc};
void setup()
{
unsigned char i;
pinMode(NRF905_CSN,OUTPUT); //to make sure SPI works
nrf905=NRF905(NRF905_CSN);
nrf905.init();
/**
default configuration, need to specify frequency
choose Z-Wave frequency band, support :
US 908.42Mhz
EUROPE 868.42MHz
AFRICA 868.42MHz
CHINA 868.42MHz
HK 919.82MHz
JAPAN 853.42MHz
AUSTRALIA 921.42MHz
NEW_ZEALAND 921.42MHz
BRASIL 921.42MHz
RUSSIA 896MHz
*/
nrf905.write_config(US);
nrf905.read_config(read_config_buf);
Serial.begin(9600);
for(i=0; i<10; i++)
{
Serial.print(read_config_buf[i],HEX);
Serial.print(' ');
}
tx_buf[12] = '0';
}
void loop()
{
/** transmit data packet with default TX Address */
nrf905.TX(tx_buf);
/** transmit data packet with specified TX Address */
// nrf905.TX(tx_buf, tx_address);
// NOTE: TX_Address and RX_Address must be the same
/** Count Sending times */
tx_buf[12]++;
if(tx_buf[12] == 0x3A){
tx_buf[12] = '0';
}
delay(50);
}
- RX Source : https://github.com/rdiot/rdiot-s117/blob/master/nRF905_RX.ino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <NRF905.h>
#include <SPI.h>
#define BUF_LEN 32
#define CONF_LEN 10
//NRF905 nrf905;
unsigned char rx_buf[BUF_LEN]= {0};
unsigned char read_config_buf[CONF_LEN];
unsigned char rx_address[4]= {0xcc,0xcc,0xcc,0xcc};
String str1="";
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display
void putstring(unsigned char *str)
{
while(*str){
str1 += char(*str++);
//Serial.write(*str++);
}
}
void setup()
{
char i;
pinMode(10,OUTPUT);
nrf905=NRF905(10);
/** pin/port configuration */
nrf905.init();
/***************************************************
default configuration, need to specify frequency
choose Z-Wave frequency band, support :
US 908.42Mhz
EUROPE 868.42MHz
AFRICA 868.42MHz
CHINA 868.42MHz
HK 919.82MHz
JAPAN 853.42MHz
AUSTRALIA 921.42MHz
NEW_ZEALAND 921.42MHz
BRASIL 921.42MHz
RUSSIA 896MHz
*/
nrf905.write_config(US);
/***********************************************************
read register configuration, check register value written */
nrf905.read_config(read_config_buf);
/** serial communication configurate */
Serial.begin(9600);
/** test configuration */
for(i=0; i<CONF_LEN; i++){
Serial.print(read_config_buf[i],HEX);
Serial.print(' ');
}
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print("start LCD2004");
delay(1000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("S117:nRF905 RCV");
/** recieve data packet with default RX address */
nrf905.RX(rx_buf);
/** recieve data packet with specified RX address */
// nrf905.RX(rx_buf, rx_address );
// NOTE: TX_Address and RX_Address must be the same
/** send recieved data to PC through serial port */
putstring(rx_buf);
lcd.setCursor(0,1);
lcd.print(str1);
str1 = "";
delay(1);
}
MQTT + Kafka + Raspberry Pi ElasticSearch Cluster [P016]
https://www.youtube.com/watch?v=coKGRMDqAJk
* GitHub : https://github.com/rdiot/rdiot-p016
* Parts
- Arduino UNO
- Ethernet W5100 Shield (W5100) [B004]
- LCD1602 I2C (LCD1602) [D016]
- Photo Resistor Module (KY-018) [S002]
- Temperature and humidity DHT22 (DHT22) [S063]
- TPM-300 Air Quality Module (TPM-300) [S092]
- Samsung ARTIK 5 (ARTIK5-V0.5) [B023]
- Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] x 3ea : for Kafka Cluster
- Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] x 4ea : for ElasicSearch Cluster
- USB Power Supply
- Ethernet Hub
* Contents
1. Raspberry Pi ElasticSearch Cluster Setup
- version : elasticsearch 2.4.6
- master config
: https://github.com/rdiot/rdiot-p016/blob/master/elasticsearch_es-pi-master-01.yml
- data node config
: https://github.com/rdiot/rdiot-p016/blob/master/elasticsearch_es-pi-data-01.yml
: https://github.com/rdiot/rdiot-p016/blob/master/elasticsearch_es-pi-data-02.yml
: https://github.com/rdiot/rdiot-p016/blob/master/elasticsearch_es-pi-data-03.yml
2. logstash configuration
- https://github.com/rdiot/rdiot-p016/blob/master/logstash-kafka-elasticsearch-airGrade.conf
- https://github.com/rdiot/rdiot-p016/blob/master/logstash-kafka-elasticsearch-cds.conf
- https://github.com/rdiot/rdiot-p016/blob/master/logstash-kafka-elasticsearch-humidity.conf
- https://github.com/rdiot/rdiot-p016/blob/master/logstash-kafka-elasticsearch-temperature.conf
3. start logstash script example
#!/bin/sh
export LS_HEAP_SIZE="500m"
/data1/logstash/logstash/bin/logstash -f /data1/logstash/logstash-kafka-elasticsearch-temperature.conf -l logstash.log &
4. Kafka logstash Monitoring
5. ElasticSearch data node shard
6. Grafana Setup
- Install in Raspberry Pi
$ sudo apt-get install libfontconfig
$ curl -L https://github.com/fg2it/grafana-on-raspberry/releases/download/v4.0.1/grafana_4.0.1-1480722482_armhf.deb -o /tmp/grafana_4.0.1-1480722482_armhf.deb
$ sudo dpkg -i /tmp/grafana_4.0.1-1480722482_armhf.deb
$ sudo vi /etc/grafana/grafana.ini
# The ip address to bind to, empty will bind to all interfaces
http_addr = 192.168.0.20
$ sudo systemctl enable grafana-server
$ sudo systemctl restart grafana-server
- Connect Grafana WebAdmin
http://92.168.0.20:3000
id/pwd : admin/admin
- Add Data Sources : http://192.168.0.20:3000/datasources/new
- edit data source examples
7. Grafana Dashboard
- Kafka-Sensor-Monitoring
: Temperature, Humidity, Cds, AirGrade
MQTT + Kafka + Amazon ElasticSearch Service [P015] (0) | 2017.10.24 |
---|---|
ARTIK MQTT + Raspberry Pi Apache Kafka Cluster Bridge [P014] (0) | 2017.09.27 |
Raspberry Pi Apache Kafka Cluster [P013] (0) | 2017.06.08 |
Raspberry Pi GPIO Ruler [B180] (0) | 2017.02.22 |
Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] (0) | 2016.09.01 |
MQTT + Kafka + Amazon ElasticSearch Service [P015]
https://www.youtube.com/watch?v=-8B8Yp52XMY
* GitHub : https://github.com/rdiot/rdiot-p015
* Parts
- Arduino UNO
- Ethernet W5100 Shield (W5100) [B004]
- LCD1602 I2C (LCD1602) [D016]
- Photo Resistor Module (KY-018) [S002]
- Temperature and humidity DHT22 (DHT22) [S063]
- TPM-300 Air Quality Module (TPM-300) [S092]
- Samsung ARTIK 5 (ARTIK5-V0.5) [B023]
- Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] x 3ea : for Kafka Cluster
- USB Power Supply
- Ethernet Hub
* Contents
1. Amazon ElasticSearch Service Setup
- Define domain
- Configure cluster
- Set up access
- Review
- Amazon Elasticsearch Service dashboard
2. ES Information example
- ElasticSearch Endpoint : https://search-rdiot-aws-es-2yolnmmxbjghreiywdbh4yrsay.ap-northeast-2.es.amazonaws.com
- Kibana URL : https://search-rdiot-aws-es-2yolnmmxbjghreiywdbh4yrsay.ap-northeast-2.es.amazonaws.com/_plugin/kibana/
3. MQTT - Kafka - Bridge (json)
- source : https://github.com/rdiot/rdiot-p015/blob/master/MqttToKafkaReConn.java
- result
{"time": 1511884443315,"value":724}
{"time": 1511884444405,"value":724}
{"time": 1511884445488,"value":723}
{"time": 1511884446579,"value":724}
{"time": 1511884447657,"value":726}
4. install logstash : tested logstash-2.4.1
$ cd /data1/logstash
$ wget https://download.elastic.co/logstash/logstash/logstash-2.4.1.tar.gz
$ tar zxvf logstash-2.4.1.tar.gz
$ ln -s logstash-2.4.1 logstash
$ sudo apt-get install ant texinfo openjdk-8-jdk build-essential
$ git clone https://github.com/jnr/jffi.git
$ export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-armhf"
$ cd jffi
$ ant jar
$ sudo cp build/jni/libjffi-1.2.so /data1/logstash/logstash/vendor/jruby/lib/jni/arm-Linux
5. logstash config : tested logstash-2.4.1
- source : https://github.com/rdiot/rdiot-p015/blob/master/logstash-kafka-aws-es.conf
input {
kafka {
zk_connect => "kafka-pi-01:2181"
group_id => "logstash"
topic_id => "cds"
consumer_threads => 2
decorate_events => true
}
}
filter {
json {
source => "message"
}
date {
match => [ "time", "UNIX"]
target => "time_new"
}
}
output {
elasticsearch {
index => "test-%{+YYYY.MM.dd}"
hosts => ["https://search-rdiot-aws-es-2yolnmmxbjghreiywdbh4yrsay.ap-northeast-2.es.amazonaws.com"]
codec => json
}
stdout {
codec => "rubydebug"
}
}
6. Amazon ElasticSearch Query Sample
7. Kibana : Search & Chart
MQTT + Kafka + Raspberry Pi ElasticSearch Cluster [P016] (0) | 2017.11.29 |
---|---|
ARTIK MQTT + Raspberry Pi Apache Kafka Cluster Bridge [P014] (0) | 2017.09.27 |
Raspberry Pi Apache Kafka Cluster [P013] (0) | 2017.06.08 |
Raspberry Pi GPIO Ruler [B180] (0) | 2017.02.22 |
Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] (0) | 2016.09.01 |
ARTIK MQTT + Raspberry Pi Apache Kafka Cluster Bridge [P014]
* Arduino MQTT Client to ARTIK MQTT Broker
* ARTIK MQTT Broker & Raspberry Pi Kafka Cluster
* Run MQTT-Kafka-Bridge
* Kafka Console Consumer
* KafkaMonitor
https://www.youtube.com/watch?v=JIEIv-pEFFs
*GitHub : https://github.com/rdiot/rdiot-p014.git
* Parts
- Arduino UNO
- Ethernet W5100 Shield (W5100) [B004]
- LCD1602 I2C (LCD1602) [D016]
- Photo Resistor Module (KY-018) [S002]
- Temperature and humidity DHT22 (DHT22) [S063]
- TPM-300 Air Quality Module (TPM-300) [S092]
- Samsung ARTIK 5 (ARTIK5-V0.5) [B023]
- Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] x 3ea
- USB Power Supply
- Ethernet Hub
* Contents
1. ARTIK MQTT Start
- mqtt broker (1883)
$ mosquitto &
2. Add MQTT Topics in the node-red
- node-red (1880)
$ node-red &
3. Arduino MQTT Client
- source
https://github.com/rdiot/rdiot-p014/blob/master/arduino_mqtt_client.ino
4. MQTT Kakfa Bridge
- source
https://github.com/rdiot/rdiot-p014/blob/master/MqttToKafkaReConn.java
- maven
<!-- mqtt-client -->
<dependency>
<groupId>org.fusesource.mqtt-client</groupId>
<artifactId>mqtt-client</artifactId>
<version>1.14</version>
</dependency>
<!-- kafka -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.1</artifactId>
<version>0.8.2.1</version>
</dependency>
- run script
https://github.com/rdiot/rdiot-p014/blob/master/mqtt-kafka-bridge.sh
$ java -jar mqtt-kafka-bridge-0.0.1-SNAPSHOT.jar
$ nohup java -jar mqtt-kafka-bridge-0.0.1-SNAPSHOT.jar > output.txt &
5. Kafka Console Consumer
- run script
https://github.com/rdiot/rdiot-p014/blob/master/consumer.sh
$ /data1/kafka/kafka/bin/kafka-console-consumer.sh --zookeeper kafka-pi-01:2181,kafka-pi-02:2181,kafka-pi-03:2181 --topic $1
- run command
$ ./consumer.sh temperature,humidity,cds,airGrade
$ ./consumer.sh temperature
MQTT + Kafka + Raspberry Pi ElasticSearch Cluster [P016] (0) | 2017.11.29 |
---|---|
MQTT + Kafka + Amazon ElasticSearch Service [P015] (0) | 2017.10.24 |
Raspberry Pi Apache Kafka Cluster [P013] (0) | 2017.06.08 |
Raspberry Pi GPIO Ruler [B180] (0) | 2017.02.22 |
Raspberry Pi 3 B Model (RASPBERRY-PI-3-B) [B088] (0) | 2016.09.01 |