Code by Scott שאול בן ישוע
README.md 4.26 KB
Newer Older
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
1
2
# Monitor & Information Rest API for Raspberry PI

Scott Grayban's avatar
Scott Grayban committed
3
Branched from @cl0udninja [project](https://github.com/cl0udninja/raspberrypi.monitor)
4
5

This is a project based on [SpringBoot](https://spring.io/projects/spring-boot) 2.0 and [Pi4J](http://pi4j.com).
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
6

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
7
Current TAG version *1.4*
8

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
9
# Hubitat Drivers
Scott Grayban's avatar
edits    
Scott Grayban committed
10

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
11
* Located under the [Driver](/sgrayban/raspberrypi.monitor/tree/master/Driver) folder
Scott Grayban's avatar
edits    
Scott Grayban committed
12

13
14
# Pre-compiled releases

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
15
The pre-compiled releases are built on the RaspberryPi 3B+ located [here](https://gitlab.borgnet.us:8443/sgrayban/raspberrypi.monitor/releases).
16
17
18

**!NOTE!!** They may not work on other boards.

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
19
20
# Pre-requisites

Scott Grayban's avatar
Scott Grayban committed
21
* [Oracle JDK 8 Linux ARM 32 Hard Float ABI](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) - ```apt install oracle-java8-jdk``` **Required to run**
22
* [Maven 3x](https://maven.apache.org/download.cgi) - ```apt install maven``` **Required to build**
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
23

Scott Grayban's avatar
edits    
Scott Grayban committed
24
25
26
# Download
Make sure you are in /root directory first then....

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
27
```git clone https://gitlab.borgnet.us:8443/sgrayban/raspberrypi.monitor.git```
Scott Grayban's avatar
edits    
Scott Grayban committed
28

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
29
## Editing for the Raspberry Pi DHT11/22 Sensor
Scott Grayban's avatar
Scott Grayban committed
30
1. You should **test** the python script first to make sure your settings are correct here or you will have to compile again.
Scott Grayban's avatar
Scott Grayban committed
31
2. Edit line 19 in src/main/java/com/cl0udninja/raspberrypi/monitor/service/TemperatureService.java
32
33
34
35
   - Line reads ```Process pr = rt.exec("/root/bin/AdafruitDHT.py 11 17");```
     - First number is the DHT type - it's either DHT11 or DHT22 - Example is 11
      - Second number is the [GPIO](https://pinout.xyz/#) BCM pin - Example is 17

Scott Grayban's avatar
edits    
Scott Grayban committed
36
# Build as root
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
37
38
39
40

Simply

```bash
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
41
42
cd /root/raspberrypi.monitor

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
43
44
45
mvn clean install
```

46
47
48
# Installation

Install raspberrypi_monitor.service as a Systemd script to start at boot
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
49

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
50
51
```bash
cp raspberrypi_monitor.service /etc/systemd/system/raspberrypi_monitor.service
52
53
54
systemctl daemon-reload
systemctl enable raspberrypi_monitor.service
systemctl start raspberrypi_monitor.service
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
55
56
```

57
Then to make sure the app is running
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
58

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
59
60
61
```bash
systemctl status raspberrypi_monitor.service
```
Scott Grayban's avatar
edits    
Scott Grayban committed
62
63
64
65
66
67
68
69
70
71
72
Should yeld something like this

```bash
# systemctl status raspberrypi_monitor.service
● raspberrypi_monitor.service - Manage raspberrypi monitor service
   Loaded: loaded (/etc/systemd/system/raspberrypi_monitor.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-04-11 16:53:01 PDT; 2min 22s ago
 Main PID: 316 (java)
   CGroup: /system.slice/raspberrypi_monitor.service
           └─316 /usr/bin/java -jar /root/janipi/target/raspberrypi.janipi-0.0.1-SNAPSHOT.jar
```
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
73

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
74
# Upgrading to version 1.3 or newer
75
76
77
78
79
80
81
82
83
84
85
86
87

A lot of things have changed since I first posted this project and as such install must change!

First raspberrypi_monitor.service has been changed.

1) Install raspberrypi_monitor.service as a Systemd script to start at boot

```bash
cp raspberrypi_monitor.service /etc/systemd/system/raspberrypi_monitor.service
systemctl daemon-reload
systemctl start raspberrypi_monitor.service
```

Scott Grayban's avatar
Scott Grayban committed
88
# Usage for PI Stats
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
89
90

```
Scott Grayban's avatar
edits    
Scott Grayban committed
91
http://Rpi-IP:8080/api/pi
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
92
93
94
95
96
97
```

Would yield something like this:

```json
{
98
"osName": Linux
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"cpuTemperature": 52.1,
"serialNumber": "0000000000000000",
"cpuCoreVoltage": 1.2,
"modelName": "ARMv7 Processor rev 4 (v7l)",
"boardType": "RaspberryPi_3B",
"totalMemory": 967700480,
"usedMemory": 221253632,
"freeMemory": 401907712,
"sharedMemory": 14475264,
"javaVersion": "1.8.0_152",
"hostname": "raspberrypi",
"ipAddresses": [
"192.168.1.40",
"172.17.0.1"
],
114
115
116
117
118
119
"nameservers":[
"8.8.8.8"
"192.168.0.36"
"2001:428::1"
"2001:428::2"
]
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
120
121
122
"cpuFrequency": 600000000
}
```
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
123

Scott Grayban's avatar
Scott Grayban committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
## Usage for the DHT sensor

```
http://Rpi-IP:8080/api/dht
```

Would yield something like this:

```json
{
"temperature":69.8,
"humidity":58.0
}
```

139
# RELEASES
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
140
2019-04-15 :: 1.3 & 1.4
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

* Added Support for Raspberry Pi 3A+
* Added support for Raspberry Pi 3B+
* Added support for Raspberry Pi Zero W
* Added support for Raspberry Pi Compute Module 3+
* Added support for Raspberry Pi Compute Module 3

# Supported Hardware

* Raspberry Pi - A
* Raspberry Pi - B (Revision 1)
* Raspberry Pi - B (Revision 2)
* Raspberry Pi - A+
* Raspberry Pi - B+
* Raspberry Pi - 2B
* Raspberry Pi - 3B
* Raspberry Pi - 3B+
* Raspberry Pi - 3A+
* Raspberry Pi - Zero
* Raspberry Pi - Zero W
* Raspberry Pi - CM1 (Compute Module)
* Raspberry Pi - CM3 (Compute Module)
* Raspberry Pi - CM3+ (Compute Module)