Skip to content

Commit

Permalink
update example info
Browse files Browse the repository at this point in the history
  • Loading branch information
avaldebe committed Apr 17, 2020
1 parent 4e2385f commit b6e5df3
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"CKSUM",
"HCHO",
"HWSERIAL",
"Hzatmega",
"MCU",
"PMSA",
"PMSerial",
"Plantower",
"SERIALPM",
"UART",
"USART",
"atmelavr",
"atmelsam",
"bluepill",
"chlen",
"datasheet",
Expand All @@ -24,6 +27,8 @@
"nbin",
"rhum",
"samd",
"stlink",
"ststm",
"uint"
]
}
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The sensor type inference does not cover the `PMS5003S` and `PMS5003T` variants,

### PMSx003 on HardwareSerial

```arduino
```c++
#include <PMserial.h>
SerialPM pms(PMSx003, Serial); // PMSx003, UART

Expand All @@ -83,7 +83,7 @@ Setup for different MCU is covered on the [HardwareSerial][] example.
### PMSx003 on SoftwareSerial
```arduino
```c++
#include <PMserial.h>
SerialPM pms(PMSx003, 10, 11); // PMSx003, RX, TX
Expand All @@ -108,30 +108,30 @@ Setup for different MCU is covered on the [SoftwareSerial][] example.
On some ESP32 boards Serial1 default pins are connected to the flash.
Using the standard constructor will cause a crash, see [espressif/arduino-esp32#148](https://github.com/espressif/arduino-esp32/issues/148).

```Arduino
```c++
// will crash the ESP32
SerialPM pms(PMSx003, Serial1);
````
```
Fortunately, it is possible to define alternative for pins by calling:
```Arduino
```c++
// define Serial1 pins
Serial1.begin(9600, SERIAL_8N1, <RX>, <TX>);
```

The PMSerial library uses this feature to implement the flexibility of SoftwareSerial

```Arduino
```c++
// define Serial1 pins
SerialPM pms(PMSx003, <RX>, <TX>);
````
```
The [SoftwareSerial example][esp32hw] uses Serial1 on pins 23 (RX) and 19 (TX).
The [HardwareSerial example][esp32hw] uses Serial2.
[esp32hw]: examples/HardwareSerial/README.md#mhetesp32minikit
[esp32sw]: examples/SoftwareSerial/README.md#mhetesp32minikit
[esp32hw]: examples/HardwareSerial/README.md#esp32-minikit
[esp32sw]: examples/SoftwareSerial/README.md#esp32-minikit
## Advanced usage
Expand Down Expand Up @@ -215,7 +215,7 @@ The available status/error codes and pre-defined error messages are:
For easy of use, the error message are pre-defined with `#define`.
See the [examples](examples/) for error handling implementation.
## Contribute back
## Contribute
If you have read this far, this is the library for your project
or you can not figure out how to use it. In any case, I can use your help.
Expand Down
84 changes: 70 additions & 14 deletions examples/HardwareSerial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

Read PMS5003 sensor on Serial/Serial1/Serial2, depending on the board.

## Arduino `leonardo`
## [Arduino Leonardo](https://docs.platformio.org/en/latest/boards/atmelavr/leonardo.html)

**Note** This is a 5V board, and the PMS5003 RX/TX pins are 3.3V.
You need to add a logic level converter, or use a 3.3V version of this board.

- Serial1 on pins 0 (RX) and 1 (TX).

```ini
[env:leonardo]
framework = arduino
platform = atmelavr
board = leonardo
build_flags = -D USE_HWSERIAL1
```

```bash
# compile
platformio run -e leonardo
Expand All @@ -20,7 +28,7 @@ platformio run -e leonardo -t upload
platformio run -e leonardo -t monitor
```

## Arduino `mega2560`
## [Arduino Mega 2560](https://docs.platformio.org/en/latest/boards/atmelavr/megaatmega2560.html)

**Note** This is a 5V board, and the PMS5003 RX/TX pins are 3.3V.
You need to add a logic level converter, or use a 3.3V version of this board.
Expand All @@ -31,6 +39,14 @@ You need to add a logic level converter, or use a 3.3V version of this board.

This example uses Serial1.

```ini
[env:mega2560]
framework = arduino
platform = atmelavr
board = megaatmega2560
build_flags = -D USE_HWSERIAL1
```

```bash
# compile
platformio run -e mega2560
Expand All @@ -42,7 +58,7 @@ platformio run -e mega2560 -t upload
platformio run -e mega2560 -t monitor
```

## STM32 `genericSTM32F103C8`
## [STM32F103C8](https://docs.platformio.org/en/latest/boards/ststm32/genericSTM32F103C8.html)

**Note** This is a 3.3V board, and the PMS5003 requires 5V.
You need provide 5V for the fan to operate properly.
Expand All @@ -53,6 +69,15 @@ You need provide 5V for the fan to operate properly.

This example uses Serial1.

```ini
[env:genericSTM32F103C8]
framework = arduino
platform = ststm32
board = genericSTM32F103C8
upload_protocol = stlink
build_flags = -D USE_HWSERIAL1
```

```bash
# compile
platformio run -e genericSTM32F103C8
Expand All @@ -64,7 +89,7 @@ platformio run -e genericSTM32F103C8 -t upload
platformio run -e genericSTM32F103C8 -t monitor
```

## STM32 `maple_mini`
## [STM32 Maple Mini](https://docs.platformio.org/en/latest/boards/ststm32/maple_mini_b20.html)

**Note** This is a 3.3V board, and the PMS5003 requires 5V.
You need provide 5V for the fan to operate properly.
Expand All @@ -75,6 +100,14 @@ You need provide 5V for the fan to operate properly.

This example uses Serial2.

```ini
[env:maple_mini]
framework = arduino
platform = ststm32
board = maple_mini_b20
build_flags = -D USE_HWSERIAL2
```

```bash
# compile
platformio run -e maple_mini
Expand All @@ -86,7 +119,7 @@ platformio run -e maple_mini -t upload
platformio run -e maple_mini -t monitor
```

## ESP8266 `esp01`
## [ESP8266 ESP-01 512k](https://docs.platformio.org/en/latest/boards/espressif8266/esp01.html)

**Note** This is a 3.3V board, and the PMS5003 requires 5V.

Expand All @@ -96,6 +129,13 @@ This example used Serial for communicating with the sensor
and printing the sensor values.
Some garbage between printouts is to be expected.

```ini
[env:esp01]
framework = arduino
platform = espressif8266
board = esp01
```

```bash
# compile
platformio run -e esp01
Expand All @@ -107,7 +147,7 @@ platformio run -e esp01 -t upload
platformio run -e esp01 -t monitor
```

## ESP32 `mhetesp32minikit`
## [ESP32 MiniKit](https://docs.platformio.org/en/latest/boards/espressif32/mhetesp32minikit.html)

**Note** This is a 3.3V board, and the PMS5003 requires 5V.
You need provide 5V for the fan to operate properly.
Expand All @@ -118,29 +158,37 @@ You need provide 5V for the fan to operate properly.
On some ESP32 boards Serial1 default pins are connected to the flash.
Using the standard constructor will cause a crash, see [espressif/arduino-esp32#148](https://github.com/espressif/arduino-esp32/issues/148).

```Arduino
```c++
// will crash the ESP32
SerialPM pms(PMSx003, Serial1);
````
```
Fortunately, it is possible to define alternative for pins by calling:
```Arduino
```c++
// define Serial1 pins
Serial1.begin(9600, SERIAL_8N1, <RX>, <TX>);
```

The PMSerial library uses this feature to implement the flexibility of SoftwareSerial

```Arduino
```c++
// define Serial1 pins
SerialPM pms(PMS5003, <RX>, <TX>);
````
```
The [SoftwareSerial example][esp32sw] uses Serial1 on pins 23 (RX) and 19 (TX).
This example uses Serial2.
[esp32sw]: ../SoftwareSerial/README.md#mhetesp32minikit
[esp32sw]: ../SoftwareSerial/README.md#esp32-minikit
```ini
[env:esp32minikit]
framework = arduino
platform = espressif32
board = mhetesp32minikit
build_flags = -D USE_HWSERIAL2
```

```bash
# compile
Expand All @@ -153,13 +201,21 @@ platformio run -e esp32minikit -t upload
platformio run -e esp32minikit -t monitor
```

## Arduino `mkrwifi1010`
## [Arduino MKR WiFi 1010](https://docs.platformio.org/en/latest/boards/atmelsam/mkrwifi1010.html)

**Note** This is a 3.3V board, and the PMS5003 requires 5V.
You need provide 5V for the fan to operate properly.

- Serial1 on pins 13 (RX) and 14 (TX).

```ini
[env:mkrwifi1010]
framework = arduino
platform = atmelsam
board = mkrwifi1010
build_flags = -D USE_HWSERIAL1
```

```bash
# compile
platformio run -e mkrwifi1010
Expand All @@ -169,4 +225,4 @@ platformio run -e mkrwifi1010 -t upload

# open serial monitor
platformio run -e mkrwifi1010 -t monitor
```
```
2 changes: 1 addition & 1 deletion examples/HardwareSerial/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ build_flags = -D USE_HWSERIAL2
platform = espressif8266
board = esp01

[env:mhetesp32minikit]
[env:esp32minikit]
platform = espressif32
board = mhetesp32minikit
build_flags = -D USE_HWSERIAL2
Expand Down
Loading

0 comments on commit b6e5df3

Please sign in to comment.