Last active
August 11, 2019 13:26
-
-
Save izzuddin91/f564f2a44eebe84670297f8f825b484d to your computer and use it in GitHub Desktop.
hydroponic project august 2019 - iteration 1 complete package
This file contains hidden or 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
#import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library | |
#from time import sleep # Import the sleep function from the time module | |
import os | |
import csv | |
r = csv.reader(open('/home/pi/Desktop/hydroponic_project/relay_running_count.csv')) # Here your csv file | |
lines = list(r) | |
original = lines[0][0] | |
print(lines[0]) | |
original = int(original) + 1 | |
lines[0][0] = str(original) | |
writer = csv.writer(open('relay_running_count.csv', 'w+')) | |
writer.writerows(lines) | |
This file contains hidden or 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
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library | |
from time import sleep # Import the sleep function from the time module | |
import os | |
GPIO.setwarnings(False) # Ignore warning for now | |
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering | |
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (off) | |
while True: # Run forever | |
os.system('python /home/pi/Desktop/hydroponic_project/increment_relay_count.py') | |
GPIO.output(8, GPIO.HIGH) # Turn on | |
# os.system('python increment_relay_count.py') | |
sleep(25) # Switch on water pump for 30 seconds | |
GPIO.output(8, GPIO.LOW) # Turn off | |
sleep(18000) # Sleep for 5 hours |
This file contains hidden or 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
import csv | |
import re | |
import time | |
import argparse | |
from luma.led_matrix.device import max7219 | |
from luma.core.interface.serial import spi, noop | |
from luma.core.render import canvas | |
from luma.core.virtual import viewport | |
from luma.core.legacy import text, show_message | |
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT | |
def demo(n, block_orientation, rotate): | |
# create matrix device | |
serial = spi(port=0, device=0, gpio=noop()) | |
device = max7219(serial, block_orientation=-90, rotate=rotate or 0, width=32, height=8) | |
print("Created device") | |
# start demo | |
# msg = "Welcome to Uniqlo!" | |
# print(msg) | |
# show_message(device, msg, fill="white", font=proportional(CP437_FONT)) | |
# time.sleep(1) | |
r = csv.reader(open('/home/pi/Desktop/hydroponic_project/relay_running_count.csv')) # Here your csv file | |
lines = list(r) | |
count = lines[0][0] | |
msg = "Water pump running count: " + count | |
print(msg) | |
show_message(device, msg, fill="white", font=proportional(CP437_FONT)) | |
time.sleep(1) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='matrix_demo arguments', | |
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | |
parser.add_argument('--cascaded', '-n', type=int, default=1, help='Number of cascaded MAX7219 LED matrices') | |
parser.add_argument('--block-orientation', type=int, default=0, choices=[0, 90, -90], help='Corrects block orientation when wired vertically') | |
parser.add_argument('--rotate', type=int, default=0, choices=[0, 1, 2, 3], help='Rotate display 0=0 , 1=90 , 2=180 , 3=270 ') | |
args = parser.parse_args() | |
demo(args.cascaded, args.block_orientation, args.rotate) |
This file contains hidden or 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
import RPi.GPIO as GPIO | |
import time | |
import os | |
import csv | |
GPIO.setmode(GPIO.BCM) | |
#pin bawah skali, seblah ground | |
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
while True: | |
input_state = GPIO.input(21) | |
if input_state == False: | |
print("button pressed") | |
os.system('python /home/pi/Desktop/hydroponic_project/run_led_display.py') | |
time.sleep(0.2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
written on 11 august 2019