We Code, built, and share our thoughts to do chemistry

Thursday, 13 February 2025

Devlog - Building Potentiostat: Microcontrollers

Potentiostat cannot run by itself. We need to configure parameters such as voltage range, scan rate, mode (linear sweep voltammetry, cyclic voltammetry), number of measurements per time, etc. It's going to be difficult to configure all of these parameters manually. Therefore, we need a controller to control and monitor the measurements.

For the microcontroller selection for potentiostat applications, there are several considerations we take into account, voltage tolerance, type  and amount of peripherals it provides. This would make sure that we can utilise and maximise the performance of the device.

First thing first, the microcontroller, there are many selections of microcontroller we select from such as Arduino, ESP32, ESP8266, Raspberry pi pico, STM32, even the RISC-V's CH32V. Arduino provides rich libraries and high digital voltage level which can be useful for potentiostat voltage range. However arduino has several limitations such as the number of timers and memory. Despite some works managed to push the limits of arduino for this application(link), We believe having more flexibility and less constraints in the project would be more beneficial during the development process. This goes the same with ESP-based microcontrollers. Even though they provide communication modules such as WiFi or bluetooth, the logic level voltage is 3.3V that might require additional peripherals such as level shifter in order to communicate with 5V based modules. Raspberry pi pico offers better performance, even with dual core and streamlined software development. However, the capability to tolerate 5V is a deal-breaker. Therefore the choices are either STM32-based microcontrollers or WCH32-based microcontrollers.

Throughout the development, We have been using both STM32 and WCH32 based microcontrollers. To be more precise, We've been using it back-and-forth for this project. Recently, We used both STM32G0-based and CH32V307-based microcontrollers. We're not sure either skill issue or hardware reliability, STM32G0 provides better hardware reliability than CH32V307 microcontrollers. Nevertheless, both provide such an experience in developing projects using various microcontrollers.

In order to optimise the use of microcontrollers for potentiostat applications,  several microcontrollers should be used. Here are several peripherals We use for the potentiostat.


PC-Device communications: UART

In order to configure and give command to the microcontroller, we need to be able to communicate with it. One of the simplest ways is to communicate through Universal Asynchronous Receiver-Transmitter(UART). It's simple and fast enough to communicate for such a simple computer-device communication. What's better in using either STM32 or CH32V-based microcontrollers we have that they both provide UART interrupt. Interrupt, as the name suggests, would intervene the current code, run the interrupt code, and return the intervened code. UART interrupt service routine (ISR) will take place when a particular condition is achieved. For example, when we provide a buffer containing several characters, when the number of characters has been achieved or past the number of available buffer, the interrupt code (handler) would take place. The use of interrupt also makes the device experience work more smoothly.

USB communication would be more desirable. However, we'll focus on completing it and making it work optimally first. Once, it's achieved we can think of better improvements.

Analogs: DAC and ADC

Since potentiostat involves heavily analog signals, analog peripherals such as digital-to-analog converter (DAC) and analog-to-digital converter (ADC) would absolutely be a must. DAC is used to generate analog signals for potentiostat. Even if we can use filters to generate similar signals, DAC provides more reliable analog signals. Therefore a microcontroller with a DAC is a must. We can still use external DAC though for better resolution and wider voltage range, though. However, somehow the DAC is conflicted with the external ADC we also use which creates an headache. Therefore, at the moment we're sticking to use internal DAC from the microcontrollers. Furthermore, 12-bit resolution is still more than adequate.

Besides the analog generator, we would also need to read the analog signal, which is why the ADC comes in. Built-in microcontroller has already 12-bit resolution. However, I use external ADC with 16-bit resolutions providing more precise reading and wider voltage range. Wider voltage range is important because the voltage generated might be over what it's designed to be. Even if we use zener diode to protect the overvoltage, It's good to have another line of protection.

Right place and the right time: Timer Interrupts

After the peripherals are all set, the question is when do we set the voltage or read the voltage? That's when we implement timers. There are many types of timer. In this case, Once the timer is start, it would intervene the current code and run the interrupt code (handler) after certain period and repeat until we tell them to stop. In our case, we use separate timers for generating and reading analog signals. We do it to prevent deep if-else conditions on handler code. It might add more complexity in which the timers have to be set and configured separately. The microcontroller has multiple number of timers which we can utilise. Moreover, preventing deeper if-else conditions in handler code can make the code run more reliably during interrupt service routine. We use 100ms interval for both signal generation and voltage reading with 50ms difference. Therefore, when the timer for signal generation is start, timer for voltage reading would be set 50ms later. This ensures the voltage settled and accurately read by the ADC.

