Merge pull request #3 from PeterGribbin/master
Create single fork of forks
This commit is contained in:
@@ -134,6 +134,12 @@ Find the address of the sensor:
|
||||
```
|
||||
i2cdetect -y 1
|
||||
```
|
||||
#### NOVUS 1040 Controller sensor
|
||||
|
||||
Connect via USB. expected COM port is named '/dev/ttyACM0'
|
||||
|
||||
install the minimalmodbus library:
|
||||
~/oprint/bin/pip install minimalmodbus
|
||||
|
||||
### Neopixel
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import json
|
||||
import copy
|
||||
from smbus2 import SMBus
|
||||
from .getPiTemp import PiTemp
|
||||
from .novus1040 import NovusTemp
|
||||
import struct
|
||||
|
||||
|
||||
@@ -1037,6 +1038,10 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP
|
||||
temp = self.read_rpi_temp() # rpi CPU Temp
|
||||
hum = 0
|
||||
airquality = 0
|
||||
elif sensor['temp_sensor_type'] == "novus1040":
|
||||
temp = self.read_novus_temp() # novus Temp
|
||||
hum = 0
|
||||
airquality = 0
|
||||
elif sensor['temp_sensor_type'] == "si7021":
|
||||
temp, hum = self.read_si7021_temp(sensor['temp_sensor_address'], sensor['temp_sensor_i2cbus'])
|
||||
airquality = 0
|
||||
@@ -1305,6 +1310,19 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP
|
||||
"Failed to get pi cpu temperature")
|
||||
self.log_error(ex)
|
||||
return 0
|
||||
|
||||
def read_novus_temp(self):
|
||||
try:
|
||||
novustemp = NovusTemp()
|
||||
temp = novustemp.getTemp()
|
||||
if self._settings.get(["debug_temperature_log"]) is True:
|
||||
self._logger.debug("Novus PV: %s", temp)
|
||||
return temp
|
||||
except Exception as ex:
|
||||
self._logger.info(
|
||||
"Failed to get Novus temperature")
|
||||
self.log_error(ex)
|
||||
return 0
|
||||
|
||||
def read_si7021_temp(self, address, i2cbus):
|
||||
try:
|
||||
|
||||
23
octoprint_enclosure/novus1040.py
Normal file
23
octoprint_enclosure/novus1040.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
import minimalmodbus
|
||||
|
||||
## setup ##
|
||||
# port name, slave address (in decimal)
|
||||
novus = minimalmodbus.Instrument('/dev/ttyACM0', 1)
|
||||
# for Novus 1040 comms documentation see:
|
||||
# https://www.novusautomation.com/downloads/Arquivos/communication_protocol_n1040_v20x_c_en.pdf
|
||||
novus.serial.baudrate = 115200
|
||||
REG_ADDR = {
|
||||
'Active SP': 0,
|
||||
'PV': 1,
|
||||
'dppo': 73
|
||||
}
|
||||
## Read decimal point precision setting ##
|
||||
DP = 3 - novus.read_register(REG_ADDR['dppo'], 0)
|
||||
#print(f'decimal places: {DP}')
|
||||
## set up complete ##
|
||||
|
||||
class NovusTemp:
|
||||
def getTemp(self):
|
||||
temperature = novus.read_register(REG_ADDR['PV'], DP)
|
||||
return '{0:0.1f}'.format(temperature)
|
||||
@@ -632,6 +632,7 @@
|
||||
<option value="max31855">MAX31855</option>
|
||||
<option value="rpi">Raspberry Pi CPU</option>
|
||||
<option value="mcp9808">MCP9808</option>
|
||||
<option value="novus1040">novus1040</option>
|
||||
<option value="temp_raw_i2c">Raw I2C Temperature</option>
|
||||
<option value="hum_raw_i2c">Raw I2C Humidity</option>
|
||||
</select>
|
||||
@@ -747,7 +748,7 @@
|
||||
</div>
|
||||
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: ($data.temp_sensor_type() == "rpi") || ($data.temp_sensor_type() == "18b20") || ($data.temp_sensor_type() == "si7021") || ($data.temp_sensor_type() == "bme280") || ($data.temp_sensor_type() == "am2320") || ($data.temp_sensor_type() == "tmp102") || ($data.temp_sensor_type() == "max31855") || ($data.temp_sensor_type() == "mcp9808") || ($data.temp_sensor_type() == "temp_raw_i2c") || ($data.temp_sensor_type() == "hum_raw_i2c") -->
|
||||
<!-- ko ifnot: ($data.temp_sensor_type() == "rpi") || ($data.temp_sensor_type() == "novus1040") || ($data.temp_sensor_type() == "18b20") || ($data.temp_sensor_type() == "si7021") || ($data.temp_sensor_type() == "bme280") || ($data.temp_sensor_type() == "am2320") || ($data.temp_sensor_type() == "tmp102") || ($data.temp_sensor_type() == "max31855") || ($data.temp_sensor_type() == "mcp9808") || ($data.temp_sensor_type() == "temp_raw_i2c") || ($data.temp_sensor_type() == "hum_raw_i2c") -->
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Pin') }}</label>
|
||||
<div class="controls">
|
||||
|
||||
Reference in New Issue
Block a user