Hard Potato A Python Library To Control Commercial Potentiostats and To Automate Electrochemical Experiments
Hard Potato A Python Library To Control Commercial Potentiostats and To Automate Electrochemical Experiments
Figure 1. API to control commercial potentiostats. The user writes a script with the high-level functions and the API translates them into the specific
commands expected by the instrument.
ment, for example, to include the control of potentiostat models macro file. Our library uses this to control the potentiostat,
not currently available to the authors. where the user only needs to write the high-level functions; then,
To test our Python API, we demonstrate its application to the internally, the API converts these instructions into macro
Randles−Š evčı ́k methodology7 to determine a diffusion commands that the CHI760E understands. The resulting macro
coefficient (D) for a soluble redox-active species undergoing file also contains instructions to save the data into a .txt and .bin
electron transfer at an electrode using the cyclic voltammetry file, the latter being the format expected by the CHI software. It
(CV) technique. This example is a staple of electrochemical also contains a termination line that closes the software and
studies, but its implementation promptly requires automation returns control to Python to continue with the next instruction
when dealing with large libraries of materials. Furthermore, to line.13 While we have focused on the CHI760E, it is possible to
showcase the flexibility provided by Python, we make use of Soft include more potentiostats into the library as depicted in Figure
Potato,8,9 an open-source library that contains electrochemical 1, where a developer would only need to write its “translator” to
equations and can simulate electrochemical processes assuming match the API’s functions to the instrument of interest. Until
semi-infinite planar diffusion and Butler−Volmer kinetics. January 2023, we have written the translators for the CH
■ EXPERIMENTAL SECTION
API implementation. The API consists of two main
Instrument potentiostats models 1205B, 1242B, 601E, and 760E
and the PalmSens Emstat Pico potentiostat, the latter enabling
the use of a low-cost potentiostat for application in an automated
components: the potentiostat module and a load_data module. electrochemical platform.
The potentiostat module contains high level functions and calls Controlling instruments from different vendors comes with
a “translator” for each commercial potentiostat available in the certain challenges. For example, the CHI760E can perform
library, while the load_data module provides easy data handling automated iR compensation if a resistance value is provided,
(see Figure 1). The potentiostat module provides generalized while this is not possible with the Emstat Pico. Meanwhile, the
functions for typical electrochemical techniques; for example, Emstat Pico has different operation modes (low speed, high
some of the arguments for the potentiostat.CV() function are speed, and maximum potential range) that can be selected. To
the scan rate (sr [V/s]), the first vertex potential (Ev1 [V]), and consider the variability in options for each model, we have
the second vertex potential (Ev2 [V]). The Supporting included optional parameters specific to each instrument. For
Information includes instructions to install the library (Section example, in cyclic voltammetry, a resistance value can be
S1) and script examples for typical experiments as well as the
included if using the CHI760E; this value will be ignored if using
Randles−Š evčı ́k methodology implemented here (Sections S3−
the Emstat Pico. This also allowed us to future-proof the code, as
S8). (See refs 10 and 11 for the latest version of the library and
developers can write the translators for their own instruments
full documentation.)
Figure 1 shows how a common API facilitates communication including the core parameters required by the general library and
between the user and each instrument. The generalized optional parameters only used by their specific instrument. We
functions act as intermediaries between the user and the have also included a validation step to ensure that potential
instrument, where the user does not have to worry about the parameters for each technique and potentiostat model fall within
specific ways on which their commercial software defines the their corresponding range. For more details on the inner
parameters. Internally, these functions are “translated” into workings of the library, see refs 10−12.
specific commands that each instrument understands. In the In the following sections, we use the CH Instruments 760E to
current version of the library (v1.3.11),12 we have included demonstrate how the library can be used to automate data
several CH Instruments potentiostats. For the following, we are acquisition and include data analysis and simulation on the same
using the CHI760E, a highly popular and versatile research script. For this, we have selected the Randles−Š evčı ́k routine, a
grade potentiostat from CH Instruments with the capability to highly used methodology and part of the general electro-
be controlled via internal macro commands, but not directly chemistry toolkit that consists of multiple repetitions and data
with Python. The CHI software allows one to save the analysis that may become tedious. To compare between
instructions as a .mcr text file and to use it as a parameter different potentiostat models and to showcase the flexibility of
when calling the software from the Windows command line. The Hard Potato, we have included the results using the CHI760E,
software then starts and runs the instructions written on the CHI1205B, and Emstat Pico and their respective Python scripts
4841 https://doi.org/10.1021/acs.analchem.2c04862
Anal. Chem. 2023, 95, 4840−4845
Analytical Chemistry pubs.acs.org/ac Technical Note
Figure 2. Results of the automated Randles−Š evčı ́k routine execution. Top: Block diagram of the routine. Bottom: (a) cyclic voltammograms
performed at 0.1, 0.2, 0.3, 0.4, and 0.5 V/s from bottom to top, (b) linear regression following eq 1 to estimate D, and (c) comparison between a cyclic
voltammogram recorded at 0.1 V/s and its simulated response. The solution used consisted of a mixture of 1 mM FcMeOH and 100 mM KNO3. The
simulation was performed assuming planar diffusion and the Butler−Volmer equation with fast electron transfer kinetics; the parameters used were n =
1, k0 = 1 × 108 cm/s, and α = 0.5.
■ RESULTS
Randles−Š evčı ́k is one of the most used electroanalytical
circuit potential (OCP) measurement and use it to estimate the
potential window of the oxidation of FcMeOH; this could be
useful when standard reduction potential of the species (E0) is
methodologies. It allows one to measure the number of unknown, for example, when characterizing new nonaqueous
electrons, the geometrical area of the electrode, or the diffusion redox molecules with unknown redox potentials. The third part
consists of a loop that describes the specific steps during
coefficient of a redox species, provided the rest of the
measurement, one for each scan rate. Here, we also import the
electrochemical parameters are known. It is also one of the
recently acquired data to be used for the analysis later. The
first methodologies taught in introductory electrochemistry fourth part consists of the data analysis and plotting, that is, the
courses.17 It consists of performing CV using a macroelectrode estimation of E0 from the average of the forward and reverse
with a redox active species and analyzing the peak currents as a peak potentials and D from eq 1. Importantly, this step allows us
function of the square root of the scan rate. If the process is to interface with other Python libraries that are useful for
diffusion controlled and displays fast electron transfer kinetics, a electrochemistry. For instance, in our analysis, we used the
linear relationship is observed that is described by the Randles− Randles−Š evčı ́k equation included in the Soft Potato library to
Š evčı ́k equation: fit the experimental peak currents and obtain D. We performed
4842 https://doi.org/10.1021/acs.analchem.2c04862
Anal. Chem. 2023, 95, 4840−4845
Analytical Chemistry pubs.acs.org/ac Technical Note
linear regression to obtain the slope of the ipeak vs ν1/2 curve and of large libraries of redox species.29 The ability to interface with
used the R2 value to ensure our experiments were above a certain third-party libraries for data analysis, plotting, simulations,
threshold, otherwise meaning that the methodology would be machine learning, and even other instruments such as
inappropriate to use due to either experimental artifacts spectrophotometers and (micro)fluidics makes this a very
(resistance, capacitance, noise), the effect of slow kinetics, or powerful tool. For example, here, we used Soft Potato, an open-
the presence of multiple electron transfer steps. Adding controls source Python library that includes typical electrochemical
such as these prevents the need for manual inspection of the equations and can perform simulations assuming semi-infinite
data, which would defeat the purpose of having a fully automated planar diffusion and Butler−Volmer kinetics. Soft Potato makes
system, or when protocols are used by nonexpert electro- the calculation of D from the Randles−Š evčı ́k equation
chemists. We have also used Soft Potato to simulate the cyclic straightforward, as the user does not need to manually code it.
voltammograms once E0 and D were estimated. Using Soft We also used it to simulate the electrochemical response and
Potato in this case helps to confirm the accuracy of the entire compare it to the corresponding experiment, everything on the
approach by plotting the experimental results alongside their same script and immediately after the experiments were
simulations. Figure 2a −c shows the results of the automated performed. Fully integrated, the Potato ecosystem can become
Randles−Š evčı ́k experimentation, data analysis, and comparison a powerful tool to automate electrochemical experimentation
to simulation, promptly displaying the obtained CVs, the linear and data analysis. Furthermore, a script can be shared between
relationship predicted by eq 1, and the comparison between an research groups “as is” to corroborate results or to make changes
experimental and simulated voltammogram. The total time of to the methodology, supporting the philosophy of more open
execution of this script was 1 min and 40 s, well below the total and transparent analytical science. The potential for this
time it would take even an experienced electrochemist to apply approach can be significantly enhanced if companies offer
the full methodology manually. To this point, the first author of compatible Python frameworks and the research community is
this work tested it themselves taking ∼30 min. involved with the development and improvement of the library.
■ DISCUSSION
The use of our API simplifies the execution of straightforward
Specific challenges that can be addressed are the ability to live
stream data to perform operations while the measurement is
being taken, for example, to change current ranges, detect
methods such as CV and enables the automation of electro- oscillations due to iR compensation, and even emergency stops.
chemical experiments. While the execution time in the case We believe that this will be essential in the coming years, since
shown here depends on the scan rates used, performing the full we see automation making its way into the chemistry realm,
methodology in a traditional way is still time consuming as it specifically, synthetic chemistry, where groups around the world
requires changing the scan rate manually for each CV, saving are building fully automated synthesis laboratories.30,31 It is only
data in an appropriate format to be used in commercial data a matter of time until digital electrochemistry becomes the
analysis software, extracting E0 and peak currents (or other norm.
suitable parameters), and performing linear regression against
the square root of the scan rate to obtain D. Additionally, the
user could still invest time in manually inputting parameters to
perform electrochemical simulations, export the simulated data,
■ CONCLUSIONS
Here, we have demonstrated the flexibility of automated
and put it back into the data analysis software to compare it with electrochemical experimentation enabled by our open-source
the experimental data. This methodology is straightforward and Hard Potato Python library. As a use case, we have implemented
can be carried out manually; however, its full implementation a workflow to estimate E0 from voltammograms and D from the
from experiment to data analysis and simulation is tedious and Randles−Š evčı ́k methodology, using these parameters to
time consuming. Our API overcomes practical obstacles not simulate and corroborate the electrochemical response, every-
only by offering automation of all these functions, but also by thing on a single script. The total run time was 1 min and 40 s,
introducing a consistent language that defines commonly used limited only by the scan rates used and the number of
parameters that are independent of the instrument used. experiments performed, as the data analysis and simulation are
The API approach shown here also raises new prospects for virtually instantaneous. The ability to centralize data acquisition,
combining electrochemical methods with a wide variety of analysis, and simulation within a single Python script showcases
Python libraries. While we focused on the Randles−Š evčı ́k how powerful and flexible this tool is. Our primary goal is to
methodology, basically, any other electrochemical routine can automate processes and facilitate the sharing of electrochemical
be easily automated. For example, immediate systematic protocols, as groups can run the same experiments independ-
experiments similar to the one here tested are found in ently of the potentiostat that they possess, provided they have
electrochemical applications such as potential window opening access to the Python script and the potentiostat “translator” is
studies,18 the Koutecky−Levich analysis,19 the implementation included in the library. Overall, we believe that our generalized
of sampled current voltammetry,20−22 the measurement of Hard Potato library can be incorporated into any electro-
electrochemical kinetics with macro23 and microelectrodes,24 chemistry workflow and opens the possibility to perform more
capacitance and solution resistance measurements with interesting problems involving automation, high throughput
voltammetry and electrochemical impedance spectroscopy,25,26 experimentation, and even artificial intelligence for closed-loop
and the electrochemistry part of a homemade scanning experimental design.
electrochemical microscope.27 For example, in our group, we
have recently reported the use of automated tools to estimate
chemical decomposition rates using a set of interdigitated
electrode arrays and an early version of Hard Potato.28 The Hard
■ ASSOCIATED CONTENT
* Supporting Information
sı
Potato library enables researchers to automate these tasks, The Supporting Information is available free of charge at
especially when dealing with repetition and/or characterization https://pubs.acs.org/doi/10.1021/acs.analchem.2c04862.
4843 https://doi.org/10.1021/acs.analchem.2c04862
Anal. Chem. 2023, 95, 4840−4845
Analytical Chemistry pubs.acs.org/ac Technical Note
Instructions on how to install the Hard Potato library, (4) Gamry Instruments Software. https://www.gamry.com/support-2/
Python script examples to perform cyclic voltammetry, software/ (accessed 2022−09−28).
chronoamperometry, open circuit potential measure- (5) Meloni, G. N. J. Chem. Educ. 2016, 93 (7), 1320−1322.
(6) Brown, E. W.; Glasscott, M. W.; Conley, K.; Barr, J.; Ray, J. D.;
ment, linear sweep voltammetry, and the Randles−Š evčı ́k
Moores, L. C.; Netchaev, A. Anal. Chem. 2022, 94 (12), 4906−4912.
methodology performed with a CHI760E, CHI1205B, (7) Bard, A. J.; Faulkner, L. R. Electrochemical Methods. Fundamentals
and Emstat Pico (PDF) and Applications, Second ed.; John Wiley & Sons, Inc.: New York, 2001.
Screen recording of the automation of the Randles− (8) Rodríguez, O. Soft Potato: An Open-Source Electrochemical
Š evčı ́k methodology (MP4) Simulator and Toolkit, ChemRxiv Preprint, 2022. DOI: 10.26434/
Data (ZIP) chemrxiv-2022-4bs3w.
(9) Rodríguez, O. Soft Potato: an open-source electrochemistry toolkit.
■ AUTHOR INFORMATION
Corresponding Authors
https://github.com/oliverrdz/SoftPotato.
(10) Hard Potato GitHub. https://github.com/jrlLAB/hardpotato
(accessed 2022−09−28).
(11) Hard Potato Wiki Page. https://github.com/jrlLAB/hardpotato/
Oliver Rodríguez − Department of Chemistry, University of wiki.
Illinois at Urbana−Champaign, Urbana, Illinois 61801, (12) Hard Potato source code v1.3.11. https://github.com/jrlLAB/
United States; Beckman Institute for Advanced Science and hardpotato/releases/tag/v1.3.11.
Technology, University of Illinois at Urbana−Champaign, (13) The implementation of the termination command in the
Urbana, Illinois 61801, United States; Joint Center for Energy CHI760E requires having the latest firmware and software installed.
Storage Research (JCESR), Argonne National Laboratory, Contact the CH Instruments Support to update them.
Lemont, Illinois 60439, United States; orcid.org/0000- (14) Harris, C. R.; Millman, K. J.; van der Walt, S. J.; Gommers, R.;
0003-2350-1214; Email: [email protected] Virtanen, P.; Cournapeau, D.; Wieser, E.; Taylor, J.; Berg, S.; Smith, N.
Joaquín Rodríguez-López − Department of Chemistry, J.; Kern, R.; Picus, M.; Hoyer, S.; van Kerkwijk, M. H.; Brett, M.;
University of Illinois at Urbana−Champaign, Urbana, Illinois Haldane, A.; del Río, J. F.; Wiebe, M.; Peterson, P.; Gérard-Marchant,
61801, United States; Beckman Institute for Advanced Science P.; Sheppard, K.; Reddy, T.; Weckesser, W.; Abbasi, H.; Gohlke, C.;
Oliphant, T. E. Nature 2020, 585, 357−362.
and Technology, University of Illinois at Urbana−Champaign, (15) Virtanen, P.; Gommers, R.; Oliphant, T. E.; Haberland, M.;
Urbana, Illinois 61801, United States; Joint Center for Energy Reddy, T.; Cournapeau, D.; Burovski, E.; Peterson, P.; Weckesser, W.;
Storage Research (JCESR), Argonne National Laboratory, Bright, J.; van der Walt, S. J.; Brett, M.; Wilson, J.; Millman, K. J.;
Lemont, Illinois 60439, United States; orcid.org/0000- Mayorov, N.; Nelson, A. R. J.; Jones, E.; Kern, R.; Larson, E.; Carey, C.
0003-4346-4668; Email: [email protected] J.; Polat, I.;̇ Feng, Y.; Moore, E. W.; VanderPlas, J.; Laxalde, D.;
Perktold, J.; Cimrman, R.; Henriksen, I.; Quintero, E. A.; Harris, C. R.;
Author Archibald, A. M.; Ribeiro, A. H.; Pedregosa, F.; van Mulbregt, P.;
Michael A. Pence − Department of Chemistry, University of Vijaykumar, A.; Bardelli, A. P.; Rothberg, A.; Hilboll, A.; Kloeckner, A.;
Illinois at Urbana−Champaign, Urbana, Illinois 61801, Scopatz, A.; Lee, A.; Rokem, A.; Woods, C. N.; Fulton, C.; Masson, C.;
United States; Beckman Institute for Advanced Science and Häggström, C.; Fitzgerald, C.; Nicholson, D. A.; Hagen, D. R.;
Technology, University of Illinois at Urbana−Champaign, Pasechnik, D. v.; Olivetti, E.; Martin, E.; Wieser, E.; Silva, F.; Lenders,
Urbana, Illinois 61801, United States; Joint Center for Energy F.; Wilhelm, F.; Young, G.; Price, G. A.; Ingold, G. L.; Allen, G. E.; Lee,
Storage Research (JCESR), Argonne National Laboratory, G. R.; Audren, H.; Probst, I.; Dietrich, J. P.; Silterra, J.; Webber, J. T.;
Lemont, Illinois 60439, United States; orcid.org/0000- Slavič, J.; Nothman, J.; Buchner, J.; Kulick, J.; Schönberger, J. L.; de
0001-5880-9812 Miranda Cardoso, J. V.; Reimer, J.; Harrington, J.; Rodríguez, J. L. C.;
Nunez-Iglesias, J.; Kuczynski, J.; Tritz, K.; Thoma, M.; Newville, M.;
Complete contact information is available at: Kümmerer, M.; Bolingbroke, M.; Tartre, M.; Pak, M.; Smith, N. J.;
https://pubs.acs.org/10.1021/acs.analchem.2c04862 Nowaczyk, N.; Shebanov, N.; Pavlyk, O.; Brodtkorb, P. A.; Lee, P.;
McGibbon, R. T.; Feldbauer, R.; Lewis, S.; Tygier, S.; Sievert, S.; Vigna,
Notes S.; Peterson, S.; More, S.; Pudlik, T.; Oshima, T.; Pingel, T. J.;
The authors declare no competing financial interest. Robitaille, T. P.; Spura, T.; Jones, T. R.; Cera, T.; Leslie, T.; Zito, T.;
Krauss, T.; Upadhyay, U.; Halchenko, Y. O.; Vázquez-Baeza, Y. Nat.
■ ACKNOWLEDGMENTS
The research was financially supported by the Joint Center for
Methods 2020, 17 (3), 261−272.
(16) Hunter, J. D. Comput. Sci. Eng. 2007, 9 (3), 90−95.
(17) Elgrishi, N.; Rountree, K. J.; McCarthy, B. D.; Rountree, E. S.;
Energy Storage Research (JCESR), an Energy Innovation Hub Eisenhart, T. T.; Dempsey, J. L. J. Chem. Educ. 2018, 95 (2), 197−206.
funded by the U.S. Department of Energy, Office of Science, (18) Diaz-Morales, O.; Hersbach, T. J. P.; Badan, C.; Garcia, A. C.;
Basic Energy Sciences. The authors would like to acknowledge Koper, M. T. M. Faraday Discuss. 2018, 210, 301−315.
the reviewers for their useful suggestions that made this work (19) Masa, J.; Batchelor-McAuley, C.; Schuhmann, W.; Compton, R.
stronger, specifically, the ideas to future-proof the code to allow G. Nano Res. 2014, 7 (1), 71−78.
for the variability in potentiostat models and the highlighting of (20) Soares, C. O.; Rodríguez, O.; Buvat, G.; Duca, M.; Garbarino, S.;
Guay, D.; Denuault, G.; Tavares, A. C. Electrochim. Acta 2020, 362,
Soft Potato as part of the Potato ecosystem. 136946.
■ REFERENCES
(1) Sevov, C. S.; Brooner, R. E. M.; Chénard, E.; Assary, R. S.; Moore,
(21) Perry, S. C.; al Shandoudi, L. M.; Denuault, G. Anal. Chem. 2014,
86 (19), 9917−9923.
(22) Rodríguez, O.; Denuault, G. J. Electroanal. Chem. 2021, 882,
J. S.; Rodríguez-López, J.; Sanford, M. S. J. Am. Chem. Soc. 2015, 137 115021.
(45), 14465−14472. (23) Nicholson, R. S. Anal. Chem. 1965, 37 (11), 1351−1355.
(2) Wang, G.; Li, W.; Huang, B.; Xiao, L.; Lu, J.; Zhuang, L. ACS Appl. (24) Kim, J.; Bard, A. J. Anal. Chem. 2016, 88 (3), 1742−1747.
Energy Mater. 2019, 2 (5), 3160−3165. (25) Morales, D. M.; Risch, M. JPhys. Energy 2021, 3 (3), 034013.
(3) PalmSens MethodSCRIPT. https://www.palmsens.com/ (26) Ciucci, F. Current Opinion in Electrochemistry 2019, 13, 132−139.
methodscript/ (accessed 2022−09−28). (27) Meloni, G. N. Anal. Chem. 2017, 89 (17), 8643−8649.
4844 https://doi.org/10.1021/acs.analchem.2c04862
Anal. Chem. 2023, 95, 4840−4845
Analytical Chemistry pubs.acs.org/ac Technical Note
4845 https://doi.org/10.1021/acs.analchem.2c04862
Anal. Chem. 2023, 95, 4840−4845