Tuesday, 11 February 2025

Thoughts: Redox-mediated materials for lithium battery recycling

Few years ago, I learnt about a startup managed to recycle a lithium battery using electricity. I found it interesting to see how it works because when I hear about "recycling", it's usually all about leaching the materials with various process of extracting the materials one at a time. When I read the press article, it was such a remarkable approach to tackle an environmental issue without causing much environmental risks and damages. 

Redox-mediator is a compound in which electron transfers are facilitated in the electrochemical reactions. Redox mediator is electrochemically reversible meaning that once the redox reactions with the redox mediator takes place, it can be reversibly regenerated to its original form. This reversibility attracts many interests for many electrochemical applications such as electrocatalysis, battery, etc.

Here's the image I found about lithium battery recycling from Singapore Battery Consortium 

Figure 1. The General Schematics of Lithium Battery Recycling(souce)

The way the lithium battery is recycled is really ingenious. I cannot really describe how the process work in details. However in general, the battery materials reacts with redox mediator leaving lithium ions floating in the solution. The solution is then  electrolysed and the lithium reacts with hydroxide ions forming lithium hydroxide. Finally, the lithium hydroxide is separated from the systems.

Principally, The battery materials (Lithium Iron Phosphate, LFP, in this case) undergoes redox reaction with redox mediator in the anodic tank, ferricyanide, in which the LFP is oxidised while ferricyanide(yellow) is reduced to ferrocyanide. This is one of the heart of the reaction in which the redox mediator plays its part, undergoing electron transfers, redox reactions. It transforms iron oxidation number +2 to +3 that pairs with the -3 phosphate leaving Lithium ions.

Here's the reaction:
Fe(CN)63-(aq) + LixFePO4(aq) → Fe(CN)64-(aq) + FePO4(s) + xLi+(aq)

The produced ferric phosphate is insoluble in water(link).  The solution containing ferricyanide and lithium ions is then electrolysed for further processing.

During electrolysis process, the ferricyanide is re-oxidised back to ferrocyanide at the anode. This reaction reverts back the reduced redox mediator to its original form allowing the oxidation of LFP for lithium ion removal in the previous process. 

At the anode:
Fe(CN)6-4(aq)  → Fe(CN)6-3(aq) 


On the other hand, there are two other interesting processes during the electrolysis, the separation of lithium from anodic tank and oxygen reduction reaction (ORR). During eleectrolysis process, the electrodes become polarised. The cathode becomes negative and it attracts the positively charged particles, ion, in this case lithium ion. Not only does this electrolysis revert back the redox mediator to its original form, but also it separates lithium ion from the previous solution. The lithium ion is attracted to the cathode and selectively passed through the membrane. This electrolysis process is similar to the lithium-ion battery charging process. Furthermore, at the cathode, the oxygen is reduced into a hydroxide ion, or so called oxygen reduction reaction. 


The formation of hydroxide ions, negatively charged, can attract lithium ion and ionically bond to lithium hydroxide. Lithium hydroxide is one of the precursors of the lithium ion batteries.

At the Cathode:
4Li+ + O2 + H2O + 4e- → 4LiOH

By the time this process is achieved, the spent LFP materials have been successfully separated into  iron(III) phosphate (in the anodic tank) and lithium hydroxide(in the cathodic tank). However, lithium hydroxide is yet fully separated from its solvent, water. Therefore, the compound would have to be separated with a particular technique. The solution containing lithium hydroxide can be further reacted with carbon dioxide producing lithium carbonate, another lithium battery precursor with lower solubility in water. This can be achieved by bubbling the solution with carbon dioxide 

References:
Wang, Q., & Juezhi, Y. U. (2024). U.S. Patent No.  2,057,559. Washington, DC: U.S. Patent and Trademark Office. (link)
2019. Redox Targeting Method For Recycling Of Spent Lithium-Ion Batteries Material. Singapore Battery Consortium (link)
Yu, J., Wang, X., Zhou, M., & Wang, Q. (2019). A redox targeting-based material recycling strategy for spent lithium ion batteries. Energy & Environmental Science, 12(9), 2672-2677. (link)

Last update: Jul 29 2025 (removed the colour of ferrocyanide)

Our potentiostat circuit design approach compared to a glucometer

Previously, we rebuilt a potentiostat circuit to improve our design. We built it on a breadboard as we can experiment with it. You can watch...