diff --git a/README.md b/README.md index 49860d2..cbf6e97 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index 9748f12..0e5060a 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -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: diff --git a/octoprint_enclosure/novus1040.py b/octoprint_enclosure/novus1040.py new file mode 100644 index 0000000..5820bb5 --- /dev/null +++ b/octoprint_enclosure/novus1040.py @@ -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) diff --git a/octoprint_enclosure/templates/enclosure_settings.jinja2 b/octoprint_enclosure/templates/enclosure_settings.jinja2 index 755fc8b..5b074ed 100644 --- a/octoprint_enclosure/templates/enclosure_settings.jinja2 +++ b/octoprint_enclosure/templates/enclosure_settings.jinja2 @@ -632,6 +632,7 @@ + @@ -747,7 +748,7 @@ - +