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

Wiring Ultrasonic sensor w/ temp compensator

Home Forums Mayfly Data Logger Wiring Ultrasonic sensor w/ temp compensator

Viewing 20 reply threads
  • Author
    Posts
    • #2253
      Luis Andres Guillen
      Participant

        Hi,
        I am trying to get a Ultrasonic sensor to work. Hope I can get help with 3 questions:

        1. I need to wire the temperature compensator Maxbotic MB7955 to the Ultrasonic sensor MB7389. I have already a terminal soldered to the Ultrasonic sensor. I know that the red cable from the temp compensator goes to pin 1 in the ultrasonic sensor, but then I have two more cables that I should attach to the sensor: Shield (yellow) and White. Where should those to cables go? In a picture from the workshop I saw one cable connected to black. But I don’t know if that is the Shield or if that is White, and what happened to the other cable.

        2. Then from the Ultrasonic sensor, I would connect to a Grove Screw terminal and just connect the B,R,G, right? The Grove Screw terminal then goes to Pin 5 in the Datalogger

        3. Is there need to have an extra line of code for the temperature compensation sensor, or the Ultrasonic sensor will work fine just by connecting it?

        Thanks in advance for any help,
        Luis Andres Guillen

      • #2255
        Shannon Hicks
        Moderator

          The temperature compensation sensor for the Maxbotix sensor doesn’t interact with the Mayfly at all. It’s connected directly to the ultrasonic sensor’s pin #1, so the Mayfly doesn’t need to know anything about it. All the Mayfly does is capture the serial data that comes from the sensor’s data pin.

          I’ll be away from my desk most of the day doing remote sensor station installation, but when I get back to my lab I’ll try to take some pictures of the wiring setup for my ultrasonic stations and post those along with a description of how to hook up the cables.

        • #2262
          Luis Andres Guillen
          Participant

            Hello Shannon,
            Did you have a chance to take the pictures of the wiring setup. Or are they posted somewhere else?
            Thank you in advance!
            Luis Andres Guillen

          • #2278
            Raider
            Participant
            • #2279
              Sara Damiano
              Moderator

                The red cable from the MaxTemp goes to pin 1 on the MaxSonar. The shield (yellow) and black cables from the MaxTemp both go to pin 7 on the MaxSonar. Pin 7 on the MaxSonar is also connected to ground (black) from the grove, so you’ll be shoving three wires into the MaxSonar screw terminal at Pin 7. Pin 6 on the MaxSonar goes to Vcc (red on the grove). Pin 5 on the MaxSonar goes to D2/white on the grove, if you want to use pin 5 on the Mayfly to receive data.

                In your data sketch, you then need to set up an instance of SoftwareSerial with the Rx set as pin 5. Then you want to use the parseInt() function to capture the data from the MaxSonar. (But throw away the first 6 lines from the MaxSonar after power-up, because it sends out a header before sending out data.) There’s an example sketch here: https://github.com/EnviroDIY/EnviroDIY_Mayfly_Logger/blob/master/examples/mayfly_sonar/mayfly_sonar.ino

                You can also use the ModularSensors library (https://github.com/EnviroDIY/ModularSensors) with the MaxSonar, if you’d prefer.

              • #2351
                Luis Andres Guillen
                Participant

                  Thank you Sara,
                  I got to work with the example sketch. Hurra!
                  I have seen how much work you have put into the ModularSensors library, and I was trying to make that work, but I’m stuck in trying to download the library dependencies as .zip files, in order to get the libraries into Arduino. I could only download the “.h” files. I’m obviously new with this so I would really some help on how to get them to work.
                  Thank you in advance!
                  Luis Andres Guillen

                • #2353
                  Sara Damiano
                  Moderator

                    I’m sorry for the library download trouble! How are you trying to download them? The easiest way is to get all the libraries for the Arduino IDE is pull them all together from the libraries repo: https://github.com/EnviroDIY/Libraries. If you scroll down, there are instructions for the Arduino IDE and PlatformIO. This will probably pull in some other libraries that you aren’t interested in, but they’re very small files so it shouldn’t be a problem.

                  • #2355
                    fisherba
                    Participant

                      Hi all,

                      I just wired up a temp compensation on MB7389, and after I dumped everything and re-cloned the modular library master branch (managed through GitHub Desktop) after the re-clone it worked for me.

                      This example sketch that Sara recommended above also seems to work ok (in pin 5).
                      https://github.com/EnviroDIY/EnviroDIY_Mayfly_Logger/blob/master/examples/mayfly_sonar/mayfly_sonar.ino

                      The sonar test from the modular library master branch (in pin 11) returns a distance and indicates “good result found” and the response matches the distance I’m measuring.
                      https://github.com/EnviroDIY/ModularSensors/blob/master/sensor_tests/sonar_test/sonar_test.ino

                      The single sensor example from the modular library master branch (in pin 11) oscillates between returning a good distance and one that is 6 meters further than reality.
                      https://github.com/EnviroDIY/ModularSensors/blob/master/examples/single_sensor/single_sensor.ino

                      After commenting out several of the extra sensors, I was also able to run it on the multisensor print sketch.
                      https://github.com/EnviroDIY/ModularSensors/blob/master/examples/multisensor_print/multisensor_print.ino

                      I have attached a photo of my wiring. @srgdamiano, great work on the modular library!

                    • #2357
                      Sara Damiano
                      Moderator

                        I’m sorry, I’ll have to look into why you’re getting some values that are too high.

                      • #2358
                        Luis Andres Guillen
                        Participant

                          Thanks Sara, I got the libraries installed now! existed to try out the new modules! Stroud rocks!

                        • #2359
                          Luis Andres Guillen
                          Participant

                            I get the same issue with the single sensor sketch. A value that is 6 meters or 5 meters more than reality.

                            I also cannot get the arduino to get the actual time. it starts and stays in 01-01-2000. Any thoughts about that?

                          • #2360
                            Luis Andres Guillen
                            Participant

                              I have the Mayfly v 0.4 could that be the issue? .

                            • #2383
                              Luis Andres Guillen
                              Participant

                                Hello community! I still have the issue with the data loggers time step. The mayfly doesn’t read my computers time and is not updating. Do you know what could be reason for that problem and how i could solve it???

                                I’ve attached the modified code from the libraries that I’m using.

                                Thanks very much in advance.

                              • #14377
                                Matt Barney
                                Participant

                                  Apologies for resurrecting an old thread, but it is exactly on-topic for my situation.

                                  I’m confused about wiring the MaxTemp. The ModularSensors documentation says to connect the red wire from MaxTemp to the MaxSonar’s pin 6 (V+). However, the MaxBotix datasheet shows no connection of the MaxTemp to V+. Likewise, @fisherba Beth’s photo above shows there are only 2 connections from MaxTemp:  one to the MaxSonar’s pin 1 (via yellow Grove wire) and the other to pin 7, GND (black wire). Beth said her circuit works, so @srgdamiano, is the ModularSensors doc incorrect?

                                  Thanks!
                                  Matt

                                • #14378
                                  Sara Damiano
                                  Moderator

                                    Follow the datasheet.  If the docs for ModularSensors disagree they’re probably outdated or just wrong.  I’m s..l..o..w..l..y.. working through the documentation and transferring to a Doxygen based documentation set here:  https://envirodiy.github.io/ModularSensors/getting_started.html.  But I’ll add this to my list of bits to fix.

                                  • #14383
                                    Matt Barney
                                    Participant

                                      OK, thanks Sara. I really like the look and layout of the new Doxygen docs. Thanks for all your efforts!

                                      Matt

                                    • #14414
                                      Matt Barney
                                      Participant

                                        I’ve probably done something dumb in my code, but can’t see what it is, so I could use another set of eyes on it…

                                        I’ve got a MaxBotix MB7589 SCXL-MaxSonar-WRMT and have it communicating via NeoSWSerial on pin 7. Using the single_sensor.ino example, it works fine. Now I’m trying to integrate it a logging sketch, based on DRWI_NoCellular.ino, and I never get any readings displayed nor written to the SD card. Code is attached. If I comment the sonar_range variable out of the variableList, it works, and the remaining variables get successfully logged.

                                        Here is the debug output after turning on the debug flag in MaxBotixSonar.h:

                                        Thanks,
                                        Matt

                                      • #14423
                                        Matt Barney
                                        Participant

                                          I think my code must not be catching the interrupt properly. It doesn’t get beyond this line in MaxBotixSonar.cpp:

                                          I am able to get it working by using AltSoftSerial (Rx on pin 6), but am unable to get NeoSWSerial to read from the MaxBotix sensor.

                                          Any help is appreciated.

                                          Thanks,
                                          Matt

                                        • #14469
                                          Matt Barney
                                          Participant

                                            Any ideas why AltSoftSerial works here, but NeoSWSerial doesn’t?

                                          • #14470
                                            Sara Damiano
                                            Moderator

                                              Oops, sorry that I missed this.

                                              Are you using slashDevin’s original NeoSWSerial or are you using my fork? (It’s in SRGDamia1, not EnviroDIY.)  The original didn’t implement the peek function which would cause it to fail.

                                            • #14471
                                              Matt Barney
                                              Participant

                                                Yep, that was it. When I didn’t find the library in EnviroDIY, I just grabbed it from slashdevin’s original. Now that I have your fork of NeoSWSerial, it works. Thanks!

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