• Orange attach time very big

    GPy attach time connectivity
    3
    0 Votes
    3 Posts
    54 Views
    C
    @Gijs I tried last pycom firware update 1.20.0.r7
  • Date Time convert to Microsoft Access

    WiPy 2&3 time lopy wipy
    5
    0 Votes
    5 Posts
    49 Views
    W
    @railmonitor thank you
  • time change for Germany

    WiPy 2&3 wipy lopy time
    8
    0 Votes
    8 Posts
    241 Views
    J
    @Wolli01 Don't have a Pycom module at hand to test, but does that actually return local time by default? If so, I wonder where it could possibly get the timezone from... But a quick glance through the code makes me think it doesn't, does it? You can control the timezone used by localtime (and mktime) using utime.timezone, but it's simplistic (just an offset from UTC), it does not handle automatic DST changes. If you want that to be handled for you (which seems overkill on such a device IMHO) you'll probably have to use an external library that supports it.
  • How to send/receive LORAWAN MAC Commands?

    LoPy lorawan lopy mac time rtc
    3
    1 Votes
    3 Posts
    748 Views
    O
    @paul-thornton said in How to send/receive LORAWAN MAC Commands?: https://docs.pycom.io/firmwareapi/pycom/network/lora.html#lorastats I'm not sure whether lora.stats() rx_timestamp is of use, it does not seem to represent a time value, but if it does, how do I convert it? [LORA ] 2019/02/21 04:51:55 (rx_timestamp=0, rssi=0, snr=0.0, sfrx=0, sftx=0, tx_trials=0, tx_power=14, tx_time_on_air=0, tx_counter=0, tx_frequency=0) [LORA ] 2019/02/21 04:52:04 (rx_timestamp=30539834, rssi=-45, snr=7.0, sfrx=3, sftx=5, tx_trials=1, tx_power=0, tx_time_on_air=57, tx_counter=0, tx_frequency=0) [LORA ] 2019/02/21 04:52:11 (rx_timestamp=38155453, rssi=-38, snr=8.0, sfrx=3, sftx=5, tx_trials=1, tx_power=0, tx_time_on_air=47, tx_counter=1, tx_frequency=0) [LORA ] 2019/02/21 09:04:47 (rx_timestamp=45778581, rssi=-43, snr=8.0, sfrx=3, sftx=5, tx_trials=1, tx_power=0, tx_time_on_air=47, tx_counter=2, tx_frequency=0) [LORA ] 2019/02/21 09:15:32 (rx_timestamp=690412324, rssi=-47, snr=6.0, sfrx=5, sftx=5, tx_trials=2, tx_power=0, tx_time_on_air=57, tx_counter=4, tx_frequency=0) [LORA ] 2019/02/21 09:15:38 (rx_timestamp=696682500, rssi=-48, snr=6.0, sfrx=5, sftx=5, tx_trials=1, tx_power=0, tx_time_on_air=57, tx_counter=5, tx_frequency=0) [LORA ] 2019/02/21 09:15:44 (rx_timestamp=702935506, rssi=-47, snr=6.0, sfrx=5, sftx=5, tx_trials=1, tx_power=0, tx_time_on_air=57, tx_counter=6, tx_frequency=0)
  • Long time before transmitting a packet.

    Discussion lopy lora time
    13
    0 Votes
    13 Posts
    926 Views
    robert-hhR
    @snehasg96 main.py is executed automatically when the device boots. If ouy wnat to run a script, like recv.py, manually, just enter at the REPL prompt (the one with >>>): import recv
  • time.sleep() not accurate

    Issues & Bugs time time of arrival lora lopy utime
    6
    0 Votes
    6 Posts
    547 Views
    S
    @crumble also, is it fine to use the utime.time() in the receiver as well or just use it in the sender? Also i tried running the code after removing time.sleep() in the receiver but for some reason i still experience the same issue.
  • machine.deepsleep does not 'reset'

    Getting Started deep sleep time sleep
    2
    0 Votes
    2 Posts
    600 Views
    V
    Hi, Have you fix it? I'm facing the same problem
  • Who defines the metadata times?

    WiPy 2&3 time ttn
    1
    0 Votes
    1 Posts
    547 Views
    No one has replied
  • 0 Votes
    9 Posts
    2k Views
    B
    @livius Hi. I have the issue, that the device does not start again after several cycles. That was a try to fix it... Update: Fixed the issue using WDT :-)
  • otta node problem with nanogateway

    LoPy nanogateway lopy lorawan otaa time ntp
    5
    0 Votes
    5 Posts
    1k Views
    L
    Did you ever get it work? Any advise for me, as I am in the exact same situation?
  • Cheapest GPS for time sync only

    LoPy gps time
    3
    0 Votes
    3 Posts
    2k Views
    L
    @jmarcelino said in Cheapest GPS for time sync only: Interesting alternative, but i will stay with GPS - it also work on ship and is really simple to use (mostly UART). As always i probably do not need position - but if i can get it than it sometimes can be usefull as a gadget. And can be simply repleaced by more accurate GPS without firmware modification. Then better is GPS for me here.
  • 0 Votes
    1 Posts
    814 Views
    No one has replied
  • time.sleep_ms -> wrong argument type ?!

    LoPy time sleep
    4
    0 Votes
    4 Posts
    1k Views
    L
    @soren current firmware is 1.6.13.b1 but i never have had problem with line number in error message Do you have line break as LF or CRLF or mixed?
  • Question about short delays

    Discussion sleep time
    6
    0 Votes
    6 Posts
    2k Views
    L
    Sleep() function actually suspends the processing of the thread in which it is called by the operating system, allowing other threads and processes to execute while it sleeps. With multiple threads and processes, sleep() suspends your thread - it uses next to zero processing power.
  • Timer and UART confugration

    WiPy 2&3 time uart0 wipy wipy 1
    9
    0 Votes
    9 Posts
    3k Views
    M
    @robert-hh Thanks a lot! :)
  • Time & Interrupts

    Moved MicroPython interrupt time sensors
    7
    0 Votes
    7 Posts
    4k Views
    robert-hhR
    @Emmanuel-Goudot Yes, that's the piece of code below, which works for my DHT22 on a Lopy. It is buried far below in a thread, where two people fight to get it running(https://forum.pycom.io/topic/1172/pure-python-library-for-reading-dht-sensor-on-pycom-boards). No clue what their problem is, since I consider it solved, even if not bullet proof. import time from machine import enable_irq, disable_irq, Pin class DTHResult: 'DHT sensor result returned by DHT.read() method' ERR_NO_ERROR = 0 ERR_MISSING_DATA = 1 ERR_CRC = 2 error_code = ERR_NO_ERROR temperature = -1 humidity = -1 def __init__(self, error_code, temperature, humidity): self.error_code = error_code self.temperature = temperature self.humidity = humidity def is_valid(self): return self.error_code == DTHResult.ERR_NO_ERROR class DTH: 'DHT sensor (dht11, dht21,dht22) reader class for Pycom' __pin = Pin('P3', mode=Pin.OPEN_DRAIN) __dhttype = 0 def __init__(self, pin, sensor=0): self.__pin = pin self.__pin(1) self.__dhttype = sensor def read(self): time.sleep(1) # send initial high #self.__send_and_sleep(1, 25000) # pull down to low #self.__send_and_sleep(0, 40000) # collect data into an array data = self.__collect_input() # parse lengths of all data pull up periods pull_up_lengths = self.__parse_data_pull_up_lengths(data) # if bit count mismatch, return error (4 byte data + 1 byte checksum) print(pull_up_lengths) if len(pull_up_lengths) != 40: return DTHResult(DTHResult.ERR_MISSING_DATA, 0, 0) # calculate bits from lengths of the pull up periods bits = self.__calculate_bits(pull_up_lengths) # we have the bits, calculate bytes the_bytes = self.__bits_to_bytes(bits) print(the_bytes) # calculate checksum and check checksum = self.__calculate_checksum(the_bytes) if the_bytes[4] != checksum: return DTHResult(DTHResult.ERR_CRC, 0, 0) # ok, we have valid data, return it [int_rh, dec_rh, int_t, dec_t, csum] = the_bytes if self.__dhttype==0: #dht11 rh = int_rh #dht11 20% ~ 90% t = int_t #dht11 0..50°C else: #dht21,dht22 rh = ((int_rh * 256) + dec_rh)/10 t = (((int_t & 0x7F) * 256) + dec_t)/10 if (int_t & 0x80) > 0: t *= -1 return DTHResult(DTHResult.ERR_NO_ERROR, t, rh) def __send_and_sleep(self, output, mysleep): self.__pin(output) time.sleep_us(mysleep) def __collect_input(self): # collect the data while unchanged found unchanged_count = 0 # this is used to determine where is the end of the data max_unchanged_count = 100 last = -1 data = [] m = [1]*500 # needs long sample size to grab all the bits from the DHT self.__pin(0) time.sleep_us(20000) self.__pin(1) irqf = disable_irq() for i in range(len(m)): m[i] = self.__pin() ## sample input and store value enable_irq(irqf) for i in range(len(m)): current = m[i] data.append(current) if last != current: unchanged_count = 0 last = current else: unchanged_count += 1 if unchanged_count > max_unchanged_count: break #print(data) return data def __parse_data_pull_up_lengths(self, data): STATE_INIT_PULL_DOWN = 1 STATE_INIT_PULL_UP = 2 STATE_DATA_FIRST_PULL_DOWN = 3 STATE_DATA_PULL_UP = 4 STATE_DATA_PULL_DOWN = 5 state = STATE_INIT_PULL_UP lengths = [] # will contain the lengths of data pull up periods current_length = 0 # will contain the length of the previous period for i in range(len(data)): current = data[i] current_length += 1 if state == STATE_INIT_PULL_DOWN: if current == 0: # ok, we got the initial pull down state = STATE_INIT_PULL_UP continue else: continue if state == STATE_INIT_PULL_UP: if current == 1: # ok, we got the initial pull up state = STATE_DATA_FIRST_PULL_DOWN continue else: continue if state == STATE_DATA_FIRST_PULL_DOWN: if current == 0: # we have the initial pull down, the next will be the data pull up state = STATE_DATA_PULL_UP continue else: continue if state == STATE_DATA_PULL_UP: if current == 1: # data pulled up, the length of this pull up will determine whether it is 0 or 1 current_length = 0 state = STATE_DATA_PULL_DOWN continue else: continue if state == STATE_DATA_PULL_DOWN: if current == 0: # pulled down, we store the length of the previous pull up period lengths.append(current_length) state = STATE_DATA_PULL_UP continue else: continue return lengths def __calculate_bits(self, pull_up_lengths): # find shortest and longest period shortest_pull_up = 1000 longest_pull_up = 0 for i in range(0, len(pull_up_lengths)): length = pull_up_lengths[i] if length < shortest_pull_up: shortest_pull_up = length if length > longest_pull_up: longest_pull_up = length # use the halfway to determine whether the period it is long or short halfway = shortest_pull_up + (longest_pull_up - shortest_pull_up) / 2 bits = [] for i in range(0, len(pull_up_lengths)): bit = False if pull_up_lengths[i] > halfway: bit = True bits.append(bit) return bits def __bits_to_bytes(self, bits): the_bytes = [] byte = 0 for i in range(0, len(bits)): byte = byte << 1 if (bits[i]): byte = byte | 1 else: byte = byte | 0 if ((i + 1) % 8 == 0): the_bytes.append(byte) byte = 0 #print(the_bytes) return the_bytes def __calculate_checksum(self, the_bytes): return the_bytes[0] + the_bytes[1] + the_bytes[2] + the_bytes[3] & 255