通過Lorawan™連接的簡單小費扣雨表。該設備計數的次數次數/滾動量的次數,並使用Lorawan™發送值。
然後,接收器應用程序可以計算降雨,並在需要時重置計數器。
降雨計算的靈感來自Arduino-Rain-gauge校準指令。
使用尺寸為11 cm x 5 cm的傾倒桶雨量表,提供了55厘米的集水區。 10毫升的降雨的集合為10 ml/55cm²= 0.181818182 cm = 1.81818182 mm降雨。
在小費桶雨量計中,桶尖/跌落10毫升(或1.81 mm的雨水)5次,因此單個尖端適用於(10/5)ml = 2ml(或0,364636364 mm)。

RFM95銷的所有必需銷都位於羽毛上,直接連接到32U4上的銷釘上,除了RFM95 DIO1。對於RFM95 dio1是Arduino引腳1,因為它是外部中斷#3,並且位於羽毛上的Dio1旁邊。 Adafruit Feather 32U4 RFM95針映射。
小費桶需要羽毛,GND和輸入上的兩個銷釘。由於輸入引腳是Arduino引腳3(外部中斷0)。
需要為Arduino引腳3啟用較弱的上下拉,因此當傾倒桶尖/滾動時,可以檢測到低信號。
使用Adafruit Feather 32U4平台板的Platformio是基礎。 Arduino-LMIC庫提供Lorawan™支持。
該固件僅計算小費桶完成的技巧/滾動數,並使用Lorawan™發送它。在消息中,還報告了電池電壓水平。
在Lorawan加入序列期間,LED正在褪色。淡出類是由Arduino淡出的LED示例構建的。
節省在兩個主要狀態下進行。下雨模式和無雨模式。
如果電池電壓低於3.5 v,則第三個模式將設備以Sleep_forever模式設置,而無需啟用任何中斷設備。這是為了使電池免於被放電銷毀。
睡眠以8秒的間隔完成,每8 s睡覺後,檢查LMIC狀態機,並且數據是否為時間數據。
默認數據發送期限為15秒。
如果未檢測到大約一小時的降雨,則設備將Sleep Mode Sleep_ forverver設置,並等待下次下雨,以便外部中斷喚醒設備。
當設備醒來時,發送消息將發送到獲取任何傳入命令。
為了簡化與網絡事物的集成,可以使用解碼器和編碼器來簡化MQTT API的使用。
mqtt命令重置設備中的雨櫃檯。參數重置應具有值234 (0xEA),以使設備接受重置命令。
mosquitto_pub -h < Region > .thethings.network -u " <AppID> " -P " <AppKey> " -t ' <AppID>/devices/<DevID>/down ' -m ' {"port":2,"confirmed":true,"payload_fields":{"reset":234}} 'MQTT命令將發送間隔設置為15分鐘。
mosquitto_pub -h < Region > .thethings.network -u " <AppID> " -P " <AppKey> " -t ' <AppID>/devices/<DevID>/down ' -m ' {"port":2,"confirmed":true,"payload_fields":{"multiplexer":15}} ' function Decoder ( bytes , port )
{
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var decoded = { } ;
if ( port === 1 )
{
if ( bytes . length >= 3 )
{
decoded . counts = ( ( ( bytes [ 2 ] & 0x80 ) >> 7 ) << 16 ) | ( bytes [ 1 ] << 8 ) | bytes [ 0 ] ;
decoded . vbat = ( ( bytes [ 2 ] & 0x7F ) + 330 ) / 100.0 ;
}
}
return decoded ;
} function Encoder ( object , port ) {
// Encode downlink messages sent as
// object to an array or buffer of bytes.
var bytes = [ ] ;
if ( port === 1 && ( ( object . multiplexer > 0 ) && ( object . multiplexer < 255 ) ) )
{
bytes [ 0 ] = 1 ;
bytes [ 1 ] = object . multiplexer ;
}
else if ( port === 2 && object . reset === 0xea )
{
bytes [ 0 ] = object . reset ;
}
return bytes ;
}