mruby/c 3.3 標準IOクラス対応
UARTのGROVEポートはtxピンとrxピンが逆であることが今更判明。
UARTのGROVEモジュールを使用する際にはスイッチサイエンスマルツにて販売しているジャンパ線を使用して、
黒:GND、赤:3.3V、白:Pin14、黄:Pin13へ接続してください。

モジュール初期設定

シリアルコンソール経由(PC->RBoard->モジュール)でモジュールの初期設定を行う際に使用するRBoardのプログラムです。
devのbaudはモジュールの初期値を指定して下さい。
例:AMW037,BGX13Pなどは115200

usb = UART.new( 1, baud:19200 )
dev = UART.new( 2, baud:19200 )
while true
  # PC -> RBoard -> モジュール
  if(usb.can_read_line())
    dev.write(usb.gets())
  end

  # モジュール -> RBoard -> PC
  if(dev.can_read_line())
    usb.write(dev.gets())
    # usb.write("> ")
  end
end

im920s

https://www.interplan.co.jp/solution/wireless/im920s/im920s.php

文字列送信


im = UART.new(19200)
while true
  im.puts("TXDA " + (23).to_s + "\r\n")
  sleep(5)
end

文字列受信


im = UART.new(19200)
while true
  puts(im.gets())
  sleep(5)
end

Bluetooth

https://www.switch-science.com/catalog/5794/
setコマンドにて値の設定、getコマンドにて設定値の確認を行うことができます。
コマンド :https://docs.silabs.com/gecko-os/1/bgx/latest/commands
パラメータ:https://docs.silabs.com/gecko-os/1/bgx/latest/variables
例:ボーレート設定コマンド
set ua b 19200
Bluetooth5に対応したAndroidスマホを準備します。
スマホアプリ「Serial Bluethooth Terminal」をインストール。
モジュールの電源を入れる。(RBoardに接続するなど)
スマホの設定→機器接続→新しい機器とペア設定する からモジュールを登録。
「Serial Bluethooth Terminal」を起動し、Devices→Bluetooth LE→モジュールの項目を長押しします。
Edit→Custam→3つのUUIDをそれぞれ選択。
右上の✓を押したら接続できるはずです。

bluetooth = UART.new(19200)
while true
  bluetooth.puts("aaaa\r\n")
  sleep(5)
end

wifi

https://www.switch-science.com/catalog/5795/

cmd = "hge https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxx/exec?data1="
wifi = UART.new(19200)
wifi.puts("\r\n")
sleep(5)
while true
  wifi.puts(cmd + (1.to_s) + "\r\n")
  sleep(10)
  wifi.puts("stream_close 0\r\n")
  sleep(10)
end