BlueBerry

The BlueBerry is a small, battery-powered device that uses Bluetooth to deliver optogenetic stimulation in freely moving mice. It is built on a simple printed circuit board (PCB) that holds a microcontroller (ATTINY 85), a dedicated Bluetooth module (RN4871), and the electronic components needed to generate high-power pulses on two independent channels. These pulses can be customized in real time through the BlueHub, an Arduino-based controller that sends commands to the BlueBerry over Bluetooth. Because it relies on off-the-shelf parts and standard soldering techniques, BlueBerry is relatively easy for most labs to assemble. In the following sections, we will explain how to build and program your own BlueBerry system, covering both the hardware setup and the software configuration.

Expanded BlueBerry Wireless Optogenetic device highlighting all the electrical components  Simplified schematic of BlueBerry wireless optogenetic device

Hardware assembly

This guide covers the entire process of building a BlueBerry device for wireless optogenetic experiments, including solder paste application, surface-mount and through-hole component placement, battery attachment, and final assembly. Before you begin, ensure you have access to the following equipment and tools:

  • A 3D printer (a basic model is sufficient) for printing the stencil alignment device.
  • A reflow oven for soldering surface-mounted components.
  • A basic soldering station for through-hole elements and connecting the battery to power pads.
  • Standard lab tools such as a microscope for inspection, tweezers, and solder paste.

To build the BlueBerry, you will need a custom PCB and various electronic components. The PCB production file can be downloaded from the download page (BlueBerry Hardware Package), and we recommend ordering from PCB GoGo, although other manufacturers can also be used. Follow these steps:

  1. Create an account on the PCB manufacturer’s website (e.g., PCB GoGo).
  2. Follow the manufacturer’s specifications for PCB material, thickness, and copper weight (oz) and SMD stencil (required for precise solder past application) as outlined in the PCB&Stencil_Order_Guide.png file in the BlueBerry Hardware package. Afterwards (when clicked on "calculate" button) you will be redirected to a new page and asked to upload the PCB Gerber file. Upload the BlueBerry_Production.zip file to complete your order (as indicated in PCB&Stencil_UploadProduction.png).
  3. Use the link below to order all required electronic components from recommended suppliers (This order list is for making only one BlueBerry device).

Additionally, for accurate stencil alignment, you will need to 3D print an alignment device designed to hold the PCBs securely in place during solder paste application. The 3D file (.stl) is also located in the BlueBerry Hardware Package. The alignment device consists of:

  • A right insert for holding the PCB’s front side up.
  • A left insert for holding the PCB’s back side up.

Once you have obtained all materials and printed the alignment device, you can proceed with the assembly process.

Equipment for assembling a BlueBerry device

Step 1: Prepare and Gather Materials

Before proceeding, make sure you have:

  • Two PCB boards (one for each side alignment).
  • 3D-printed alignment tool.
  • Stencil for solder paste application.
  • Tweezers.
  • Transparent tape.
  • Solder paste.
  • Old credit card (or similar flat edge) for spreading solder paste.

Lay them out as shown in the reference image to streamline the assembly process.

Basic components to assemble BlueBerry Wireless Optogenetic hardware

Step 2: Front-Side Solder Paste Application

  1. Place two PCBs in the jig (one on each side).
  2. Align the stencil over the right-side PCB, ensuring all surface-mount pads are visible through the stencil openings. Use a microscope (if needed) to check alignment. Tape the stencil securely to the 3D alignment tool once alignment is correct, preventing movement during paste application.
  3. Place a small amount of solder paste on the stencil near the right PCB area.
  4. Use the credit card to carefully spread the solder paste across the stencil openings.
  5. Flip the stencil away gently (like turning a page) to expose the PCB. Inspect the pads to ensure each has an even layer of solder paste.
BlueBerry's PCB and stencil alignment for solder paste application

Step 3: Place Components (Front Side)

  1. Prepare all necessary components for the front (top) side according to the shown schematic and the parts list provided below.
  2. Use tweezers to position each component precisely onto the corresponding paste-covered pads. When placing the micro- LED, ensure correct orientation according to the reference image, so that the anode and cathode align properly with the PCB pads.
  3. Carefully grab the PCB by inserting the tweezers into the two through-holes while and transfer the PCB to the reflow ovenBake according to your oven’s reflow profile.
  4. Allow it to cool, then verify that all components are correctly soldered.
Soldering the front side of BlueBerry PCB including the LED indicator and the Bluetooth module for wirelessly received optogenetic stimulation protocols

