• 1 Votes
    4 Posts
    697 Views
    T
    @rcolistete Thanks for the links. Thats a great start, and already has helped me in the implementation of one of my components. As a noob to Pycom, it really has taken longer than it should have to acquaint myself with where to find information, drivers, tutorials, and examples for Pycom. For instance, the links you provided are very useful, but for a newcomer they are very much in the woodworks, and I still think everything is too scattered. Some consolidation would be greatly appreciated. Even a pinned getting started page with links would be a start. Through comparing a few Pycom libraries that were adapted from Micropython libraries I have gotten the hang of how to convert over libraries. If there was a good centralized place to post Pycom libraries I would be happy to share my adaptations and the libraries I've created for some components that don't have libraries out there at all. A tutorial, for converting libraries would still be great, thanks @Paul-Thornton for your consideration.
  • Pycom + Azure IoT Hub SDK

    MicroPython azure library pycom micropython
    1
    0 Votes
    1 Posts
    370 Views
    No one has replied
  • Calling functions in uMQTT

    Discussion umgtt mqtt micropython adafruit io wipy mqtt
    4
    0 Votes
    4 Posts
    538 Views
    P
    @dezert754 We've all had those moments :P glad its all sorted.
  • 0 Votes
    4 Posts
    520 Views
    bmarkusB
    @qwab said in Would you consider using MicroPython to create small, standalone executables for desktop platforms?: I have been considering making some contributions to MicroPython to enable the generation of small, standalone executables for desktop platforms. It seems MicroPython executables could be as little as 500KB in size, compared to around 5MB for CPython (with PyInstaller). What do you mean 'desktop platforms'? How do you create a MicroPython 'standalone desktop executables'? Which PyCom hardware are you intending to use to create such applications and how?
  • Any MicroPython fans?

    Getting Started micropython
    4
    0 Votes
    4 Posts
    604 Views
    S
    It isn't really portable between devices yet It isn't pythonic enough yet Might as well use C However I think it is going to be great when it is more mature 9apps app cartoon hd
  • Tarballs

    Discussion tarballs micropython python code porting
    1
    0 Votes
    1 Posts
    293 Views
    No one has replied
  • WDT Reset, RTC also reset

    MicroPython pycom gpy micropython watchdog rtc
    1
    0 Votes
    1 Posts
    474 Views
    No one has replied
  • Assembler in micropython

    MicroPython micropython assembler functions ws2812 ws2812b
    10
    0 Votes
    10 Posts
    1k Views
    M
    @robert-hh, @jcaron Thanks again for the reply. I knew about the possability to build own firmware but i don't know how to do that and it's going way to far. So i will use the RTM module and multiplex the pins. Haven't tried it yet because actual i'm doing my Bachelor Thesis and i don't have much time for personal projects.
  • Confusing development process

    Discussion micropython version management
    24
    4 Votes
    24 Posts
    3k Views
    robert-hhR
    @iwahdan There is another branch now called stable_update. I understand that this is the trial update to 1.18.1.rx. I left a note there on one of the newer commits. Having a note somewhere about the intention of each branch would be helpful.
  • JSON posts

    Support & Troubleshooting requests urequests micropython
    4
    0 Votes
    4 Posts
    929 Views
    E
    @kjm Line 52 doesn't seem to be related to datapayload, so i suppose that data = ujson.dumps({"post_wrapper":payload})) do the work. I don't know what OSError 128 mean but the line seem to be related to networking. Does your software have do correctly the connect with your wifi hotspot before trying to send your request ?
  • MicropyGPS: Failed to write file

    LoPy lopy micropython frozen modules micropygps
    16
    0 Votes
    16 Posts
    2k Views
    robert-hhR
    @paloma You can configure Filezilla in a way, that double-click on a file in the LoPy pane will open that file in your Favorite editor. Storing that file will transfer it back to the LoPy. For REPL, you might also use other tools like screen, picocom, putty, .., which support VT100 code sequences, in case you need them.
  • 0 Votes
    4 Posts
    760 Views
    robert-hhR
    @rcolistete You can always connect Vin via a voltage divider to a GPIO Pin.
  • GY-87 micropython library

    Discussion micropython gy-80 lopy4
    32
    0 Votes
    32 Posts
    5k Views
    robert-hhR
    @tttadam Updated code. The name of the methods are changed to reflect PEP8. SO readRaw() -> read_raw and a new read_scaled(), which returns the values as Gauss and Β°C. The constructor has an optional second argument for the temperature offset in Β°C . # # initial code by Sebastian Folz, M.Sc. at # http://nobytes.blogspot.com/2018/03/qmc5883-magnetic-field-sensor.html # which, I assume, was itself ported from C-Code # See also https://github.com/RigacciOrg/py-qmc5883l # # Changes and Additions: # - port to micropython's I2C methods # - add method read() for scaled values # - reading register values into a static buffer # - parsed register values in one single struct call # - changed method names according to PEP8 # - apply PyLint and fixed bugs & warnings reported by it # import time import struct from machine import idle class QMC5883: #Default I2C address ADDR = 0x0D #QMC5883 Register numbers X_LSB = 0 X_MSB = 1 Y_LSB = 2 Y_MSB = 3 Z_LSB = 4 Z_MSB = 5 STATUS = 6 T_LSB = 7 T_MSB = 8 CONFIG = 9 CONFIG2 = 10 RESET = 11 STATUS2 = 12 CHIP_ID = 13 #Bit values for the STATUS register STATUS_DRDY = 1 STATUS_OVL = 2 STATUS_DOR = 4 #Oversampling values for the CONFIG register CONFIG_OS512 = 0b00000000 CONFIG_OS256 = 0b01000000 CONFIG_OS128 = 0b10000000 CONFIG_OS64 = 0b11000000 #Range values for the CONFIG register CONFIG_2GAUSS = 0b00000000 CONFIG_8GAUSS = 0b00010000 #Rate values for the CONFIG register CONFIG_10HZ = 0b00000000 CONFIG_50HZ = 0b00000100 CONFIG_100HZ = 0b00001000 CONFIG_200HZ = 0b00001100 #Mode values for the CONFIG register CONFIG_STANDBY = 0b00000000 CONFIG_CONT = 0b00000001 # Mode values for the CONFIG2 register CONFIG2_INT_DISABLE = 0b00000001 CONFIG2_ROL_PTR = 0b01000000 CONFIG2_SOFT_RST = 0b10000000 def __init__(self, i2c, offset=50.0): self.i2c = i2c self.temp_offset = offset self.oversampling = QMC5883.CONFIG_OS64 self.range = QMC5883.CONFIG_2GAUSS self.rate = QMC5883.CONFIG_100HZ self.mode = QMC5883.CONFIG_CONT self.register = bytearray(9) self.reset() def reset(self): self.i2c.writeto_mem(QMC5883.ADDR, QMC5883.RESET, 0x01) time.sleep(0.1) self.reconfig() def reconfig(self): # print("{0:b}".format(self.oversampling | self.range | self.rate | self.mode)) self.i2c.writeto_mem(QMC5883.ADDR, QMC5883.CONFIG, self.oversampling | self.range | self.rate | self.mode) time.sleep(0.01) self.i2c.writeto_mem(QMC5883.ADDR, QMC5883.CONFIG2, QMC5883.CONFIG2_INT_DISABLE) time.sleep(0.01) def set_oversampling(self, x): self.oversampling = x self.reconfig() def set_range(self, x): self.range = x self.reconfig() def set_sampling_rate(self, x): self.rate = x self.reconfig() def ready(self): status = self.i2c.readfrom_mem(QMC5883.ADDR, QMC5883.STATUS, 1)[0] # prevent hanging up here. # Happens when reading less bytes then then all 3 axis and will end up in a loop. # So, return any data but avoid the loop. if status == QMC5883.STATUS_DOR: print("Incomplete read") return QMC5883.STATUS_DRDY return status & QMC5883.STATUS_DRDY def read_raw(self): try: while not self.ready(): idle() self.i2c.readfrom_mem_into(QMC5883.ADDR, QMC5883.X_LSB, self.register) except OSError as e: print ("OSError", e) pass # just silently re-use the old values # Convert the axis values to signed Short before returning x, y, z, _, t = struct.unpack('<hhhBh', self.register) return (x, y, z, t) def read_scaled(self): x, y, z, t = self.read_raw() scale = 12000 if self.range == QMC5883.CONFIG_2GAUSS else 3000 return (x / scale, y / scale , z / scale, (t / 100 + self.temp_offset))
  • How Decrypt LoRa data

    LoPy lopy micropython decrypt
    4
    0 Votes
    4 Posts
    3k Views
    M
    @rcolistete Thank you for your time and explanation
  • 0 Votes
    23 Posts
    4k Views
    robert-hhR
    @jcaron I think that this was @tttadam's conclusion.
  • 0 Votes
    10 Posts
    1k Views
    T
    @robert-hh Thank you, It works like a charm! :)
  • 1 Votes
    3 Posts
    701 Views
    T
    Thank you for the detailed answer! This is the best solution what I could find.
  • File compression on a Pycom device

    MicroPython compression micropython
    1
    1 Votes
    1 Posts
    457 Views
    No one has replied
  • First use on MacOS & Serial doesn't work

    Discussion micropython setup macos mac
    3
    0 Votes
    3 Posts
    674 Views
    D
    Woo Hoo!! πŸ™πŸΌπŸ’ƒπŸ½πŸ’₯πŸŽ‰πŸŽ‰ Thanks, I guess I assumed that the expansion board was just the drivers for an onboard serial port. Next time, I'll look at the schematics as well, since the WiPy docs said that there wasn't any driver needed for use. It's all working, now I can geek out having combined my two favorite worlds... embedded systems and Python!
  • FFI Lib module not found

    Discussion modules lib micropython
    3
    0 Votes
    3 Posts
    705 Views
    S
    Thank you for the answer. I want to adapt this raspberrypi script to my Pycom WiPy. but I stuck ... :-( #!/usr/bin/python import io # used to create file streams import fcntl # used to access I2C parameters like addresses import time # used for sleep delay and timestamps import string # helps parse strings class AtlasI2C: long_timeout = 1.5 # the timeout needed to query readings and calibrations short_timeout = .5 # timeout for regular commands default_bus = 1 # the default bus for I2C on the newer Raspberry Pis, certain older boards use bus 0 default_address = 98 # the default address for the sensor current_addr = default_address def __init__(self, address=default_address, bus=default_bus): # open two file streams, one for reading and one for writing # the specific I2C channel is selected with bus # it is usually 1, except for older revisions where its 0 # wb and rb indicate binary read and write self.file_read = io.open("/dev/i2c-"+str(bus), "rb", buffering=0) self.file_write = io.open("/dev/i2c-"+str(bus), "wb", buffering=0) # initializes I2C to either a user specified or default address self.set_i2c_address(address) def set_i2c_address(self, addr): # set the I2C communications to the slave specified by the address # The commands for I2C dev using the ioctl functions are specified in # the i2c-dev.h file from i2c-tools I2C_SLAVE = 0x703 fcntl.ioctl(self.file_read, I2C_SLAVE, addr) fcntl.ioctl(self.file_write, I2C_SLAVE, addr) self.current_addr = addr def write(self, cmd): # appends the null character and sends the string over I2C cmd += "\00" self.file_write.write(cmd) def read(self, num_of_bytes=31): # reads a specified number of bytes from I2C, then parses and displays the result res = self.file_read.read(num_of_bytes) # read from the board response = filter(lambda x: x != '\x00', res) # remove the null characters to get the response if ord(response[0]) == 1: # if the response isn't an error # change MSB to 0 for all received characters except the first and get a list of characters char_list = map(lambda x: chr(ord(x) & ~0x80), list(response[1:])) # NOTE: having to change the MSB to 0 is a glitch in the raspberry pi, and you shouldn't have to do this! return "Command succeeded " + ''.join(char_list) # convert the char list to a string and returns it else: return "Error " + str(ord(response[0])) def query(self, string): # write a command to the board, wait the correct timeout, and read the response self.write(string) # the read and calibration commands require a longer timeout if((string.upper().startswith("R")) or (string.upper().startswith("CAL"))): time.sleep(self.long_timeout) elif string.upper().startswith("SLEEP"): return "sleep mode" else: time.sleep(self.short_timeout) return self.read() def close(self): self.file_read.close() self.file_write.close() def list_i2c_devices(self): prev_addr = self.current_addr # save the current address so we can restore it after i2c_devices = [] for i in range (0,128): try: self.set_i2c_address(i) self.read() i2c_devices.append(i) except IOError: pass self.set_i2c_address(prev_addr) # restore the address we were using return i2c_devices def main(): device = AtlasI2C() # creates the I2C port object, specify the address or bus if necessary print(">> Atlas Scientific sample code") print(">> Any commands entered are passed to the board via I2C except:") print(">> List_addr lists the available I2C addresses.") print(">> Address,xx changes the I2C address the Raspberry Pi communicates with.") print(">> Poll,xx.x command continuously polls the board every xx.x seconds") print(" where xx.x is longer than the %0.2f second timeout." % AtlasI2C.long_timeout) print(">> Pressing ctrl-c will stop the polling") # main loop while True: input = raw_input("Enter command: ") if input.upper().startswith("LIST_ADDR"): devices = device.list_i2c_devices() for i in range(len (devices)): print devices[i] # address command lets you change which address the Raspberry Pi will poll elif input.upper().startswith("ADDRESS"): addr = int(string.split(input, ',')[1]) device.set_i2c_address(addr) print("I2C address set to " + str(addr)) # continuous polling command automatically polls the board elif input.upper().startswith("POLL"): delaytime = float(string.split(input, ',')[1]) # check for polling time being too short, change it to the minimum timeout if too short if delaytime < AtlasI2C.long_timeout: print("Polling time is shorter than timeout, setting polling time to %0.2f" % AtlasI2C.long_timeout) delaytime = AtlasI2C.long_timeout # get the information of the board you're polling info = string.split(device.query("I"), ",")[1] print("Polling %s sensor every %0.2f seconds, press ctrl-c to stop polling" % (info, delaytime)) try: while True: print(device.query("R")) time.sleep(delaytime - AtlasI2C.long_timeout) except KeyboardInterrupt: # catches the ctrl-c command, which breaks the loop above print("Continuous polling stopped") # if not a special keyword, pass commands straight to board else: if len(input) == 0: print "Please input valid command." else: try: print(device.query(input)) except IOError: print("Query failed \n - Address may be invalid, use List_addr command to see available addresses") if __name__ == '__main__': main()