From 12552b69f89bcd1934520946157d9b44f8e2cc25 Mon Sep 17 00:00:00 2001
From: "remi.clement" <remi.clement@irstea.fr>
Date: Wed, 30 Dec 2020 16:27:12 +0100
Subject: [PATCH] new logo for ohmpi, add CPU temeprature information

---
 Ohmpi.py         | 43 ++++++++++++----------------
 cpuinfpotest.py  |  3 ++
 measurement.csv  | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
 ohmpi_param.json |  2 +-
 4 files changed, 95 insertions(+), 26 deletions(-)
 create mode 100644 cpuinfpotest.py

diff --git a/Ohmpi.py b/Ohmpi.py
index 56103da7..ab83f4ce 100644
--- a/Ohmpi.py
+++ b/Ohmpi.py
@@ -3,11 +3,14 @@ created on January 6, 2020
 Update December 2021
 Ohmpi.py is a program to control a low-cost and open hardward resistivity meter OhmPi that has been developed by Rémi CLEMENT(INRAE),Vivien DUBOIS(INRAE),Hélène GUYARD(IGE), Nicolas FORQUET (INRAE), and Yannick FARGIER (IFSTTAR).
 """
+
+print('\033[1m'+'\033[31m'+' ________________________________')
 print('|  _  | | | ||  \/  || ___ \_   _|')
 print('| | | | |_| || .  . || |_/ / | |' ) 
 print('| | | |  _  || |\/| ||  __/  | |')  
 print('\ \_/ / | | || |  | || |    _| |_') 
 print(' \___/\_| |_/\_|  |_/\_|    \___/ ')
+print('\033[0m')
 print('OHMPI start' )
 print('Vers: 1.50')
 print('Import library')
@@ -25,7 +28,7 @@ from adafruit_ads1x15.analog_in import AnalogIn
 import pandas as pd
 import os.path
 import json
-
+from gpiozero import CPUTemperature
 """
 display start time
 """
@@ -35,7 +38,7 @@ print(current_time.strftime("%Y-%m-%d %H:%M:%S"))
 """
 hardware parameters
 """
-R_ref = 47.4 # reference resistance value in ohm
+R_ref = 50.0# reference resistance value in ohm
 coef_p0 = 2.5009 # slope for current conversion for ADS.P0, measurement in V/V
 coef_p1 = 2.4947 # slope for current conversion for ADS.P1, measurement in V/V
 coef_p2 = 2.4985 # slope for current conversion for ADS.P2, measurement in V/V
@@ -95,19 +98,7 @@ def read_quad(filename, nb_elec):
         sys.exit(1)
     else:
         return output
-
-def gain_auto(channel):
-    gain=2/3
-    if ((abs(channel.voltage)<2.040) and (abs(channel.voltage)>=1.023)):
-        gain=2
-    elif ((abs(channel.voltage)<1.023) and (abs(channel.voltage)>=0.508)):
-        gain=4
-    elif ((abs(channel.voltage)<0.508) and (abs(channel.voltage)>=0.250)):
-        gain=8
-    elif abs(channel.voltage)<0.256:
-        gain=16
-    #print(gain)
-    return gain        
+       
 
 # perform a measurement
 def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1, coefp2, coefp3, elec_array):
@@ -149,6 +140,7 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1, coefp2, co
             sum_Vmn=sum_Vmn+Vmn1
             sum_Ps=sum_Ps+Vmn1
     # return averaged values
+    cpu= CPUTemperature()
     output = pd.DataFrame({
         "time":[datetime.now()],
         "A":elec_array[0],
@@ -161,7 +153,8 @@ def run_measurement(nb_stack, injection_deltat, Rref, coefp0, coefp1, coefp2, co
         "I[mA]":[(sum_I/(3+2*nb_stack-1))*1000],
         "R":[( (sum_Vmn/(3+2*nb_stack-1)/(sum_I/(3+2*nb_stack-1))))],
         "Ps[mV]":[(sum_Ps/(3+2*nb_stack-1))*1000],
-        "nbStack":[nb_stack]
+        "nbStack":[nb_stack],
+        "CPU temp [°C]":[cpu.temperature]
     })
     output=output.round(2)
     print(output.to_string())
@@ -188,10 +181,10 @@ GPIO.setwarnings(False)
 """
 Initialization of multiplexer channels
 """
-pinList = [12,16,20,21,26,18,23,24,25,19,6,13,4,17,27,22,10,9,11,5] # List of GPIOs enabled for relay cards (electrodes)
-for i in pinList:
-    GPIO.setup(i, GPIO.OUT)
-    GPIO.output(i, GPIO.HIGH)
+# pinList = [12,16,20,21,26,18,23,24,25,19,6,13,4,17,27,22,10,9,11,5] # List of GPIOs enabled for relay cards (electrodes)
+# for i in pinList:
+#     GPIO.setup(i, GPIO.OUT)
+#     GPIO.output(i, GPIO.HIGH)
 
 
 """
