Code by Scott שאול בן ישוע
Commit 4a093637 authored by Sha'ul ben Yeshua's avatar Sha'ul ben Yeshua 🎗
Browse files

code changes and DHT updates

parent 5a6c0abc
# Monitor & Information Rest API for Raspberry PI
This is a very lean little project based on [SpringBoot](https://spring.io/projects/spring-boot) 2.0 and [Pi4J](http://pi4j.com).
Branched from this [project](https://github.com/cl0udninja/raspberrypi.monitor)
This is a project based on [SpringBoot](https://spring.io/projects/spring-boot) 2.0 and [Pi4J](http://pi4j.com).
Current version *1.3*
......
......@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RaspberryPiStatusService {
@SuppressWarnings("unchecked")
......@@ -25,8 +26,9 @@ public class RaspberryPiStatusService {
log.debug("Querying system information");
SystemInfoDTO systemInfo = new SystemInfoDTO();
systemInfo.setPlatformName(PlatformManager.getPlatform().getLabel());
systemInfo.setPlatformID(PlatformManager.getPlatform().getId());
systemInfo.setOsName(SystemInfo.getOsName());
systemInfo.setOsVersion(SystemInfo.getOsVersion());
systemInfo.setCpuTemperature(SystemInfo.getCpuTemperature());
systemInfo.setSerialNumber(SystemInfo.getSerial());
systemInfo.setCpuCoreVoltage(SystemInfo.getCpuVoltage());
......
......@@ -16,13 +16,13 @@ public class TemperatureService {
public TemperatureDTO getTemperature() throws IOException, InterruptedException {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("/home/pi/smartthings/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 4");
Process pr = rt.exec("/root/bin/AdafruitDHT.py 11 17");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
int exitCode = pr.waitFor();
log.info(String.format("DHT22 sensor reader exited with %s", exitCode));
log.info(String.format("DHT11/22 sensor reader exited with %s", exitCode));
StringBuffer sb = new StringBuffer();
String line = null;
......@@ -30,10 +30,10 @@ public class TemperatureService {
sb.append(line + "\t");
}
log.info(String.format("Read DHT22 data: %s", sb.toString()));
log.info(String.format("Read DHT11/22 data: %s", sb.toString()));
TemperatureDTO dto = new TemperatureDTO();
dto.setTemperatureC(Double.parseDouble(sb.toString().substring(5, 9)));
dto.setTemperature(Double.parseDouble(sb.toString().substring(5, 9)));
dto.setHumidity(Double.parseDouble(sb.toString().substring(21, 25)));
return dto;
......
......@@ -12,7 +12,7 @@ import com.cl0udninja.raspberrypi.monitor.service.TemperatureService;
import com.cl0udninja.raspberrypi.monitor.web.dto.TemperatureDTO;
@RestController
@RequestMapping("/api/temperature")
@RequestMapping("/api/dht")
public class TemperatureDHT22Controller {
@Autowired
......
......@@ -15,6 +15,10 @@ import lombok.Data;
@Data
public class SystemInfoDTO {
@JsonProperty
private String platformName;
@JsonProperty
private String platformID;
@JsonProperty
private String osName;
@JsonProperty
......
......@@ -8,7 +8,7 @@ import lombok.Data;
public class TemperatureDTO {
@JsonProperty
public Double temperatureC;
public Double temperature;
@JsonProperty
public Double humidity;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment