Skip to content

Instantly share code, notes, and snippets.

View unforgiven512's full-sized avatar

Gerad Munsch unforgiven512

View GitHub Profile
import utime
#import machine
from machine import RTC
try:
import usocket as socket
except:
import socket
try:
import ustruct as struct
import machine
def print_all_reset_causes():
print("\n +------------------------+")
print(" | KNOWN RESET CAUSES |")
print(" +------------------------+\n")
print(" PWRON_RESET: %d" % machine.PWRON_RESET)
print(" WDT_RESET: %d" % machine.WDT_RESET)
print(" SOFT_RESET: %d" % machine.SOFT_RESET)
print(" DEEPSLEEP_RESET: %d" % machine.DEEPSLEEP_RESET)
@unforgiven512
unforgiven512 / main.py
Created July 18, 2019 21:54
new main.py file on MicroPython ESP8266 board #7
import network
import utime
import ntptime
import onewire
import ds18x20
import socket
import os
import sys
import esp
import machine
@unforgiven512
unforgiven512 / boot.py
Created July 18, 2019 21:55
new boot.py file on MicroPython ESP8266 board #7
# This file is executed on every boot (including wake-boot from deepsleep)
# Import any necessary modules for early in the system boot process
import esp
import gc
import webrepl
import machine
import network
# import socket
import uos
@unforgiven512
unforgiven512 / boot.py
Created July 18, 2019 21:55
old boot.py file on MicroPython ESP8266 board #7
# This file is executed on every boot (including wake-boot from deepsleep)
import esp
import gc
import webrepl
import machine
import network
# import socket
# Disable debug output
@unforgiven512
unforgiven512 / main.py
Created July 18, 2019 21:55
old main.py file on MicroPython ESP8266 board #7
#
# main.py
#
# Example for MicroPython
#
from machine import Pin, RTC, PWM, Signal, I2C
# from machine import I2C
# from machine import SPI
@unforgiven512
unforgiven512 / bme280.py
Created July 18, 2019 21:56
old bme280.py library file on MicroPython ESP8266 board #7
# Author: Paul Cunnane 2016
#
# This module borrows heavily from the Adafruit BME280 Python library
# and the Adafruit GPIO/I2C library. Original copyright notices are reproduced
# below.
#
# Those libraries were written for the Raspberry Pi. This modification is
# intended for the MicroPython and WiPy boards.
#
#
@unforgiven512
unforgiven512 / ds1621.py
Created July 18, 2019 21:56
old ds1621.py library file on MicroPython ESP8266 board #7
"""
This is a MicroPython driver for the Dallas (Maxim) DS1621 digital temperature sensor.
The DS1621 is an I2C device, and is able to provide digital temperature data with a resolution of 9 bits, resulting in a
granularity of 0.5 degrees Celsius.
Additionally, the DS1621 is a relatively simple device; as such, the I2C command set is rather simple. The simplicity is
a great factor for utilizing this device (and driver) as a simple example for use of I2C on MicroPython; the basic read,
write, and other functionality are demonstrated. Additionally, some simple data manipulation methods are demonstrated.
"""
@unforgiven512
unforgiven512 / ssd1306.py
Created July 18, 2019 21:56
old ssd1306.py library file on MicroPython ESP8266 board #7
"""
This is a MicroPython driver for the SSD1306 OLED display.
The driver implements both the I2C and SPI interfaces, as the SSD1306 is available with either interface.
"""
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
import time
@unforgiven512
unforgiven512 / example.py
Created July 18, 2019 21:57
INA219 library (example) for MicroPython
"""Example script.
Edit the I2C interface constant to match the one you have
connected the sensor to.
"""
from ina219 import INA219
from machine import I2C
# Edit to match interface the sensor is connect to (1 or 2).