-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
201 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"protocol": "sftp", | ||
"host": "192.168.0.44", | ||
"port": 22, | ||
"user": "pi", | ||
"pass": "raspberry", | ||
"promptForPass": false, | ||
"remote": "/home/pi/lcdtest", | ||
"agent": "", | ||
"privatekey": "", | ||
"passphrase": "", | ||
"hosthash": "", | ||
"ignorehost": true, | ||
"connTimeout": 10000, | ||
"keepalive": 10000, | ||
"keyboardInteractive": false, | ||
"watch": [], | ||
"watchTimeout": 500 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class DisplaySystem(): | ||
|
||
def __init__(self, config, nodes): | ||
self.config = config | ||
self.nodes = nodes | ||
|
||
def update_temp(temp): | ||
for node in self.nodes: | ||
node.send('show_temp', temp) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,69 @@ | ||
import Adafruit_DHT | ||
import RPi.GPIO as GPIO | ||
|
||
import Adafruit_Nokia_LCD as LCD | ||
import Adafruit_GPIO.SPI as SPI | ||
|
||
|
||
class LocalExecutor(): | ||
|
||
def execute(self, command): | ||
def __init__(self): | ||
GPIO.setup(17, GPIO.OUT) | ||
# Raspberry Pi hardware SPI config: | ||
DC = 23 | ||
RST = 24 | ||
SPI_PORT = 0 | ||
SPI_DEVICE = 0 | ||
|
||
# Hardware SPI usage: | ||
disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000)) | ||
|
||
# Initialize library. | ||
disp.begin(contrast=60) | ||
|
||
def power_on(): | ||
GPIO.output(17, True) | ||
|
||
def power_off(): | ||
GPIO.output(17, False) | ||
|
||
def read_temp(): | ||
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 4) | ||
return temperature | ||
|
||
def display_temp(temp): | ||
# Clear display. | ||
disp.clear() | ||
disp.display() | ||
|
||
bool = False | ||
image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT)) | ||
draw = ImageDraw.Draw(image) | ||
draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255) | ||
|
||
# Load default font. | ||
font = ImageFont.truetype("/usr/share/fonts/truetype/roboto/Roboto-Regular.ttf", 30) | ||
fontHumidity = ImageFont.truetype("/usr/share/fonts/truetype/roboto/Roboto-Regular.ttf", 16) | ||
# Write some text. | ||
draw.text((0,0), '{0:0.1f} C'.format(temp), font=font) | ||
draw.text((5,30), '{0:0.1f} HUM'.format(humidity), font=fontHumidity) | ||
|
||
disp.image(image) | ||
|
||
disp.display() | ||
return True | ||
|
||
|
||
def execute(self, command, *args): | ||
result = False | ||
if (command == 'on'): | ||
print('Execute on') | ||
bool = True | ||
result = True | ||
elif (command == 'off'): | ||
print('Execute off') | ||
bool = True | ||
return bool | ||
result = True | ||
elif (command == 'temp'): | ||
result = read_temp() | ||
elif (command == 'show_temp'): | ||
result = display_temp(args[0]) | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
from Executor import LocalExecutor | ||
import serial | ||
|
||
class Node: | ||
def send(self, command): | ||
def send(self, command, *args): | ||
return False | ||
|
||
class BTNode(Node): | ||
def send(self, command): | ||
def __init__(self, port): | ||
self.port = port | ||
self.s = serial.Serial(port=port, baudrate=9600) | ||
|
||
def send(self, command, *args): | ||
self.s.write(command) | ||
print self.s.readline() | ||
# if (connected): | ||
# result = btmanager.send(command) | ||
print('connecting to BT node') | ||
return True | ||
|
||
class LocalNode(Node): | ||
def __init__(self): | ||
self.executor = LocalExecutor() | ||
|
||
def send(self, command): | ||
return self.executor.execute(command) | ||
def send(self, command, *args): | ||
return self.executor.execute(command, args) | ||
|
||
node = BTNode('/dev/tty.HC-06-DevB') | ||
node.send('on') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
REST -> | ||
|
||
heater.schedule_week(from, to, temp) - inform job (actor) | ||
heater.on(timeout) - | ||
heater.off() | ||
|
||
report service -- (heater control nodes, sensor nodes) | ||
getHeaterHistory | ||
getTempHistory | ||
getHumHistory | ||
setInterval(minutes) | ||
|
||
|
||
|
||
heater service -- (heater control node, sensor nodes, display nodes) | ||
add schedule | ||
get schedules | ||
get status | ||
set target temo | ||
on (time: Optional) | ||
off (num days: Optional) | ||
|
||
|
||
QUEUE | ||
|
||
heater control node - on, off, temp, status | ||
sensor node - read temp, read hum, read lum | ||
display node - show temp, show hum, show heater status, show target temp, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import time | ||
|
||
import RPi.GPIO as GPIO | ||
import Adafruit_DHT | ||
|
||
import Adafruit_Nokia_LCD as LCD | ||
import Adafruit_GPIO.SPI as SPI | ||
|
||
from PIL import Image | ||
from PIL import ImageDraw | ||
from PIL import ImageFont | ||
|
||
|
||
# Raspberry Pi hardware SPI config: | ||
DC = 23 | ||
RST = 24 | ||
SPI_PORT = 0 | ||
SPI_DEVICE = 0 | ||
|
||
# Hardware SPI usage: | ||
disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000)) | ||
GPIO.setup(17, GPIO.OUT) | ||
|
||
relay_out = True | ||
|
||
# Initialize library. | ||
disp.begin(contrast=60) | ||
|
||
def refresh_temp(): | ||
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 4) | ||
|
||
# Clear display. | ||
disp.clear() | ||
disp.display() | ||
|
||
image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT)) | ||
draw = ImageDraw.Draw(image) | ||
draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255) | ||
|
||
# Load default font. | ||
font = ImageFont.truetype("/usr/share/fonts/truetype/roboto/Roboto-Regular.ttf", 30) | ||
fontHumidity = ImageFont.truetype("/usr/share/fonts/truetype/roboto/Roboto-Regular.ttf", 16) | ||
# Write some text. | ||
draw.text((0,0), '{0:0.1f} C'.format(temperature), font=font) | ||
draw.text((5,30), '{0:0.1f} HUM'.format(humidity), font=fontHumidity) | ||
|
||
disp.image(image) | ||
|
||
disp.display() | ||
|
||
while True: | ||
time.sleep(5) | ||
refresh_temp() | ||
GPIO.output(17, relay_out) | ||
relay_out = not relay_out |