diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d7664a --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 3a4a96b..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "python.languageServer": "Pylance", - "python.linting.pylintEnabled": false, - "python.analysis.diagnosticSeverityOverrides": { - "reportMissingModuleSource": "none" - }, - "python.analysis.extraPaths": [ - "", - "/Users/peter/.vscode/extensions/joedevivo.vscode-circuitpython-0.1.19-darwin-x64/stubs", - "/Users/peter/Library/Application Support/Code/User/globalStorage/joedevivo.vscode-circuitpython/bundle/20220820/adafruit-circuitpython-bundle-py-20220820/lib" - ], - "circuitpython.board.version": null -} \ No newline at end of file diff --git a/ConnectWiFi.py b/ConnectWiFi.py index 2b51c5c..e2654af 100644 --- a/ConnectWiFi.py +++ b/ConnectWiFi.py @@ -1,11 +1,9 @@ def connect(): import network - from time import sleep_ms + from time import sleep, sleep_ms - ssid = "-Netzlein-" - password = "Lau5Buam!" - #ssid = "Phaser" - #password = "toolbelt555" + ssid = "YourSSID" + password = "totallysecurepassword" print("Connecting to WiFi") diff --git a/README.md b/README.md new file mode 100644 index 0000000..92280fb --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# ESP8266 Thermometer with OLED display + +![thermometer](images/thermometer.jpg) + +## Hardware +- ESP-12F, WiFi Module Based on ESP8266 (preferrably with breakout board) +- SSD1306 128 x 64 Dot Matrix OLED with Controller +- DS1820 parasitic power 1-Wire temperature sensor + +## Features +- Connects to Wifi +- Gets outside temperature via openweathermap +- Gets inside temperature via DS1820 temperature sensor +- Plots both temperatures against each other +- Handles Wifi and service outages gracefully +- Handles possible collisions of temperature labels + +## Images +![ESP breakout board](images/board.jpg) +![display module](images/display.jpg) +![plot](images/plot.jpg) +![outage](images/outage.jpg) diff --git a/images/board.jpg b/images/board.jpg new file mode 100644 index 0000000..b557143 Binary files /dev/null and b/images/board.jpg differ diff --git a/images/display.jpg b/images/display.jpg new file mode 100644 index 0000000..bcfc06a Binary files /dev/null and b/images/display.jpg differ diff --git a/images/outage.jpg b/images/outage.jpg new file mode 100644 index 0000000..e503321 Binary files /dev/null and b/images/outage.jpg differ diff --git a/images/plot.jpg b/images/plot.jpg new file mode 100644 index 0000000..7e59bcd Binary files /dev/null and b/images/plot.jpg differ diff --git a/images/thermometer.jpg b/images/thermometer.jpg new file mode 100644 index 0000000..ef54f5a Binary files /dev/null and b/images/thermometer.jpg differ diff --git a/main.py b/main.py index 01b11d4..6554601 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ from machine import Pin, I2C import ssd1306 -from time import sleep_ms +from time import sleep, sleep_ms import onewire, ds18x20 import urequests import ConnectWiFi @@ -45,23 +45,6 @@ outer_templog = [] refresh_counter = 1 burn_in_counter = 0 -""" -def rand( floor, mod=0, negative = False): - # return random value from -floor.mod to floor.mod if negative is True - - from os import urandom as rnd - - sign = 1 if ord(rnd(1))%10 > 5 else -1 - sign = sign if negative else 1 - - if mod: - value = float(('{}.{}').format(ord(rnd(1))%floor, ord(rnd(1))%mod)) - else: - value = int(('{}').format(ord(rnd(1))%floor)) - - return sign*value -""" - def cleanedlist(list): return [i for i in list if i != errortemp] @@ -210,7 +193,7 @@ def refresh_outer(): if connection_success: try: - response = urequests.get('http://api.openweathermap.org/data/2.5/weather?zip=79106,de&appid=50fdc9dbace8903dae0ac4ee4143b3b5') + response = urequests.get('http://api.openweathermap.org/data/2.5/weather?zip=---your-zip---,de&appid=---your-app-id---') parsed = response.json() if 'cod' in parsed: @@ -284,7 +267,7 @@ while True: do_refresh_outer = False ds18b20.convert_temp() # refresh value ahead of time for minimum latency - sleep_ms(1000) # refresh inner temp every second + sleep(1) # refresh inner temp every second print('.', end='')