@@ -206,7 +199,7 @@ for g in range(0,pardict.get("nbr_meas")): # for time-lapse monitoring
 
     for i in range(0,N.shape[0]): # loop over quadripoles
         # call the switch_mux function to switch to the right electrodes
-        switch_mux(N[i,])
+#         switch_mux(N[i,])
 
         # run a measurement
         current_measurement = run_measurement(pardict.get("stack"), pardict.get("injection_duration"), R_ref, coef_p0, coef_p1, coef_p2, coef_p3, N[i,])
@@ -215,9 +208,9 @@ for g in range(0,pardict.get("nbr_meas")): # for time-lapse monitoring
         append_and_save(pardict.get("export_path"), current_measurement)
 
         # reset multiplexer channels
-        GPIO.output(12, GPIO.HIGH); GPIO.output(16, GPIO.HIGH); GPIO.output(20, GPIO.HIGH); GPIO.output(21, GPIO.HIGH); GPIO.output(26, GPIO.HIGH)
-        GPIO.output(18, GPIO.HIGH); GPIO.output(23, GPIO.HIGH); GPIO.output(24, GPIO.HIGH); GPIO.output(25, GPIO.HIGH); GPIO.output(19, GPIO.HIGH)
-        GPIO.output(6, GPIO.HIGH); GPIO.output(13, GPIO.HIGH); GPIO.output(4, GPIO.HIGH); GPIO.output(17, GPIO.HIGH); GPIO.output(27, GPIO.HIGH)
-        GPIO.output(22, GPIO.HIGH); GPIO.output(10, GPIO.HIGH); GPIO.output(9, GPIO.HIGH); GPIO.output(11, GPIO.HIGH); GPIO.output(5, GPIO.HIGH)
+#         GPIO.output(12, GPIO.HIGH); GPIO.output(16, GPIO.HIGH); GPIO.output(20, GPIO.HIGH); GPIO.output(21, GPIO.HIGH); GPIO.output(26, GPIO.HIGH)
+#         GPIO.output(18, GPIO.HIGH); GPIO.output(23, GPIO.HIGH); GPIO.output(24, GPIO.HIGH); GPIO.output(25, GPIO.HIGH); GPIO.output(19, GPIO.HIGH)
+#         GPIO.output(6, GPIO.HIGH); GPIO.output(13, GPIO.HIGH); GPIO.output(4, GPIO.HIGH); GPIO.output(17, GPIO.HIGH); GPIO.output(27, GPIO.HIGH)
+#         GPIO.output(22, GPIO.HIGH); GPIO.output(10, GPIO.HIGH); GPIO.output(9, GPIO.HIGH); GPIO.output(11, GPIO.HIGH); GPIO.output(5, GPIO.HIGH)
 
     time.sleep(pardict.get("sequence_delay")) #waiting next measurement (time-lapse)
