• utimeq in uhttpd for simple webserver

    micropython http post server
    6
    0 Votes
    6 Posts
    3k Views
    K
    +1 utimeq enabled in sigfox would be awesome I'd like to use the latest version of picoweb on my LoPy but it has utimeq as a dependency. https://github.com/pfalcon/picoweb
  • Lopy ,GPS, micropython

    micropython lopy gps
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Log all uncaught exceptions to a file

    exception
    1
    1 Votes
    1 Posts
    1k Views
    No one has replied
  • increment files in SD card in python on Sipy

    sipy codeing micropython
    4
    2
    0 Votes
    4 Posts
    2k Views
    C
    Thanks anyway but the problem fixed itself after I updated the firmware and made a few other changes to my code but i still don't know what the problem was but am all good now. Kind regards, Chris
  • Learn python..

    python curses
    1
    6 Votes
    1 Posts
    1k Views
    No one has replied
  • At what time should I manually run gc.collect()?

    garbagecollecto
    6
    0 Votes
    6 Posts
    2k Views
    B
    So it sounds like one risk is latency. What other risks are there from running it?
  • Import a module by a name stored in a variable? (importlib?)

    import
    1
    0 Votes
    1 Posts
    859 Views
    No one has replied
  • LTE CatM1 and NB rollout timeframe, anyone?

    Moved lte global
    11
    0 Votes
    11 Posts
    3k Views
    B
    What I meant is, I haven't planned to cover Poland as a specific country. I will cover it under the various Mobile Networks Operators. At the moment I don't have much specific to go by other than I know Deutsche Telecom is rolling NB-IoT out in cites across Poland through 2017. I am trying to understand via our contacts what Orange is doing specifically in Poland and will come back to you as soon as I have the information.
  • GPL v3

    Moved license
    10
    0 Votes
    10 Posts
    2k Views
    J
    @this.wiederkehr GPL has a specific source exclusion for System Libraries (otherwise you couldn't have GPL projects on closed source operating systems)
  • Converting sensor data to byte

    micorpython ttn lora lopy
    4
    0 Votes
    4 Posts
    2k Views
    T
    Thanks for the suggestions! Still looking to get some examples how to serialize sensor data with MicroPython for TTN. All examples I found are for Arduino. Maybe @bucknall has some nice examples around?
  • OSC Library for micropython/pycom

    osc library micropython pycom
    1
    0 Votes
    1 Posts
    978 Views
    No one has replied
  • Homekit

    homekit question
    3
    0 Votes
    3 Posts
    2k Views
    B
    @tobz I've been working on a tutorial that utilizes a RPi as a Homekit MQTT Hub and has a pytrack/pysense sending data up to the RPi broker. When I get a break in my schedule, I'll share it!
  • Shinyei PPD42NS particle sensor

    dust sensor ppd42ns shinyei
    10
    2 Votes
    10 Posts
    4k Views
    PiAirP
    [image: 1497383994155-20170613_215443_hdr_klein.jpeg] Arrived in time for the hackaton this Saturday. :)
  • Time & Interrupts

    Moved 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
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Frozen modules - parser could not allocate enough memory

    frozen
    3
    0 Votes
    3 Posts
    1k Views
    L
    @robert-hh Ok, thank you for the confirmation I must now test this feature :)
  • PMS5003 air quality sensor

    pms5003 micropython lib
    4
    2 Votes
    4 Posts
    2k Views
    RobTuDelftR
    @bucknall If you could clarify that would be great, thanks! I left out the timeout for now.
  • Future Expansion Board suggestions

    Moved expansionboard suggestions
    4
    5 Votes
    4 Posts
    2k Views
    B
    After a week playing with my new LoPy modules and the expansion board, here is my list of suggestions: I found very confusing the difference in numbering between the LoPy pinout (Pxx, GPIOxx, pin numbers... and the expansion board (Gxx). @jmarcelino has mentioned this already. I don't really understand why the user button and the LED are mapped on the same pins used for I2C. Why not any pin on the right hand side not used for other functions P12-P22? It would be great to add a couple of Grove connectors mapped to the I2C pins and two other GPIO pins. They are pretty much the standard these days and there are plenty of sensor modules available. A solar charging circuit and connector would be awesome for so many projects. Using a solar panel on the USB is kind of risky and definitely not ideal.
  • ESP32 wifi range

    Moved wifi range
    7
    1 Votes
    7 Posts
    4k Views
    L
    @jmarcelino Yes, long range it is interesting from first time i saw it in Pycom module description few months ago ;-)
  • Any news about promised FiPy KS #10 Update?

    Moved fipy kickstarter news update
    3
    1 Votes
    3 Posts
    2k Views
    S
    To make it more annoying, I ordered a couple ages ago as part of a larger order and it looks like they are sending none of it until the FiPy is available.

Pycom on Twitter