Skip to content

Commit ff2f4d7

Browse files
committed
Add v3 decoder
1 parent 9df55d2 commit ff2f4d7

File tree

1 file changed

+62
-42
lines changed

1 file changed

+62
-42
lines changed

README.md

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,62 @@
1-
# Arduino Pro Mini TTN LoRaWAN sensor node
2-
3-
<img src="img/case_open.jpg">
4-
5-
`Arduino Pro Mini` TTN LoRaWAN Node with `DHT22` and `RFM95` module powered by an 18650 protected battery.
6-
The Arduino was converted to [LowPower](https://jackgruber.github.io/2019-12-27-Low-power-Arduino-Pro-Mini/) by desoldering the power LED and the voltage converter.
7-
8-
## Circuit
9-
10-
<img src="img/circuit.jpg">
11-
<img src="gerber/promini_rfm95.jpg">
12-
13-
## Case
14-
15-
<img src="img/case_3d.jpg">
16-
17-
## Diagrams
18-
<img src="img/value_plot.jpg">
19-
20-
### Battery voltage curve over 12 months with measure and send data all 5 minutes
21-
22-
<img src="img/vcc_plot.jpg">
23-
24-
## TTN payload decoder
25-
26-
```javascript
27-
function Decoder(bytes, port) {
28-
var decoded = {};
29-
30-
decoded.vcc = (bytes[0] + 200)/100;
31-
32-
if(bytes[1] != 255){
33-
decoded.humidity = bytes[1];
34-
decoded.humidity &= ~(1 << 7);
35-
if(bytes[1] >> 7 == 1) { decoded.humidity +=0.5 }
36-
}
37-
38-
if(bytes[2] != 255 || bytes[3] != 255) decoded.temperature = ((bytes[2]<<24>>16 | bytes[3]) / 10);
39-
return decoded;
40-
}
41-
```
42-
1+
# Arduino Pro Mini TTN LoRaWAN sensor node
2+
3+
<img src="img/case_open.jpg">
4+
5+
`Arduino Pro Mini` TTN LoRaWAN Node with `DHT22` and `RFM95` module powered by an 18650 protected battery.
6+
The Arduino was converted to [LowPower](https://jackgruber.github.io/2019-12-27-Low-power-Arduino-Pro-Mini/) by desoldering the power LED and the voltage converter.
7+
8+
## Circuit
9+
10+
<img src="img/circuit.jpg">
11+
<img src="gerber/promini_rfm95.jpg">
12+
13+
## Case
14+
15+
<img src="img/case_3d.jpg">
16+
17+
## Diagrams
18+
<img src="img/value_plot.jpg">
19+
20+
### Battery voltage curve over 12 months with measure and send data all 5 minutes
21+
22+
<img src="img/vcc_plot.jpg">
23+
24+
## TTN payload decoder (v2)
25+
26+
```javascript
27+
function Decoder(bytes, port) {
28+
var decoded = {};
29+
30+
decoded.vcc = (bytes[0] + 200)/100;
31+
32+
if(bytes[1] != 255){
33+
decoded.humidity = bytes[1];
34+
decoded.humidity &= ~(1 << 7);
35+
if(bytes[1] >> 7 == 1) { decoded.humidity +=0.5 }
36+
}
37+
38+
if(bytes[2] != 255 || bytes[3] != 255) decoded.temperature = ((bytes[2]<<24>>16 | bytes[3]) / 10);
39+
return decoded;
40+
}
41+
```
42+
43+
## TTN payload decoder (v3)
44+
45+
```javascript
46+
function decodeUplink(input) {
47+
var decoded = {};
48+
decoded.vcc = (input.bytes[0] + 200)/100;
49+
if(input.bytes[1] != 255){
50+
decoded.humidity = input.bytes[1];
51+
decoded.humidity &= ~(1 << 7);
52+
if(input.bytes[1] >> 7 == 1) { decoded.humidity +=0.5 }
53+
}
54+
if(input.bytes[2] != 255 || input.bytes[3] != 255) decoded.temperature = ((input.bytes[2]<<24>>16 | input.bytes[3]) / 10);
55+
56+
return {
57+
data: decoded,
58+
warnings: [],
59+
errors: []
60+
};
61+
}
62+
```

0 commit comments

Comments
 (0)