diff --git a/cpuinfpotest.py b/cpuinfpotest.py
new file mode 100644
index 00000000..ee9fd0fa
--- /dev/null
+++ b/cpuinfpotest.py
@@ -0,0 +1,3 @@
+from gpiozero import CPUTemperature
+cpu= CPUTemperature()
+print(cpu.temperature)
\ No newline at end of file
diff --git a/measurement.csv b/measurement.csv
index 2164545d..3444a903 100644
--- a/measurement.csv
+++ b/measurement.csv
@@ -3062,3 +3062,76 @@
 0,2020-12-29 21:13:58.427785,1,4,2,3,-1680.71,1095.17,12.75,11.16,-150.6,1.21,10
 0,2020-12-29 21:14:19.942566,1,4,2,3,-1682.07,1098.71,12.75,11.12,-151.21,1.89,10
 0,2020-12-29 21:14:41.475175,1,4,2,3,-1681.39,1098.7,12.75,11.12,-151.15,1.89,10
+0,2020-12-29 21:15:02.985555,1,4,2,3,-1681.05,1090.99,12.75,11.2,-150.15,1.55,10
+0,2020-12-29 21:15:24.496614,1,4,2,3,-1681.39,1097.99,12.75,11.13,-151.05,1.89,10
+0,2020-12-29 21:15:45.972969,1,4,2,3,-1680.37,1096.54,12.75,11.15,-150.67,1.55,10
+0,2020-12-29 21:16:07.498663,1,4,2,3,-1680.37,1098.7,12.75,11.12,-151.06,1.55,10
+0,2020-12-29 21:16:29.024131,1,4,2,3,-1682.07,1095.88,12.75,11.15,-150.82,1.21,10
+0,2020-12-29 21:16:50.550539,1,4,2,3,-1681.05,1095.17,12.75,11.16,-150.63,1.55,10
+0,2020-12-29 21:17:12.067708,1,4,2,3,-1682.75,1100.09,12.75,11.12,-151.37,1.89,10
+0,2020-12-29 21:17:33.559489,1,4,2,3,-1680.71,1092.39,12.75,11.18,-150.31,0.53,10
+0,2020-12-29 21:17:55.073621,1,4,2,3,-1681.73,1093.76,12.75,11.17,-150.5,0.87,10
+0,2020-12-29 21:18:16.595703,1,4,2,3,-1681.05,1097.29,12.75,11.14,-150.93,2.23,10
+0,2020-12-29 21:18:38.090552,1,4,2,3,-1682.07,1097.29,12.75,11.14,-151.02,0.53,10
+0,2020-12-29 21:18:59.615859,1,4,2,3,-1680.37,1098.0,12.75,11.13,-150.96,0.19,10
+0,2020-12-29 21:19:21.140353,1,4,2,3,-1680.71,1093.76,12.75,11.17,-150.41,1.89,10
+0,2020-12-29 21:19:42.664635,1,4,2,3,-1681.73,1095.16,12.75,11.16,-150.69,1.55,10
+0,2020-12-29 21:20:04.138869,1,4,2,3,-1679.34,1096.58,12.75,11.15,-150.67,-0.16,10
+0,2020-12-29 21:20:25.649277,1,4,2,3,-1680.71,1094.46,12.75,11.17,-150.51,0.53,10
+0,2020-12-29 21:20:47.074672,1,4,2,3,-1681.73,1095.17,12.75,11.16,-150.69,2.23,10
+0,2020-12-29 21:21:08.487375,1,4,2,3,-1681.05,1095.17,12.75,11.16,-150.63,2.23,10
+0,2020-12-29 21:21:29.874381,1,4,2,3,-1681.39,1095.84,12.74,11.16,-150.66,1.21,10
+0,2020-12-29 21:23:54.328220,1,4,2,3,-1680.02,1100.05,12.75,11.12,-151.12,1.89,10
+0,2020-12-29 21:24:15.876584,1,4,2,3,-1680.37,1095.1,12.76,11.17,-150.47,0.87,10
+0,2020-12-29 21:24:37.348517,1,4,2,3,-1679.34,1097.22,12.76,11.15,-150.67,1.21,10
+0,2020-12-29 21:24:58.849062,1,4,2,3,-1681.05,1096.55,12.75,11.15,-150.82,-0.5,10
+0,2020-12-29 21:26:00.478244,1,4,2,3,-1678.66,1098.64,12.75,11.13,-150.8,2.57,10
+0,2020-12-29 21:28:39.164568,1,4,2,3,-1680.71,1097.2,12.76,11.15,-150.79,3.93,10
+0,2020-12-29 21:29:00.671897,1,4,2,3,-1680.37,1089.51,12.76,11.22,-149.79,3.59,10
+0,2020-12-29 21:29:22.093937,1,4,2,3,-1681.05,1092.27,12.76,11.2,-150.14,2.91,10
+0,2020-12-29 21:29:43.536627,1,4,2,3,-1680.71,1092.28,12.76,11.2,-150.11,0.52,10
+0,2020-12-29 21:30:05.000339,1,4,2,3,-1680.37,1093.68,12.75,11.18,-150.28,2.91,10
+0,2020-12-29 21:30:26.412283,1,4,2,3,-1681.39,1097.21,12.76,11.15,-150.85,0.52,10
+0,2020-12-29 21:30:48.678076,1,4,2,3,-1680.71,1093.69,12.76,11.18,-150.31,2.57,10
+0,2020-12-29 21:31:10.208221,1,4,2,3,-1677.98,1092.99,12.76,11.19,-149.97,1.21,10
+0,2020-12-30 15:53:10.367528,1,4,2,3,-1636.06,1094.03,12.44,10.88,-150.32,2.29,10
+0,2020-12-30 15:53:31.878107,1,4,2,3,-1636.06,1091.29,12.45,10.9,-150.03,1.61,10
+0,2020-12-30 15:53:53.314481,1,4,2,3,-1636.41,1089.93,12.44,10.91,-149.97,2.63,10
+0,2020-12-30 15:54:14.823329,1,4,2,3,-1638.45,1092.66,12.44,10.89,-150.44,3.31,10
+0,2020-12-30 15:54:36.310839,1,4,2,3,-1636.75,1087.21,12.45,10.94,-149.63,2.97,10
+0,2020-12-30 15:54:57.809531,1,4,2,3,-1634.7,1087.89,12.45,10.94,-149.44,2.97,10
+0,2020-12-30 15:55:19.275827,1,4,2,3,-1635.72,1088.58,12.45,10.94,-149.54,4.67,10
+0,2020-12-30 15:55:40.780507,1,4,2,3,-1636.41,1091.28,12.45,10.91,-149.97,3.31,10
+0,2020-12-30 15:56:02.292584,1,4,2,3,-1636.41,1093.33,12.45,10.89,-150.25,2.63,10
+0,2020-12-30 15:56:23.801575,1,4,2,3,-1637.09,1089.91,12.45,10.92,-149.94,3.31,10
+0,2020-12-30 15:56:45.316319,1,4,2,3,-1635.38,1085.18,12.45,10.97,-149.13,4.33,10
+0,2020-12-30 15:57:06.831429,1,4,2,3,-1637.09,1092.64,12.45,10.9,-150.22,2.63,10
+0,2020-12-30 15:57:28.339547,1,4,2,3,-1637.77,1091.95,12.45,10.9,-150.28,3.31,10
+0,2020-12-30 15:57:49.843582,1,4,2,3,-1635.04,1091.27,12.45,10.91,-149.84,2.63,10
+0,2020-12-30 15:58:11.345164,1,4,2,3,-1635.72,1089.91,12.45,10.92,-149.81,1.27,10
+0,2020-12-30 15:58:32.859205,1,4,2,3,-1636.75,1093.32,12.45,10.89,-150.28,2.29,10
+0,2020-12-30 15:58:54.384335,1,4,2,3,-1639.47,1089.24,12.45,10.93,-149.97,5.01,10
+0,2020-12-30 15:59:15.889812,1,4,2,3,-1637.43,1092.64,12.45,10.9,-150.25,2.29,10
+0,2020-12-30 15:59:37.402209,1,4,2,3,-1639.13,1090.59,12.46,10.91,-150.22,2.63,10
+0,2020-12-30 15:59:58.903752,1,4,2,3,-1638.45,1094.01,12.45,10.88,-150.53,1.95,10
+0,2020-12-30 16:00:20.400919,1,4,2,3,-1637.77,1091.27,12.45,10.91,-150.09,2.63,10
+0,2020-12-30 16:00:41.858107,1,4,2,3,-1637.09,1093.32,12.45,10.88,-150.41,3.31,10
+0,2020-12-30 16:01:03.249346,1,4,2,3,-1637.43,1090.59,12.45,10.92,-149.97,2.29,10
+0,2020-12-30 16:01:24.684061,1,4,2,3,-1636.07,1096.06,12.45,10.87,-150.5,3.65,10
+0,2020-12-30 16:01:46.133028,1,4,2,3,-1636.75,1088.55,12.45,10.93,-149.72,4.33,10
+0,2020-12-30 16:02:25.469704,1,4,2,3,-1636.66,1091.25,12.45,10.91,-149.99,2.33,30
+0,2020-12-30 16:03:07.721599,1,4,2,3,-1638.23,1088.15,12.45,10.94,-149.8,2.94,30
+0,2020-12-30 16:03:49.947533,1,4,2,3,-1637.99,1091.48,12.45,10.91,-150.14,3.42,30
+0,2020-12-30 16:17:11.621030,1,4,2,3,-1639.68,1085.9,12.46,10.97,-149.53,1.97,30,43.47
+0,2020-12-30 16:17:53.876836,1,4,2,3,-1639.2,1090.93,12.47,10.92,-150.08,2.69,30,43.47
+0,2020-12-30 16:18:36.025620,1,4,2,3,-1638.84,1090.01,12.45,10.92,-150.02,2.33,30,44.01
+0,2020-12-30 16:19:18.211787,1,4,2,3,-1638.59,1094.37,12.46,10.88,-150.6,2.33,30,45.62
+0,2020-12-30 16:19:56.334674,1,4,2,3,-1638.59,1091.42,12.46,10.92,-150.1,2.57,30,42.93
+0,2020-12-30 16:20:38.738228,1,4,2,3,-1638.71,1093.36,12.45,10.9,-150.37,2.69,30,44.55
+0,2020-12-30 16:22:12.325222,1,4,2,3,-1638.71,1089.29,12.45,10.93,-149.91,2.21,30,45.08
+0,2020-12-30 16:23:01.179237,1,4,2,3,-1639.08,1091.22,12.46,10.91,-150.21,2.33,30,44.01
+0,2020-12-30 16:23:43.399589,1,4,2,3,-1638.11,1097.26,12.45,10.86,-150.85,2.33,30,43.47
+0,2020-12-30 16:24:25.660117,1,4,2,3,-1638.35,1095.8,12.45,10.87,-150.68,1.85,30,42.93
+0,2020-12-30 16:25:07.889573,1,4,2,3,-1638.23,1094.87,12.46,10.88,-150.63,1.97,30,42.93
+0,2020-12-30 16:25:50.091842,1,4,2,3,-1637.02,1089.06,12.45,10.93,-149.72,2.94,30,43.47
+0,2020-12-30 16:26:32.339063,1,4,2,3,-1638.47,1090.02,12.46,10.92,-149.99,2.45,30,43.47
diff --git a/ohmpi_param.json b/ohmpi_param.json
index b722a948..4eddedd0 100644
--- a/ohmpi_param.json
+++ b/ohmpi_param.json
@@ -3,6 +3,6 @@
     "injection_duration": 0.250,
     "nbr_meas": 10000,
     "sequence_delay": 10,
-    "stack": 10,
+    "stack": 30,
     "export_path": "/home/pi/myohmpi/ohmpi1_5/measurement.csv" 
 }
-- 
GitLab