micropython

How to convert from bytearray/bytes in micropython?

How to convert from bytearray/bytes in micropython? Question: I’m hashing things with uhashlib in micropython on the pi pico. Here’s an example: import sys import os import uhashlib import time time_now = "blergh" hash_test = uhashlib.sha256(time_now).digest() print(time_now) print(hash_test) This outputs: blergh b’Y|x84Wxa1x1dx86cb~x0bLx1e\x92xcd-x93x05xddzx0exe1x9fx9axc1H6x93xd8x0c8′ …which, clearly, isn’t super useful. I’ve tried a bunch of things, but I …

Total answers: 3

Micropython get correct current time

Micropython get correct current time Question: Because of micropython doesn’t import the datetime. I want use time or utime modules to get current time. But the time.localtime() result is like (2000, 1, 1, 0, 12, 35, 5, 1) I guess the time start at the 2000/1/1. How to set the start time on that? Or …

Total answers: 4

Fetching the IP address using MicroPython

Fetching the IP address using MicroPython Question: Trying to use pybricks-micropython Want to get the localhost name/IP address. Can do in CPython with this code… but doesn’t seem to be an equivalent I can find in MicroPython? hostName = socket.gethostname() hostIPA = socket.gethostbyname(hostName) Searching on the net, but cannot seem to find anything I can …

Total answers: 1

CRC32 calculation in Python without using libraries

CRC32 calculation in Python without using libraries Question: I have been trying to get my head around CRC32 calculations without much success, the values that I seem to get do not match what I should get. I am aware that Python has libraries that are capable of generating these checksums (namely zlib and binascii) but …

Total answers: 2