Code by Scott שאול בן ישוע
README.md 3.91 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

7
8
Current version *1.3*

Scott Grayban's avatar
edits    
Scott Grayban committed
9
10
# Projects using this java app

Scott Grayban's avatar
Scott Grayban committed
11
* Hubitat [RaspberryPi Stats and DHT](https://github.com/sgrayban/Hubitat-Ports/tree/master/Drivers/rpi)
Scott Grayban's avatar
edits    
Scott Grayban committed
12

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
13
14
# Pre-requisites

Scott Grayban's avatar
edits    
Scott Grayban committed
15
16
* [JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) - apt install oracle-java8-jdk
* [Maven 3x](https://maven.apache.org/download.cgi) - apt install maven
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
17

Scott Grayban's avatar
edits    
Scott Grayban committed
18
19
20
21
22
# Download
Make sure you are in /root directory first then....

```git clone https://github.com/sgrayban/raspberrypi.monitor.git```

23
## Editing for the [Raspberry Pi DHT11/22 Sensor](https://raw.githubusercontent.com/sgrayban/Hubitat-Ports/master/Drivers/rpi/Raspberry-Pi-DHT-Sensor.groovy)
Scott Grayban's avatar
Scott Grayban committed
24
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
25
2. Edit line 19 in src/main/java/com/cl0udninja/raspberrypi/monitor/service/TemperatureService.java
26
27
28
29
   - 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
30
# Build as root
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
31
32
33
34

Simply

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

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
37
38
39
mvn clean install
```

40
41
42
# Installation

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

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
44
45
```bash
cp raspberrypi_monitor.service /etc/systemd/system/raspberrypi_monitor.service
46
47
48
systemctl daemon-reload
systemctl enable raspberrypi_monitor.service
systemctl start raspberrypi_monitor.service
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
49
50
```

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

Sha'ul ben Yeshua's avatar
edits    
Sha'ul ben Yeshua committed
53
54
55
```bash
systemctl status raspberrypi_monitor.service
```
Scott Grayban's avatar
edits    
Scott Grayban committed
56
57
58
59
60
61
62
63
64
65
66
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
67

68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Upgrading to version 1.3

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
```

Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
82
83
84
# Usage

```
Scott Grayban's avatar
edits    
Scott Grayban committed
85
http://Rpi-IP:8080/api/pi
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
86
87
88
89
90
91
```

Would yield something like this:

```json
{
92
"osName": Linux
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"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"
],
108
109
110
111
112
113
"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
114
115
116
"cpuFrequency": 600000000
}
```
Sha'ul ben Yeshua's avatar
Sha'ul ben Yeshua committed
117

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# RELEASES
2019-04-15 :: 1.3

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