Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testar servidor rodando na raspberry #9

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ae5e671
Add function to get stick sensor
davialvb Nov 29, 2019
6a4904c
Add funtion to sticks sensor
davialvb Nov 30, 2019
effde61
Add funtion to sticks sensor
davialvb Nov 30, 2019
8f2c1d5
Add funtion to sticks sensor in websocket.py
davialvb Nov 30, 2019
c13de1e
Merge remote-tracking branch 'origin/master' into rasp_communication
victorciurlini Nov 30, 2019
aa634d2
Add update function
davialvb Nov 30, 2019
c5c8cb1
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Nov 30, 2019
62f4015
Add new function to sticks
davialvb Dec 1, 2019
10ed561
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
ee87bc1
Fix errors
davialvb Dec 1, 2019
736b2ad
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
f9b0982
Fix errors
davialvb Dec 1, 2019
8272d78
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
228f8eb
Fix errors
davialvb Dec 1, 2019
c4e8676
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
2b10e66
Fix errors
davialvb Dec 1, 2019
94e7a4d
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
743313d
Clean class RaspGPIO
davialvb Dec 1, 2019
6539398
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
f5a567d
Fix sticks positions
davialvb Dec 1, 2019
aee6860
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
8474a38
Fix sticks positions
davialvb Dec 1, 2019
4964349
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 1, 2019
ee204f2
Get update to sticks
victorciurlini Dec 1, 2019
af7b844
Test save
victorciurlini Dec 1, 2019
c30d6dd
Update requirements
gabrielziegler3 Dec 1, 2019
286c663
Merge branch 'rasp_communication' of github.com:SmartMeat-UnB/smartme…
gabrielziegler3 Dec 1, 2019
98d8912
Merge branch 'master' of github.com:SmartMeat-UnB/smartmeat-socket in…
gabrielziegler3 Dec 1, 2019
5ab52c4
Add last version code to socket without thread
victorciurlini Dec 3, 2019
74e3490
Add update code working with thread
victorciurlini Dec 3, 2019
86c8205
Fix motors without start
victorciurlini Dec 3, 2019
a529185
Test motors
davialvb Dec 3, 2019
7bb133d
Add new function to temperature
davialvb Dec 4, 2019
3e724c6
Add new function to temperature
davialvb Dec 4, 2019
2ef33cb
Add new function to temperature
davialvb Dec 4, 2019
fda1c22
Add new function to temperature
davialvb Dec 4, 2019
490dabc
Add new function to temperature
davialvb Dec 4, 2019
4a16fa7
Add new function to rasp
davialvb Dec 4, 2019
14dfd00
add Top.py
victorciurlini Dec 4, 2019
dad29b8
Merge branch 'rasp_communication' of https://github.com/SmartMeat-UnB…
victorciurlini Dec 4, 2019
ff00b89
add new function to create txt file
victorciurlini Dec 4, 2019
2583d8b
Add logger
victorciurlini Dec 4, 2019
1f61d2f
Merge branch 'master' into rasp_communication
davialvb Dec 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ python-socketio
qrcode
pygame
netifaces
RPi.GPIO
pytz

223 changes: 223 additions & 0 deletions socketio/Top.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import RPi.GPIO as GPIO
import time
import os
from threading import Thread
from websocketio import set_temp_rasp


def triac(temperatura):
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
valor2 =0
tempo = 0
entrada = 16 #pin 16
saida = 18 #pin 18
GPIO.setup(saida, GPIO.OUT)
GPIO.output(saida, False)
GPIO.setup(entrada, GPIO.IN)

def acende(a):
microseconds = 0.00001*float(tempo)
time.sleep(microseconds)
GPIO.output(saida, True)
time.sleep(0.001)
GPIO.output(saida, False)


GPIO.add_event_detect(entrada, GPIO.RISING, callback=acende)

while True:
valor = temperatura
print(valor)
if(valor == 0):
valor2 = 800
if(valor == 1):
valor2 = 70
if(valor == 2):
valor2 = 20
if(valor == 3):
valor2 = 0
print(valor2)
tempo = (90*valor2)
time.sleep(0.005)
#Definindo funcao para deteccao dos slots e ativacao dos motores
def mainBTN ():

def mainTermo():
import RPi.GPIO as gpio
CLK1 = 33
DBIT1 = 35 #S0
CS1 = 37

CLK2 = 36
DBIT2 = 38 #S0
CS2 = 40


gpio.setmode(gpio.BOARD)
gpio.setwarnings(False)
gpio.setup(CLK1, gpio.OUT)
gpio.setup(DBIT1, gpio.IN)
gpio.setup(CS1, gpio.OUT)
gpio.setup(CLK2, gpio.OUT)
gpio.setup(DBIT2, gpio.IN)
gpio.setup(CS2, gpio.OUT)


def Thermal_Couple_Read(CLK, DBIT, CS):
value = 0
#iniciar sensor
gpio.output(CS, False)
time.sleep(0.002)
gpio.output(CS, True)
time.sleep(0.2)

#Ler o chip e retornar a temperatura
gpio.output(CS, False)
gpio.output(CLK, True)
gpio.output(CLK, False)

i = 14
while i>= 0:
gpio.output(CLK, True)
## print("\nvalor1",value)
value += gpio.input(DBIT) << i
## print("\nValor 2", value)
gpio.output(CLK, False)
i = i-1

#if((value & 0x04)==0x04):
#return -1

return value >> 3

SENSOR_VALUE1 = 0
SENSOR_VALUE2 = 0
x = 1
i=0

