私はnode-redとIoTの初心者ですが、現在はプロジェクトで作業中です。 基本的に私の目的は、建設労働者のための警告システムを作成することです。Node-REDでの複数入力の実装
高度、周囲温度、安全機構の状態(ロックされているかどうか)を測定したい。測定値に基づいて、システムが決定を下します(測定値がしきい値を超えた場合 - 通知[ブザー/ LED]を送信します)。電流を測定、(まだ定義されていない)は、時間の特定の期間後にシステムがオンになると
- 、初期高度(Hの初期)を測定し、
- :
ロジックは以下の通りであります高度(h電流)。
- 現在の高度と初期高度の差は、実際の作業者の高度(h)です。
- 高度hが2メートル以上の場合は、ブザー信号を送信してください。 hが0より小さい場合は、h initialとh currentを再度計算します。
私はTI CC2650 SensorTagをRPiのNode-redに接続しています。読み取るセンサーの読み取り数に応じて、node-redをjsonオブジェクトとして赤色に送信します。私の場合(温度、圧力)で、私は順番に2 jsonsを受け付けております:
{ "d": { "id": "b827ebb2b2bd.c4be84711c81.0", "tstamp": { "$date": 1469565713321 }, "json_data": { "object": 21.40625, "ambient": 27.125 } } }
{ "d": { "id": "b827ebb2b2bd.c4be84711c81.4", "tstamp": { "$date": 1469565713328 }, "json_data": { "pressure": 1016.36 } } }
私は、次のような問題に直面しました:
私は-REDのノードに複数のデータを供給することができませんでした。関数ノードに送信する方法(温度、圧力、機構の状態[1または0]のデータ)を誰かに教えられるかどうか疑問に思っていました。
警告について。基本的に、実際の標高を見つけるには2つの高度測定が必要です。私は何とか2つの圧力/温度測定値を保存する必要があります。測定データを配列として保存する必要がありますか、これに対処するより良い方法がありますか?
誰もがこれを手伝ってくれれば助かりますか?
P.S.フローのクリップボードはかなり長いので、ここに貼り付けないと決めましたが、だれでもリクエストすれば送信できます。ノード-REDノードは一つだけ入力タブがありますが
非常に非常に生のコードは
var hInit;
var hChecked;
var h;
//p0 is the hardcoded pressure on the level of the sea
//hardcoded for the current area
var p0 = 1019;
//extract the pressure value and the ambient temp from jsons
tagPressure = msg.payload.json_data.pressure;
tagTemp = msg.payload.json_data.ambient;
//the formula to convert a pressure to an altitude
//here it should measure the altitde (hInit) when the testbest is turned on
hInit = (((Math.pow((tagTemp/p0), (1/5.257)))-1)*(tagTemp + 273.15))/0.0065;
//hChecked is the measured altitude afterwards
hChecked = (((Math.pow((tagTemp/p0), (1/5.257)))-1)*(tagTemp + 273.15))/0.0065;
//h is the actual altitude the worker is working on
h = hChecked - hInit;
//in the case if a worker turned the testbed on
//when he was operating on the altitude he then
//might go down so altitude can reduce.
//therefore if the altitude h is < 0 we need to
//calculate a new reference
if (h < 0) {
hInit = (((Math.pow((tagTemp/p0), (1/5.257)))-1)*(tagTemp + 273.15))/0.0065;
hChecked = (((Math.pow((tagTemp/p0), (1/5.257)))-1)*(tagTemp + 273.15))/0.0065;
h = hChecked - hInit;
return h;
}
//check current altitude
while (h>0){
if (h>2){
if (lockerState == 1) {
msg.payload = "safe";
return msg;
}
else if (lockerState === 0) {
msg.payload = "lock your belt!";
//basically i want to send a 1 signal
//to the buzzer which is a pin on the RPI3
//so probably msg.payload = 1;
return msg;
}
}
}
//return msg;
ありがとうございました!文脈は私を助けた! –