Close
0%
0%

Autonomous Research Laboratories

A closed-loop spectroscopy laboratory demo using dimmable LEDs and a spectrophotometer. < $100, < 1 sq. ft, < 1 hr setup.

Similar projects worth following
Starting from
$100.00
sgbaird has 0 orders / 0reviews
Ships from United States of America
We need new materials faster than ever before to solve the world's challenges such as climate change, plastics pollution, and cancer. Self-driving laboratories (autonomous research laboratories) can accelerate the time-to-market from 20 years and $100 million to as little as 1 year and $1 million. However, the barrier to entry for researchers is high in terms of both capital and multi-disciplinary expertise required (hardware, robotics, electronics, artificial intelligence, simulations). There are several excellent low-cost platforms and demos that help reduce barrier-to-entry; however, for wider adoption, we need something that is cheaper and easier to set up. We propose Closed-loop Spectroscopy Lab (CLSLab): a "Hello, World!" for teaching and prototyping self-driving laboratories using a Raspberry Pi Pico W microcontroller, an RGB LED, a light sensor, and optimization algorithms.

Note: much of the content here are snippets from https://dx.doi.org/10.2139/ssrn.4164234. See also the most recent version of the manuscript (as of 2022-09-10).
While there are several excellent platforms in chemistry and materials science for low-cost self-driving laboratories or SDLs (i.e. autonomous research laboratories) [1, 2, 34, 5, 6], for wider adoption of a demo, it needs to be cheaper, smaller, and simpler to set up while still preserving the functional aspects of a materials acceleration platform (MAP). In programming, a minimal working example (MWE) “is a code snippet that can be copied and pasted into an empty ... file and still have the same features (working), and that does not include unnecessary details (minimal). [7]” Here, we pose the question:
What does a minimal working example look like for a self-driving laboratory?

We introduce the idea of a self-driving optics demo for less than $100, a square foot of desk space, and an hour of total setup time. See the following video for an introduction of how this works:


We believe our demonstration adequately meets the minimal, complete, and reproducible requirements of a MWE SDL (Table 1)

ProgrammingSelf-driving Laboratory
MinimalUse as little code as possible that still produces the same problem [7]Minimize the cost, size, and setup while still being an SDL
CompleteProvide all parts needed to reproduce the problem in the question itself [7]Provide software with documentation and a bill of materials with setup instructions
ReproducibleTest the code you’re about to provide to make sure it reproduces the problem [7]Benchmark the SDL using a fixed configuration and verify the results are expected

as well as the high-level definition of a MAP (though not materials specific):

[A system that] carries out high-throughput and/or automated experiments, the results of which are fed back into the AI that guides the selection of subsequent rounds of experimentation to optimize or make a discovery.

The demonstration involves controlling the brightness of light-emitting diodes (LEDs) at fixed wavelengths, sensing the light mixture via a discrete-channel spectrometer, decision-making to tune the inputs to best match the desired spectrum, and optionally, cloud-based simulations to aid in decision-making. The setup is summarized in Figure 1.

Figure 1: Summary of the self-driving laboratory demonstration (SDL-Demo). A microcontroller (Raspberry Pi (RPi)) sends commands to a dimmable red green blue (RGB) light-emitting diode (LED) to control the brightness at different wavelengths. A spectrophotometer measures the light signal at eight individual wavelengths. The microcontroller reads the intensity values from the spectrophotometer and uses these newly measured values and prior information (including e.g. prior measurements and physics-based simulations performed in the cloud) to choose the next set of LED parameters in an effort to better match a target spectrum. The setup adequately meets the minimal requirement of a minimal working example (MWE) self-driving laboratory (SDL) by costing less than 100 USD, occupying less than 1 ft2 (0.1 m2) of desk space, and requiring less than 1 h of setup time.

For more context, see a recording based on my talk at the 2022 acceleration conference in Toronto.


Build Instructions


References

[1] D. Caramelli, D. Salley, A. Henson, G. A. Camarasa, S. Sharabi, G. Keenan, L. Cronin, Networking chemical robots for reaction multitasking, Nature Communications 9 (2018) 3406. URL: https://www.nature.com/articles/s41467-018-05828-8. doi:10.1038/s41467 -018-05828-8, number: 1 Publisher: Nature Publishing Group.