Step 4: Back-Side Solder Paste Application

  1. Flip the PCB with front side already soldered, so that the backside faces up, and place it into the left insert of the 3d printed alignment tool.
  2. If you have not removed the taped stencil, swing it back over the PCB; you should see the backside pads through the stencil openings. Since the back side uses component with finer details, you might need to check your stencil alignment with the PCB under microscope.
  3. Apply solder paste in the same manner as before, using the credit card to spread evenly.
  4. Flip the stencil away gently (like turning a page) to expose the PCB. Inspect the pads to ensure each has an even layer of solder paste.
Applying solder paste with 3d printed alignment device for the front side of BlueBerry's PCB

Step 5: Place Components (Back Side)

  1. Prepare all necessary components for the back (bottom) side according to the shown schematic and the parts list provided below.
    Important note: Adjust the values of R5 and R6 resistors based on the forward voltage of LEDs you will be using for optogenetic stimulation. Here we are using zero-ohms as the BlueBerry was used for to drive blue LEDs (Forward voltage~3.3V) in a pulsed manner. You can keep these resistor at zero-ohm leading to 3.3V output voltage but if you plan to use different color of LEDs (with lower forward voltage) you can alternatively add resistor on your brain implants.
  2. Use tweezers to position each component precisely onto the corresponding paste-covered pads. Given the smaller pads and tighter spacing on the back side of the PCB, it would be easier to do these fine placements under a microscope.
  3. For the output 2x2 connector, you need to cut down a standard 20x2 Mill-Max connector strip to the required 2×2 size. Also, you can customize the height of the connector by trimming the legs of the 2×2 connector to the desired length, as shown in the reference image. Having it cut to the intermediate level is recommended for beginner.
  4. Same as before carefully grab the PCB by inserting the tweezers into the two through-holes and transfer the PCB to the reflow oven. Inspect that all components especially the micro-connector is correctly soldered.
Soldering components to back side of the BlueBerry wireless optogenetic PCB.

Step 6: Micro-switch attachment

  1. Prepare the micro switch by cutting off the third contact, then bending the remaining two leads as shown in the reference image.
  2. Insert the micro switch into the two through-holes from the backside. Solder the micro switch leads from the opposite side using a small amount of solder paste or standard solder
  3. Make sure you are leaving enough clearance between the micro switch and the voltage regulator as shown in the reference image.
Adding micro switch to BlueBerry board

Step 7: battery attchment

  1. Prepare the copper wire: Cut a piece of thin copper wire to approximately 10 mm. Use a razor blade to strip the insulation from both ends, exposing the copper. Dip both stripped ends into solder paste. With a standard soldering iron, briefly heat both ends of the wire where the solder paste was applied, allowing the solder to flow and form a small bead on each end.
  2. Solder the copper wire to the battery’s negative side: Take a VARTA coin battery and orient it so the negative side is facing upward. Place a small amount of solder paste on the center of the battery’s bottom (the negative side). Position one end of the copper wire onto the solder paste on the battery; ensure the wire is angled to the left as shown in the reference image. Briefly apply heat with the soldering iron to attach the wire to the battery’s negative terminal. Gently bend the free (unattached) side of the wire according to the reference image.
  3. Attach the battery to the PCB (negative lead): Pick up the battery by hand (avoid using metal tweezers to prevent short circuits). Align the free end of the copper wire (already attached to the battery’s negative terminal) with the negative (GND) pad on the PCB, and solder it in place. Gently press the battery so that it rests on top of the Bluetooth module’s shield (without covering the antenna) and remains centered on the board, as shown in the image. Since the shield is also connected to ground, there is no issue with the battery’s negative side making contact at this point.. Apply a small amount of solder paste where the battery contacts the shield, then briefly heat it with a soldering tip to secure the battery’s position.
  4. Attach the battery’s positive lead: Cut and strip another copper wire (7–10 mm) in the same manner, removing insulation from both ends and tinning each end with solder. Solder one end of this wire to the positive side of the coin battery. This may involve carefully positioning the wire along the battery’s edge and momentarily applying heat. Align and solder the other end of the wire to the VDD (plus) pad on the PCB, ensuring a clean connection.
Coin battery attachment to the BlueBerry Wireless optogenetic device

BlueBerry Software

Below is a step-by-step guide to uploading the base BlueBerry program onto your device. These instructions cover programming both the ATtiny85 microcontroller (responsible for controlling optogenetic stimulation parameters) and the RN4871 Bluetooth module (responsible for receiving BLE packets from the BlueHub and forwarding them to the ATtiny85). Before you begin, ensure that:

  • You have the Arduino IDE installed and possess basic familiarity with its use.
  • You are using a PC running Ubuntu as your operating system.
  • You have a BlueHub device available for programming the BlueBerry.

