@@ -0,0 +1,67 @@
# coding=utf-8
import setuptools

########################################################################################################################

plugin_identifier = "navbartemp"
plugin_package = "octoprint_%s" % plugin_identifier
plugin_name = "OctoPrint-NavbarTemp"
plugin_version = "0.7"
plugin_description = "Displays temperatures on navbar"
plugin_author = "Jarek Szczepanski"
plugin_author_email = "imrahil@imrahil.com"
plugin_url = "https://github.com/imrahil/OctoPrint-NavbarTemp"
plugin_license = "AGPLv3"
plugin_additional_data = []

########################################################################################################################

def package_data_dirs(source, sub_folders):
import os
dirs = []

for d in sub_folders:
folder = os.path.join(source, d)
if not os.path.exists(folder):
continue

for dirname, _, files in os.walk(folder):
dirname = os.path.relpath(dirname, source)
for f in files:
dirs.append(os.path.join(dirname, f))

return dirs

def params():
# Our metadata, as defined above
name = plugin_name
version = plugin_version
description = plugin_description
author = plugin_author
author_email = plugin_author_email
url = plugin_url
license = plugin_license

# we only have our plugin package to install
packages = [plugin_package]

# we might have additional data files in sub folders that need to be installed too
package_data = {plugin_package: package_data_dirs(plugin_package, ['static', 'templates', 'translations'] + plugin_additional_data)}
include_package_data = True

# If you have any package data that needs to be accessible on the file system, such as templates or static assets
# this plugin is not zip_safe.
zip_safe = False

# Read the requirements from our requirements.txt file
install_requires = open("requirements.txt").read().split("\n")

# Hook the plugin into the "octoprint.plugin" entry point, mapping the plugin_identifier to the plugin_package.
# That way OctoPrint will be able to find the plugin and load it.
entry_points = {
"octoprint.plugin": ["%s = %s" % (plugin_identifier, plugin_package)]
}

return locals()

setuptools.setup(**params())
@@ -23,74 +23,63 @@
import Adafruit_DHT
import pigpio
from time import sleep
import logging



pi = pigpio.pi()

heater_pin = 17
fan_pin = 27
sensor_type = 22
sensor_pin = 4
heater_delayheat = 5 # Seconds required to heat the heating element
heater_delaycool = 15 # Second required to cool the heating element
heater_pin = 27
sensor_pin = 17
sensor_type = 22 # DHT22

# Parse command line parameters.

if len(sys.argv) == 2:
sensor_type = 22
sensor_pin = 4
tempSet = float(sys.argv[1])
else:
print 'usage: sudo $1 <desired temperature (F)>'
print 'example: sudo $1 80F #set control temperature to 80F'
sys.exit(1)

logging.basicConfig(level=logging.INFO,
filename='heaterloop.log', # log to this file
format='%(asctime)s %(message)s') # include timestamp

# Try to grab a sensor reading. Use the read_retry method which will retry up
# to 15 times to get a sensor reading (waiting 2 seconds between each retry).


# Note that sometimes you won't get a reading and
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
# guarantee the timing of calls to read the sensor).
# If this happens try again!

pi.write(heater_pin,0)
pi.write(fan_pin,0)

while True:

humidity, temperature = Adafruit_DHT.read_retry(sensor_type, sensor_pin)

if humidity is not None and temperature is not None:
temperature = temperature * 9/5.0 + 32
print 'Current Temperature: %d' % temperature
print 'Desired Temperature: %d' % tempSet
#print 'Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity)
logging.info('%dF/%dF Heater:%s' % (temperature, tempSet, pi.read(heater_pin)))
print '%dF/%dF' % (temperature, tempSet)
# print 'Humidity={1:0.1f}%'.format(humidity)

if temperature < tempSet and pi.read(heater_pin) == False:
print 'Trigger: tempset, heaterpin == False'
print 'Turning on heater, waiting %d seconds for heat' % heater_delayheat
pi.write(heater_pin,1) #Enable
sleep(heater_delayheat)
print 'Enabling fan'
pi.write(fan_pin, 1) #Enable fan
print '==== Now Heating ===='
pi.write(heater_pin,1) #Enable

elif temperature >= tempSet:
print 'Temperature >= tempSet'

if pi.read(fan_pin) and pi.read(heater_pin):
print 'fan and heater enabled, going into cooldown'
pi.write(heater_pin,0)
print 'waiting %d seconds for element cooldown' % heater_delaycool
sleep(heater_delaycool)
print 'Disabling fan'
pi.write(fan_pin,0)
else:
# Make sure everything is off, just in case.
if pi.read(heater_pin) == True:
print '==== Heater Disabled ===='
pi.write(heater_pin,0)
pi.write(fan_pin,0)

else:
print 'Failed to get reading. Try again!'
print 'Failed to get reading. Try again! (Heater Disabled)'
pi.write(heater_pin,0)
sys.exit(1)
sleep(1)
sleep(2)




@@ -0,0 +1,102 @@
#!/usr/bin/python
# Author: Skyler Ogden

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import sys
import Adafruit_DHT
import pigpio
from time import sleep

pi = pigpio.pi()

heater_pin = 27
# fan_pin = 27
sensor_type = 22
sensor_pin = 17
heater_delayheat = 5 # Seconds required to heat the heating element
heater_delaycool = 15 # Second required to cool the heating element

# Parse command line parameters.

if len(sys.argv) == 2:
sensor_type = 22
sensor_pin = 4
tempSet = float(sys.argv[1])
else:
print 'usage: sudo $1 <desired temperature (F)>'
print 'example: sudo $1 80F #set control temperature to 80F'
sys.exit(1)

# Try to grab a sensor reading. Use the read_retry method which will retry up
# to 15 times to get a sensor reading (waiting 2 seconds between each retry).


# Note that sometimes you won't get a reading and
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
# If this happens try again!

pi.write(heater_pin,0)
# pi.write(fan_pin,0)

while True:

humidity, temperature = Adafruit_DHT.read_retry(sensor_type, sensor_pin)
if humidity is not None and temperature is not None:
temperature = temperature * 9/5.0 + 32
print 'Current Temperature: %d' % temperature
print 'Desired Temperature: %d' % tempSet
#print 'Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity)
if temperature < tempSet and pi.read(heater_pin) == False:
print 'Trigger: tempset, heaterpin == False'
print 'Turning on heater, waiting %d seconds for heat' % heater_delayheat
pi.write(heater_pin,1) #Enable
sleep(heater_delayheat)
print 'Enabling fan'
# pi.write(fan_pin, 1) #Enable fan

elif temperature >= tempSet:
print 'Temperature >= tempSet'

if pi.read(heater_pin): # and pi.read(fan_pin):
print 'fan and heater enabled, going into cooldown'
pi.write(heater_pin,0)
print 'waiting %d seconds for element cooldown' % heater_delaycool
sleep(heater_delaycool)
print 'Disabling fan'
# pi.write(fan_pin,0)
else:
# Make sure everything is off, just in case.
pi.write(heater_pin,0)
# pi.write(fan_pin,0)
else:
print 'Failed to get reading. Try again!'
sys.exit(1)
sleep(1)