Page 1 of 1

How to make IR and BLE function work correctly at the same time?

Posted: Thu Jul 15, 2021 11:07 am
by jd3096
Chips:esp32 Firmware: micropython 1.14

I wrote a program that receive ir singals and send datas to other BLE device,when the deceive is dispaired,all things works correctly,but when the BLE is connected,IR time ticks chaos at the same time, when i disconnected the devie ,program returned to normal immediately.

So i guess that BLE communication influence the ir signals receive,tick_ms chaos.

Is there a way to make IR signal receive function runs complete independence and can't be influenced by other program process?

Here is part of my code:

Code: Select all

recive=Pin(PIN,Pin.IN,Pin.PULL_UP)

def getByteNEC():  
    byte = 0
    timeRisingEdge = 0
    timeFallingEdge = 0
    timeSpan = 0
    for i in range(0, 8):
        while recive.value() == 0:
            pass
        if recive.value() == 1:
            t3=time.ticks_us()
            while recive.value() == 1:   
                pass
            t4=time.ticks_us()                  
            timeSpan=t4-t3
        if timeSpan > 1500:   
            byte |= 1 << i  
    return byte