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

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
jd3096
Posts: 13
Joined: Mon Jul 05, 2021 1:22 pm

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

Post by jd3096 » Thu Jul 15, 2021 11:07 am

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
Last edited by jimmo on Mon Jul 19, 2021 1:27 pm, edited 1 time in total.
Reason: Add [code] formatting

Post Reply