Also confirm that your BlueBerry hardware is fully assembled and powered on via its micro switch. Once these requirements are met, you can proceed with the following steps to configure your BlueBerry.

Step 1: Prepare the BlueHub for programming BLUEBERRY

  1. Replace the Arduino UNO Rev4 on the BlueHub with a standard Arduino UNO. Confirm that the that the programming mode switch is in the correct position (Away from the USB plug, see picture below) for Arduino programming and therefoire orange LED on the BlueHub is off.
  2. In the Arduino IDE, open File → Examples → ArduinoISP → ArduinoISP and upload this sketch to your Arduino UNO. Upload the ArduinoISP program onto the Arduino UNO. This configures the UNO as an in-system programmer (ISP) for programming the ATTINY85 module of the BlueBerry device.

Programming the Attiny85 module module of BlueBerry device through programming station of the BlueHub controlling unit

Step 2: Install Boards and Libraries for the ATtiny85

  1. Open the Arduino IDE and go to File → Preferences. In the “Additional Boards Manager URLs” field, add:
https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
  1. Next, navigate to Tools → Board → Board Manager. Type “attiny” into the search bar and install the ATTiny board library by David A. Mellis.
  2. Download the TinyWire library (.ZIP file) for I²C communication on the ATtiny85 form the link below and in the Arduino IDE, go to Sketch → Include Library → Add .ZIP Library, then select the downloaded file to complete the installation.
https://github.com/lucullusTheOnly/TinyWire

Step 3: Adjusting the Clock and Programming the ATtiny85

  1. Power on your BlueBerry device via its micro switch, then attach it to the BlueHub’s programming port. Ensure that the Arduino UNO (configured as ISP) is connected to your computer.
  2. In the Arduino IDE, select
    • Tools → Board → ATtiny Microcontrollers → ATtiny25/45/85
    • Set Tools → Clock to Internal 1 MHz to reduce power usage on the BlueBerry device.
    • Under Tools → Programmer, select Arduino as ISP,
    • Under Tools → Port, choose the port for the connected Arduino UNO.
    • Verify that your selections match the recommended configuration shown on image below.
    • Finally click Tools → Burn Bootloader. The micro LED on the BlueHub should blink during this process, indicating successful bootloader burning.
  3. Download and Unzip the BlueBerry base software package and open the BlueBerryATTINY85Config.ino file in the Arduino IDE. With the exact same settings as previous step (Internal 1 MHz clock, Arduino as ISP, correct board and port), upload the sketch. The Arduino UNO will program the BlueBerry’s microcontroller, which decodes incoming BLE packets transmitted via I2C to control optogenetic stimulation (frequency, pulse width, number of pulses, and output channel).
Programming the Attiny85 module module of BlueBerry device through programming station of the BlueHub controlling unit

Step 4: Configuring the RN4871 Bluetooth Module

  1. Unplug the BlueBerry device from the BlueHub and reset the BlueBerry device but turning it off and on again via the BlueBerry micro switch. Connect again your BlueBerry device to the BlueHub programming port, but this time slide the programming switch of BlueHub toward the Arduino’s USB plug (as shown in the image below), turning the orange LED on. This puts the Arduino UNO into a reset mode, effectively acting as a USB-to-serial converter for communication with the Bluetooth module of BlueBerry, the RN4871.
  2. On your Ubuntu machine, open a terminal and navigate to the folder containing the BlueBerry software package where next to the .ino file there is also a bash file called BlueBerryBLEConfig.sh. This script will reset all Bluetooth settings, allows you to give an ID to your BlueBerry device and finally upload the program for the Bluetooth module allowing to transmit the received packet via I2C to the ATTINY85 microcontroller.
    • First make the configuration script executable by typing:
      chmod +x BlueBerryBLEConfig.sh
    • Now you can run the script by typing:
      sudo ./BlueBerryBLEConfig.sh
    • The script automatically detects the serial port of the Arduino UNO and asks you to assign a unique ID (1–9) to your BlueBerry.
    • Once completed, the indicator LED of BlueBerry device will blink (ramping), indicating that it is ready for a BLE connection.
BlueHub configuring BlueBerry BLE module for optogenetic stimulation

STEP5: Final Check and Usage

At this point, both the ATtiny85 microcontroller and the RN4871 Bluetooth module on your BlueBerry are fully configured. You can attach any required optogenetic implants and use the BlueHub’s manual testing switches (next to the BNC inputs) to test stimulation. With the BlueBerry powered on and the BlueHub properly configured, the device is ready for closed-loop or open-loop optogenetic experiments in freely moving animals. Please check the User Manual from the documentation page to test and use BlueBerry devices.

Wirelessly activated optogenetic stimulation on a BlueBerry device through BlueHub Controlling unit