My current project is running with the following architecture--
1. 3 axis accelerometer+3 axis gyroscope data coming from smartphone via WiFi using APK (Client).
2. A python3 server is running on laptop command prompt which is receiving the data via UDP and storing it in in a file as well as writing it in the command prompt.
I am still in the "hello world" phase in micro-python (Although have some basic knowledge of python, but the treatment and modules are entirely different here).
I am running WebRepl and connected with my ESP8266 (LOLIN) via my home router. I also have a MPU6050 module that is attached with my ESP and ran successfully in Arduino sketch.
I like to do the following --
1. Substitute the smartphone with ESP8266+MPU6050 to receive 3 axis accelerometer and gyroscope data to python server on laptop via WiFi.
2. Use al python 3 server code to run it as independent server on command prompt.
This is the current server code in python
Code: Select all
import sys from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) @sockets.route('/accelerometer') def echo_socket(ws): f=open("acc.json","w") while True: message = ws.receive() print(message) ws.send(message) print>>f,message f.close() @sockets.route('/gyroscope') def echo_socket(ws): f=open("gyroscope.txt","a") while True: message = ws.receive() print(message) ws.send(message) print>>f,message f.close() @app.route('/') def hello(): return 'Hello World!' if __name__ == "__main__": from gevent import pywsgi from geventwebsocket.handler import WebSocketHandler server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, handler_class=WebSocketHandler) server.serve_forever()
However when I uploaded entire thing into ESP8266 module via WebRepl and restart, the module crashed and I ended up reloading the Firmware again [ Guess the effect of driving a car without learning how to drive ]