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
-[x]`analogRead`: NodeMCU command(s): `adc.read` or custom sensor command
65
-
-[ ]`reset_all`: Reset state machine, NodeMCU command(s): `gpio.write`, `pwm.setduty`
66
-
-[x]`poll`: return cached values of `digitalRead`, `analogRead`
67
+
-[x]`Set network` (`initNet`): Initialize WiFi subnet (only one subnet is supported simultaneously), IP address is a sum of subnet address and device id.
68
+
-[x]`set pin` (`pinMode`): NodeMCU command(s): `gpio.mode` or `pwm.setup` + `pwm.start`
-[x] (`reset_all`): Reset state machine, NodeMCU command(s): `gpio.write`, `pwm.setduty`
77
+
-[x]- (`poll`): return cached values of `digitalRead`, `analogRead`
67
78
68
79
Bridge Features:
69
80
-[x] Supporting more NodeMCUs in one WiFi network
@@ -73,14 +84,15 @@ Bridge Features:
73
84
-[x] Overload protection by batch command sending (programmatically configured)
74
85
-[x] Overload protection by rare poll and caching digitalRead/analogRead values
75
86
-[ ] Overload protection by queue size limitation (drop)
76
-
-[] Name resolution (instead of IP address)
87
+
-[x] Name resolution (instead of IP address)
77
88
-[ ] Unit tests
78
89
79
90
Controller Features:
91
+
-[x] Basic digital pin handling (mode, high/low, PWM)
80
92
-[ ]`analogRead`: `adc.read` registers value to D16 (virtual)
81
93
-[x]`analogPairWrite`: transform a [-100,+100] value to 2 pins of H-bridge for a DC motor
82
-
-[]`tankWrite`: transform a joystick value pair ([-100,+100], [-100,+100]) to pins of H-bridge for 2 DC motor
83
-
-[]`getName`: returns Bridge name
94
+
-[x]`tankWrite`: transform a joystick value pair ([-100,+100], [-100,+100]) to pins of H-bridge for 2 DC motor
95
+
-[x]`getName`: returns Bridge name
84
96
-[ ] Too small PWM value is overwritten to 0 (for DC motors)
85
97
-[x] WiFi station and AP mode
86
98
-[x] MAC-based configuration
@@ -90,7 +102,7 @@ Controller Features:
90
102
-[ ] Send values back to RoboRemo
91
103
-[ ] TCP
92
104
-[x] Supporting more NodeMCUs in one WiFi network, for Bridge
93
-
-[] Supporting more NodeMCUs in one WiFi network, for Roboremo (Controller proxy)
105
+
-[x] Supporting more NodeMCUs in one WiFi network, for Roboremo (UDP broadcast)
94
106
-[x] HC-SR04 sensor support
95
107
-[ ] DHT sensor support
96
108
-[ ] BMP180 sensor support
@@ -120,7 +132,7 @@ D8 pin works well with Pololu DRV8833 as B2 input, but activates motor B with ch
120
132
121
133
HC-SR04 needs 5V power, Echo pin output is 5V, too (3.3V input is good for Trig). A 4k7 with built-in 10k Pull-down resistor behave as a voltage divider, see: [HC-SR04 Ultrasonic Range Sensor on the Raspberry Pi](http://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi).
122
134
123
-
Pin D4 is used by shields [DHT](http://www.wemos.cc/Products/dht_shield.html) and [DHT Pro](http://www.wemos.cc/Products/dht_pro_shield.html).
135
+
Pin D4 is used by WeMos shields [DHT](http://www.wemos.cc/Products/dht_shield.html) and [DHT Pro](http://www.wemos.cc/Products/dht_pro_shield.html).
124
136
125
137
Other pinout can also be used.
126
138
@@ -133,6 +145,29 @@ Copy `secure.lua.example` to `secure.lua` and edit own WiFi authentication confi
133
145
134
146
[ESPlorer](http://esp8266.ru/esplorer/) can be used to upload Lua files to ESP. Upload all `*.lua` files of directory `lua` to NodeMCU. After reset, NodeMCU will be ready to receive commands and send back input values.
135
147
148
+
#### Socat
149
+
`socat` can be used for testing Controller without any GUIs (Scratch, RoboRemo). Socat can be installed on Cygwin and Linux. Anoter famous program, `netcat`, also can send UDP messages, but cannot send from and receive to same port.
150
+
151
+
Example for sending commands to a specific IP address (Scratch use case):
There are several online portals, where broadcast address can be calculated, for example: [http://www.subnet-calculator.com/](IP Subnet Calculator).
170
+
136
171
### Bridge
137
172
Bridge requires Python 2.7. Command line options will be printed out by `--help` parameter.
138
173
@@ -155,26 +190,38 @@ Pyton 2.7 package installation is described at the Linux distributor. Example fo
155
190
Install [Scratch 2 Offline Editor](https://scratch.mit.edu/scratch2download). Import ESP42S extension description `src/ESP4S2.s2e` (shift-click on "File" and select "Import Experimental Extension" from the menu). The new extension blocks will appear in the More Blocks palette.
156
191
157
192
### RoboRemo
158
-
[RoboRemo](http://www.roboremo.com) can be installed on Android by [Google Play](https://play.google.com/store/apps/details?id=com.hardcodedjoy.roboremo).
193
+
[RoboRemo](http://www.roboremo.com) can be installed for Android by [Google Play](https://play.google.com/store/apps/details?id=com.hardcodedjoy.roboremo).
194
+
195
+
#### Single Controller
159
196
To connect RoboRemo to Controller, use "Internet (UDP)" connection. Example for a connection string: `192.168.10.102:9876`, where the ip and port was set up in `lua/config.lua`.
160
197
A button should be created for initialize pins. Example init button configuration for a H-bridged DC motor on pins 5, 6 and a LED on pin 4:
* set press action (`\n` is also supported instead of Enter):
199
+
```
200
+
pinMode 4 1
201
+
pinMode 5 3
202
+
pinMode 6 3
203
+
```
162
204
* repeat: delay, period = `0`, `only press action`
163
205
164
206
Example on/off button configuration for a LED on pin 4:
165
-
* set press action: `digitalWrite 4 1` or `digitalWrite 4 0`, depending on a pull-up resistor on the pin.
207
+
* set press action: `digitalWrite 4 1` or `digitalWrite 4 0`, depending on a pull-up resistor of the pin.
166
208
* repeat: delay, period = `0`, `only press action`
167
209
168
210
Example slider for a H-bridged DC motor on pins 5, 6:
169
211
* set id: `analogPairWrite 5 6`
170
212
* set min, max: min = `-100`, max = `100`
171
-
* send when released (tricky: `send when mover` should be seen)
213
+
* send when released (tricky: `send when move` should be seen)
172
214
* set repeat period: `500` ms
173
215
216
+
#### Multiple Controllers
217
+
RoboRemo cannot connect to multiple IP addresses. In this case, the boradcast IP address of subnet can be used. For example, if the subnet is 192.168.10.0/24, the broadcast address is 192.168.10.255. There are several online portals, where broadcast address can be calculated, for example: [http://www.subnet-calculator.com/](IP Subnet Calculator). The command sending to this address will be received by all of Controllers. The target Controller name must be marked by the beginning of the command, for example: `tank-tower pinMode 4 1`, `tank-tower pinMode 4 1`, `tank-tower digitalWrite 4 1`. Without marking the Controller name, all of Controller will execute the command.
218
+
174
219
## Scratch Programer's Guide
175
-
After starting Bridge (`src/ESP4S2.py`) and loading ESP42S extension description (`src/ESP4S2.s2e`), Scratch is ready to create block programs. The first block which must be executed is the `Set network`, for example: .
176
-
This block initializes Bridge and requests Controllers to send its names for name resolution. One second must be wait to collect responses from Controllers.
177
220
221
+
### First steps
222
+
After starting Bridge (`src/ESP4S2.py`) and loading ESP42S extension description (`src/ESP4S2.s2e`), Scratch is ready to create block programs. The first block which must be executed is the `Set network`. This block initializes Bridge and requests Controllers to send its names back for name resolution. Example for `Set network` block: , where `192.168.10.0` is the subnet ID and `24` is the subnet mask bits. There are several online portals, where subnet ID and subnet mask bits can be calculated, for example: [http://www.subnet-calculator.com/](IP Subnet Calculator). One second must be wait to collect responses from Controllers, for example: .
223
+
224
+
### Blocks
178
225
Pin mode must be set before using a pin (`set pin`). A block can be executed immediately (`E`) or with the next (`W`). More blocks can be bundled to one group until the first `E` block. The last block of execution bundle must be `E`. Examples for bundled blocks:
@@ -190,3 +237,32 @@ H-bridged DC motors can be controlled by `analog write pin pair` block, for exam
190
237
Values can be used by blocks `digital read pin` and `analog read pin`, for example:
191
238
*
192
239
*
240
+
241
+
### LED project
242
+
It's the "Hello, World!" example of microcontroller world. Built-in blue LED of WeMos is connected to pin `4`. Because of built-in pull-up resistor, LED behaves opposite. After starting Controller and Bridge, please create the below project:
243
+
244
+

245
+
246
+
Click once on `Set network`. The `192.168.10.0/24` network will be used for communicating to Bridges. It will be valid until Brigde running. Depending on the network setup (WiFi router, ESP AP), the network can be different.
247
+
248
+
Click on . Block `set pin` will set pin `4` to OUTPUT.
249
+
250
+
When `o` key pressed, pin 4 will be set Low (`0`). Because of built-in pull-up resistor, LED will be turned on. When `x` key pressed, pin 4 will be set High (`1`). Because of built-in pull-up resistor, LED will be turned off.
251
+
252
+
Click on  to stop all pins.
253
+
254
+
### PWM project
255
+
This project demonstrates PWM. Because of built-in pull-up resistor on pin `4`, LED behaves opposite: it will ligth strongest by setting PWM duty cycle to 0% and LED will be turned off by setting PWM duty cycle 100%. After starting Controller and Bridge, please create the below project:
256
+
257
+

258
+
259
+
Click once on `Set network`. It will be valid until Brigde running.
260
+
261
+
Click on . Block `set pin` will set pin `4` to PWM.
0 commit comments