[2] T. Fuhrmann, D. I. Ahmed, L. Arikson, M. Wirth, M. L. Miller, E. Li, A. Lam, P. Blikstein, I. Riedel-Kruse, Scientific Inquiry in Middle Schools by combining Computational Thinking, Wet Lab Experiments, and Liquid Handling Robots, in: Interaction Design and Children, ACM, Athens Greece, 2021,...

Read more »

4.2-paho-mqtt-colab-sdl-demo-test.ipynb

A cloud-based, publicly accessible self-driving lab demo via internet-of-things style MQTT data transfer.

ipynb - 124.01 kB - 10/23/2022 at 03:24

Download

View all 8 components

  • Data logging and backup

    Sterling Baird11/06/2022 at 05:12 0 comments

    On the Pico W device, logs backup data to an SD card if available (JSON strings in a .txt file, one line per experiment), and sends the dictionary data to a free MongoDB server. https://github.com/sparks-baird/self-driving-lab-demo/blob/main/src/public_mqtt_sdl_demo/main.py

  • The sculpting wire is a nice low-cost DIY solution, but what about alternatives?

    Sterling Baird10/23/2022 at 06:08 0 comments

    The sculpting wire is a pretty nice substitute for a gooseneck fixture. The sensor is adjustable yet steady, and additional sensors can be easily added.

    However, for a more scalable solution, a gooseneck fixture with an appropriate adapter to connect to the PCB might be a better choice. For now, I'll stick with threading and twisting some cheap wire :)

  • Batch optimization: three ☁️-based experiments controlled by a central "brain"

    Sterling Baird10/22/2022 at 23:30 0 comments

  • Advanced optimization topics underway

    Sterling Baird10/21/2022 at 04:45 0 comments

    The notebook mentioned in the previous log post illustrates a basic comparison of grid search vs. random search vs. Bayesian optimization. One of SDL-Demo's appeals is the ability to illustrate more advanced optimization topics such as multi-objective optimization, constrained optimization, multi-fidelity optimization, high-dimensional optimization, and combinations thereof.

    So far, I've made example notebooks for multi-objective and continuous multi-fidelity optimization, with more to come. Feedback welcome!

    Multi-objective:

    In this notebook, we will use multi-objective optimization to find optimal trade-offs between each of the 8 recorded wavelengths. This is in contrast to minimizing a scalarized objective such as MAE, RMSE, or Frechet distance relative to a target spectrum. ...

    Open In Colab

    Multi-fidelity (Introduction):

    In the previous notebook, we covered multi-objective optimization: i.e. looking at optimal tradeoffs between multiple, sometimes competing, objectives. Here, we'll take a look a multi-fidelity optimization. First, let's start off by loosely defining a fidelity parameter as a parameter that controls the quality of the information being obtained. ...

    Open In Colab

    Continuous multi-fidelity:

    In the previous notebook, I provided a brief introduction of multi-fidelity optimization in the context of the physical sciences. This notebook will cover Bayesian optimization using two continuous fidelity parameters (atime and astep). We'll compare the total integration time using the multi-fidelity optimization with the integration time costs of running the simulation ...

    Open In Colab

  • Cloud-based, publicly accessible SDL-Demo

    Sterling Baird10/21/2022 at 04:33 0 comments

    I made a Colab notebook allowing remote, public access to an SDL-Demo sitting above my desk in SLC, Utah. The Python package and device-side code are such that you can use a unique ID associated with a Pico W device (or an ID of one's choosing) to communicate with the SDL-Demo over the internet-of-things style MQTT protocol. Give it a spin!

    Open In Colab

  • Basic tests with Pico W

    Sterling Baird08/24/2022 at 06:09 0 comments


    I soldered headers for two Pico W's. Unfortunately, one of the boards seems to be fried, or maybe it's a short-circuit that I need to go in and fix. Either way, my laptop wasn't recognizing it. Soldering iron was non-adjustable in terms of temperature, the soldering wire I had available was thick, and I had trouble with the debug headers. I'm pretty sure it was when I was messing with the debug headers that I messed something up with the RP2040 processor right by it. For the second attempt, I soldered underneath with the black casing of the header pins on top so that I wasn't poking the soldering iron around the surface mount electronics.

    I inserted the headers into the Maker Pi Pico base to act as the soldering mount (similar to the guide here) and taped the Maker Pi Pico base to the table I was working at. I watched a video, though I think the tutorial I linked previously would have been good to go through first. Even better, I should have gone out and bought thinner soldering wire and been more careful where I put the hot soldering tip.

    Many of the indicator LEDs on the Maker Pi still light up for the Pico W that wouldn't connect, but I'm not sure if that means it's worth it to try to fix.

    After that, I set up VS Code with the CircuitPython extension and started testing out the Pico W. `circup` made it pretty easy:

    pip install circup
    circup install neopixel
    circup install adafruit-circuitpython-as7341

     (maybe instead of neopixel I should have installed adafruit-circuitpython-neopixel, but it worked nonetheless).

    I guess the cached directory was getting larger than the drive storage allowed due to mypy linting, so I made it so it caches elsewhere via a .vscode/settings.json file with the --cache-dir mypy argument:

    {
        "python.linting.mypyArgs": [
            "--follow-imports=silent",
            "--ignore-missing-imports",
            "--show-column-numbers",
            "--no-pretty",
            "--cache-dir=C:/Users/<my username>/.mypy_cache",
        ]
    }

    I ran an AS7341 example and the Maker Pi Pico Neopixel example. See a snapshot of those examples here. I was able to control the NeoPixel brightness and RGB values and read the spectrophotometer measurements.

    Next, I need to set up a web server per these instructions. Oof, do I need to switch to using MicroPython instead of CircuitPython? I think probably not.

    Read more »

  • 5 Pico W's just came in

    Sterling Baird08/18/2022 at 02:06 0 comments

  • Mounting

    Sterling Baird08/18/2022 at 01:44 0 comments

    For my first mounting test, I used what was on hand and formed strips of aluminum foil around the wire and added an arm to support it. While it had a nice trade-off of maintaining its position and adjustability, it was too kludgy. I ordered some sculpting wire from Amazon and tried a near-identical setup to the Al foil, but it was also lacking. Unfortunately, the wire was too large to fit through the mounting holes. So, instead, I wrapped the wire around the Blinkt! module and fastened the wire using fishing line.

  • Redesigned for Pico instead of Zero 2 W

    Sterling Baird08/13/2022 at 23:27 0 comments

    • Adafruit Pico version bill of materials
    • For mounting (all versions), thick sculpting wire wrapped around Stemma-QT cable
    • I ordered 5 Pico W's with unsoldered headers at PiShop instead of Adafruit (out of stock)
      • I couldn't find a solderless JIG for the Pico W, but maybe someone will come up with one eventually
      • When the Pico WH is available (and assuming it can be sourced), this is the preferred option
      • The Maker Pi Pico is a version that comes with the Pico directly soldered on, but this didn't seem to be in stock, and I'm not sure if it would come with the Pico W

    The key difference in the switch from RPi Zero 2 W to the RPi Pico W is the Blinkt! module has been replaced by a single NeoPixel LED on a Maker Pi Pico base. The Maker Pi Pico base has Grove ports instead of Stemma-QT, so a Grove to Stemma-QT adapter is included in the parts list. 

    Maker Pi Pico has an example script for the NeoPixel LED. Setup for the Pico can be found in this Adafruit guide or similar guides.

View all 9 project logs

  • 1
    QUICK START

    👇Build Instructions Video Tutorial👇

    1. Prerequisites
      1. Required parts [Self-contained Digikey Order] (60.80 USD + shipping as of 2022-10-20)
      2. Access to a 2.4 GHz WiFi network (SSID + password)
      3. Access to a computer (for initial setup only)
      4. Soldering iron and soldering wire (thinner is better in this case)
      5. (Optional) Before soldering, ensure the Pico W can successfully connect to a computer
    2. Hardware setup
      1. Solder the headers to the Pico W [MagPi guide]
      2. Thread the sculpting wire through the mounting holes on the Maker Pi Pico base and the AS7341
      3. Position the sensor so the pinhole is facing the RGB LED ~3-4" away
      4. Connect the Grove/Stemma-QT connector into Grove port 6 (GP26&27) and the AS7341
      5. Insert the Pico W into the Maker Pi Pico base
      6. Plug the micro-USB-B cable into the Pico W
      7. While holding the BOOTSEL button on the Pico W, plug the USB-A cable into a computer
    3. Software setup
      1. Download and install Thonny. Use the default settings: "Standard (default)"
      2. Click on the lower-right dropdown and "Install MicroPython" (Micropython variant: Raspberry Pi - Pico W / Pico WH)
      3. Change the interpreter from Local Python 3 to Micropython Raspberry Pi Pico
      4. In Thonny's menubar, click "View" then "Files" to open a sidebar
      5. Download sdl_demo.zip from the latest release at self-driving-lab-demo and unzip
      6. Open secrets.py, enter your WiFi network name (SSID) and password, and save
      7. While holding Ctrl (Windows) or Cmd (Mac), select "lib", "main.py", and "secrets.py", right click in the gray region, and click "Upload to /"
      8. Double-click to open main.py, click the green play button and note the PICO ID that prints to the command window ("prefix/picow/<PICO_ID>/")
    4. Control SDL-Demo from the cloud
      1. In the GitHub repository, navigate to notebooks/4.2-paho-mqtt-colab-sdl-demo-test.ipynb and click the "Open in Colab" badge
      2. Scroll to the first code cell and click the play button to install the self-driving-lab-demo Python package
      3. Copy the PICO ID from the Thonny editor and paste it in place of "test" (without quotes)
      4. Run the remaining code cells
        1. Instantiate a SelfDrivingLabDemo class
        2. Perform optimizations for grid search, random search, and Bayesian optimization
        3. Visually compare results
  • 2
    Prerequisites
    1. Order the required parts [Self-contained Digikey Order] (60.80 USD + shipping as of 2022-10-20)
      1. The sculpting wire is also available at Amazon. Approximately 3' is required.
      2. The purpose of the wall adapter is so that, after initial setup, the SDL-Demo can be powered standalone
      3. The bill of materials is also available at Adafruit, though you may need to source a Pico W with headers or a Pico WH separately. See Raspberry Pi's supported resellers for the Pico W.
    2. Access to a 2.4 GHz WiFi network (SSID + password)
      1. The Pico W only supports 2.4 GHz WiFi networks. See self-driving-lab-demo #76 for additional context.
        1. WPA enterprise networks such as Eduroam and other networks that use captive portals (most schools, coffee shops, etc.) aren't supported. It needs to be a network such that on a computer, you can click on the WiFi name (SSID), enter the password, and click connect (no additional steps).
        2. Home networks can have both a 5G and a 2.4 GHz network (e.g. "My Network 5G" and "My Network")
        3. If you use a mobile hotspot, you may need to use your device's "extended compatibility" feature to drop the mobile hotspot from 5G to 2.4 GHz
        4. See also prepaid, long-expiry hotspot and classroom demo with standalone network access discussions
    3. Access to a computer (for initial setup only)
      1. At a minimum, the computer needs to be able to run the Thonny editor (lightweight) and it needs at least one USB-A port
    4. Access to a soldering iron and soldering wire (thinner is better in this case)
    5. (Optional) Before soldering, ensure the Pico W can successfully connect to a computer
      1. You can do this by holding the BOOTSEL button on the Pico W while connecting the Pico W to your computer via the USB cable. If a new drive appears, that indicates the Pico W is working normally
      2. Be careful only to heat the gold pads while soldering to avoid damaging the circuitry
  • 3
    Hardware Setup
    1. Solder headers onto the Pico W
      1. Insert the Pico W headers into the Maker Pi Pico base
      2. Place the Pico W on top of the headers
      3. Solder the headers to the Pico W
        1. MagPi guide
        2. Tom's hardware guide
        3. YouTube video
      4. Remove the Pico W from the Maker Pi Pico base
    2. Prepare 3 feet of sculpting wire (cut with wire cutters or bend until it breaks)
    3. Thread the sculpting wire through each mounting hole on the Maker Pi Pico base, then twist the wires together near the RGB LED. This setup will allow the position and orientation of the sensor to be both adjustable and steady. Continue twisting until you have 4 to 6 inches of twisted wire, and ensure that there are at least 3 inches of loose, untwisted wire at each end (the leftover, untwisted wire will be threaded through the mounting holes of the light sensor in the next step). For reference, a diagram is also attached below.
    4. Thread the same sculpting wire through the AS7341 light sensor, and position the sensor so the pinhole is facing approximately 3 to 4 inches away from the RGB LED.

    5. Connect the Grove/Stemma-QT connector into Grove port 6 (GP26&27) and the AS7341, insert the Pico W, and while holding the BOOTSEL button, connect the Pico W to the computer.

View all 6 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates