Skip to content

Commit 567b6a9

Browse files
committed
Create structure
1 parent 8e0e4b5 commit 567b6a9

8 files changed

Lines changed: 387 additions & 1 deletion

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MANIFEST
2+
__pycache__
3+
*.egg-info
4+
*/dist/
5+
*.org
6+
*.1

README.md

Lines changed: 381 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,381 @@
1-
# micropython-steami-lib
1+
# micropython-steami-lib
2+
3+
This repository contains all the drivers for the main components of the [STeaMi](https://www.steami.cc/) board. These drivers are written for MicroPython and are designed to be used either in the construction of the official MicroPython firmware for the STeaMi board or independently for custom projects.
4+
5+
## Repository Contents
6+
7+
The repository is organized as follows:
8+
9+
```
10+
micropython-steami-lib/
11+
├── lib/ # Drivers for the different components
12+
│ ├── bq27441/ # Battery gauge BQ27441-G1
13+
│ │ ├── README.md # Component-specific documentation
14+
│ │ ├── manifest.py # Manifest file for firmware inclusion
15+
│ │ ├── bq27441/ # Driver source code
16+
│ │ └── examples/ # Usage examples
17+
│ ├── w2564jv/ # SPI flash memory W2564JV-DTR
18+
│ ├── ssd1327/ # OLED display controller SSD1327ZB
19+
│ ├── mcp23009/ # I2C I/O expander MCP23009
20+
│ ├── vl53l1cx/ # Distance sensor VL53L1CX
21+
│ ├── apds9960/ # Gesture and color sensor APDS-9960
22+
│ ├── wsen_hids/ # Humidity sensor WSEN-HIDS 2525020210001
23+
│ ├── ism330dlc/ # Accelerometer and gyroscope ISM330DLCTR
24+
│ ├── lis2mdl/ # Magnetometer LIS2MDLTR
25+
│ ├── wsen_pads/ # Pressure sensor WSEN-PADS 25110202133011
26+
│ ├── im34dt05/ # Digital microphone IM34DT05
27+
├── LICENSE # Project license
28+
└── README.md # This file
29+
```
30+
31+
## Installation
32+
33+
### Method 1: Using mpremote
34+
35+
To use the drivers without permanent installation, you can use `mpremote` to mount the desired driver on your STeaMi board and run examples.
36+
37+
1. Make sure you have installed `mpremote`:
38+
39+
```bash
40+
pip install mpremote
41+
```
42+
43+
2. Connect your STeaMi board to your computer via USB.
44+
45+
3. Mount the driver and run an example (see the specific section for each driver below).
46+
47+
### Method 2: Permanent Installation
48+
49+
If you want to permanently install the drivers on your board:
50+
51+
```bash
52+
mpremote cp -r lib/<driver>/<driver_folder> :lib/
53+
```
54+
55+
For example, to install the SSD1327 display driver:
56+
57+
```bash
58+
mpremote cp -r lib/ssd1327/ssd1327 :lib/
59+
```
60+
61+
## Using the Drivers
62+
63+
Here's the documentation for each driver available in this repository:
64+
65+
### BQ27441-G1 (Battery Gauge)
66+
67+
The BQ27441-G1 is a precision battery gauge that monitors battery status.
68+
69+
#### Mounting and Running an Example
70+
71+
```bash
72+
# Mount the driver and run the example
73+
mpremote mount lib/bq27441 run lib/bq27441/examples/fuel_gauge.py
74+
```
75+
76+
#### Basic API
77+
78+
```python
79+
from bq27441 import BQ27441
80+
81+
# Initialization with default I2C
82+
i2c = machine.I2C(0)
83+
bq = BQ27441(i2c)
84+
85+
# Reading battery information
86+
bq.state_of_charge() # State of charge in %
87+
bq.voltage() # Voltage in mV
88+
bq.current_average() # Average current discharge in mA
89+
bq.capacity_full() # Full capacity in mAh
90+
bq.capacity_remaining() # Remaining capacity in mAh
91+
```
92+
93+
### W2564JV-DTR (SPI Flash Memory)
94+
95+
The W2564JV-DTR is a 64 Mbit SPI flash memory.
96+
97+
#### Mounting and Running an Example
98+
99+
```bash
100+
# Mount the driver and run the example
101+
mpremote mount lib/w2564jv run lib/w2564jv/examples/flash_read_write.py
102+
```
103+
104+
#### Basic API
105+
106+
```python
107+
from w2564jv import W2564JV
108+
109+
# Initialization with SPI
110+
spi = machine.SPI(0)
111+
cs = machine.Pin(5, machine.Pin.OUT)
112+
flash = W2564JV(spi, cs)
113+
114+
# Reading and writing
115+
data = b'Hello, STeaMi!'
116+
flash.write(0, data)
117+
read_data = flash.read(0, len(data))
118+
```
119+
120+
### SSD1327ZB (OLED Display Controller)
121+
122+
The SSD1327ZB is a monochrome OLED display controller.
123+
124+
#### Mounting and Running an Example
125+
126+
```bash
127+
# Mount the driver and run the example
128+
mpremote mount lib/ssd1327 run lib/ssd1327/examples/helloworld.py
129+
```
130+
131+
#### Basic API
132+
133+
```python
134+
from ssd1327 import SSD1327
135+
136+
# Initialization
137+
spi = SPI(1)
138+
dc = Pin("DATA_COMMAND_DISPLAY")
139+
res = Pin("RST_DISPLAY")
140+
cs = Pin("CS_DISPLAY")
141+
142+
display = ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs)
143+
144+
# Display
145+
display.fill(0) # Clear the screen
146+
display.text("STeaMi", 0, 0) # Display text
147+
display.show() # Update the display
148+
```
149+
150+
### MCP23009 (I2C I/O Expander)
151+
152+
The MCP23009 is an 8-bit I/O expander with I2C interface.
153+
154+
#### Mounting and Running an Example
155+
156+
```bash
157+
# Mount the driver and run the example
158+
mpremote mount lib/mcp23009 run lib/mcp23009/examples/gpio_control.py
159+
```
160+
161+
#### Basic API
162+
163+
```python
164+
from mcp23009 import MCP23009
165+
166+
# Initialization
167+
i2c = machine.I2C(1)
168+
mcp = MCP23009(i2c)
169+
170+
# Pin configuration and control
171+
mcp.setup(0, MCP23009.OUT) # Configure pin 0 as output
172+
mcp.output(0, 1) # Set pin 0 high
173+
mcp.setup(1, MCP23009.IN) # Configure pin 1 as input
174+
value = mcp.input(1) # Read pin 1 state
175+
```
176+
177+
### VL53L1CX (ToF Distance Sensor)
178+
179+
The VL53L1CX is a precision time-of-flight (ToF) distance sensor.
180+
181+
#### Mounting and Running an Example
182+
183+
```bash
184+
# Mount the driver and run the example
185+
mpremote mount lib/vl53l1cx run lib/vl53l1cx/examples/distance.py
186+
```
187+
188+
#### Basic API
189+
190+
```python
191+
from vl53l1cx import VL53L1CX
192+
193+
# Initialization
194+
i2c = machine.I2C(1)
195+
tof = VL53L1CX(i2c)
196+
197+
# Configuration and measurement
198+
distance = tof.read() # Distance in mm
199+
200+
```
201+
202+
### ISM330DLCTR (Accelerometer and Gyroscope)
203+
204+
The ISM330DLCTR is a 6DOF inertial module integrating accelerometer and gyroscope.
205+
206+
#### Mounting and Running an Example
207+
208+
```bash
209+
# Mount the driver and run the example
210+
mpremote mount lib/ism330dlc run lib/ism330dlc/examples/imu_reading.py
211+
```
212+
213+
#### Basic API
214+
215+
```python
216+
from ism330dlc import ISM330DLC
217+
218+
# Initialization
219+
i2c = machine.I2C(1)
220+
imu = ISM330DLC(i2c)
221+
222+
# Reading values
223+
accel_x, accel_y, accel_z = imu.read_accel()
224+
gyro_x, gyro_y, gyro_z = imu.read_gyro()
225+
226+
# Configuration
227+
imu.set_accel_odr(ISM330DLC.ACCEL_ODR_104HZ)
228+
imu.set_gyro_odr(ISM330DLC.GYRO_ODR_104HZ)
229+
```
230+
231+
### APDS-9960 (Gesture and Color Sensor)
232+
233+
The APDS-9960 is a proximity, gesture, color, and ambient light sensor.
234+
235+
#### Mounting and Running an Example
236+
237+
```bash
238+
# Mount the driver and run the example
239+
mpremote mount lib/apds9960 run lib/apds9960/examples/ambient_light.py
240+
```
241+
242+
#### Basic API
243+
244+
```python
245+
from apds9960 import APDS9960
246+
247+
# Initialization
248+
i2c = machine.I2C(1)
249+
apds = APDS9960(i2c)
250+
251+
apds.enableLightSensor()
252+
light = apds.readAmbientLight()
253+
254+
```
255+
256+
### WSEN-HIDS (Humidity Sensor)
257+
258+
The WSEN-HIDS 2525020210001 is a high-precision humidity and temperature sensor.
259+
260+
#### Mounting and Running an Example
261+
262+
```bash
263+
# Mount the driver and run the example
264+
mpremote mount lib/wsen_hids run lib/wsen_hids/examples/humidity.py
265+
```
266+
267+
#### Basic API
268+
269+
```python
270+
from wsen_hids import WSEN_HIDS
271+
272+
# Initialization
273+
i2c = machine.I2C(1)
274+
hids = WSEN_HIDS(i2c)
275+
276+
# Reading values
277+
humidity = hids.humidity() # Relative humidity in %
278+
temperature = hids.temperature() # Temperature in °C
279+
```
280+
281+
### LIS2MDLTR (Magnetometer)
282+
283+
The LIS2MDLTR is a high-precision 3-axis magnetometer.
284+
285+
#### Mounting and Running an Example
286+
287+
```bash
288+
# Mount the driver and run the example
289+
mpremote mount lib/lis2mdl run lib/lis2mdl/examples/compass.py
290+
```
291+
292+
#### Basic API
293+
294+
```python
295+
from lis2mdl import LIS2MDL
296+
297+
# Initialization
298+
i2c = machine.I2C(1)
299+
mag = LIS2MDL(i2c)
300+
301+
# Reading values
302+
mag_x, mag_y, mag_z = mag.read_mag()
303+
304+
# Configuration
305+
mag.set_data_rate(LIS2MDL.DATA_RATE_10HZ)
306+
```
307+
308+
### WSEN-PADS (Pressure Sensor)
309+
310+
The WSEN-PADS 25110202133011 is a high-precision pressure and temperature sensor.
311+
312+
#### Mounting and Running an Example
313+
314+
```bash
315+
# Mount the driver and run the example
316+
mpremote mount lib/wsen_pads run lib/wsen_pads/examples/pressure.py
317+
```
318+
319+
#### Basic API
320+
321+
```python
322+
from wsen_pads import WSEN_PADS
323+
324+
# Initialization
325+
i2c = machine.I2C(1)
326+
pads = WSEN_PADS(i2c)
327+
328+
# Reading values
329+
pressure = pads.pressure() # Pressure in hPa
330+
temperature = pads.temperature() # Temperature in °C
331+
```
332+
333+
### IM34DT05 (Digital Microphone)
334+
335+
The IM34DT05 is a MEMS digital microphone with PDM interface.
336+
337+
#### Mounting and Running an Example
338+
339+
```bash
340+
# Mount the driver and run the example
341+
mpremote mount lib/im34dt05 run lib/im34dt05/examples/sound_level.py
342+
```
343+
344+
#### Basic API
345+
346+
```python
347+
from im34dt05 import IM34DT05
348+
349+
# Initialization
350+
clock_pin = machine.Pin(MIC_CLK, machine.Pin.OUT)
351+
data_pin = machine.Pin(MIC_IN, machine.Pin.IN)
352+
mic = IM34DT05(clock_pin, data_pin)
353+
354+
# Audio acquisition
355+
mic.start()
356+
samples = mic.read_samples(1024)
357+
mic.stop()
358+
359+
# Audio processing
360+
level = mic.sound_level(samples) # Sound level in dB
361+
```
362+
363+
## Contributing
364+
365+
Contributions are welcome! Here's how you can contribute:
366+
367+
1. Fork the repository
368+
2. Create a branch for your feature (`git checkout -b my-new-feature`)
369+
3. Commit your changes (`git commit -am 'Add a new feature'`)
370+
4. Push to the branch (`git push origin my-new-feature`)
371+
5. Create a new Pull Request
372+
373+
## License
374+
375+
This project is licensed under the [GPL v3](LICENSE) License. See the LICENSE file for more details.
376+
377+
## Additional Resources
378+
379+
- [STeaMi Official Website](https://www.steami.cc/)
380+
- [MicroPython Documentation](https://docs.micropython.org/)
381+
- [mpremote Documentation](https://docs.micropython.org/en/latest/reference/mpremote.html)

lib/ism330dl/.gitkeep

Whitespace-only changes.

lib/lis2mdl/.gitkeep

Whitespace-only changes.

lib/mcp23009e/.gitkeep

Whitespace-only changes.

lib/w2564jv/.gitkeep

Whitespace-only changes.

lib/wsen-hids/.gitkeep

Whitespace-only changes.

lib/wsen-pads/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)