Home › Forums › Mayfly Data Logger › Wiring Ultrasonic sensor w/ temp compensator
Tagged: Datalogging, mayfly, Temperature compensation, Ultrasonic sensor, wiring
- This topic has 21 replies, 7 voices, and was last updated 2021-07-22 at 7:51 AM by Vinay Ayala.
-
AuthorPosts
-
-
2017-06-07 at 2:21 PM #2253
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 GuillenAttachments:
-
2017-06-08 at 12:36 AM #2255
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.
-
2017-06-27 at 10:14 AM #2262
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 -
2017-07-13 at 9:36 PM #2278
You can try:
https://www.maxbotix.com/Ultrasonic_Sensors/MB7955.htm
https://www.maxbotix.com/Ultrasonic_Sensors/MB7389.htm
for the data sheets.Hope it helps.
-
2017-07-14 at 4:41 PM #2279
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.
-
2017-10-02 at 3:54 PM #2351
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 -
2017-10-05 at 4:49 PM #2353
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.
-
2017-10-06 at 12:26 PM #2355
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.inoThe 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.inoThe 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.inoAfter 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.inoI have attached a photo of my wiring. @srgdamiano, great work on the modular library!
Attachments:
-
2017-10-06 at 12:42 PM #2357
I’m sorry, I’ll have to look into why you’re getting some values that are too high.
-
2017-10-06 at 4:10 PM #2358
Thanks Sara, I got the libraries installed now! existed to try out the new modules! Stroud rocks!
-
2017-10-09 at 10:21 PM #2359
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?
-
2017-10-09 at 10:30 PM #2360
I have the Mayfly v 0.4 could that be the issue? .
-
2017-11-07 at 9:03 AM #2383
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.
-
2020-07-23 at 1:01 PM #14377
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 -
2020-07-23 at 6:08 PM #14378
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.
-
2020-07-23 at 11:28 PM #14383
OK, thanks Sara. I really like the look and layout of the new Doxygen docs. Thanks for all your efforts!
Matt
-
2020-07-31 at 1:40 PM #14414
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:
C++1234567891011121314151617181920212223242526272829303132Now running DRWI_NoCellular.ino on Logger XXXXXUsing ModularSensors Library version 0.25.1Logger timezone is set to UTC -5RTC timezone is set to UTCCurrent RTC time is: 2020-07-31T11:46:29-05:00SonarRange has a non-unique UUID!Battery has a non-unique UUID!12345678-abcd-1234-ef00-1234567890ab -> SonarRange12345678-abcd-1234-ef00-1234567890ab -> Battery12345678-abcd-1234-ef00-1234567890ab -> BoardTempThis logger has a variable array with 3 variables, of which 3 come from 3 sensors and 0 are calculated.Sampling feature UUID is: 12345678-abcd-1234-ef00-1234567890abLogger portion of setup finished.Setting up sensors...Setting up file on SD cardData will be saved as XXXXX_2020-07-31.csvPutting processor to sleep------------------------------------------Dumping Header Lines from MaxBotix on sonarStream_trigger-1 <--MaxBotixSonar0 - SCXL-MaxSonar-WRMT <--MaxBotixSonar1 - MB7589-1XX <--MaxBotixSonar2 - Copr. 2011-2019 <--MaxBotixSonar3 - MaxBotix Inc. <--MaxBotixSonar4 - R71 0819 <--MaxBotixSonar5 - TempE <--MaxBotixSonarDumping 6 characters from MaxBotix stream buffer: <--MaxBotixSonar824857495713MaxBotixMaxSonar at sonarStream_trigger-1 is reporting: <--MaxBotixSonarThanks,
MattAttachments:
-
2020-08-03 at 11:13 AM #14423
I think my code must not be catching the interrupt properly. It doesn’t get beyond this line in MaxBotixSonar.cpp:
1result = _stream->parseInt();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 -
2020-08-12 at 11:14 AM #14469
Any ideas why AltSoftSerial works here, but NeoSWSerial doesn’t?
-
2020-08-12 at 11:19 AM #14470
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.
-
2020-08-13 at 2:53 PM #14471
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!
-
-
AuthorPosts
- You must be logged in to reply to this topic.