gpio.output(CS1, True)
gpio.output(CLK1, False)
gpio.output(CS2, True)
gpio.output(CLK2, False)

SENSOR_VALUE1 = Thermal_Couple_Read(CLK1, DBIT1, CS1)
#print("\nS1: ", SENSOR_VALUE1)
SENSOR_VALUE2 = Thermal_Couple_Read(CLK2, DBIT2, CS2)
#print("\nS2: ", SENSOR_VALUE2)

Ctemp1 = SENSOR_VALUE1*0.25
Ctemp2 = SENSOR_VALUE2*0.25
print("===================")
#print("\nTemperatura 1 = ", Ctemp1)
#print("\nTemperatura 2 = ", Ctemp2)
#CtempMedia = (Ctemp1+Ctemp2)/2
print("\nTemperatura Media = ", Ctemp2)

#Nao esquecer de alterar para os pinos da rasp
slot1 = 11
slot2 = 13
slot3 = 12
slot4 = 7

#Definindo constantes dos motores
motor1 = 31
motor2 = 22
motor3 = 29
motor4 = 15

#Inicializa os stickers
sticker1=False
sticker2=False
sticker3=False
sticker4=False

#Constantes para o PWM
dc1 = 0
dc2 = 0
dc3 = 0
dc4 = 0

#GPIO.setmode(GPIO.BCM)
# BCM significa que estamos utilizando pelo numero GPIO
# Caso queira usar pelo numero da porta basta comentar a linha de cima e descomentar a de baixo
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)


#Estao definidos resistores de pull ups externos. Ou seja, sempre 5 e fecha quando o botao for pressionado
GPIO.setup(slot1, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(slot2, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(slot3, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(slot4, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

#GPIO para os motores
GPIO.setup(motor1, GPIO.OUT)
GPIO.setup(motor2, GPIO.OUT)
GPIO.setup(motor3, GPIO.OUT)
GPIO.setup(motor4, GPIO.OUT)

#Iniciando os motores com dutyCycle igual a 0
#Ou seja desligados
pwmMot1 = GPIO.PWM(motor1,100)
pwmMot1.start(0)

pwmMot2 = GPIO.PWM(motor2,100)
pwmMot2.start(0)

pwmMot3 = GPIO.PWM(motor3,100)
pwmMot3.start(0)

pwmMot4 = GPIO.PWM(motor4,100)
pwmMot4.start(0)


while True:
## os.system('clear') or None

if (GPIO.input(slot1) == True):
sticker1=True
pwmMot1.ChangeDutyCycle(35)


elif (GPIO.input(slot1) == False):
sticker1=False
pwmMot1.ChangeDutyCycle(0)

if (GPIO.input(slot2) == True):
sticker2=True
pwmMot2.ChangeDutyCycle(55)

elif (GPIO.input(slot2) == False):
sticker2=False
pwmMot2.ChangeDutyCycle(0)

if (GPIO.input(slot3) == True):
sticker3=True
pwmMot3.ChangeDutyCycle(35)


elif (GPIO.input(slot3) == False):
sticker3=False
pwmMot3.ChangeDutyCycle(0)

if (GPIO.input(slot4) == True):
sticker4=True
pwmMot4.ChangeDutyCycle(35)


elif (GPIO.input(slot4) == False):
sticker4=False
pwmMot4.ChangeDutyCycle(0)

mainTermo()
print("\nSticker 1 = ", sticker1)
print("\nSticker 2 = ", sticker2)
print("\nSticker 3 = ", sticker3)
print("\nSticker 4 = ", sticker4)
print("===================")
time.sleep(0.5)


controle = Thread(target=triac,args=set_temp_rasp())
mainBTN()
39 changes: 39 additions & 0 deletions socketio/classTriac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import RPi.GPIO as GPIO
import time
from websocketio import set_temp_rasp as temp

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
valor2 =0
tempo = 0
entrada = 16 #pin 16
saida = 18 #pin 18
GPIO.setup(saida, GPIO.OUT)
GPIO.output(saida, False)
GPIO.setup(entrada, GPIO.IN)

def acende(a):
microseconds = 0.00001*float(tempo)
time.sleep(microseconds)
GPIO.output(saida, True)
time.sleep(0.001)
GPIO.output(saida, False)


GPIO.add_event_detect(entrada, GPIO.RISING, callback=acende)

while True:
valor = int(input())
print(valor)
print(valor)
if(valor == 0):
valor2 = 800
if(valor == 1):
valor2 = 70
if(valor == 2):
valor2 = 20
if(valor == 3):
valor2 = 0
print(valor2)
tempo = (90*valor2)
time.sleep(0.005)
2 changes: 1 addition & 1 deletion socketio/display_qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def format_ipaddr(ipaddr):


def get_ipaddr():
network_interface = 'enp34s0'
network_interface = 'wlan0'
ip = ni.ifaddresses(network_interface)[ni.AF_INET][0]['addr']
return format_ipaddr(ip)

Expand Down
16 changes: 16 additions & 0 deletions socketio/init_motors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import RPi.GPIO as gpio

gpio.setmode(gpio.BOARD)
gpio.setwarnings(False)

gpio.setup(29, gpio.OUT)
gpio.setup(15, gpio.OUT)
gpio.setup(22, gpio.OUT)
gpio.setup(31, gpio.OUT)

gpio.output(29, True)
gpio.output(15, True)
gpio.output(22, True)
gpio.output(31, True)


Loading