GithubHelp home page GithubHelp logo

software-iot-flask's People

Contributors

dkzafiro avatar

Stargazers

 avatar

Watchers

 avatar

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.