Code by Scott שאול בן ישוע
README.md 4.45 KB
Newer Older
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
1
2
<a href = "https://www.paypal.me/sgrayban"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif"></a>

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
3
4
# Monitor & Information Rest API for Raspberry PI

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

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
8

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
9
Current TAG version *1.4*
10

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
11
# Hubitat Drivers
Scott Grayban's avatar
edits    
Scott Grayban committed
12

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
13
* Located under the [Driver](https://gitlab.borgnet.us:8443/sgrayban/raspberrypi.monitor/tree/master/Driver) folder
Scott Grayban's avatar
edits    
Scott Grayban committed
14

15
16
# Pre-compiled releases

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

19
**!NOTE!!** You can use OpenJDK to run it but not to compile it..
20

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
21
22
# Pre-requisites

23
24
* [Download the Oracle JDK 8 Linux ARM 32 deb](http://sgrayban.borgnet.online:8081/raspberrypi.monitor/oracle-java8-jdk_8u65_armhf.deb) - ```dpkg -i oracle-java8-jdk_8u65_armhf.deb``` * **Required to compile**
* [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
25

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

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

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
31
## Editing for the Raspberry Pi DHT11/22 Sensor
Scott Grayban's avatar
Scott Grayban committed
32
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
33
2. Edit line 19 in src/main/java/com/cl0udninja/raspberrypi/monitor/service/TemperatureService.java
34
35
36
37
   - 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
38
# Build as root
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
39
40
41
42

Simply

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

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
45
46
47
mvn clean install
```

48
49
50
# Installation

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

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

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

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
61
62
63
```bash
systemctl status raspberrypi_monitor.service
```
Scott Grayban's avatar
edits    
Scott Grayban committed
64
65
66
67
68
69
70
71
72
73
74
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
75

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

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
90
# Usage for PI Stats
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
91
92

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

Would yield something like this:

```json
{
100
"osName": Linux
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"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"
],
116
117
118
119
120
121
"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
122
123
124
"cpuFrequency": 600000000
}
```
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
125

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

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

Would yield something like this:

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

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

* 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)