ESP32 Circuit
This circuit will serve as the communication circuit using the ESP32, a microcontroller with WiFi and BLE (Bluetooth Low Energy) capabilities. This circuit will send all sensor data to the IoT platform or the MQTT broker over WiFi and to the mobile app over BLE. It will receive control signals from the mobile app over BLE and remotely via MQTT over WiFi.
The ESP32 circuit will exchange data with the Nano 1 and Pico circuits over UART and with the Nano 2 circuit over LoRa.
In this step we will add the OLED display and the LED module.
See the OLED micro-circuits guide.
We will pick this circuit up again later and update the program to enable data exchange with the MQTT Broker over WiFi and data exchange with the IoT App over BLE.
In the Node-RED variant of the solution the Nano and Pico circuits will be directly connected with USB cables to the computer running Node-RED which will exchange data with the MQTT broker. In this scenario, the ESP32 circuit is not required. However, if the ESP32 cricuit is not included, the Node-RED variant will also not support BLE communication with the mobile app.
Components
Component | Function | Voltage | Pins |
---|---|---|---|
LoRa communication Module (SX1278-RA02) | For LoRa communication between boards. | 3.3V | SPI |
OLED Display | Used to display data. | 3.3V | I2C |
LED Module | Used as an indicator. | 3.3V | Digital Out |
Circuit Diagram
Connections
Board pin numbers are those printed on the board while code pin numbers need to be used in code (generally indicated in the pinout diagram as the GPIO pin number). They may be the same or different, depending on the board.
Board Pin | Code Pin | Mode | Component | Pin |
---|---|---|---|---|
D2 | 2 | SPI CS | Lora SX1278-RA02 | NSS |
D4 | 4 | GPIO | - | - |
D13 | 13 | Hardware UART1 TX | Nano 2 | A1 (RX) |
D14 | 14 | Hardware UART1 RX | Nano 2 | A2 (TX) |
RX2 | 16 | Hardware UART2 RX | Pico | D4 (TX) |
TX2 | 17 | Hardware UART2 TX | Pico | D7 (RX) |
D18 | 18 | SPI SCK | Lora SX1278-RA02 | SCK |
D19 | 19 | SPI CIPO | Lora SX1278-RA02 | CIPO |
D21 | 21 | I2C SDA | OLED | SDA |
D22 | 22 | I2C SCL | OLED | SCK |
D23 | 23 | SPI COPI | Lora SX1278-RA02 | COPI |
D25 | 25 | GPIO Digital Out | RGB LED Module | Green Cathode |
D26 | 26 | GPIO | Lora SX1278-RA02 | DIO0 |
D27 | 27 | GPIO | Lora SX1278-RA02 | RST |
D32 | 32 | GPIO Digital Out | RGB LED Module | Red Cathode |
D33 | 33 | GPIO Digital Out | RGB LED Module | Blue Cathode |
Code
The code for this circuit is distributed across multiple files, so will not be displayed here. It will be available for download for subscribers.