Skip to content

Commit 929d016

Browse files
authored
refactor display and update_task to use Delay trait, enhance sensor d… (#16)
* refactor display and update_task to use Delay trait, enhance sensor data handling with SoilMoistureRawLevel * refactor sensor_task to improve battery voltage sample handling and logging
1 parent 6e33e34 commit 929d016

File tree

9 files changed

+166
-167
lines changed

9 files changed

+166
-167
lines changed

.github/workflows/rust_ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
uses: esp-rs/[email protected]
3333
with:
3434
default: true
35-
buildtargets: esp32
35+
buildtargets: esp32s3
3636
ldproxy: false
37-
version: "1.84.0"
37+
version: "1.85.0"
3838
- name: Enable caching
3939
uses: Swatinem/rust-cache@v2
4040
- name: Run build

Cargo.lock

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ esp-backtrace = { version = "0.15.0", features = [
1010
"panic-handler",
1111
"defmt",
1212
] }
13-
esp-hal = { version = "1.0.0-beta.0", features = ["esp32s3", "defmt", "unstable"] }
13+
esp-hal = { version = "1.0.0-beta.0", features = [
14+
"esp32s3",
15+
"defmt",
16+
"unstable",
17+
] }
1418
esp-alloc = { version = "0.7.0" }
1519
embassy-net = { version = "0.6.0", features = [
1620
"tcp",
@@ -43,7 +47,7 @@ rust-mqtt = { version = "0.3.0", default-features = false, features = [
4347
embedded-text = "0.7.2"
4448
embedded-graphics = { version = "0.8.1", features = ["defmt"] }
4549
embedded-hal = { version = "1.0.0", features = ["defmt-03"] }
46-
serde = { version = "1.0.215", default-features = false, features = ["derive"] }
50+
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
4751
serde_json = { version = "1.0.133", default-features = false, features = [
4852
"alloc",
4953
] }

README.md

+38-82
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ESP32 Plant Watering System
22

3-
A microcontroller-based system for automated plant watering with ESP32. Monitor soil moisture and control watering pump.
3+
A microcontroller-based system for automated plant watering with ESP32. Monitor soil moisture and control the watering pump.
44

55
Built for [LilyGO T-Display-S3](https://github.com/Xinyuan-LilyGO/T-Display-S3) ESP32-S3 development board
66

@@ -18,7 +18,6 @@ Built for [LilyGO T-Display-S3](https://github.com/Xinyuan-LilyGO/T-Display-S3)
1818
- DHT11 Digital (Temperature/Humidity) → GPIO1
1919
- Water Pump Relay → GPIO2
2020
- Battery Voltage → GPIO4
21-
- Moisture Digital → GPIO10
2221
- Moisture Analog → GPIO11
2322
- Moisture Power → GPIO18
2423
- Water Level Analog → GPIO12
@@ -29,7 +28,7 @@ Built for [LilyGO T-Display-S3](https://github.com/Xinyuan-LilyGO/T-Display-S3)
2928
- **Sensor Integration**
3029

3130
- DHT11 temperature/humidity monitoring
32-
- Capacitive soil moisture sensing
31+
- Capacitive soil moisture sensing (analog)
3332
- Water level detection
3433
- Battery voltage monitoring
3534

@@ -57,52 +56,44 @@ Built for [LilyGO T-Display-S3](https://github.com/Xinyuan-LilyGO/T-Display-S3)
5756

5857
The project uses several Rust crates to provide functionality:
5958

60-
## Async/Embedded Frameworks
59+
### Async/Embedded Frameworks
6160

62-
These crates provide support for asynchronous programming models and embedded futures.
63-
64-
- [`embassy`](https://crates.io/crates/embassy)
65-
- [`embassy-executor`](https://crates.io/crates/embassy-executor)
66-
- [`embassy-futures`](https://crates.io/crates/embassy-futures)
67-
- [`embassy-net`](https://crates.io/crates/embassy-net)
68-
- [`embassy-sync`](https://crates.io/crates/embassy-sync)
69-
- [`embassy-time`](https://crates.io/crates/embassy-time)
61+
- [embassy](https://crates.io/crates/embassy)
62+
- [embassy-executor](https://crates.io/crates/embassy-executor)
63+
- [embassy-futures](https://crates.io/crates/embassy-futures)
64+
- [embassy-net](https://crates.io/crates/embassy-net)
65+
- [embassy-sync](https://crates.io/crates/embassy-sync)
66+
- [embassy-time](https://crates.io/crates/embassy-time)
7067

7168
---
7269

73-
## Hardware Abstraction & Embedded I/O
74-
75-
These crates are used to interact with embedded hardware and interfaces.
70+
### Hardware Abstraction & Embedded I/O
7671

77-
- [`embedded-hal`](https://crates.io/crates/embedded-hal)
78-
- [`embedded-text`](https://crates.io/crates/embedded-text)
79-
- [`embedded-graphics`](https://crates.io/crates/embedded-graphics)
72+
- [embedded-hal](https://crates.io/crates/embedded-hal)
73+
- [embedded-text](https://crates.io/crates/embedded-text)
74+
- [embedded-graphics](https://crates.io/crates/embedded-graphics)
8075

8176
---
8277

83-
## Networking
84-
85-
Crates for network communication and protocols.
78+
### Networking
8679

87-
- [`rust-mqtt`](https://crates.io/crates/rust-mqtt)
88-
- [`esp-wifi`](https://crates.io/crates/esp-wifi)
80+
- [rust-mqtt](https://crates.io/crates/rust-mqtt)
81+
- [esp-wifi](https://crates.io/crates/esp-wifi)
8982

9083
---
9184

92-
## ESP32-Specific Crates
93-
94-
Crates related to ESP32 platforms, Wi-Fi support, and memory management.
85+
### ESP32-Specific Crates
9586

96-
- [`esp-alloc`](https://crates.io/crates/esp-alloc)
97-
- [`esp-backtrace`](https://crates.io/crates/esp-backtrace)
98-
- [`esp-hal`](https://crates.io/crates/esp-hal)
99-
- [`esp-hal-embassy`](https://crates.io/crates/esp-hal-embassy)
87+
- [esp-alloc](https://crates.io/crates/esp-alloc)
88+
- [esp-backtrace](https://crates.io/crates/esp-backtrace)
89+
- [esp-hal](https://crates.io/crates/esp-hal)
90+
- [esp-hal-embassy](https://crates.io/crates/esp-hal-embassy)
10091

10192
---
10293

103-
## Display
94+
### Display
10495

105-
The project uses the built-in 1.9" ST7789 LCD display (170x320) on the T-Display-S3 with the following pins:
96+
The built-in 1.9" ST7789 LCD display on the T-Display-S3 has the following pin configuration:
10697

10798
- Backlight: GPIO38
10899
- CS: GPIO6
@@ -112,37 +103,25 @@ The project uses the built-in 1.9" ST7789 LCD display (170x320) on the T-Display
112103
- RD: GPIO9
113104
- Data pins: GPIO39-42, GPIO45-48
114105

115-
- [`mipidsi`](https://crates.io/crates/mipidsi)
106+
- [mipidsi](https://crates.io/crates/mipidsi)
116107

117108
---
118109

119-
## Sensor Support
110+
### Serialization
120111

121-
Crates for interfacing with sensors like DHT11.
122-
123-
- [`embedded-dht-rs`](https://github.com/rust-dd/embedded-dht-rs)
112+
- [serde](https://crates.io/crates/serde)
113+
- [serde_json](https://crates.io/crates/serde_json)
124114

125115
---
126116

127-
## Serialization
128-
129-
Crates for data serialization and deserialization.
117+
### Miscellaneous
130118

131-
- [`serde`](https://crates.io/crates/serde)
132-
- [`serde_json`](https://crates.io/crates/serde_json)
133-
134-
---
135-
136-
## Miscellaneous
137-
138-
Other supporting crates for various use cases.
139-
140-
- [`heapless`](https://crates.io/crates/heapless)
141-
- [`static_cell`](https://crates.io/crates/static_cell)
142-
- [`rand_core`](https://crates.io/crates/rand_core)
143-
- [`defmt`](https://crates.io/crates/defmt)
144-
- [`defmt-rtt`](https://crates.io/crates/defmt-rtt)
145-
- and more...
119+
- [heapless](https://crates.io/crates/heapless)
120+
- [static_cell](https://crates.io/crates/static_cell)
121+
- [rand_core](https://crates.io/crates/rand_core)
122+
- [defmt](https://crates.io/crates/defmt)
123+
- [defmt-rtt](https://crates.io/crates/defmt-rtt)
124+
- ...and others
146125

147126
---
148127

@@ -159,17 +138,14 @@ cd esp32-homecontrol-no-std-rs
159138

160139
### 2. Install Rust and the necessary tools
161140

162-
https://docs.esp-rs.org/book/introduction.html
141+
See the [ESP-RS book](https://docs.esp-rs.org/book/introduction.html).
163142

164-
Install espup
165-
https://github.com/esp-rs/espup
166-
and probe-rs
167-
https://github.com/probe-rs/probe-rs
143+
Install espup: [espup GitHub](https://github.com/esp-rs/espup)
144+
Install probe-rs: [probe-rs GitHub](https://github.com/probe-rs/probe-rs)
168145

169146
```sh
170147
espup install
171148
. $HOME/export-esp.sh
172-
173149
```
174150

175151
---
@@ -185,7 +161,7 @@ cp .env.dist .env
185161

186162
## Usage
187163

188-
To flash the firmware to your ESP32 device, use the following command:
164+
To flash the firmware to your ESP32 device, run:
189165

190166
```sh
191167
cargo run --release
@@ -199,69 +175,49 @@ cargo run --release
199175

200176
- [DHCP Wi-Fi Example with Embassy](https://github.com/esp-rs/esp-hal/blob/main/examples/src/bin/wifi_embassy_dhcp.rs)
201177

202-
---
203-
204178
### MQTT Communication
205179

206180
- [MQTT Example](https://github.com/etiennetremel/esp32-home-sensor/blob/fff5f7ca4055e38ed5c296d0544fa8e61d855388/src/main.rs)
207181

208-
---
209-
210182
### Display Interfaces
211183

212184
- [MIDISPI Example with Display](https://github.com/embassy-rs/embassy/blob/227e073fca97bcbcec42d9705e0a8ef19fc433b5/examples/rp/src/bin/spi_gc9a01.rs#L6)
213185
- [Display Example via SPI](https://github.com/embassy-rs/embassy/blob/227e073fca97bcbcec42d9705e0a8ef19fc433b5/examples/rp/src/bin/spi_display.rs#L6)
214186

215-
---
216-
217187
### Sensors
218188

219189
- [DHT11 Sensor Integration Example](https://github.com/rust-dd/embedded-dht-rs)
220190
- [Moisture Sensor Example](https://github.com/nand-nor/plant-minder/blob/4bc70142a9ec11e860b5422deb9d85ad192bab66/pmindp-esp32-thread/src/sensor/probe_circuit.rs#L63)
221191

222-
---
223-
224192
### UI & Graphics
225193

226194
- [Icons and UI Example with Display & Publish](https://github.com/sambenko/esp32s3box-display-and-publish)
227195

228-
---
229-
230196
### Projects and Games
231197

232198
- [Pacman Game Example](https://github.com/georgik/esp32-spooky-maze-game)
233199
- [Motion Sensors & Body Tracking Example](https://github.com/SlimeVR/SlimeVR-Rust/blob/9eff429f4f01c8b7c607f3c3988de82729c753b3/firmware/src/peripherals/esp32/esp32c3.rs#L38)
234200

235-
---
236-
237201
### Networking
238202

239203
- [Netstack & MQTT Struct Example](https://github.com/mirkomartn/esp32c3-embassy-poc/blob/9ad954dcba19897a973e3453fd83196829eee485/src/netstack.rs)
240204
- [HTTP Request Example with Embassy](https://github.com/embassy-rs/embassy/blob/86578acaa4d4dbed06ed4fcecec25884f6883e82/examples/rp/src/bin/wifi_webrequest.rs#L136)
241205
- [NTP Socket Example](https://github.com/vpetrigo/sntpc/blob/2711f17d42b9a681ced02639780fe72cd8042b36/examples/smoltcp-request/src/main.rs)
242206

243-
---
244-
245207
### Miscellaneous Examples
246208

247209
- [Joystick Analog Pin Input Example](https://github.com/WJKPK/rc-car/blob/f1ce37658c7b8b6cbc47c844243ea8b90d1e1483/pilot/src/main.rs)
248210
- [Battery Monitoring Example](https://github.com/longxiangam/work_timer/blob/788c0bee18ec47adce07e3ba71e884920e6473e1/src/battery.rs)
249211

250-
---
251-
252212
### Tutorials
253213

254214
- [ESP32 Rust HAL Tutorials](https://blog.theembeddedrustacean.com/series/esp32c3-embedded-rust-hal)
255215

256-
---
257-
258216
### Advanced Examples
259217

260218
- [Futures Example](https://github.com/kamo104/esp32-rust-mqtt-esp-now-gateway/blob/main/src/main.rs)
261219
- [Sleep, Display Layout, Logging, Dashboard, Multiple Tasks](https://github.com/claudiomattera/esp32c3-embassy/blob/master/esp32c3-embassy/src/sleep.rs)
262220

263-
---
264-
265221
### Bitcoin Device, USB, & OTA Updates
266222

267223
- [Fancy Bitcoin Device with GUI Example](https://github.com/frostsnap/frostsnap/blob/0b2d589bcf8a0863e1067595aae8c9376cfb4867/device/src/graphics/animation.rs)

0 commit comments

Comments
 (0)