Close
0%
0%

Wireless automated homecage two-bottle choice test

A wireless adaptation of https://hackaday.io/project/158279-automated-mouse-homecage-two-bottle-choice-test

Public Chat
Similar projects worth following
457 views
This is a wireless adapation of the 2 bottle choice test made by Meaghan Creed:https://hackaday.io/project/158279-automated-mouse-homecage-two-bottle-choice-test. It uses a Particle Photon (https://www.particle.io/) as the microcontroller, and logs data in Blynk using tools in MIOS ecosystem: https://hackaday.io/project/129085-mos

This project is an adaptation of an automated 2-bottle choice test that uses a Particle Photon instead of an Arduino, to send data wirelessly.  The data is visualized and exported using MIOS tools in Blynk.

Tasks to do for this project:

1) Update 3D housing to hold Photon and 3-cell battery - COMPLETED JULY 17, 2018

2) Adapt code to Particle Photon - COMPLETED JULY 17, 2018

3) Design app in Blynk - COMPLETED JULY 17, 2018

4) Create 10 devices and collect validation data - STARTING THIS NOW!

  • Setting up the Blynk app

    Lex Kravitz06/30/2018 at 22:00 0 comments

    See instructions here for info on how to set up a Blynk app to monitor multiple devices like this, including exporting data, etc.


    I've set this up to have a home-screen that tracks total interaction time on both sippers (currently only showing one device but the idea is to monitor many of these at once. For each device we're tracking total interaction time on each sipper, as well as battery voltage.  I'll re-post screenshots when I have more devices online!

    If you want to follow along, here's the QR for the Blynk app!

  • Particle code

    Lex Kravitz06/30/2018 at 21:54 0 comments

    The code is also a lot simpler than the original design, as this is an IoT device.  That means that it doesn't need to keep track of the time (the internet knows this), or log data (we'll use Blynk for real-time visualization and logging).  So really all the code needs to do is monitor 2 photointerrupters and count how long they are broken.  

    Here's my first code!

    It works and is probably good enough, but I may try to implement sleep on the Photon to save battery.  Right now I'm not doing that because I don't want to lose data while it's re-connecting to WIFI after sleep, and I can only get the Photon to wake on 1 pin, not 2.  So I could only have it wake on one sipper.  If anyone has insight into how to implement sleep in this project please drop me a line!

    /******************************************************************************
    Blynk virtual pins:
    V0 = Battery voltage
    V1 = Battery altert
    V2 = left licks
    V3 = right licks
    V4 = total licks
    V5 = left binary (1 if it's active)
    V6 = right binary (1 if it's active)
    V7 = Left - right (difference in seconds)
    
    Original Creation Date: June 29, 2018
    
    This code is released under the MIT license.
    Distributed as-is; no warranty is given.
    ******************************************************************************/
    
    #include <blynk.h>
    #include <SparkFunMAX17043.h>
    
    double voltage = 0; // Variable to keep track of LiPo voltage
    double soc = 0; // Variable to keep track of LiPo state-of-charge (SOC)
    bool alert; // Variable to keep track of whether alert has been triggered
    char auth[] = "BLYNK TOKEN HERE";  //Blynk token (get this from the app!)
    int leftPin = 2;
    int rightPin = 3;
    int left=0;
    int right=0;
    int leftbinary=0;
    int rightbinary=0;
    int total=0;
    
    void setup()
    {
        Serial.begin(9600); // Start serial, to output debug data
        lipo.begin(); // Initialize the MAX17043 LiPo fuel gauge
        lipo.quickStart();
        lipo.setThreshold(20); // Set alert threshold to 20%.
        Blynk.begin(auth);
        delay (500); //allow device to settle
    }
    
    void loop()
    {
        if (digitalRead(leftPin)==LOW){
            leftbinary=1;
            delay (650);  //this delay slows incrementing to 1 count per second
            left++;  //increment leftlicks by 1
            total++;
        }
    
        if (digitalRead(rightPin)==LOW){
            rightbinary=1;
            delay (650);    //this delay slows incrementing to 1 count per second 
            right++;  //increment leftlicks by 1
            total++;
        }
        
        voltage = lipo.getVoltage();
        soc = lipo.getSOC();
        alert = lipo.getAlert();
        
        //Write data to Blynk
        Blynk.virtualWrite(V0, voltage);
        Blynk.virtualWrite(V1, alert);
        Blynk.virtualWrite(V2, left);
        Blynk.virtualWrite(V3, right);
        Blynk.virtualWrite(V4, total);
        Blynk.virtualWrite(V5, leftbinary);
        Blynk.virtualWrite(V6, rightbinary);
        Blynk.virtualWrite(V7, left-right);
        
        Blynk.run();
        delay(200);
        leftbinary=0;
        rightbinary=0;
    }

  • Circuitry is much simpler!

    Lex Kravitz06/30/2018 at 21:50 0 comments

    The circuitry for this one is much simpler, due to it being an IoT project and not a stand-alone datalogging project.  As the internet already knows the time we don't need an RTC, and as Blynk logs data we don't need an SD card reader.  

    I decided to use the Sparkfun Photon battery shield, as I want this to be battery powered and it contains a "fuel gauge" chip in it.  For $13 it seems like a very convenient solution.

    This shield has the pins broken out for soldering.  I just needed to wire up 2 photo-interrupters and attach them to 3.3V, GND, and D2/D3 (left/right).  And then plug in a battery.

    More detailed schematics coming, but that's it for the hardware!

  • 3D design

    Lex Kravitz06/30/2018 at 21:45 0 comments

    Working on the 3D design.  Photos of the prints coming soon!

View all 4 project logs

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