<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Pytrack and.or Deep Sleep break terminal output ?]]></title><description><![CDATA[<p dir="auto">Guy,</p>
<p dir="auto">I'm trying a new tracker code with Lopy and Pytrack + sleep and wake interrupt, but I'm suck with console output problem, so I restarted from library example code <code>accelerometer_wake</code> to reproduce the issue.</p>
<p dir="auto">I modified a little to have some print and wait to be able to connect terminal (because deep sleep shut down usb device seen in windows)</p>
<p dir="auto">Here the code</p>
<pre><code class="language-python">import machine 
from machine import UART
from pytrack import Pytrack
from LIS2HH12 import LIS2HH12
from network import Bluetooth
from network import WLAN
import pycom
import time
import os

uart = UART(0, 115200)
os.dupterm(uart)

WLAN().deinit()
Bluetooth().deinit()

# Wait for terminal to connect
print(&quot;Wait for sync &quot;, end='')
for x in range(0, 10):
    print(&quot;#&quot;, end='')
    time.sleep(1)
print(&quot; OK!&quot;, flush=True)

rst = machine.reset_cause()
print(&quot;starting, Reset=&quot;, rst)

pycom.heartbeat(False)
print(&quot;stage 1&quot;, flush=True)

py = Pytrack()
print(&quot;stage 2&quot;, flush=True)

print(&quot;Wakeup reason: &quot;, flush=True)
print(py.get_wake_reason())
print(&quot;; Aproximate sleep remaining: &quot;, flush=True)
print(py.get_sleep_remaining())
print(&quot; sec&quot;, flush=True)

# enable wakeup source from INT pin
py.setup_int_pin_wake_up(False)

# enable activity and also inactivity interrupts, using the default callback handler
py.setup_int_wake_up(True, True)

acc = LIS2HH12()
# enable the activity/inactivity interrupts
# set the accelereation threshold to 2000mG (2G) and the min duration to 200ms
acc.enable_activity_interrupt(2000, 200)

# wait 15 second before deep sleep to be able to upload 
print(&quot;Wait for update &quot;, end='', flush=True)
for x in range(0, 15):
    print(&quot;.&quot;, end='', flush=True)
    time.sleep(1)
print(&quot; OK!&quot;, flush=True)

# go to sleep for 30 seconds max if no accelerometer interrupt happens
print(&quot;Go to deep sleep...&quot;)
py.setup_sleep(30)
py.go_to_sleep()
</code></pre>
<p dir="auto">The fact is that the program works pretty fine (I know this because 15 seconds after printing stage 1 the device goes to deep sleep (windows beep) and wake up after 30s of deep sleep (windows beep agin and device shows up in device manager), Then I reconnect and got display until stage 1 again</p>
<p dir="auto">Here the output of terminal (I manually disconnect when entering deep sleep and  reconnect after deep sleep wake)</p>
<p dir="auto"><img src="/assets/uploads/files/1524047768855-5ec1bc05-3ab0-4e02-86d3-2f227965ddbf-image.png" alt="0_1524047768270_5ec1bc05-3ab0-4e02-86d3-2f227965ddbf-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">What I am missing ? Looks like some system call break the dupterm,  I tried to reset console after stage 1 but same things.</p>
<pre><code>py = Pytrack()
uart = UART(0, 115200)
os.dupterm(uart)
print(&quot;stage 2&quot;, flush=True)
</code></pre>
<p dir="auto">I'm using latest firmware as today 1.17.3.b1 and latest pymakr but also tried with another terminal, same thing</p>
<p dir="auto">Any idea of what's going wrong there ?</p>
]]></description><link>https://forum.pycom.io/topic/3075/pytrack-and-or-deep-sleep-break-terminal-output</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 16:25:46 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/3075.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Apr 2018 10:48:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 10:50:36 GMT]]></title><description><![CDATA[<p dir="auto">Guy,</p>
<p dir="auto">I'm trying a new tracker code with Lopy and Pytrack + sleep and wake interrupt, but I'm suck with console output problem, so I restarted from library example code <code>accelerometer_wake</code> to reproduce the issue.</p>
<p dir="auto">I modified a little to have some print and wait to be able to connect terminal (because deep sleep shut down usb device seen in windows)</p>
<p dir="auto">Here the code</p>
<pre><code class="language-python">import machine 
from machine import UART
from pytrack import Pytrack
from LIS2HH12 import LIS2HH12
from network import Bluetooth
from network import WLAN
import pycom
import time
import os

uart = UART(0, 115200)
os.dupterm(uart)

WLAN().deinit()
Bluetooth().deinit()

# Wait for terminal to connect
print(&quot;Wait for sync &quot;, end='')
for x in range(0, 10):
    print(&quot;#&quot;, end='')
    time.sleep(1)
print(&quot; OK!&quot;, flush=True)

rst = machine.reset_cause()
print(&quot;starting, Reset=&quot;, rst)

pycom.heartbeat(False)
print(&quot;stage 1&quot;, flush=True)

py = Pytrack()
print(&quot;stage 2&quot;, flush=True)

print(&quot;Wakeup reason: &quot;, flush=True)
print(py.get_wake_reason())
print(&quot;; Aproximate sleep remaining: &quot;, flush=True)
print(py.get_sleep_remaining())
print(&quot; sec&quot;, flush=True)

# enable wakeup source from INT pin
py.setup_int_pin_wake_up(False)

# enable activity and also inactivity interrupts, using the default callback handler
py.setup_int_wake_up(True, True)

acc = LIS2HH12()
# enable the activity/inactivity interrupts
# set the accelereation threshold to 2000mG (2G) and the min duration to 200ms
acc.enable_activity_interrupt(2000, 200)

# wait 15 second before deep sleep to be able to upload 
print(&quot;Wait for update &quot;, end='', flush=True)
for x in range(0, 15):
    print(&quot;.&quot;, end='', flush=True)
    time.sleep(1)
print(&quot; OK!&quot;, flush=True)

# go to sleep for 30 seconds max if no accelerometer interrupt happens
print(&quot;Go to deep sleep...&quot;)
py.setup_sleep(30)
py.go_to_sleep()
</code></pre>
<p dir="auto">The fact is that the program works pretty fine (I know this because 15 seconds after printing stage 1 the device goes to deep sleep (windows beep) and wake up after 30s of deep sleep (windows beep agin and device shows up in device manager), Then I reconnect and got display until stage 1 again</p>
<p dir="auto">Here the output of terminal (I manually disconnect when entering deep sleep and  reconnect after deep sleep wake)</p>
<p dir="auto"><img src="/assets/uploads/files/1524047768855-5ec1bc05-3ab0-4e02-86d3-2f227965ddbf-image.png" alt="0_1524047768270_5ec1bc05-3ab0-4e02-86d3-2f227965ddbf-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">What I am missing ? Looks like some system call break the dupterm,  I tried to reset console after stage 1 but same things.</p>
<pre><code>py = Pytrack()
uart = UART(0, 115200)
os.dupterm(uart)
print(&quot;stage 2&quot;, flush=True)
</code></pre>
<p dir="auto">I'm using latest firmware as today 1.17.3.b1 and latest pymakr but also tried with another terminal, same thing</p>
<p dir="auto">Any idea of what's going wrong there ?</p>
]]></description><link>https://forum.pycom.io/post/18715</link><guid isPermaLink="true">https://forum.pycom.io/post/18715</guid><dc:creator><![CDATA[Charly86]]></dc:creator><pubDate>Wed, 18 Apr 2018 10:50:36 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 11:24:58 GMT]]></title><description><![CDATA[<p dir="auto">Is the Pytrack firmware upgraded to the latest version?</p>
]]></description><link>https://forum.pycom.io/post/18717</link><guid isPermaLink="true">https://forum.pycom.io/post/18717</guid><dc:creator><![CDATA[jcaron]]></dc:creator><pubDate>Wed, 18 Apr 2018 11:24:58 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 11:29:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1538">@jcaron</a> sorry forgot to mention, it's 0.0.8, looks like the latest?</p>
]]></description><link>https://forum.pycom.io/post/18718</link><guid isPermaLink="true">https://forum.pycom.io/post/18718</guid><dc:creator><![CDATA[Charly86]]></dc:creator><pubDate>Wed, 18 Apr 2018 11:29:12 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 11:37:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1854">@charly86</a>  I believe so, yes. What do you have in your <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a>? Have you tried clearing the filesystem completely and re-uploading all the files? Sometimes you end up with old files which result in weird stuff like this.</p>
<p dir="auto">Have you tried adding a pause just after the stage 1 print + another print before instantiating the Pytrack object? Just to see if it's timing-related or directly related to the connection to the Pytrack...</p>
]]></description><link>https://forum.pycom.io/post/18720</link><guid isPermaLink="true">https://forum.pycom.io/post/18720</guid><dc:creator><![CDATA[jcaron]]></dc:creator><pubDate>Wed, 18 Apr 2018 11:37:12 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 11:42:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1538">@jcaron</a> I do not have <code>boot.py</code> for this sample issue (I wanted the sample to be simple)</p>
<p dir="auto">has suggested, I've done the changes, same thing.</p>
<p dir="auto"><img src="/assets/uploads/files/1524051715382-47c35dd5-401f-45a8-92af-5bf254320fbe-image-resized.png" alt="0_1524051714557_47c35dd5-401f-45a8-92af-5bf254320fbe-image.png" class="img-responsive img-markdown" /></p>
]]></description><link>https://forum.pycom.io/post/18721</link><guid isPermaLink="true">https://forum.pycom.io/post/18721</guid><dc:creator><![CDATA[Charly86]]></dc:creator><pubDate>Wed, 18 Apr 2018 11:42:26 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 11:48:22 GMT]]></title><description><![CDATA[<p dir="auto">I took a new Fresh Lopy / Pytrack, updated firmware on both devices and flashed same code</p>
<p dir="auto">Same result</p>
<p dir="auto"><img src="/assets/uploads/files/1524052069959-0ccfa829-be98-462d-a38d-bc12dc432e7f-image.png" alt="0_1524052069278_0ccfa829-be98-462d-a38d-bc12dc432e7f-image.png" class="img-responsive img-markdown" /></p>
]]></description><link>https://forum.pycom.io/post/18722</link><guid isPermaLink="true">https://forum.pycom.io/post/18722</guid><dc:creator><![CDATA[Charly86]]></dc:creator><pubDate>Wed, 18 Apr 2018 11:48:22 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 11:54:42 GMT]]></title><description><![CDATA[<p dir="auto">I believe there is a default <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a> which already contains the dupterm stuff on a fresh module, not sure if having that both in the <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a> and the <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a> may be an issue?</p>
]]></description><link>https://forum.pycom.io/post/18723</link><guid isPermaLink="true">https://forum.pycom.io/post/18723</guid><dc:creator><![CDATA[jcaron]]></dc:creator><pubDate>Wed, 18 Apr 2018 11:54:42 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 12:10:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1538">@jcaron</a> Absolutely, thanks for pointing this out</p>
<p dir="auto">I created a <code>boot.py</code></p>
<pre><code class="language-python">from machine import UART
import os

