From 4ce94d38b6d43c562d6ff901c57deaac2ae2b317 Mon Sep 17 00:00:00 2001
From: Clement Remi <remi.clement@irstea.fr>
Date: Wed, 16 Nov 2022 21:40:03 +0100
Subject: [PATCH] Update OhmPi.py correction of the relay switch number

---
 ohmpi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ohmpi.py b/ohmpi.py
index 53ec36ea..d7d5c3fe 100644
--- a/ohmpi.py
+++ b/ohmpi.py
@@ -1206,7 +1206,7 @@ class OhmPi(object):
             # find I2C address of the electrode and corresponding relay
             # considering that one MCP23017 can cover 16 electrodes
             i2c_address = 7 - (electrode_nr - 1) // 16  # quotient without rest of the division
-            relay_nr = electrode_nr - (electrode_nr // 16) * 16 + 1
+            relay_nr = (electrode_nr-1) - ((electrode_nr-1) // 16) * 16
 
             if i2c_address is not None:
                 # select the MCP23017 of the selected MUX board
-- 
GitLab