Wiring Ultrasonic sensor w/ temp compensator

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

This topic contains 12 replies, has 5 voices, and was last updated by  Luis Andres Guillen 2 weeks, 3 days ago.

  • 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

    Attachments:
  • #2255

    Shannon Hicks
    Keymaster

    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
    Participant

    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
    Participant

    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!

    Attachments:
  • #2357

    Sara Damiano
    Participant

    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.

You must be logged in to reply to this topic.