Skip to content

Commit c616d5d

Browse files
committed
initial commit
0 parents  commit c616d5d

20 files changed

+17223
-0
lines changed

.gitignore

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/
133+
134+
# pytype static type analyzer
135+
.pytype/
136+
137+
# Cython debug symbols
138+
cython_debug/

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Projet airSU
2+
3+
![](doc/m5_sen0220.jpg =350x)
4+
5+
## Matériel
6+
7+
* Capteur SEN0220
8+
* M5 Gray
9+
* Batterie M5Stack M002
10+
* Horloge DS3231 avec pile
11+
* Carte microSD (FAT32)
12+
* Chargeur USB + cable rallonge USB
13+
14+
15+
## Branchement
16+
17+
18+
* Capteur SEN0220
19+
20+
|SEN0220| fil | M5stack |
21+
|-------|--------|---------|
22+
| 5V |rouge | 5V |
23+
| GND |noir | GND |
24+
| TX |bleu |GPIO17/T2|
25+
| RX |vert |GPIO16/R2|
26+
27+
28+
Remarque : il n'y a pas d'inversion entre RX et TX.
29+
30+
* DS3231
31+
32+
|DS3231 |M5stack|
33+
|--------|-------|
34+
| - | GND |
35+
| + | 5V |
36+
|D(data) | G2 |
37+
|C(clock)| G5 |
38+
39+
Les branchements peuvent être effectués sur un M5 PROTO
40+
41+
![](doc/face_arriere.jpg =350x)
42+
43+
## Flasher le firmware
44+
45+
On peut soit utiliser un outil graphique sous windows (Download Flash Tool https://www.espressif.com/en/support/download/other-tools) soit l'outil en ligne de command esptools.
46+
47+
La ligne de commande pour esptool sera (remplacer /dev/ttuUSB0 par le port COMxx sous windows ):
48+
49+
python -m esptool --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x0 app_output.bin
50+
51+
## Fichiers
52+
53+
Le projet est écrit en utilisant <a href=https://github.com/m5stack/M5Stack_MicroPython>micropython pour le M5 stack</a>.
54+
55+
* lib : librairie pour le capteur et l'horloge RTC
56+
* main : contient le script principale de l'appication
57+
* bin : fichier binaire à installer
58+
* doc : documentation
59+
* notebook : exemple de notebook jupyter pour analyser les données

build/appplication_v0.1_black.bin

4 MB
Binary file not shown.

build/appplication_v0.1_grey.bin

4 MB
Binary file not shown.

doc/compilation.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Compilation
2+
3+
## Micropython
4+
5+
Normalemement, il n'est pas nécéssaire de recompiler micropython cependant cette étage permet d'avoir sous la main les utilitaires pour créer les fichiers binaires.
6+
7+
Télécharger Micropython pour le M5 ici : <a href=https://github.com/m5stack/M5Stack_MicroPython>micropython pour le M5 stack</a> et suivre les instructions.
8+
9+
## Mémoire flash
10+
11+
L'ESP32 contient une mémoire flash qui est partagé en plusieurs espaces : bootloader, micropython et un système de fichier. Cette étape a pour but de 1/ créer une image binaire du système de fichier et 2/ regrouper tous les espaces de la mémoire flash en un seul fichier que l'on pourra distribuer.
12+
13+
### Système de fichier :
14+
15+
Mettre tous les fichiers dans un repertoire (ici /tmp/image) et executer:
16+
17+
./MicroPython_BUILD/components/mkspiffs/mkspiffs -c /tmp/image -b 4096 -p 256 -s 2621440 ./MicroPython_BUILD/build/spiffs_image.img
18+
19+
### Fusion des fichiers binaires :
20+
21+
On utilise merge_bin_esp.py disponible <a href="https://github.com/vtunr/esp32_binary_merger">ici</a>. Il faut utiliser python2.
22+
23+
Ligne de commande deppuis le repertoire MicroPython_BUILD/build:
24+
25+
python2 merge_bin_esp.py --output_name app_output.bin --bin_path bootloader/bootloader.bin phy_init_data.bin MicroPython.bin partitions_mpy.bin spiffs_image.img --bin_address 0x1000 0xf000 0x10000 0x8000 0x180000
26+
27+
Le fichier binaire se trouve dans output/app_output.bin
28+
29+
30+

doc/face_arriere.jpg

959 KB
Loading

doc/m5_sen0220.jpg

428 KB
Loading

images/physique_SU.bmp

17.5 KB
Binary file not shown.

images/physique_SU.jpg

12.1 KB
Loading

lib/SEN0220.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Author : Pierre Cladé
2+
""" Driver for the SEN0220 (MH-Z19) CO2 sensor on ESP32
3+
4+
Usage :
5+
uart = UART(2, tx=17, rx=16)
6+
sensor = SEN0220(uart)
7+
sensor.concentration
8+
"""
9+
10+
from machine import UART
11+
from utime import sleep
12+
13+
READ_GAS_CONCENTATION = b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'
14+
CALIBRATE = b'\xff\x01\x87\x00\x00\x00\x00\x00\x78'
15+
16+
class SEN0220(object):
17+
def __init__(self, uart=None):
18+
if uart is None:
19+
uart = UART(2, tx=17, rx=16)
20+
uart.init(9600, bits=8, parity=None, stop=1)
21+
self.uart = uart
22+
23+
def read_concentration(self):
24+
self.uart.write(READ_GAS_CONCENTATION)
25+
sleep(0.001)
26+
out = self.uart.read()
27+
if len(out)==0:
28+
return 0
29+
return out[2]*256 + out[3]
30+
31+
@property
32+
def concentration(self):
33+
return self.read_concentration()
34+
35+
def calibrate(self):
36+
self.uart.write(CALIBRATE)
37+

0 commit comments

Comments
 (0)