software-iot-flask's People
software-iot-flask's Issues
HOW TU RUN!
1. Run this file
arduino.py
2. Run this another file
ejemplo5_flask.py
3. go googlechorme and run localhost:5000
Typical error
Check the serial port from
arduino.py
import serial
import random
from time import sleep
port = "COM9"
ser = serial.Serial(port,9600)
ser.flushInput()
ser.flushOutput()
while True:
#new pyhton arduino! ------------------------
HR=random.randint(1,200)
RR=random.randint(500,1000)
n1 = str(RR)
n1 += "\r\n"
n2 = str(HR)
n2 += "\r\n"
ser.write(n1.encode())
ser.write(n2.encode())
print ("HR es:",HR)
print ("RR es:",RR)
sleep(0.5)
ser.close()
here im using a virtual port simulated for com0com, check com0com and put the correct serial port in
ejemplo5_flask.py
in the next code
@app.route("/aleatorio")
def aleatorio():
#pyhton backend working---------------------------
port = "COM10"
ser = serial.Serial(port,9600)
RR = ser.readline().decode()
RR = RR.replace("\r\n","")
print(RR)
HR = ser.readline().decode()
HR = HR.replace("\r\n","")
print(HR)
#HR=ser.read(ser.inWaiting()).split()
#print "tipo de dato:",type(HR)
#if HR >= "201":
# HR=1
#print HR
#HR = HR[0]
#HR=random.randint(1,200)
#RR=random.randint(1,1000)
sesion=1
estampa=time.time()*1000
#if ser.isOpen():
# print "open:", ser.portstr
# print "traigo algo:",HR
ser.close()
man.agregar_num(estampa, HR, RR, sesion)
#print "Serial:",respuesta
#print "HR",HR, "RR",RR, "sesion", sesion
return "{\"HR\":"+str(HR)+",\"RR\":" +str(RR)+",\"sesion\":" +str(sesion)+"}"
in my case y com0com say to put COM9 and COM10 respectively
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.