Exemple #1
0
# Files
# https://docs.micropython.org/en/latest/esp8266/tutorial/filesystem.html

v = '1.0'
moduleName = 'helpFiles'
from Utils import identifyModule, myLog

identifyModule(moduleName, v)

import os
import gc


# from https://forum.micropython.org/viewtopic.php?t=3499
def df():
    s = os.statvfs('//')
    return ('{0} MB'.format((s[0] * s[3]) / 1048576))


# from https://forum.micropython.org/viewtopic.php?t=3499
def free(full=False):
    gc.collect()
    F = gc.mem_free()
    A = gc.mem_alloc()
    T = F + A
    P = '{0:.2f}%'.format(F / T * 100)
    if not full: return P
    else: return ('Total:{0} Free:{1} ({2})'.format(T, F, P))


def printFile(fichero):
Exemple #2
0
# https://docs.micropython.org/en/latest/esp8266/quickref.html#deep-sleep-mode

# Wemos ds18x20 shield uses D2

# You must also power the sensors and connect a 4.7k Ohm resistor between the data pin and the power pin.
import time
import machine
import onewire, ds18x20

from Utils import myLog, identifyModule

v = '0.5.5'
moduleName = 'OneWire_ds18x20'

identifyModule(v, moduleName)

# the device is on GPIO12
pinDS = machine.Pin(23)

# create the onewire object
ds = ds18x20.DS18X20(onewire.OneWire(pinDS))

# scan for devices on the bus
roms = ds.scan()
if len(roms) > 0:
    print('found devices:', roms)

    # loop 10 times and print all temperatures
    for i in range(10):
        print('temperatures:', end=' ')
        ds.convert_temp()