Skip to content

Code runs differently through Thonny vs battery powered? #10185

Discussion options

You must be logged in to vote

Okay, I got it working. Thank you @karfas for the Putty suggestion.

import time
from machine import UART, Pin

time.sleep(2)  # wait a little bit to make sure everything is ready

uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1), bits=8, parity=None, stop=1)
pir = Pin(16, Pin.IN, Pin.PULL_DOWN)
msg = 'AT+TEST=TXLRPKT "ABCD"\r\n'  # this is sent when motion is detected

uart.write('AT+MODE=TEST\r\n')   # mode setup for the Grove E5
time.sleep(1)

# if pir detects motion, send the msg
while True:
    if pir.value() == 1:
        uart.write(msg)
        time.sleep(10)

When plugging into a battery, the program starts to run immediately and sends the first UART AT message to the transmitter.…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@jolbertti
Comment options

Comment options

You must be logged in to vote
3 replies
@karfas
Comment options

@jolbertti
Comment options

@jolbertti
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jolbertti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants