You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://github.com/n-elia/MAX30102-MicroPython-driver/actions/workflows/python-publish.yml)[](https://badge.fury.io/py/micropython-max30102)
2
2
# Maxim MAX30102 MicroPython driver
3
3
4
4
A port of the SparkFun driver for Maxim MAX30102 sensor to MicroPython.
5
-
It _should_ work for MAX30105, too. Please check if it works for MAX30105 and report in the Discussions section :)
5
+
6
+
It _should_ work for MAX30105, too. If you have the chance to test this library with a MAX30105, please leave your feedback in the Discussions section.
6
7
7
8
## Aknowledgements
8
9
@@ -31,14 +32,19 @@ This work is not intended to be used in professional environments, and there are
31
32
- Driver: `./max30102`
32
33
- Example: `./example`
33
34
34
-
## Additional information
35
-
36
-
This driver has been tested with Maxim Integrated MAX30102 sensor.
37
-
However, it *should* work with MAX30105 sensor, too.
35
+
## Changelog
36
+
- v0.3.4
37
+
- The package has been refactored to be compliant to PEP standards.
38
+
- v0.3.3
39
+
- Made a PyPi package. Now you can install this package with upip.
40
+
- Tested with Raspberry Pi Pico and non-genuine sensors.
41
+
- v0.3
42
+
- Tested with TinyPico board (based on ESP32-D4) and genuine Maxim MAX30102 sensor.
38
43
39
-
### How to import the library and run the example
44
+
## How to import the library and run the example
45
+
Important note: the library will load the default TinyPico ESP32 board I2C configuration (SDA Pin 21, SCL Pin 22, 400kHz speed). If you're using a different board, follow the instructions given below, in *Setup and configuration* section.
40
46
41
-
####Including this library into your project (network-enabled MicroPython ports)
47
+
### Including this library into your project (**network-enabled MicroPython ports**)
42
48
To include the library into a network-enabled MicroPython project, it's sufficient to install the package:
43
49
44
50
```python
@@ -50,32 +56,37 @@ Make sure that your firmware runs these lines **after** an Internet connection h
50
56
51
57
To run the example in `./example` folder, please set your WiFi credentials in `boot.py` and then upload `./example` content into your microcontroller. If you prefer, you can perform a manual install as explained below.
52
58
53
-
####Including this library into your project (manual way)
59
+
### Including this library into your project (**manual way**)
54
60
55
-
To directly include the library into a MicroPython project, it's sufficient to copy the `max30102` module next to your `main.py`, and then import it as follows:
61
+
To directly include the library into a MicroPython project, it's sufficient to copy `max30102/circular_buffer.py` and `max30102/max30102.py`next to your `main.py` file. Then, import the constructor as follows:
56
62
57
63
```python
58
64
from max30102 importMAX30102
59
65
```
60
66
61
-
For instance, to run the example in `./example` folder, copy the `./max30102` directory and paste it in the `./example` folder. Then, upload `./example` content into your microcontroller and run it.
67
+
To run the example in `./example` folder, copy `max30102/circular_buffer.py` and `max30102/max30102.py` into the `./example` directory. Then, upload the `./example` directory content into your microcontroller.
68
+
69
+
70
+
### Setup and configuration
71
+
#### I2C pins
62
72
63
-
#### Setup and configuration
73
+
When creating a sensor instance, if you leave the arguments empty, the library will load the default TinyPico ESP32 board I2C configuration (SDA Pin 21, SCL Pin 22, 400kHz speed).
64
74
65
-
At first, create a sensor instance. If you leave the arguments empty, the library will load the default TinyPico ESP32 board I2C configuration (SDA Pin 21, SCL Pin 22, 400kHz speed).
75
+
If you have a different board, you can set different I2C pins as shown in the following example:
Then, the sensor has to be setup. The library provides a method to setup the sensor at once. Leaving the arguments empty, makes the library load their default values.
80
91
81
92
> Default configuration values:
@@ -104,44 +115,44 @@ The library provides the methods to change the configuration parameters one by o
104
115
105
116
```python
106
117
# Set the number of samples to be averaged by the chip
However, there are some limitations on sensor side and on micropocessor side that may affect the acquisition rate (see issue #6 for more details about it). Is is possible to measure the real throughput as in [this](https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library/blob/master/examples/Example9_RateTesting/Example9_RateTesting.ino) example sketch by SparkFun, using the following snippet:
@@ -195,33 +206,33 @@ from utime import ticks_diff, ticks_ms
195
206
# Starting time of the acquisition
196
207
t_start = ticks_ms()
197
208
# Number of samples that has been collected
198
-
samples_n =0
199
-
200
-
while(True):
201
-
sensor.check()
202
-
203
-
if(sensor.available()):
204
-
# Access the storage FIFO and gather the readings (integers)
205
-
red_sample = sensor.popRedFromStorage()
206
-
ir_sample = sensor.popIRFromStorage()
207
-
208
-
# We can compute the real frequency at which we receive data
209
-
if (compute_frequency):
210
-
samples_n=samples_n+1
211
-
if (ticks_diff(ticks_ms(), t_start) >999):
212
-
f_HZ = samples_n/1
213
-
samples_n =0
214
-
t_start = ticks_ms()
215
-
print("Acquisition frequency = ",f_HZ)
209
+
samples_n =0
210
+
211
+
while(True):
212
+
sensor.check()
213
+
214
+
if(sensor.available()):
215
+
# Access the storage FIFO and gather the readings (integers)
216
+
red_sample = sensor.pop_red_from_storage()
217
+
ir_sample = sensor.pop_ir_from_storage()
218
+
219
+
# We can compute the real frequency at which we receive data
220
+
if (compute_frequency):
221
+
samples_n =samples_n+1
222
+
if (ticks_diff(ticks_ms(), t_start) >999):
223
+
f_HZ = samples_n/1
224
+
samples_n =0
225
+
t_start = ticks_ms()
226
+
print("Acquisition frequency = ",f_HZ)
216
227
```
217
228
218
229
#### Die temperature reading
219
230
220
-
The `readTemperature()` method allows to read the internal die temperature. An example is proposed below.
231
+
The `read_temperature()` method allows to read the internal die temperature. An example is proposed below.
0 commit comments