Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Atlas Scientific Logger – Sleep between readings

Home Forums Mayfly Data Logger Atlas Scientific Logger – Sleep between readings

Viewing 9 reply threads
  • Author
    Posts
    • #14714
      ggraves
      Participant

        Hi,

        I am having an issue attempting to setup a datalogger to record readings and put the Mayfly to sleep. My setup is an Atlas Scientific EC and temperature probe as I2C protocol connected to an I2C hub. I would like to simultaneously take readings from both of these sensors and save them to the SD card. Meanwhile, have the sensors go to sleep between readings. Would anyone be able to tell me what I’m missing? Please see code below

        Thanks!

      • #14715
        Shannon Hicks
        Moderator

          It looks like this code was based on one of our old sleeping Mayfly logger example sketches, but there’s some stuff in the main Loop that is out of order. I’m assuming you’ve got the Atlas sensors connected to the I2C Grove port on the Mayfly. If you want to be able to switch their power on and off, then you need to move the small jumper on the headers pins next to those Grove ports to the 3.3v-SWITCHED position. Then you need to turn on the sensor power pin (D22) on and off in your code. Pin D8 is the green LED and your code sets it low once but never does anything else with it. I typically turn the green LED on when the board is awake and taking a reading, to let the use know that something is happening. You’ll also see the red LED by the Grove sockets turn on when the switched power is turned on, too. You’ve also got to run the sensor sampling function while the sensor power is on, and in your code you’ve got that happening after everything, including writing the data. I didn’t go through the entire sketch to look for all problems, but I think fixing a few things in the main Loop will get you most of the way to solving your issue. Here’s how I would write that section, but you might want to change it based on your goals.

        • #14716
          ggraves
          Participant

            Thanks! I worked through a couple of things, including your suggestions, and I still can’t get the logger to wake up… I know the switch works because if I set it to HIGH in the setup the board does come on and the sensors read/turn on without the sleep functions (and the RTC is functioning/correct). Do I need to have a wakeup function or something in the getdata() function for the sensors as well?

          • #14717
            Shannon Hicks
            Moderator

              Is the board sleeping all the time and not waking? Or is it awake all the time and not sleeping? Is data being saved to the card or printed to the serial terminal?

            • #14718
              ggraves
              Participant

                It is sleeping all the time and not waking. No data is being saved or printed to the serial terminal.

              • #14719
                Shannon Hicks
                Moderator

                  I just compiled and ran your code on my own Mayfly board (replacing the Loop function with the one I edited above), and commenting out anything relate to the Atlas sensors since I don’t have any here for testing, and the Mayfly board slept properly, woke up every minute and took a “sample”, wrote data to the card, and went back to sleep.

                  If you board isn’t waking up and you don’t even have the two header lines on your memory card, then that means your board isn’t even getting to the main loop. I would guess there’s problem with either your memory card, memory card socket, RTC chip or battery (you have the positive side of the coin cell facing up, right?), or something wrong in your sensor wiring that is either shorting something out or causing the sketch to lock up before it can run.

                • #14721
                  ggraves
                  Participant

                    Thanks for troubleshooting the code. Looking at it more…It works with one sensor but not with both on the same I2C hub. It seems that there is a problem when both grounds are connected to the hub with the sleep/RTC pin. I have tried multiple hubs/cables to no avail. Starting to think it is a conflict with one of the sleep functions/libraries because I can run 2 sensors on this hub just fine if I don’t have the sleep code.

                  • #14738
                    Jim Moore
                    Participant

                      I am using the same hardware with my Low Cost EC stations   which is set up for UART mode but I have since upgraded to I2C mode when I added the 2G modems.  I am using the sensorex probe for the EZO EC which has an integral RTD which I read thru the analog input.  I think its only about a $30 premium for the the RTD option.  Maybe there are some ideas in my blog that will help.

                    • #14755
                      Sara Damiano
                      Moderator

                        I’m sorry I’m late to the game on this one.

                        Shannon said more clearly what I would have said. But re-reading, I remember that the Atlas sensors are special. You can’t cut the power to the Atlas circuits while they’re connected to the I2C bus of the Mayfly or your program will crash. The Atlas circuits have the I2C lines pulled up to the voltage in line. If you set the voltage in to ground (ie, turn it off) the I2C lines get pulled down as well. The Arduino I2C (Wire) library hangs forever when that happens. So if you want to power down your Atlas sensors you need to get an isolator.

                      • #14756
                        Sara Damiano
                        Moderator

                          All of the Atlas sensors do have a built in sleep command that you can use for low power without needing the isolator. You should be able to add ‘RTD.send_cmd(“SLEEP”);’ and ‘EC.send_cmd(“SLEEP”);’ to your system sleep function.

                          • #14823
                            ggraves
                            Participant

                              Thanks, @srgdamiano and @shicks! After working through the code, what seemed to work was actually placing the sensor sleep commands in my getdata() function. For whatever reason it didn’t work too well in the systemSleep function as it seemed to stall my sensors and not allow enough time to wakeup the sensors for reading. Still working on cleaning up the code, but will share for those that are interested once I get everything up and running!

                        Viewing 9 reply threads
                        • You must be logged in to reply to this topic.