51
mruby/c: IoT system for SAKE brewery HASUMI Hitoshi @hasumikin Monstar Lab SWEST21 ♨♨♨ 下呂温泉 水明館 Sep. 6, 2019

SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

mruby/c: IoT system for🍶 SAKE brewery 🍶

HASUMI Hitoshi @hasumikinMonstar Lab

SWEST21 ♨♨♨ 下呂温泉 水明館Sep. 6, 2019

Page 2: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

MeHASUMI Hitoshi@hasumikin

Matsue city,a holy place of Ruby

Sake 🍶Soba 🍜Coffee ☕

Page 3: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Me

Page 4: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Me

Page 5: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Me

Page 6: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Me

Page 7: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,
Page 8: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

旭日酒造

one of the best Japanese Sake brewery

Asahi-shuzo and I make an IoT system using mruby/c

Page 9: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Asahi-shuzo旭酒造(Asahi-shuzo), Yamaguchi: 獺祭(Dassai). fruity, aromatic and sweet

朝日酒造(Asahi-shuzo), Niigata: 久保田(Kubota). clear, dry and sharp

朝日酒造(Asahi-shuzo), Fukui: ???

旭日酒造(Asahi-shuzo), Shimane: 十旭日(Juji-Asahi). tasteful, mature with years and good for お燗(warmed style)

Page 10: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

What is mruby/c?

Page 11: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

What is mruby/c?github.com/mrubyc/mrubyc

yet another implementation of mruby

`/c` symbolizes compact,concurrent and capability

especially dedicated toone-chip microcontroller

Page 12: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

mruby and mruby/cmruby mruby/c

v1.0.0 in Jan 2014 v1.0 in Jan 2017for general embedded software

for one-chip microcontroller

RAM < 400KB RAM < 40KB

Page 13: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

About my IoT projectIoT system for Asahi-shuzo

delivered to actual brew work in January 2018

devices post temperature of Sake materials in brewing, surrounding temperature and humidity to server

data is displayed on smartphone app

Page 14: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

About my IoT project

Page 15: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

What is "taking temperature" ?

Page 16: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

what is "taking temperature" ?

Page 17: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

what is "taking temperature" ?

Page 18: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY)

Page 19: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY)

before mruby/c

Page 20: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY)

Page 21: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY) architecturesensortags ->(BLE)-> gateway

gateway ->(WiFi)-> router

router ->(3G)-> internet

Page 22: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY) architecturesensortags ->(BLE)-> gateway

gateway ->(WiFi)-> router

router ->(3G)-> internet

Having a stack of multiple wirelesses is so hard

😨

Page 23: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY) architecture

Page 24: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY) architecture

超えられない壁

Page 25: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

1st season (2017BY) architecturea thick wall

BLE couldn't through the wall

water everywhere

power suppply issuenumber of instrument should be minimized

Page 26: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

BY?

Page 27: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

BY?Brewing Year, from July to June

in Asahi-shuzo a BY work starts on November and finishes on April (depends on year)

Page 28: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)

Page 29: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)

A N E W H O P E

Page 30: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)

m r u b y / c

Page 31: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY) architecture

devices ->(3G)-> Internet

Page 32: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY) the device

Page 33: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY) architecture

Page 34: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY) architecture

Page 35: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY) mruby/cmruby/c does everything

sensors - I2C, ADCFixnum, Float, Math

7seg LED display - transistor arrayString, Mutex

3G communication module - UARTString, flow control

Page 36: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)what were difficult about mruby/c?

we can neither do step execution nor look into appropriate memory address of mruby/c's variables

so many troubles in IoThard to find why the application doesn't work well

Page 37: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)what were difficult about mruby/c?

mruby/c was growingbugs, lack of features, docs and examples

Page 38: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)so, was mruby/c bad?

Page 39: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

2nd season (2018BY)so, was mruby/c bad? - NO

IoT at work makes you hurryyou have to go back and forth between dark 10℃ storage cellar and humid 35℃ manufacturing room

you have to amend your firmware with your small laptop in 10 minutes

you will thank Ruby's descriptiveness and agility

Page 40: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

RubyKaigi 2018

Page 41: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

3rd season (2019BY)

Page 42: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

RubyKaigi 2019

Page 43: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

RubyKaigi 2019

Page 44: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Technology stack of IoT (1/2)TCP/IP

cloud service

RDB and KVS

server programming

mobile programming

security

test

Page 45: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Technology stack of IoT (2/2)high school physics electricity and transistor

microcontroller and peripherals like UART, I2C, ADC, etc.

circuit and PCB artwork

soldering and wiring

3D CAD for housing

suppliers

firmware programming

Page 46: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Summarymruby/c

mruby/c

mruby/c

mruby/c

Page 47: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Summarymruby/c is a Ruby for microcontroller

mruby/c

mruby/c

mruby/c

Page 48: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Summarymruby/c is a Ruby for microcontroller

mruby/c runs on Asahi-shuzo

mruby/c

mruby/c

Page 49: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Summarymruby/c is a Ruby for microcontroller

mruby/c runs on Asahi-shuzo

mruby/c can be ensured by test

mruby/c

Page 50: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Summarymruby/c is a Ruby for microcontroller

mruby/c runs on Asahi-shuzo

mruby/c can be ensured by test

mruby/c is ready

Page 51: SAKE brewery 🍶 · 🍶 SAKE brewery 🍶 HASUMI Hitoshi @hasumikin ... Fixnum, Float, Math 7seg LED display - transistor array String, Mutex 3G communication module - UART String,

Thank you!