Skip to main content

温湿度センサー SHT3x

Sensirion 温湿度センサー SHT3x シリーズのための Thing です。 Node-RED とノードモジュール node-red-contrib-sht31 を使用します。

必要なもの#

配線図#

I2C を利用して下記の図のように接続します。

配線図

インストール方法#

ノードモジュール node-red-contrib-sht31 を検索し、パレットにノードを追加します

フローの作成#

フローの例

フローを表示

下記のフローをインポートします

[{"id":"50452d392224267f","type":"http in","z":"06a0338690ed940e","name":"","url":"/sht31","method":"get","upload":false,"swaggerDoc":"","x":80,"y":40,"wires":[["e5e0095fb2347dd6"]]},{"id":"e5e0095fb2347dd6","type":"Sht31","z":"06a0338690ed940e","name":"","bus":"1","address":"0x44","topic":"sht31","x":250,"y":40,"wires":[["33cb2c8c6eb85dc6"]]},{"id":"33cb2c8c6eb85dc6","type":"http response","z":"06a0338690ed940e","name":"","statusCode":"","headers":{},"x":410,"y":40,"wires":[]}]

Thing Description の例#

スキーム・ホスト名・ポート番号 http://localhost:1880 を自分の使っているアドレスに置き換えて使用します。

{  "@context": "https://www.w3.org/2019/wot/td/v1",  "title": "SHT31",  "securityDefinitions": {    "nosec_sc": {      "scheme": "nosec"    }  },  "security": [    "nosec_sc"  ],  "properties": {    "sht31": {      "title": "SHT31 Reading Sensor Data",      "type": "object",      "properties": {        "model": {          "const": "SHT31"        },        "temperature_C": {          "title": "Temperatures in degrees Celsius",          "type": "number"        },        "humidity": {          "title": "Humidity",          "type": "number"        }      },      "forms": [        {          "href": "http://localhost:1880/sht31",          "op": [            "readproperty"          ]        }      ]    }  }}

Thing Description をダウンロード:

curl -sLO https://raw.githubusercontent.com/w3c/wot-jp-cg/main/docs/examples/sht3x/sht31.jsonldeditor sht31.jsonld

使用例#

上記の Thing Description の例を元にして JSON-LD ファイルを作成し、node-red-nodegen を使用してノードモジュールを作成します。

ノードを作成:

npx node-red-nodegen sht31.jsonldnpm --prefix ~/.node-red install ./node-red-contrib-wotsht31

使用例