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
description: Automate simulations in Wokwi using YAML-based automation scenarios. Simulate button presses, sensor input, and verify serial output to test firmware programmatically.
Automation scenarios allow you to automate the simulation, push buttons, change the state of the sensors, and check the serial output. You can use automation scenarios to test your firmware in a realistic environment, and verify that it behaves as expected.
9
11
10
12
Each automation scenario is a YAML file that describes a sequence of actions that the simulator should take. You can use the `--scenario` CLI option to load an automation scenario file.
11
13
14
+
## Scenario File Structure
15
+
12
16
The basic structure of an automation scenario file is as follows:
13
17
14
18
```yaml
@@ -30,6 +34,178 @@ steps:
30
34
Automation scenarios are currently in alpha. The API is not fully documented yet, and may change in the future. You can use the [example projects](github-actions#examples) as a reference.
31
35
:::
32
36
37
+
## Available Steps
38
+
39
+
These can be used as a sequence of actions to perform when running the scenario. Use these to build a list of steps for
40
+
testing your project.
41
+
42
+
### Wait (`delay`)
43
+
Wait for an amount of time.
44
+
45
+
#### Parameters
46
+
| Name | Description |
47
+
| :- | :- |
48
+
| `value` | Amount of time to wait for. Units are required (e.g. `200ms`) |
49
+
50
+
#### Example Usage
51
+
```yaml
52
+
delay: 30ms
53
+
```
54
+
55
+
### Assert Pin Value (`expect-pin`)
56
+
Check if a pin is set to an expected value.
57
+
58
+
#### Parameters
59
+
| Name | Description |
60
+
| :- | :- |
61
+
| `part-id` | ID of the target compontent |
62
+
| `pin` | Name of pin to check |
63
+
| `value` | Expected value of the pin |
64
+
65
+
#### Example Usage
66
+
```yaml
67
+
expect-pin:
68
+
part-id: esp
69
+
pin: 2
70
+
expected: 1
71
+
```
72
+
73
+
### Control a Part (`set-control`)
74
+
Set a controllable part of a compontent to a specified value. View part documentation for available controls or see a
75
+
list of [supported parts](#supported-parts-with-automation-controls) below.
76
+
77
+
#### Parameters
78
+
| Name | Description |
79
+
| :- | :- |
80
+
| `part-id` | ID of the target compontent |
81
+
| `control` | Aspect of the target compontent to modify (e.g. temperature, humidity) |
82
+
| `value` | Value to set the `control` to |
83
+
84
+
#### Example Usage
85
+
```yaml
86
+
set-control:
87
+
part-id: dht
88
+
control: humidity
89
+
value: 39
90
+
```
91
+
92
+
### Wait and Match Text from Serial (`wait-serial`)
93
+
Wait for serial console output which matches a given string.
94
+
95
+
#### Parameters
96
+
| Name | Description |
97
+
| :- | :- |
98
+
| `text` | String to wait and match for |
99
+
100
+
#### Example Usage
101
+
```yaml
102
+
wait-serial: 'Ready for testing!'
103
+
```
104
+
105
+
### Write to Serial (`write-serial`)
106
+
Write text or an array of numbers to the serial console.
107
+
108
+
#### Parameters
109
+
| Name | Description |
110
+
| :- | :- |
111
+
| `value` | The string or array of numbers to write to the serial console |
[DHT22 Sensor Test (ESP32)] Expected text matched: "DHT22 test!"
200
+
Humidity: 45.80% Temperature: 23.50°C
201
+
[DHT22 Sensor Test (ESP32)] Expected text matched: "Humidity: 45.80% Temperature: 23.50°C"
202
+
Humidity: 45.80% Temperature: 23.50°C
203
+
[DHT22 Sensor Test (ESP32)] Expected text matched: "Humidity: 45.80% Temperature: 23.50°C"
204
+
Humidity: 66.90% Temperature: 21.50°C
205
+
[DHT22 Sensor Test (ESP32)] Expected text matched: "Humidity: 66.90% Temperature: 21.50°C"
206
+
[DHT22 Sensor Test (ESP32)] Scenario completed successfully
207
+
```
208
+
33
209
## Supported Parts with Automation Controls
34
210
35
211
Several Wokwi parts support automation controls that can be controlled using automation scenarios. These controls allow you to programmatically change the state of sensors, press buttons, and modify component values during simulation.
0 commit comments