how to combine SPI input with websocket in nodemcu python

Thread Starter

yef smith

Joined Aug 2, 2020
112
nodemcu is a very common device ,and i am really struggling for a long time with sending over wifi input spi data with python. I google many times this sort of combination and tryind to assemble the code.Is there a good manual which could show how exactly to broardcast over socket SPI data?
Thanks.

Code:
from machine import Pin,SPI
import network
import usocket as socket
ap_if = network.WLAN(network.AP_IF)
ssid = 'sensor_net'
password = '123456789'
ap_if.active(True)
ap_if.config(essid=ssid, password=password)
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('',80))
s.listen(5)
spi=SPI(1, baudrate=1000000, polarity=0, phase=0)
while True:
    spi.write(b'1234')
    conn, addre=s.accept()
    request='<p style="color:red"><u><h1>The temperature is:</u></p>'
    request2=str(12.7)
    response='gyhkjgku'
    conn.send('HTTP/1.1 200 OK\n')
    conn.send('Content-type: text/html\n')
    conn.send('Connection: close\n\n')
    conn.sendall(request)
    conn.sendall(request2)
    conn.close()
    spi.write(b'1234')
 
Top