some problems that makes the board literally unplayable
Hi! I got an openchessboard with the arduino nano 33 IoT, but it's impossible to have it work for a full game. I have 2 issues that prevent me from playing:
- Sometimes the board start to never accept my moves, and whatever I do, it wont let me continue.
- I really don't understand what is happening, it keeps only 1 or 2 squares light up i move something, often only one, which is the one where there last was a change (piece put or taken).
Since I don't understand the debug and the code, I'll post all the console here for you to see if you got time to check: (I know it's huge, but there's only a some little things useful, most of it are repeateadly the same things)
All the bad moves are because the magnets under my pieces are really not powerful, so it sometimes thinks I try to do a move, when a piece is not detected and I put it back.
Connected to wifi
SSID: Freebox-78EAC5-2.4Ghz
IP Address: 192.168.1.165
signal strength (RSSI):-79 dBm
Starting connection to server...
Connected to Server...
Find ongoing game
Connected to Server...
Find ongoing game
Connected to Server...
Find ongoing game
Connected to Server...
Find ongoing game
NBfmTMUt
Start move stream from game
move received: e2e4
opponents move: e2e4
wait for move accept...
move accepted!
wait for move input...my move: g7g7d7
Unexpected response: HTTP/1.1 404 Not Found **It starts to refuse all my moves from there**
wrong move!
g7g7
g7g7
my move: d7g7
Unexpected response: HTTP/1.1 404 Not Found
wrong move!
g7d7
g7d7
my move: d7d7
Unexpected response: HTTP/1.1 404 Not Found
wrong move!
d7d7
my move: d7g7
Unexpected response: HTTP/1.1 404 Not Found
wrong move!
g7d7
g7g7
c8c8
c8c8
c8c8
c8c8
c8c8
g7d7
my move: d7d7
Unexpected response: HTTP/1.1 404 Not Found
wrong move!
d7d7
my move: d7d5d7
Unexpected response: HTTP/1.1 404 Not Found
wrong move!
d5d7
d5d7
my move: d7d5
Unexpected response: HTTP/1.1 404 Not Found
wrong move!
d5d7
d5d5
d7d7
d7d5
d6d6d7
d7d5
d5d7
**unplugged the arduino here to retry**
Attempting wifi
connection ...
Attempting to connect to SSID: Freebox-78EAC5-2.4Ghz
Attempting to connect to SSID: Freebox-78EAC5-2.4Ghz
Attempting to connect to SSID: Freebox-78EAC5-2.4Ghz
Connected to wifi
SSID: Freebox-78EAC5-2.4Ghz
IP Address: 192.168.1.165
signal strength (RSSI):-70 dBm
Starting connection to server...
Connected to Server...
Find ongoing game
NBfmTMUt
Start move stream from game
move received: e2e4
opponents move: e2e4
wait for move accept...
move accepted!
wait for move input...my move: d7d5
move success!
move received: d1f3
opponents move: d1f3
wait for move accept...
move accepted!
wait for move input...my move: d5d5
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
d5d5
my move: d5e4
move success!
move received: f3e4
opponents move: f3e4
wait for move accept...
move accepted!
wait for move input...my move: f7f5
move success!
move received: e4e3
opponents move: e4e3
wait for move accept...
move accepted!
wait for move input...my move: e7e6e7
move success!
move received: d2d3
opponents move: d2d3
wait for move accept...
move accepted!
wait for move input...my move: f8f8e8
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
f8f8
e8f8
f8e8
b4b4
f8e8f8
e8e8
e8e8
e8e8
f8f8
my move: f8f8
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
f8f8
my move: f8f8
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
f8f8
my move: f8b4
move success!
move received: f8b4
received move was played by me! (API response)
move received: b1c3
opponents move: b1c3
wait for move accept...
move accepted!
wait for move input...my move: b4c3
move success!
move received: c1d2
opponents move: c1d2
wait for move accept...
move accepted!
wait for move input...my move: c3d2
move success!
move received: e1d1
opponents move: e1d1
wait for move accept...
move accepted!
wait for move input...my move: d2e3
move success!
move received: d1e1
opponents move: d1e1
wait for move accept...
move accepted!
wait for move input...my move: d8d8
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
d8d8
my move: d8d8
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
d8d8
my move: d8h4
move success!
move received: d8h4
received move was played by me! (API response)
move received: g1e2
opponents move: g1e2
wait for move accept...
move accepted!
wait for move input...my move: h4g2
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
**Completely broken from there, only the last square with a changed
state stay lighted up, and sometimes another one**
g2h4
g2g2
g2g2
g2g2
g2g2
g2g2
h2h2
g2g2
h4f2
f2f2
f2h4
f2f2
h4h4
h4h4
f2h4
h4f2
f2h4
h4f2
f2f2
h4h4
h3h4
h4f2
f2f2
f2f2
h4h4
h4h4
h4h4
e3e3
f5g4
f5h4
f5g5
h4h4
f5f5
h4h4
move received: h4f2 **I finished the game on lichess**
move received: e1d1
move received: b8c6
move received: a1b1
move received: c6d4
move received: b1c1
move received: d4e2
move received: g2g4
move received: e2c1
move received: h2h3
Game Status: mate","
move received: f2d2
h4e6
**Was still broken on this game**
Connected to Server...
Find ongoing game
Bn1yCtnt
Start move stream from game
move received: ","
wait for move input...my move: g1c1
Unexpected response: HTTP/1.1 400 Bad Request
wrong move!
c1g1
c1g1
my move: d8d8
Unexpected response: <html>
wrong move!
d8d8
my move: d8d7d8
Unexpected response: <html>
wrong move!
d7d8
d7d5
d5d7
d7d7
d5d5
d5d7
d2d4
d4d2
d2d2
d4d2
d2d4
move received: d2d3 **One move I did on lichess to see if it solves the problem...**
move received: e7e5
d4d2 **... It didn't**
d2d4
d4d2
d2d3
d3d2
d3d3
d4d4
d2d3
Ask me if you want more informations
Hi Loris, Thank you for posting this issue and the detailed logs. This helps a lot to understand the issue.
There are multiple issues I can see from the logs:
-
There are multiple moves with the same square like "e8e8" or "d7d7". This is due to the week magnets only registering a piece slightly and toggling during move input. If there are to many wrong moves received as input the take bake method fails. I will try to come up with a quick fix which discards those single field inputs and does not get in a bad state. But in the meantime: Try stronger magnets or remove the spacers between the PCB and the chessboard.
-
you seem to have a week wifi connection as it is a below -70dB and even -79dB. This could result in disconnects followed by a 404 error indicating that the server is not reachable due to the disconnect. Solution: Try the board closer to your wifi router or use your smartphone with hosting an access point.
Usually If you have only a disconnect and play a move. The board does not accept it and shows that you play the revers move. But If you play the reverse move and play another move it also gets rejected. In this case a board restart as should solve the issue.
However, there are a lot of bad inputs received due to the week magnets that it is not able to recover to a stable state.
If you can not fix the move input by adjusting the magnets or the distance between PCB and board. Use the following change for the input function in board_driver.ino
String getMoveInput(void) {
const char columns[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
String mvInput; // Declare mvInput outside the loop to retain its value
while (true) { // Loop until valid input is received
byte hallBoardStateInit[8];
byte hallBoardState1[8];
byte hallBoardState2[8];
byte hallBoardState3[8];
byte ledBoardState[8];
for (int k = 0; k < 8; k++) {
hallBoardStateInit[k] = 0x00;
hallBoardState1[k] = 0x00;
hallBoardState2[k] = 0x00;
hallBoardState3[k] = 0x00;
ledBoardState[k] = 0x00;
}
bool mvStarted = false;
bool mvFinished = false;
// Get initial position
readHall(hallBoardStateInit);
// Wait for Start move event
while (!mvStarted) {
readHall(hallBoardState1);
for (int row_index = 0; row_index < 8; row_index++) {
for (int col_index = 0; col_index < 8; col_index++) {
int state1 = bitRead(hallBoardStateInit[row_index], col_index);
int state2 = bitRead(hallBoardState1[row_index], col_index);
if (state1 != state2) {
ledBoardState[7 - row_index] |= 1UL << (7 - col_index);
#ifdef PLUG_AT_TOP
mvInput = mvInput + (String)columns[7 - col_index] + (String)(7 - row_index + 1);
#else
mvInput = mvInput + (String)columns[7 - row_index] + (String)(col_index + 1);
#endif
mvStarted = true;
break;
}
}
}
}
digitalWrite(LED_LATCH_PIN, 0);
shiftOut(ledBoardState);
digitalWrite(LED_LATCH_PIN, 1);
digitalWrite(LED_OE_N_PIN, 0);
// Wait for end move event
while (!mvFinished) {
readHall(hallBoardState2);
delay(100);
readHall(hallBoardState3);
delay(100);
for (int row_index = 0; row_index < 8; row_index++) {
for (int col_index = 0; col_index < 8; col_index++) {
int state_prev = bitRead(hallBoardState1[row_index], col_index);
int hallBoardState1 = bitRead(hallBoardState2[row_index], col_index);
int hallBoardState2 = bitRead(hallBoardState3[row_index], col_index);
if ((hallBoardState1 != state_prev) && (hallBoardState2 != state_prev)) {
if (hallBoardState1 == hallBoardState2) {
mvFinished = true;
ledBoardState[7 - row_index] |= 1UL << (7 - col_index);
#ifdef PLUG_AT_TOP
mvInput = mvInput + (String)columns[7 - col_index] + (String)(7 - row_index + 1);
#else
mvInput = mvInput + (String)columns[7 - row_index] + (String)(col_index + 1);
#endif
}
}
}
}
}
digitalWrite(LED_LATCH_PIN, 0);
shiftOut(ledBoardState);
digitalWrite(LED_LATCH_PIN, 1);
digitalWrite(LED_OE_N_PIN, 0);
delay(300);
// Check if the first two characters match the third and fourth characters
if (mvInput.length() >= 4 &&
mvInput.substring(0, 2) == mvInput.substring(2, 4)) {
// Invalid input, clear mvInput and restart loop
mvInput = ""; // Reset mvInput if invalid
continue;
}
// If valid input, break the loop and return the move
break;
}
return mvInput;
}