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

Reply To: Wiring Ultrasonic sensor w/ temp compensator

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

#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.