49 Commits

Author SHA1 Message Date
Kristjan Komlosi
ec8d3ca94c rename init to app change camel case to snake case, added __name__ conditional 2020-08-27 14:22:35 +02:00
Kristjan Komlosi
88687124f2 fixing packaging #1 2020-08-27 13:52:24 +02:00
Kristjan Komlosi
97233f27c3 fixing packaging #1 2020-08-27 11:14:01 +02:00
Kristjan Komlosi
b35aacad3f add travis config 2020-07-22 11:54:46 +02:00
Kristjan Komlosi
2136406a28 changed JS to match 1c49490 2020-07-14 11:12:43 +02:00
Kristjan Komlosi
ff13d8eeeb Add a semistandard badge to readme 2020-07-14 10:54:06 +02:00
Kristjan Komlosi
fece181c6f added an ESLint config file 2020-07-14 10:38:17 +02:00
Kristjan Komlosi
85d7be4117 refactor updateData to use simpler $.get method 2020-07-14 10:37:57 +02:00
Kristjan Komlosi
56e8282a82 specter --> spectrum 2020-07-14 10:02:18 +02:00
Kristjan Komlosi
1c4949020b change element IDs for irradiance values and table rows 2020-07-14 10:01:13 +02:00
Kristjan Komlosi
a71d8565c4 Change HTML indent to 4 2020-07-14 09:59:04 +02:00
Kristjan Komlosi
7e09a1e51f modify index.html into Jinja2 rendering template 2020-07-13 14:28:09 +02:00
Kristjan Komlosi
92fac02a9e formatting 2020-07-13 14:01:19 +02:00
Kristjan Komlosi
320bcae78e Merge branch 'development' of github.com:cls-02/TeraHz into developmen 2020-07-13 13:56:30 +02:00
Kristjan Komlosi
d6a0efd69b Merge branch 'development' of github.com:cls-02/TeraHz into development 2020-07-13 13:55:44 +02:00
Kristjan Komlosi
40a79af9af moved static files to conform with Flask 2020-07-13 13:54:30 +02:00
Kristjan Komlosi
229719cc5c moved static files to conform with Flask 2020-07-13 13:47:13 +02:00
Kristjan Komlosi
ac6345c5b5 modify gitignore 2020-07-13 13:42:08 +02:00
Kristjan Komlosi
7773788e20 Merge branch 'development' of github.com:cls-02/TeraHz into development 2020-07-13 13:28:36 +02:00
Kristjan Komlosi
ac154e6770 moved templates 2020-07-13 13:28:32 +02:00
Kristjan Komlosi
a4ec93f412 moved templates 2020-07-13 13:23:24 +02:00
Kristjan Komlosi
16d7624154 update copyright and add a root route 2020-07-13 13:13:01 +02:00
Kristjan Komlosi
54b93cb05c cleaning up 2020-07-13 13:11:10 +02:00
Kristjan Komlosi
3d3254c4a7 formatting 2020-07-13 13:01:34 +02:00
Kristjan Komlosi
cfe6e3c286 remove old-unused files 2020-07-13 12:13:31 +02:00
Kristjan Komlosi
7a3877b34b remove unused FastCGI configuration file 2020-07-13 11:55:21 +02:00
Kristjan Komlosi
f20dd30292 remove unused config file 2020-07-13 11:54:35 +02:00
Kristjan Komlosi
ef5c87d8d2 removed janky and unused storage module 2020-07-13 11:54:20 +02:00
Kristjan Komlosi
4878df9ca8 Shortened error messages 2020-07-13 11:52:22 +02:00
Kristjan Komlosi
89ea9564c8 fixed onclick binding 2020-06-02 10:45:16 +02:00
Kristjan Komlosi
00c619ce34 fixed typo 2020-06-02 09:53:09 +02:00
Kristjan Komlosi
8f22a6baee removed lighttpd configuration as the defaults work fine 2020-06-02 09:52:40 +02:00
Kristjan Komlosi
fa2c1cccb1 removed old pipfiles 2020-06-02 09:52:08 +02:00
Kristjan Komlosi
7058512ee0 tidied comments, condensed UV calculation, removed redundant getA/B/I() 2020-04-24 16:49:09 +02:00
Kristjan Komlosi
325f1176c3 tidied translation tables 2020-04-24 16:47:43 +02:00
Kristjan Komlosi
0a9e610dd7 pruned import 2020-04-24 16:46:53 +02:00
Kristjan Komlosi
43b5277923 pipenv update 2020-04-24 16:46:27 +02:00
Kristjan Komlosi
5265ba9ae9 hotfix #2 2020-02-15 22:02:36 +01:00
Kristjan Komlosi
16e9c52194 rc.local hotfix 2020-02-15 21:59:41 +01:00
Kristjan Komlosi
c5db357cc0 fixed lighttpd root directory 2020-02-15 21:50:03 +01:00
Kristjan Komlosi
b7eb29f78b made rc.local executable 2020-02-15 21:46:12 +01:00
Kristjan Komlosi
1457655f16 GUI redesign 2020-02-15 15:56:28 +01:00
Kristjan Komlosi
a3f3558f7c fixed wavelength order in spectrogram 2020-02-14 14:18:38 +01:00
Kristjan Komlosi
bc72207187 fixed broken git headers 2019-11-18 17:19:18 +01:00
Kristjan Komlosi
7837f605cf Merge branch 'master' of github.com:cls-02/TeraHz 2019-11-17 22:23:28 +01:00
Kristjan Komlosi
3d1a925ba6 added school logo 2019-11-17 22:23:09 +01:00
Kristjan Komlosi
682fe20db2 added school logo 2019-11-17 22:21:54 +01:00
Kristjan Komlosi
949dd0bef2 Updated the main readme 2019-11-17 22:04:57 +01:00
Kristjan Komlosi
58cb777935 Documentation updates 2019-11-17 19:07:47 +01:00
68 changed files with 485 additions and 520 deletions

