Different behaviour with and without serial communication

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Monstercrunch
Posts: 1
Joined: Wed Mar 20, 2019 3:19 pm

Different behaviour with and without serial communication

Post by Monstercrunch » Wed Mar 20, 2019 3:53 pm

Hi,

Context: I'm developing a little weather station with a 5110 Lcd display.

Process: while developing I write my code in a main.py file which I send to my board (Esp32 devkitc-v4), then I open the serial prompt with picocom, press the reset button on the board and read my logs for debugging.

I was happy with my program with everything working and I wanted to try it in "standalone" mode. Just powering the board without displaying logs. But something strange occurred: I could say the program crashed as the data on the LCD wasn't updating. I tried to isolate the problem by logging directly on the lcd and found out that the line touchpad.read() was guilty. The program is almost as follow (can't use the [code] tag :| ):

#main.py

from machine import Pin, TouchPad
import utime

touch1 = TouchPad(Pin(0))
touch2 = TouchPad(Pin(2))
led = Pin(32, Pin.OUT, value=0)
led.off()

touchPads = [touch1, touch2]

def handler1():
print("Hi1")
led.on()

def handler2():
print("Hi2")
led.off()

handlers = [handler1, handler2]
TRESHOLD = 150

def checkTouchPads():
for index, touchpad in enumerate(touchPads):
if touchpad.read() < TRESHOLD:
handlers[index]()

while True:
checkTouchPads()
utime.sleep(0.25)

So this is working when I have picocom activated but not in standalone. Any idea why ?

Post Reply