uart = UART(0, 115200)
os.dupterm(uart)
</code></pre>
<p dir="auto">of course removed this line from <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a></p>
<p dir="auto">it's far better but console still looks up after call to <code>py.get_sleep_remaining()</code></p>
<p dir="auto"><img src="/assets/uploads/files/1524053416385-759f188a-53fc-4fb2-8a29-b52c9bb78ed7-image.png" alt="0_1524053415579_759f188a-53fc-4fb2-8a29-b52c9bb78ed7-image.png" class="img-responsive img-markdown" /></p>
]]></description><link>https://forum.pycom.io/post/18725</link><guid isPermaLink="true">https://forum.pycom.io/post/18725</guid><dc:creator><![CDATA[Charly86]]></dc:creator><pubDate>Wed, 18 Apr 2018 12:10:38 GMT</pubDate></item><item><title><![CDATA[Reply to Pytrack and.or Deep Sleep break terminal output ? on Wed, 18 Apr 2018 12:21:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1538">@jcaron</a> I think I got it</p>
<p dir="auto">The <code>calibrate_rtc()</code> in library <code>pycoproc</code> break the console output, if I comment this call from <code>get_sleep_remaining()</code> No problem</p>
<pre><code class="language-shell">Connecting on COM24...
# OK!
starting, Reset= 0
stage 1
stage 2
Wakeup reason:
4
; Aproximate sleep remaining:
calibrate_rtc
0
 sec
stage 4
Wait for update .............
</code></pre>
<p dir="auto">may be the deal is out there</p>
<pre><code>def calibrate_rtc(self):
        # the 1.024 factor is because the PIC LF operates at 31 KHz
        # WDT has a frequency divider to generate 1 ms
        # and then there is a binary prescaler, e.g., 1, 2, 4 ... 512, 1024 ms
        # hence the need for the constant
        self._write(bytes([CMD_CALIBRATE]), wait=False)
        self.i2c.deinit()
        Pin('P21', mode=Pin.IN)
        pulses = pycom.pulses_get('P21', 100)
        self.i2c.init(mode=I2C.MASTER, pins=(self.sda, self.scl))
        idx = 0
</code></pre>
]]></description><link>https://forum.pycom.io/post/18726</link><guid isPermaLink="true">https://forum.pycom.io/post/18726</guid><dc:creator><![CDATA[Charly86]]></dc:creator><pubDate>Wed, 18 Apr 2018 12:21:00 GMT</pubDate></item></channel></rss>