Binary file not shown.

5
.eslintrc Normal file
View File

@@ -0,0 +1,5 @@
parserOptions:
ecmaVersion: 2019
env:
browser: true
jquery: true

4
.gitignore vendored
View File

@@ -128,5 +128,5 @@ dmypy.json
# Pyre type checker
.pyre/
# Include frontend libraries though
!/frontend/lib
# Include frontend ibraries though
!terahz/templates/lib

1
.travis.yml Normal file
View File

@@ -0,0 +1 @@
language: python

15
Pipfile Normal file
View File

@@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
flask = "*"
smbus2 = "*"
pyserial = "*"
pandas = "*"
[requires]
python_version = "3.8"

184
Pipfile.lock generated Normal file
View File

@@ -0,0 +1,184 @@
{
"_meta": {
"hash": {
"sha256": "7fb3ae0afbe0d0c2af92f618aa1c54442566daeb561480eee2c2a299f1c2bee7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"click": {
"hashes": [
"sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a",
"sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"
],
"version": "==7.1.2"
},
"flask": {
"hashes": [
"sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060",
"sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557"
],
"index": "pypi",
"version": "==1.1.2"
},
"itsdangerous": {
"hashes": [
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
"sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
],
"version": "==1.1.0"
},
"jinja2": {
"hashes": [
"sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0",
"sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035"
],
"version": "==2.11.2"
},
"markupsafe": {
"hashes": [
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
"sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
"sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
"sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
"sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42",
"sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
"sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
"sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
"sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
"sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
"sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
"sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b",
"sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
"sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15",
"sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
"sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
"sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
"sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
"sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
"sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
"sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
"sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
"sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
"sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
"sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
"sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
"sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
"sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
"sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
"sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
"sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2",
"sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7",
"sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"
],
"version": "==1.1.1"
},
"numpy": {
"hashes": [
"sha256:082f8d4dd69b6b688f64f509b91d482362124986d98dc7dc5f5e9f9b9c3bb983",
"sha256:1bc0145999e8cb8aed9d4e65dd8b139adf1919e521177f198529687dbf613065",
"sha256:309cbcfaa103fc9a33ec16d2d62569d541b79f828c382556ff072442226d1968",
"sha256:3673c8b2b29077f1b7b3a848794f8e11f401ba0b71c49fbd26fb40b71788b132",
"sha256:480fdd4dbda4dd6b638d3863da3be82873bba6d32d1fc12ea1b8486ac7b8d129",
"sha256:56ef7f56470c24bb67fb43dae442e946a6ce172f97c69f8d067ff8550cf782ff",
"sha256:5a936fd51049541d86ccdeef2833cc89a18e4d3808fe58a8abeb802665c5af93",
"sha256:5b6885c12784a27e957294b60f97e8b5b4174c7504665333c5e94fbf41ae5d6a",
"sha256:667c07063940e934287993366ad5f56766bc009017b4a0fe91dbd07960d0aba7",
"sha256:7ed448ff4eaffeb01094959b19cbaf998ecdee9ef9932381420d514e446601cd",
"sha256:8343bf67c72e09cfabfab55ad4a43ce3f6bf6e6ced7acf70f45ded9ebb425055",
"sha256:92feb989b47f83ebef246adabc7ff3b9a59ac30601c3f6819f8913458610bdcc",
"sha256:935c27ae2760c21cd7354402546f6be21d3d0c806fffe967f745d5f2de5005a7",
"sha256:aaf42a04b472d12515debc621c31cf16c215e332242e7a9f56403d814c744624",
"sha256:b12e639378c741add21fbffd16ba5ad25c0a1a17cf2b6fe4288feeb65144f35b",
"sha256:b1cca51512299841bf69add3b75361779962f9cee7d9ee3bb446d5982e925b69",
"sha256:b8456987b637232602ceb4d663cb34106f7eb780e247d51a260b84760fd8f491",
"sha256:b9792b0ac0130b277536ab8944e7b754c69560dac0415dd4b2dbd16b902c8954",
"sha256:c9591886fc9cbe5532d5df85cb8e0cc3b44ba8ce4367bd4cf1b93dc19713da72",
"sha256:cf1347450c0b7644ea142712619533553f02ef23f92f781312f6a3553d031fc7",
"sha256:de8b4a9b56255797cbddb93281ed92acbc510fb7b15df3f01bd28f46ebc4edae",
"sha256:e1b1dc0372f530f26a03578ac75d5e51b3868b9b76cd2facba4c9ee0eb252ab1",
"sha256:e45f8e981a0ab47103181773cc0a54e650b2aef8c7b6cd07405d0fa8d869444a",
"sha256:e4f6d3c53911a9d103d8ec9518190e52a8b945bab021745af4939cfc7c0d4a9e",
"sha256:ed8a311493cf5480a2ebc597d1e177231984c818a86875126cfd004241a73c3e",
"sha256:ef71a1d4fd4858596ae80ad1ec76404ad29701f8ca7cdcebc50300178db14dfc"
],
"version": "==1.19.1"
},
"pandas": {
"hashes": [
"sha256:01b1e536eb960822c5e6b58357cad8c4b492a336f4a5630bf0b598566462a578",
"sha256:0246c67cbaaaac8d25fed8d4cf2d8897bd858f0e540e8528a75281cee9ac516d",
"sha256:0366150fe8ee37ef89a45d3093e05026b5f895e42bbce3902ce3b6427f1b8471",
"sha256:16ae070c47474008769fc443ac765ffd88c3506b4a82966e7a605592978896f9",
"sha256:1acc2bd7fc95e5408a4456897c2c2a1ae7c6acefe108d90479ab6d98d34fcc3d",
"sha256:391db82ebeb886143b96b9c6c6166686c9a272d00020e4e39ad63b792542d9e2",
"sha256:41675323d4fcdd15abde068607cad150dfe17f7d32290ee128e5fea98442bd09",
"sha256:53328284a7bb046e2e885fd1b8c078bd896d7fc4575b915d4936f54984a2ba67",
"sha256:57c5f6be49259cde8e6f71c2bf240a26b071569cabc04c751358495d09419e56",
"sha256:84c101d0f7bbf0d9f1be9a2f29f6fcc12415442558d067164e50a56edfb732b4",
"sha256:88930c74f69e97b17703600233c0eaf1f4f4dd10c14633d522724c5c1b963ec4",
"sha256:8c9ec12c480c4d915e23ee9c8a2d8eba8509986f35f307771045c1294a2e5b73",
"sha256:a81c4bf9c59010aa3efddbb6b9fc84a9b76dc0b4da2c2c2d50f06a9ef6ac0004",
"sha256:d9644ac996149b2a51325d48d77e25c911e01aa6d39dc1b64be679cd71f683ec",
"sha256:e4b6c98f45695799990da328e6fd7d6187be32752ed64c2f22326ad66762d179",
"sha256:fe6f1623376b616e03d51f0dd95afd862cf9a33c18cf55ce0ed4bbe1c4444391"
],
"index": "pypi",
"version": "==1.1.1"
},
"pyserial": {
"hashes": [
"sha256:6e2d401fdee0eab996cf734e67773a0143b932772ca8b42451440cfed942c627",
"sha256:e0770fadba80c31013896c7e6ef703f72e7834965954a78e71a3049488d4d7d8"
],
"index": "pypi",
"version": "==3.4"
},
"python-dateutil": {
"hashes": [
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
"sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"
],
"version": "==2.8.1"
},
"pytz": {
"hashes": [
"sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed",
"sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048"
],
"version": "==2020.1"
},
"six": {
"hashes": [
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
"version": "==1.15.0"
},
"smbus2": {
"hashes": [
"sha256:210e66eebe4d0b1fe836b3ec2751841942e1c4918c0b429b20a0e20a222228b4"
],
"index": "pypi",
"version": "==0.3.0"
},
"werkzeug": {
"hashes": [
"sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43",
"sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c"
],
"version": "==1.0.1"
}
},
"develop": {}
}

View File

@@ -1,23 +1,38 @@
# TeraHz
[![Documentation Status](https://readthedocs.org/projects/terahz/badge/?version=latest)](https://terahz.readthedocs.io/en/latest/?badge=latest)
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard)
# <img alt="TeraHz logo" src="docs/imgs/logo-sq.png" width="200px"> TeraHz
TeraHz is a low-cost spectrometer based on a Raspberry Pi 3 or 3 B+ and three sensors:
+ [__AS7265x__](https://www.tindie.com/products/onehorse/compact-as7265x-spectrometer/)
is a 18 channel spectrometer chipset that provides the device with spectral data
+ [__VEML6075__](https://www.sparkfun.com/products/15089) is an
UVA/UVB sensor
+ [__APDS-9301__](https://www.sparkfun.com/products/14350) is a calibrated illuminance (lux) meter that provides the device with reliable readings
*Za slovensko različico se odpravite na <http://git.sckr-lab.tk/kristjank/TeraHz>*
## Why?
Because people and institutions could use an affordable and accurate light-analysing device that is also portable, easy to use and simple to assemble. TeraHz was started as an answer to our high school not being able to afford a commercially available solution. One TeraHz spectrometer costs around 150$ in parts, which makes it a competitive alternative to other solutions on the market today.
TeraHz is a low-cost portable spectrometer based on Raspberry Pi and a few
commonly available sensor breakout boards. It's designed to bring low-cost
scientific exploration of the light spectrum to educational institutions that
cannot afford the options available on the current market. It costs less than
200€ with money to spare and uses only free, libre and open-source software
(FLOSS). It is free to use under the ISC license, a spiritual successor to the
classic 3-clause BSD license.
## How to install
Stable releases are available under the releases tab and can be installed either
by flashing a **preinstalled** ready to boot image with a stable version of
TeraHz preinstalled or by flashing a **preconfigured** image of DietPi and
installing TeraHz manually, which is useful if you want to test bleeding edge
releases. For more information, check out the [Build
guide](https://terahz.readthedocs.io/en/latest/build/).
## Docs
TeraHz usually works out of the box. A wireless network named `TeraHz_XXXXXX`
(XXXXXX = the last half of the MAC address) will appear. Password is
`terahertz`. After connection, open a web browser and visit `terahz.site`.
The UI will appear. To fetch data from the sensors, press the 'Get Data' button.
The readings are then plotted and written into the tables below the graph.
More documentation is available at <https://terahz.readthedocs.io>
## Development team
Copyright 2018, 2019
- Kristjan Komloši (cls-02) - Project leader and main programmer
- Jakob Kosec (D3m1j4ck) - Frontend designer
- Juš Dolžan (ANormalPerson) - Math double-checker
- Kristjan "cls-02" Komloši (electronics, sensor drivers, backend)
- Jakob "D3m1j4ck" Kosec (frontend)
I would also like to thank Juš "ANormalPerson" Dolžan, who decided to leave the
team, but helped me a lot with backend development.
<img alt="TeraHz logo" src="http://www.sckr.si/documents/upload/konektor/logo/_SC.gif" width="200px">
TeraHz has been developed under guidance and financial support of Šolski Center Kranj (Kranj School Centre). Without their support, this project might have never been possible.

View File

@@ -1,17 +0,0 @@
# app.py - main backend program
'''Main TeraHz backend program'''
# All code in this file is licensed under the ISC license, provided in LICENSE.txt
from flask import Flask
import flask
import sensors
app = Flask(__name__)
@app.route('/data')
def sendData():
'''Responder function for /data route'''
s = sensors.Spectrometer(path='/dev/serial0', baudrate=115200, tout=1)
u = sensors.UVSensor()
l = sensors.LxMeter()
response = flask.jsonify([s.getData(), l.getData(), u.getABI()])
response.headers.add('Access-Control-Allow-Origin', '*')
return response

View File

@@ -1,4 +0,0 @@
#!/bin/bash
# run.sh - run the backend server
cd `dirname $0`
sudo gunicorn app:app -b 0.0.0.0:5000 &

Binary file not shown.

View File

@@ -1,37 +0,0 @@
# storage.py - storage backend for TeraHz
'''TeraHz storage backend'''
# Copyright Kristjan Komloši 2019
# All code in this file is licensed under the ISC license,
# provided in LICENSE.txt
import sqlite3
class jsonStorage:
'''Class for simple sqlite3 database of JSON entries'''
def __init__(self, dbFile):
'''Storage object constructor. Argument is filename'''
self.db = sqlite3.connect(dbFile)
def listJSONs(self):
'''Returns a list of all existing entries.'''
c = self.db.cursor()
c.execute('SELECT * FROM storage')
result = c.fetchall()
c.close()
return result
def storeJSON(self, jsonString, comment):
'''Stores a JSON entry along with a timestamp and a comment.'''
c = self.db.cursor()
c.execute(('INSERT INTO storage VALUES (datetime'
'(\'now\', \'localtime\'), ?, ?)'), (comment, jsonString))
c.close()
self.db.commit()
def retrieveJSON(self, timestamp):
'''Retrieves a JSON entry. Takes a timestamp string'''
c = self.db.cursor()
c.execute('SELECT * FROM storage WHERE timestamp = ?', (timestamp,))
result = c.fetchall()
c.close()
return result

View File

View File

@@ -1,7 +0,0 @@
#!/usr/bin/python3
# Minimal flup configuration for Flask
from flup.server.fcgi import WSGIServer
from app import app
if __name__ == '__main__':
WSGIServer(app, bindAddress='/var/www/api/terahz.sock').run()

View File

@@ -7,17 +7,12 @@ TeraHz was developed on and for the Raspberry Pi 3 Model B+. Compatibility with
other Raspberries can probably be achieved by tweaking the device paths in the
`app.py` file, but isn't confirmed at this point. Theoretically, 3 Model B and
Zero W should work out of the box, but models without Wi-Fi will need an
external Wi-Fi adapter if Wi-Fi functionality is desired. The practicality of
compiling Python on the first generation of Raspberry Pis is also very
questionable.
external Wi-Fi adapter if Wi-Fi functionality is desired.
Sensors required for operation are:
- AS7265x
- VEML6075
- APDS-9301
They provide the spectrometry data, UV data and illuminance data, respectively.
They all support I2C, AS7265x supports UART in addition.
TeraHz depends on three separate sensor boards:
- AS7265x spectral chipset
- VEML6075 UV sensor
- APDS-9301 lux-meter
The sensors leech power from the GPIO connector, thus eliminating the need for a
separate power supply. The necessary power for the whole system is delivered through

View File

@@ -1,3 +0,0 @@
interface=wlan0
dhcp-range=192.168.1.10,192.168.1.100,255.255.255.0,24h
address=/terahz.site/192.168.1.1

View File

@@ -1,6 +0,0 @@
#!/bin/bash
# edit_ssid.sh - edits hostapd.conf and sets a MAC address-based SSID
cd `dirname $0`
ssid=`ip link | awk '/wlan0/ {getline; print $2}' | awk -v FS=':' '{printf("TeraHz_%s%s%s\n", $4, $5, $6)}'`
sed "/ssid=.*/s/ssid=.*/ssid=$ssid/" hostapd.conf > newconf
mv newconf hostapd.conf

View File

@@ -1,9 +0,0 @@
interface=wlan0
hw_mode=g
channel=8
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=TeraHz
wpa_passphrase=terahertz

View File

@@ -1,20 +0,0 @@
# install.sh - install TeraHz onto a Raspbian or DietPi installation
cd `dirname $0`
apt -y update
apt -y full-upgrade
apt install -y python3 python3-pip lighttpd dnsmasq hostapd libatlas-base-dev
pip3 install numpy pandas flask smbus2 pyserial gunicorn
cp -R hostapd/ /etc
chmod +rx /etc/hostapd/edit_ssid.sh
cp dnsmasq.conf /etc
cp rc.local /etc
cp interfaces-terahz /etc/network/interfaces.d/
cp -R ../frontend/* /var/www/html
mkdir -p /usr/local/lib/terahz
cp -R ../backend/* /usr/local/lib/terahz
systemctl unmask dnsmasq hostapd lighttpd
systemctl enable dnsmasq hostapd lighttpd

View File

@@ -1,3 +0,0 @@
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0

View File

@@ -1,27 +0,0 @@
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect"
)
server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

View File

@@ -1,16 +0,0 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/etc/hostapd/edit_ssid.sh &
/usr/local/lib/terahz/run.sh &
sleep 3
service hostapd restart # restart hostapd to prevent a weird startup race condition

View File

@@ -1,46 +0,0 @@
// All code in this file is licensed under the ISC license, provided in LICENSE.txt
$('#update').click(function () {
updateData();
});
// jQuery event binder
function updateData () {
const url = 'http://' + window.location.hostname + ':5000/data';
$.ajax({ // spawn an AJAX request
url: url,
success: function (data, status) {
console.log(data);
graphSpectralData(data[0], 0);
fillTableData(data);
},
timeout: 2500 // this should be a pretty sane timeout
});
}
function graphSpectralData (obj, dom) {
// graph spectral data in obj into dom
var graphPoints = [];
var graphXTicks = [];
Object.keys(obj).forEach((element, index) => {
graphPoints.push([index, obj[element]]); // build array of points
graphXTicks.push([index, element]); // build array of axis labels
});
// console.log(graphPoints);
const options = {
grid: {color: 'white'},
xaxis: {ticks: graphXTicks}
};
$.plot('#graph', [graphPoints], options);
// flot expects an array of arrays (lines) of 2-element arrays (points)
}
function fillTableData (obj) {
// fill the obj data into HTML tables
Object.keys(obj[0])
.forEach((element) => { $('#' + element).text(obj[0][element]); });
$('#lx').text(obj[1]);
$('#uva').text(obj[2][0]);
$('#uvb').text(obj[2][1]);
$('#uvi').text(obj[2][2]);
}

View File

@@ -1,162 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<link rel="stylesheet" href="lib/bootstrap.min.css">
<link rel="stylesheet" href="stylesheet.css">
<title>TeraHz</title>
</head>
<body>
<div class="container text-center">
<h1><img src="lib/logo-sq.png" height="64px">TeraHz</h1>
</div>
<div class="container">
<button id="update" class="btn btn-primary m-1 float-right">Get data</button>
<p id="debug">
</p>
<h3>Spectrogram</h3>
<div id="graph" style="height:480px;width:720px"></div>
<h3>Spectral readings</h3>
<table class="table table-dark table-sm" id="specter">
<thead class="thead-dark">
<tr>
<th>Band</th>
<th>Wavelength [nm]</th>
<th>Irradiance [μW/cm²]</th>
</tr>
</thead>
<tr>
<td>A</td>
<td>410 nm</td>
<td id="A">---</td>
</tr>
<tr>
<td>B</td>
<td>435 nm</td>
<td id="B">---</td>
</tr>
<tr>
<td>C</td>
<td>460 nm</td>
<td id="C">---</td>
</tr>
<tr>
<td>D</td>
<td>485 nm</td>
<td id="D">---</td>
</tr>
<tr>
<td>E</td>
<td>510 nm</td>
<td id="E">---</td>
</tr>
<tr>
<td>F</td>
<td>535 nm</td>
<td id="F">---</td>
</tr>
<tr>
<td>G</td>
<td>560 nm</td>
<td id="G">---</td>
</tr>
<tr>
<td>H</td>
<td>585 nm</td>
<td id="H">---</td>
</tr>
<tr>
<td>R</td>
<td>610 nm</td>
<td id="R">---</td>
</tr>
<tr>
<td>I</td>
<td>645 nm</td>
<td id="I">---</td>
</tr>
<tr>
<td>S</td>
<td>680 nm</td>
<td id="S">---</td>
</tr>
<tr>
<td>J</td>
<td>705 nm</td>
<td id="J">---</td>
</tr>
<tr>
<td>T</td>
<td>730 nm</td>
<td id="T">---</td>
</tr>
<tr>
<td>U</td>
<td>760 nm</td>
<td id="U">---</td>
</tr>
<tr class="table-secondary">
<td>V</td>
<td>810 nm</td>
<td id="V">---</td>
</tr>
<tr class="table-secondary">
<td>W</td>
<td>860 nm</td>
<td id="W">---</td>
</tr>
<tr class="table-secondary">
<td>K</td>
<td>900 nm</td>
<td id="K">---</td>
</tr>
<tr class="table-secondary">
<td>L</td>
<td>940 nm</td>
<td id="L">---</td>
</tr>
</table>
<br>
<h3>Lux and UV readings</h3>
<table class="table-dark table" id="luxuv">
<thead class="thead-dark">
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
</thead>
<tr>
<td>Illuminance [lx]</td>
<td id="lx">---</td>
</tr>
<tr>
<td>UVA irradiance [μW/cm²]</td>
<td id="uva">---</td>
</tr>
<tr>
<td>UVB irradiance [μW/cm²]</td>
<td id="uvb">---</td>
</tr>
<tr>
<td>UVA/UVB average [μW/cm²]</td>
<td id="uvi">---</td>
</tr>
</table>
</div>
<script src="lib/bootstrap.bundle.min.js"></script>
<script src="lib/jquery-3.4.1.min.js"></script>
<script src="lib/flot/jquery.flot.js"></script>
<script src="frontend.js"></script>
<script src="lib/flot/jquery.canvaswrapper.js"></script>
<script src="lib/flot/jquery.colorhelpers.js"></script>
<script src="lib/flot/jquery.flot.js"></script>
<script src="lib/flot/jquery.flot.saturated.js"></script>
<script src="lib/flot/jquery.flot.browser.js"></script>
<script src="lib/flot/jquery.flot.drawSeries.js"></script>
<script src="lib/flot/jquery.flot.uiConstants.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

22
setup.py Normal file
View File

@@ -0,0 +1,22 @@
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="terahz", # Replace with your own username
version="1.0.0",
author="Kristjan Komloši",
author_email="kristjan.komlosi@gmail.com",
description="Low cost spectrometry webapp",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/cls-02/TeraHz",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)

46
terahz/app.py Normal file
View File

@@ -0,0 +1,46 @@
# app.py - main backend program
'''Main TeraHz backend program'''
# All code in this file is licensed under the ISC license, provided in LICENSE.txt
from flask import Flask, jsonify, render_template
from . import terahz
def start_flaskapp():
'''Initialize global variables'''
global app, s, u, l
app = Flask(__name__)
s = terahz.Spectrometer(path='/dev/serial0')
u = terahz.UVSensor()
l = terahz.LxMeter()
@app.route('/data')
def sendData():
'''Responder function for /data route'''
response = jsonify([s.getData(), l.getData(), u.getABI()])
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/')
def renderTable():
''''Main page renderer'''
wavelengthDict = {
'A': '410 nm',
'B': '435 nm',
'C': '460 nm',
'D': '485 nm',
'E': '510 nm',
'F': '535 nm',
'G': '560 nm',
'H': '585 nm',
'R': '610 nm',
'I': '645 nm',
'S': '680 nm',
'J': '705 nm',
'T': '730 nm',
'U': '760 nm',
'V': '810 nm',
'W': '860 nm',
'K': '900 nm',
'L': '940 nm'}
data = [s.getData(), l.getData(), u.getABI()]
return render_template('index.html', data=data, wavelengths=wavelengthDict)

42
terahz/static/frontend.js Normal file
View File

@@ -0,0 +1,42 @@
// All code in this file is licensed under the ISC license, provided in LICENSE.txt
$('#update').click(updateData);
// jQuery event binder
function updateData () {
const url = '/data';
$.get(url, (data, status) => {
if (status === '200') {
graphSpectralData(data[0], 0);
fillTableData(data);
} else alert('Data request failed, please refresh page.');
});
}
function graphSpectralData (obj, dom) {
// graph spectral data in obj into dom
var graphPoints = [];
var graphXTicks = [];
const spectrum = 'ABCDEFGHRISJTUVWKL';
for (var i = 0; i < spectrum.length; i++) {
graphPoints.push([i, obj[spectrum[i]]]);
graphXTicks.push([i, spectrum[i]]);
}
const options = {
grid: { color: 'white' },
xaxis: { ticks: graphXTicks }
};
$.plot('#graph', [graphPoints], options);
// flot expects an array of arrays (lines) of 2-element arrays (points)
}
function fillTableData (obj) {
// fill the obj data into HTML tables
Object.keys(obj[0]).forEach((element) =>
{ $('#' + element + '_value').text(obj[0][element]); });
$('#lx').text(obj[1]);
$('#uva').text(obj[2][0]);
$('#uvb').text(obj[2][1]);
$('#uvi').text(obj[2][2]);
}

View File

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 136 KiB

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<link rel="stylesheet" href="static/bootstrap.min.css">
<link rel="stylesheet" href="static/stylesheet.css">
<title>TeraHz</title>
<!-- script imports -->
<script src="static/bootstrap.bundle.min.js"></script>
<script src="static/jquery-3.4.1.min.js"></script>
<script src="static/flot/jquery.flot.js"></script>
<script src="static/frontend.js"></script>
<script src="static/flot/jquery.canvaswrapper.js"></script>
<script src="static/flot/jquery.colorhelpers.js"></script>
<script src="static/flot/jquery.flot.js"></script>
<script src="static/flot/jquery.flot.saturated.js"></script>
<script src="static/flot/jquery.flot.browser.js"></script>
<script src="static/flot/jquery.flot.drawSeries.js"></script>
<script src="static/flot/jquery.flot.uiConstants.js"></script>
</head>
<body>
<div class="container text-center">
<h1><img src="static/logo-sq.png" height="64px">TeraHz</h1>
</div>
<div class="container">
<button id="update" onclick="updateData()" class="btn btn-primary">Get data</button>
<button id="download" class="btn btn-primary">Download</button>
<button id="debug" class="btn btn-danger">DEBUG</button>
</div>
<div class="container">
<div class="row">
<div class="col-sm">
<h4>Spectrogram</h4>
<div id="graph" style="height:480px;width:720px"></div>
</div>
<div class="col-sm">
<h4>Visible+IR spectrum</h4>
<table class="table table-dark table-sm" id="specter">
<thead class="thead-dark">
<tr>
<th>Band</th>
<th>Wavelength [nm]</th>
<th>Irradiance [μW/cm²]</th>
</tr>
</thead>
{% for band, irr in data[0] %}
<tr id="{{band}}">
<td>
{{band}}
</td>
<td>
{{wld[band]}}
</td>
<td id="{{band}}_value">
{{irr}}
</td>
</tr>
{% endfor %}
</table>
</div>
<div class="col-sm">
<h4>UV+Illuminance</h4>
<table class="table-dark table table-sm" id="luxuv">
<thead class="thead-dark">
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
</thead>
<tr>
<td>Illuminance [lx]</td>
<td id="lx">{{data[1]}}</td>
</tr>
<tr>
<td>UVA irradiance [μW/cm²]</td>
<td id="uva">{{data[2][0]}}</td>
</tr>
<tr>
<td>UVB irradiance [μW/cm²]</td>
<td id="uvb">{{data[2][1]}}</td>
</tr>
<tr>
<td>UVA/UVB average [μW/cm²]</td>
<td id="uvi">{{data[2][2]}}</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,6 +1,6 @@
# sensors.py - a module for interfacing to the sensors
# terahz.py - a module for interfacing to the sensors
'''Module for interfacing with TeraHz sensors'''
# Copyright 2019 Kristjan Komloši
# Copyright 2019, 2020 Kristjan Komloši
# All code in this file is licensed under the ISC license, provided in LICENSE.txt
import serial as ser
import pandas as pd
@@ -8,6 +8,7 @@ import smbus2
class Spectrometer:
'''Class representing the AS7265X specrometer'''
def initializeSensor(self):
'''confirm the sensor is responding and proceed\
with spectrometer initialization'''
@@ -23,8 +24,7 @@ class Spectrometer:
if rstring == 'ERROR':
raise Exception # sensor is in error state
except:
raise Exception(
'An exception ocurred when performing spectrometer handshake')
raise Exception('No AT command response')
def setParameters(self, parameters):
'''applies the parameters like LED light and gain to the spectrometer'''
@@ -53,8 +53,7 @@ class Spectrometer:
self.serialObject.write('ATLED3={}\n'.format(led).encode())
self.serialObject.readline()
except:
raise Exception(
'An exception occured during spectrometer initialization')
raise Exception('Error setting spectrometer parameters')
def getData(self):
'''Returns spectral data in a pandas DataFrame.'''
@@ -62,11 +61,10 @@ class Spectrometer:
self.serialObject.write(b'ATCDATA\n')
rawresp = self.serialObject.readline().decode()
except:
raise Exception(
'An exception occurred when polling for spectrometer data')
raise Exception('Error polling spectrometer data')
else:
responseorder = [i for i in 'RSTUVWGHIJKLABCDEF']
realorder = [i for i in 'ABCDEFGHRISJTUVWKL']
responseorder = list('RSTUVWGHIJKLABCDEF')
realorder = list('ABCDEFGHRISJTUVWKL')
response = pd.Series(
[float(i) / 35.0 for i in rawresp[:-3].split(',')], index=responseorder)
return pd.DataFrame(response, index=realorder, columns=['uW/cm^2']).to_dict()['uW/cm^2']
@@ -78,14 +76,14 @@ class Spectrometer:
try:
self.serialObject = ser.Serial(path, baudrate, timeout=tout)
except:
raise Exception(
'An exception occured when opening the serial port at {}'.format(path))
raise Exception('Error opening serial port: {}'.format(path))
else:
self.initializeSensor()
class LxMeter:
'''Class representing the APDS-9301 digital photometer.'''
def __init__(self, busNumber=1, addr=0x39):
self.addr = addr
try:
@@ -93,14 +91,14 @@ class LxMeter:
self.bus = smbus2.SMBus(busNumber)
except:
raise Exception(
'An exception occured opening the SMBus {}'.format(self.bus))
'Error opening SMBus {}'.format(self.bus))
try:
self.bus.write_byte_data(
self.addr, 0xa0, 0x03) # enable the sensor
self.setGain(16)
except:
raise Exception('An exception occured when enabling lux meter')
raise Exception('Error enabling lux meter')
def setGain(self, gain):
'''Set the sensor gain. Either 1 or 16.'''
@@ -109,15 +107,13 @@ class LxMeter:
temp = self.bus.read_byte_data(self.addr, 0xa1)
self.bus.write_byte_data(self.addr, 0xa1, 0xef & temp)
except:
raise Exception(
'An exception occured when setting lux meter gain')
raise Exception('Error setting lux meter gain')
if gain == 16:
try:
temp = self.bus.read_byte_data(self.addr, 0xa1)
self.bus.write_byte_data(self.addr, 0xa1, 0x10 | temp)
except:
raise Exception(
'An exception occured when setting lux meter gain')
raise Exception('Error setting lux meter gain')
else:
raise Exception('Invalid gain')
@@ -160,7 +156,7 @@ class LxMeter:
except:
raise Exception('An exception occured fetching lux channels')
# scary computations ahead! refer to the apds-9301 datasheet!
# Refer to APDS-9301 datasheet!
if chB / chA <= 0.5 and chB / chA > 0:
lux = 0.0304 * chA - 0.062 * chA * (chB / chA)**1.4
elif chB / chA <= 0.61 and chB / chA > 0.5:
@@ -176,6 +172,7 @@ class LxMeter:
class UVSensor:
'''Class representing VEML6075 UVA/B meter'''
def __init__(self, bus=1, addr=0x10):
self.addr = addr
try:
@@ -187,9 +184,16 @@ class UVSensor:
try:
# enable the sensor and set the integration time
self.bus.write_byte_data(self.addr, 0x00, 0b00010000)
# trigger a measurement to prevent bus errors at first read
self.bus.write_byte_data(self.addr, 0x00, 0b00010010) # UV_AF=1
self.bus.write_byte_data(self.addr, 0x00, 0b00010110) # UV_TRIG=1
self.bus.write_byte_data(
self.addr, 0x00, 0b00010000) # normal mode
except:
raise Exception(
'An exception occured when initalizing the UV Sensor')
'Error initalizing the UV Sensor')
def getABI(self):
'''Calculates the UVA and UVB irradiances,
@@ -202,40 +206,16 @@ class UVSensor:
c1 = self.bus.read_word_data(self.addr, 0x0a)
c2 = self.bus.read_word_data(self.addr, 0x0b)
except:
raise Exception('An exception occured when fetching raw UV data')
# scary computations ahead! refer to Vishay app note 84339 and Sparkfun
# VEML6075 documentation.
# compensate for visible and IR noise
aCorr = aRaw - 2.22 * c1 - 1.33 * c2
bCorr = bRaw - 2.95 * c1 - 1.74 * c2
# convert values into irradiances
a = aCorr * 1.06
b = bCorr * 0.48
# zero out negative results (readings with no uv)
if a < 0:
a = 0
if b < 0:
b = 0
# last, calculate the UV index
i = (a + b) / 2
raise Exception('Error fetching raw UV data')
# Refer to Vishay app note 84339 and Sparkfun VEML6075 documentation.
# The computed values may be negative if UV is vastly weaker than
# visible and IR light. This is not a bug!
a = (aRaw - 2.22 * c1 - 1.33 * c2) * 1.06
b = (bRaw - 2.95 * c1 - 1.74 * c2) * 0.48
i = (a + b) / 2 # calculate UV index
return [a, b, i]
def getA(self):
'''Returns UVA value. A getABI() wrapper.'''
return self.getABI()[0]
def getB(self):
'''Returns UVB value. A getABI() wrapper.'''
return self.getABI()[1]
def getI(self):
'''Returns UV index. A getABI() wrapper.'''
return self.getABI()[2]
def on(self):
'''Turns the UV sensor on after shutdown.'''
try:
@@ -244,7 +224,7 @@ class UVSensor:
self.bus.write_byte_data(self.addr, 0x00, 0x10)
except:
raise Exception(
'An exception occured when turning the UV sensor on')
'Error turning the UV sensor on')
def off(self):
'''Shuts the UV sensor down.'''
@@ -254,4 +234,4 @@ class UVSensor:
self.bus.write_byte_data(self.addr, 0x00, 0x11)
except:
raise Exception(
'An exception occured when shutting the UV sensor down')
'Error shutting the UV sensor down')

View File

@@ -1,45 +0,0 @@
# getcdata.py - fetch the calibrated data from the AS7265x module
# All code in this file is licensed under the ISC license, provided in LICENSE.txt
import serial as ser
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import time
#global variables
uartpath = '/dev/ttyUSB0'
uartbaud = 115200
uarttout = 5
wl = [410, 435, 460, 485, 510, 535, 560, 585, 610, 645, 680, 705, 730, 760, 810, 860, 900, 940]
responseorder = [i for i in 'RSTUVWGHIJKLABCDEF'] # works, do NOT touch!
realorder = [i for i in 'ABCDEFGHRISJTUVWKL']
print('getcdata')
print('This utility is part of the TeraHz project')
wavelens = pd.Series(realorder)
plt.ion()
win = plt.figure()
spectrum=win.add_subplot(111)
with ser.Serial(uartpath, uartbaud, timeout=uarttout) as sensor:
while True:
sensor.write(b'ATCDATA\n')
rawresp = sensor.readline().decode()
# parses, calculates and saves the data
response = pd.Series([float(i)/35.0 for i in rawresp[:-3].split(',')], index=responseorder)
data = pd.DataFrame(response, index=realorder, columns = ['uW/cm^2']) # puts data into a DataFrame
data.insert(0, 'wavelenght', wl) #inserts a legend
print(data)
spectrum.cla()
spectrum.plot(data['wavelenght'], data['uW/cm^2'])
spectrum.set_xlabel('Valovna dolžina')
spectrum.set_ylabel('uW/cm2')
win.canvas.draw()
time.sleep(0.1)

View File

@@ -1,12 +0,0 @@
import smbus2
bus = smbus2.SMBus(1)
result = bus.read_byte_data(0x39, 0x8a)
print('LUX Meter ID = {}'.format(result))
result = bus.read_word_data(0x10, 0x0c)
print('UV sensor ID = {}'.format(result))
result = bus.read_word_data(0x39, 0xec)
print('LUX chan 0 = {}'.format(result))

View File

@@ -1,22 +0,0 @@
from serial import Serial
import tkinter as tk
import pandas as pd
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
uartpath = '/dev/ttyUSB0'
uartbaud = 115200
uarttout = 5
wl = [410, 435, 460, 485, 510, 535, 560, 585, 610, 645, 680, 705, 730, 760, 810, 860, 900, 940]
responseorder = [i for i in 'RSTUVWGHIJKLABCDEF'] # works, do NOT touch!
realorder = [i for i in 'ABCDEFGHRISJTUVWKL']
root = tk.Tk()
root.wm_title('TeraHz Demo')
fig = Figure(figsize=(5, 4), dpi=100)
plot = fig.add_subplot(111)
canvas = FigureCanvasTkAgg(fig, master=root)