Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

WIFI commands blocking SPI commands in NODEMCU micropython

Status
Not open for further replies.

yefj

Advanced Member level 4
Joined
Sep 12, 2019
Messages
1,192
Helped
1
Reputation
2
Reaction score
3
Trophy points
38
Activity points
7,199
Hello,I have built a wifi network which worked fine. then i added SPI commands to transfer data simultaniosly with wifi as shown in the code bellow. if i use spi.write after conn=s.accept() my SPI sends nothing. If i write spi.write before conn=s.accept() it sends SPI sequence as shown in the photo bellow. Why the Socket commands block SPI commands?
Thanks.

1608476529781.png

Code:
from machine import Pin,SPI
from time import sleep
import network
import usocket as socket
spi = machine.SPI(1, baudrate=1000000, polarity=0, phase=0)
ap_if = network.WLAN(network.AP_IF)
ssid = 'Sensor network4'
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)

while True:
    spi.write(b'1234')
    spi.write(b'1234')
    conn=s.accept()
    request=conn.recv(1024)
    request='<p style="color:red"><u><h1>The temperature is:</u></p>'
    request2=str(12.9)
    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()
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top