Skip to content

Commit

Permalink
added link to EasyEDA project
Browse files Browse the repository at this point in the history
  • Loading branch information
PBrunot committed Feb 4, 2024
1 parent 1d48cbd commit 32df3b3
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,46 @@ Test suite : [![Test suite](https://github.com/PBrunot/rfid-arduino-copy/actions

* Together with the [backend project](https://github.com/fablab-bergamo/rfid-backend) which can run on a Raspberry Pi Zero, it manages user authentication, track machine usage / maintenance needs.

* Assembled version:
* Assembled version:

![image](https://github.com/fablab-bergamo/rfid-arduino/assets/6236243/9898c6a5-cc16-4479-851a-b326ad31a4d6)

* It uses MQTT to talk to the backend. Machine control is achieved through an external relay.

* View hardware project (WORK IN PROGRESS) on EASYEDA : [Electrical scheme, BOM, PCB](https://oshwlab.com/pascal.brunot/rfid-arduino-fablab-bg)

## Hardware requirements

- ESP32, ESP32-S2 or ESP32-S3 chips
- WiFi connection to the backend
- RFID reader (using mfrc522 compatible chip)
- LCD driver (using Hitachi HD44780 compatible chip)
- 3.3V Relay (or [Shelly](https://www.shellyitalia.com/shelly-plus-1-mini-gen3/) MQTT device)
- 3.3V Buzzer
- A LED or NeoPixel
- RFID tags or cards for user authentication
* ESP32, ESP32-S2 or ESP32-S3 chips
* WiFi connection to the backend
* RFID reader (using mfrc522 compatible chip)
* LCD driver (using Hitachi HD44780 compatible chip)
* 3.3V Relay (or [Shelly](https://www.shellyitalia.com/shelly-plus-1-mini-gen3/) MQTT device)
* 3.3V Buzzer
* A LED or NeoPixel
* RFID tags or cards for user authentication

### Other requirements

- MQTT Broker on WiFi network. Board can also work in offline mode with whitelisted RFID tags.
* MQTT Broker on WiFi network. Board can also work in offline mode with whitelisted RFID tags.

> Tested with Mosquitto. See the backend side project in [Github rfid-backend](https://github.com/fablab-bergamo/rfid-backend)
## Build environment

- Language: C++20 with ArduinoFramework for ESP32
- IDE: VSCode + Platform.io extension as a minimun
- To build, rename <code>secrets.hpp.example</code> to <code>secrets.hpp</code>.
* Language: C++20 with ArduinoFramework for ESP32
* IDE: VSCode + Platform.io extension as a minimun
* To build, rename <code>secrets.hpp.example</code> to <code>secrets.hpp</code>.

> Platform IO can be used from command-line without VSCode <code>pio run</code>
> CMakeList.txt is generated from platform.io, do not use other build tools directly (ESP, cmake...)
- To use hostname for MQTT server, mDNS is used by the Arduino stack built over ESP-IDF 4.4. When Arduino core for ESP will move to ESP-IDF 5.0+ an additional dependency to mDNS will be needed as mDNS is now an independent component.
* To use hostname for MQTT server, mDNS is used by the Arduino stack built over ESP-IDF 4.4. When Arduino core for ESP will move to ESP-IDF 5.0+ an additional dependency to mDNS will be needed as mDNS is now an independent component.

## TEST Suite

- A set a test scripts based on Platformio+Unity is included in the project.
- There are two ways to run the tests:
* A set a test scripts based on Platformio+Unity is included in the project.
* There are two ways to run the tests:

1. Use real hardware connected over USB with Platform.io command

Expand All @@ -58,24 +60,24 @@ pio test --environment esp32-s3

## DEMO - view it in the browser

- Download latest <code>esp32-wokwi.zip</code> file from Github Actions / platformio.yml / Artifacts
- Extract <code>esp32-wokwi.bin</code> file from artifact ZIP
- Open WOKWI Circuit [link](https://wokwi.com/projects/363448917434192897)
- In code editor, press F1 > Upload firmware ... and pick the <code>esp32-wokwi.bin</code> file
* Download latest <code>esp32-wokwi.zip</code> file from Github Actions / platformio.yml / Artifacts
* Extract <code>esp32-wokwi.bin</code> file from artifact ZIP
* Open WOKWI Circuit [link](https://wokwi.com/projects/363448917434192897)
* In code editor, press F1 > Upload firmware ... and pick the <code>esp32-wokwi.bin</code> file

![image](https://github.com/fablab-bergamo/rfid-arduino/assets/6236243/5c41092e-f8bf-451a-95ec-8dc6d7e07824)

- When the preprocessor constant <code>WOKWI_SIMULATION</code> is set to true:
- RFID chip is replaced with a mockup simulating random RFID tags from whitelist from time to time (<code>MockRFIDWrapper</code> class).
- A simple MQTT broker (<code>MockMQTTBroker</code> class) is run in a separate thread on esp32s2
* When the preprocessor constant <code>WOKWI_SIMULATION</code> is set to true:
* RFID chip is replaced with a mockup simulating random RFID tags from whitelist from time to time (<code>MockRFIDWrapper</code> class).
* A simple MQTT broker (<code>MockMQTTBroker</code> class) is run in a separate thread on esp32s2

## Configuration steps (/conf folder)

- See <code>pins.hpp</code> to set the GPIO pins for LCD parallel interface, relay, buzzer and RFID reader SPI interface.
- See <code>conf.hpp</code> to configure LCD dimensions, timeouts, debug logs and some behaviours (e.g. time before to power off the machine)
- See <code>secrets.hpp</code> to configure network SSID/Password credentials, MQTT credentials and whitelisted RFID tags
* See <code>pins.hpp</code> to set the GPIO pins for LCD parallel interface, relay, buzzer and RFID reader SPI interface.
* See <code>conf.hpp</code> to configure LCD dimensions, timeouts, debug logs and some behaviours (e.g. time before to power off the machine)
* See <code>secrets.hpp</code> to configure network SSID/Password credentials, MQTT credentials and whitelisted RFID tags

- A configuration portal based on WiFiManager allows to configured WiFi credentials, MQTT Broker address and Shelly topic (facultative). This makes editing <code>conf.hpp</code> required only for MQTT Broker credentials settings.
* A configuration portal based on WiFiManager allows to configured WiFi credentials, MQTT Broker address and Shelly topic (facultative). This makes editing <code>conf.hpp</code> required only for MQTT Broker credentials settings.

> To add a white-listed RFID card, edit the tuples list <code>whitelist</code>. These RFID tags will be always authorized, even without server connection.
Expand Down Expand Up @@ -105,17 +107,17 @@ namespace conf::default_config

This is a facultative but very helpful setup to shorten the development workflow.

- Install ESP-IDF extension, Wokwi extension with community evaluation license
* Install ESP-IDF extension, Wokwi extension with community evaluation license

> Make sure ESP-IDF platform is esp32s2 (used by wokwi Platformio environment)
- Build PlatformIO wokwi project, and start simulation with command <code>Wokwi: Start Simulator</code>, you shall see the program running:
* Build PlatformIO wokwi project, and start simulation with command <code>Wokwi: Start Simulator</code>, you shall see the program running:

![image](https://github.com/fablab-bergamo/rfid-arduino/assets/6236243/dfdf33e3-74ac-4246-9c92-4631e0009034)

> See files wokwi.toml and diagram.json
- To configure GDB connection to the Wokwi simulator, edit .vscode\launch.json and add the following fragment inside <code>"configurations"</code> array
* To configure GDB connection to the Wokwi simulator, edit .vscode\launch.json and add the following fragment inside <code>"configurations"</code> array

```json
{
Expand All @@ -130,7 +132,7 @@ This is a facultative but very helpful setup to shorten the development workflow
}
```

- To test debugging, first start Wokwi with <code>Wokwi: Start Simulator and wait for debugger</code>
- You can then run the application, setup breakpoints, inspect variables from the Wokwi debugger:
* To test debugging, first start Wokwi with <code>Wokwi: Start Simulator and wait for debugger</code>
* You can then run the application, setup breakpoints, inspect variables from the Wokwi debugger:

![image](https://github.com/fablab-bergamo/rfid-arduino/assets/6236243/55f926b5-eec8-49d9-b217-628e07f7e3b8)

0 comments on commit 32df3b3

Please sign in to comment.