This repository provides the code and documentation for controlling a scoreboard and shotclock system using multiple microcontrollers, including Arduino Mega 2560, NodeMCU 8266, and ESP8266-based boards. The system allows for real-time control and synchronization of the scoreboard and shotclock via wireless communication.
- π Overview
- π Hardware Setup
- πΆ ESP-NOW Configuration
- π» Programming Method
- π Programming Steps
- π Connections and Pinouts
- πΉ DIP Switch Settings
- π Troubleshooting
- π License
- π¨βπ» Author
The project consists of multiple components that communicate with each other over ESP-NOW and serial communication:
- Remote Controller Board: Arduino Mega 2560 + ESP8266
- Wi-Fi Module for Remote Controller: NodeMCU 8266
- Scoreboard/Shotclock: NodeMCU 8266 for controlling the shotclock & scoreboard
- USE LEVEL SHIFTER WHEN CONNECTING MEGA+WIFI TO NODEMCU8266.
- The ESP8266 on the Mega+WiFi setup is disabled and not used due to performance issues.
- The system includes firmware for the different components:
- Scoreboard_Controller_FW: Runs on the Arduino Mega 2560.
- Scoreboard_Controller_WiFi_FW: Runs on the NodeMCU 8266 for the Wi-Fi module.
- Scoreboard_FW: Runs on the NodeMCU 8266 for the scoreboard.
- Shotclock_FW: Runs on the NodeMCU 8266 for the shotclock.
- Arduino Mega 2560: Acts as the main controller for the scoreboard.
- NodeMCU 8266 x 1 (Wi-Fi Module): Communicates with the Mega+WiFi board via UART.
- NodeMCU 8266 x 3 (Scoreboard/Shotclock): Controls the shotclock functionality.
- Level Shifter: Converts voltage between Arduino Mega (5V) and NodeMCU 8266 (3.3V) for UART communication.
- Arduino Mega 2560
- NodeMCU 8266 (for Wi-Fi communication)
- NodeMCU 8266 (for Scoreboard/Shotclock control)
- Level shifter (3.3V to 5V for serial communication)
To set up the ESP-NOW communication protocol for the system, follow these steps to configure the firmware files for the Wi-Fi modules:
- Open the
Scoreboard_Controller_WiFi_FW.ino
file. - Locate the section where the ESP-NOW peer devices are defined.
- Add the MAC addresses of the peer devices (e.g., the shotclock module and scoreboard controller) to the ESP-NOW peer list.
uint8_t broadcast1_1[] = {0xBC, 0xDD, 0xC2, 0x13, 0x30, 0x9F};
uint8_t broadcast1_2[] = {0x2C, 0xF4, 0x32, 0x79, 0x15, 0x0F};
uint8_t broadcast1_3[] = {0x40, 0x91, 0x51, 0x48, 0x27, 0xEA};
uint8_t broadcast1_4[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
To set the second group (optional) fill in the rest of the MAC Addresses
uint8_t broadcast2_1[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t broadcast2_2[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t broadcast2_3[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t broadcast2_4[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
The device will have 3 modes.
- Group 1 Connect
- Group 2 Connect
- Connect to All
NOTE: This configuration is only for the Scoreboard_Controller_WiFi_FW and the ESP8266 it is programmed on. To change modes, set the voltage of A0 in the controller as follows:
- 0V: Group 1
- 1.5V: Group 2
- 3.3V: Connect to All
The rest of the other NodeMCU devices will not use A0; only this one does.
To know the MAC Address of device, refer to π Programming Steps.
Follow these steps to flash the correct firmware onto each board:
- Flash the Shotclock and Scoreboard Firmware: Flash the NodeMCU 8266 shot clock with the Shotclock_FW and the scoreboard with the Scoreboard_FW.
- Clear the Mega+WiFi ESP8266 Code: Flash the ESP8266 module with blank Arduino code.
- Flash the Mega+WiFi Controller Firmware: Flash the Arduino Mega 2560 with the Scoreboard_Controller_FW firmware.
- Flash the Wi-Fi Module for Mega+WiFi: Flash the NodeMCU 8266 for the Mega+WiFi board with the Scoreboard_Controller_WiFi_FW.
-
For Setup Board 1:
- In the code, define Board 1 by setting
#define BOARD 1
.
- In the code, define Board 1 by setting
-
For Setup Board 2:
- In the code, define Board 2 by setting
#define BOARD 2
.
- In the code, define Board 2 by setting
-
Upload Firmware to the NodeMCU 8266:
- After setting the correct board definition, upload the firmware to the corresponding board.
- For Board 1, upload the Scoreboard firmware 1 to the NodeMCU 8266 controlling the scoreboard.
- For Board 2, upload the Scoreboard firmware 2 to the NodeMCU 8266 controlling the Scoreboard.
- In Arduino IDE, click the Upload button to send the firmware to the selected board.
/*
* Choose the board you are using by setting the following:
* - If you are using Board 1, set: #define BOARD 1
* - If you are using Board 2, set: #define BOARD 2
*
* Only **one** of the options should be set at a time.
* Change the correct line based on your setup.
*/
#define BOARD 1
Part of code to choose which fw version to upload to NODEMCU
ESP8266 MAC Address
- Upload Shotclock Firmware: Using Arduino IDE, upload the Shotclock_FW firmware to the NodeMCU 8266 controlling the shotclock.
- Set DIP Switch to 00001110: Configures the ESP8266 on the Mega board to programming mode.
- Flash the ESP8266: Using Arduino IDE, upload blank Arduino code to the ESP8266 on the Mega to clear its memory.
- Unplug Power: Disconnect the power from the Mega+WiFi board.
- Set DIP Switch to 00110000: Configures the Mega board to load the scoreboard controller firmware.
- Upload the Firmware: Using Arduino IDE, upload the Scoreboard_Controller_FW firmware to the Mega 2560.
- Unplug Power: Disconnect the power from the Mega+WiFi board.
- Configure the MAC Addresses: Use the MAC addresses from the other modules and set them in the code before flashing.
- Flash the Wi-Fi Firmware: Using Arduino IDE, upload the Scoreboard_Controller_WiFi_FW firmware to the NodeMCU 8266 Wi-Fi module.
- Unplug Power: Disconnect the power after flashing the firmware.
ESP8266 Flash Settings
- Set the DIP switch to 00110000 to configure the Mega for scoreboard control.
- Set serial connection switch to RXD0 and TXD0 to ensure no collision with RXD3 and TXD3.
- RX/TX Communication: The Mega's Serial3 (TX/RX β PIN 14 & 15) must be connected to the RX/TX pins on the NodeMCU 8266.
- Use a level shifter for proper voltage conversion between the 5V logic of the Mega and the 3.3V logic of the NodeMCU.
- Connections: RX > TX and TX > RX.
- The shot clock board is pre-configured with its firmware (Shotclock_FW) and works independently.
Ensure the following DIP switch settings are correctly configured for each step:
- For Clearing Mega+WiFi ESP8266:
- Set DIP switch to 00001110.
- For Flashing the Mega+WiFi 2560 with the Scoreboard Controller Firmware:
- Set DIP switch to 00110000.
- Set Serial switch to RX0/TX0.
Refer to the DIP switch diagram for further details.
- Solution: Ensure the serial communication lines between the Mega 2560 and the NodeMCU are connected properly, and that level shifters are used to protect the 3.3V NodeMCU from the 5V Mega.
- Solution: Check the DIP switch settings and ensure that the correct board is selected in the Arduino IDE. Verify that the correct port is being used for uploading.
- Solution: Double-check the MAC Addresses in the Scoreboard_Controller_WiFi_FW. Ensure the NodeMCU 8266 is correctly configured.
This project is licensed under the MIT License. See the LICENSE file for details.
This project was created by Jezreel Tan. Feel free to contact me at jztan25@gmail.com.