Atlas Scientific EZO logging program

Home Forums Mayfly Data Logger Atlas Scientific EZO logging program

This topic contains 11 replies, has 2 voices, and was last updated by Profile photo of JimMoore JimMoore 3 months ago.

  • Author
    Posts
  • #2016
    Profile photo of JimMoore
    JimMoore
    Participant

    I am working on code to log data from the Atlas Scientific EZO sensors. I have a working program that will calibrate and configure the subject sensors and log data to an SD card using the Mayfly board.
    After attending the excellent 2 day seminar at Stroud I was inspired to add the sleep functionality and got the sample program (Mayfly-sleep) functioning but limited to simply turning on my sensor via the grove connector for 10 seconds.

    I have added additional code to send r\r to the sensor to initiate data collection and log this data. The attached code is where I’m at and it now won’t compile and I get a “collect2.exe: error: ld returned 1 exit status” error. I’m stuck and any help would be appreciated.

    Also is the code for the Decagon sensors that we set up at the seminar available?

  • #2019
    Profile photo of JimMoore
    JimMoore
    Participant

    By process of elimination the the compile error seems to be related to

      #include <SoftwareSerial.h</ul

      …and I assume this is where the code goes.

  • #2020
    Profile photo of JimMoore
    JimMoore
    Participant

    Maybe I should put all of my code in the sensorWake() function…

  • #2021
    Profile photo of JimMoore
    JimMoore
    Participant

    I tried the NewSoftSerial.h library, which I understand uses interupts instead of polling, and still no joy.

    I think I have run out of options so any suggestions would be appreciated!

  • #2022
    Profile photo of Shannon Hicks
    Shannon Hicks
    Keymaster

    The error you’re getting is because the SoftwareSerial library uses an interrupt method that conflicts with the SODAQ_PcInt library. In order to use those 2 libraries together, you have to use the modified versions of the libraries we posted in our Github repo, along with modifying the library names in your sketch in 3 places. Plus you’ll need to change the pins for your Atlas sensors to use 10 and 11 instead of 6 and 7. This is because the SoftwareSerialMod library ignores interrupts on the port that includes all of the analog pins (where the DS3231 interrupt is on A7) and it ignores pins D0-D7. This allows people to use the SDI12_Mod library to look at SDI12 sensors on pin D6 or D7.

    So download all of the libraries from our repo: https://github.com/EnviroDIY/Libraries/tree/master and be sure to follow the instructions on that page about how to download the .zip file from the tree and not use the green “clone or download” button.

    Once you have the libraries installed, restart you IDE and then modify the top section of your code to point to the new library filenames and update the pin numbers. It’ll look like this:

    I compiled your code with the above changes and get no errors.

    Or if all of this is too complicated, and you have Mayfly board v0.4, you can simply cut the trace on the back of the board on JP1 to change the clock interrupt from A7 to D10, so you can use the board’s third hardware interrupt pin to wake it up instead of using the PcInt pin change library. Then you can remove all reference to the PCInt library from your sketch, change the wakeup pin from A7 to 10, and then use the regular SoftwareSerial library, and putting your sensors back on D6-7. Another user brought this issue up recently: https://envirodiy.org/topic/low-power-project/

  • #2023
    Profile photo of JimMoore
    JimMoore
    Participant

    I have version 0.3 and it looks like I would cut the trace at JP1 but would then have to wire the int pin to D10 since there is only two pads at JP1. I think I can add the wire with out making too much of a mess. Will this work? I’ll also give the software fix a try.

    Any updates on Amazon stock and protoshield availability?

    Thanks for all your help!

  • #2024
    Profile photo of Shannon Hicks
    Shannon Hicks
    Keymaster

    Just do the software fix as suggested above and leave the clock interrupt on A7, then you won’t have to worry about doing any wiring changes. I added the D10 interrupt option on version 0.4 and higher because I thought it might come in handy for people who had interrupt library complications. But it works just fine if you simply use the modified libraries instead.

    I’m still waiting for the shipment of boards from the manufacturer, but hope to have them and the protoshields on Amazon by the end of the month.

  • #2025
    Profile photo of JimMoore
    JimMoore
    Participant

    Thanks, that’s what I did and my program now compiles but doesn’t work but its progress and I’m learning.

    Btw, the libraries.zip gave me a corrupt file error but loading the two _Mod libraries separately worked.

    Is the Decagon code that was used in the seminar available? That might help me understand the deep sleep mode better.

  • #2082
    Profile photo of JimMoore
    JimMoore
    Participant

    I would appreciate help on a problem with my code derived from the Mayfly-sleep.ino example. I am using the SoftwareSerialMod.h library as recommended to resolve a pin conflict. However, when I activate myserial.begin(9600) the program does

      not

    go into sleep mode.

    attached is my code:

    • #2088
      Profile photo of Shannon Hicks
      Shannon Hicks
      Keymaster

      How did you verify that the board isn’t going into sleep mode? Can I assume that you didn’t modify the pads on JP1 and that the clock interrupt is still connected to A7 and you didn’t do anything with D10 other than use the D10-D11 grove port for connecting your sensor?

  • #2090
    Profile photo of JimMoore
    JimMoore
    Participant

    You assume correctly. When operating correctly the red power LED3 is off during sleep mode. I just retested with my sensor disconnected and works properly with myserial.begin(9600) active. Therefor my problem seems to be when the sensor is connected and returning data.

    I need to do a bit more trouble shooting. The objective is to wake the mayfly, turn on the sensor and let it collect n samples of data (1 per second) then go to sleep. A possible related problem is that the tx pin (10) needs to be set low when in sleep mode otherwise it feeds Vcc to the sensor.

    I’ll report back after some further testing.

    Thanks, Shannon

  • #2101
    Profile photo of JimMoore
    JimMoore
    Participant

    I finally solved the never-sleep problem. The problem seems to be related to the slow decay of the power to the Grove connector. With the sensor connected the decay is approximately 50ms. In the senosrSleep() function the power and rx/tx are turned off but the Vcc voltage doesn’t get a chance to decay before this function is exited which seems to cause an immediate wakeup. I added a 100ms delay to that function and now seems to work as planned.

    I am not sure what causes the immediate wake up but must be related to the residual voltage on the pwr pin. With the sensor disconnected the code works with out the delay probably because there is no capacitance to hold up the voltage.

    I cleaned up the code a bit and here is rev 1.0

You must be logged in to reply to this topic.