C172 instructor pilot reported a NMAC with an aircraft climbing underneath them.
Synopsis
C172 instructor pilot reported a NMAC with an aircraft climbing underneath them.
Narrative
This was a training flight coming back to ZZZ from ZZZ1. Me and my student; who was under foggles for instrument time; picked up VFR flight following shortly after taking off from ZZZ1. We were under our own navigation; maintaining 4500 only a few miles from the shore around the 230 radial from ZZZ VOR. ZZZ Approach notified us of a Caravan at our '9 o'clock' and climbing. I let ZZZ know that I did not have traffic in sight. I began scanning for this traffic and could not find the aircraft. I looked at the ADSB-IN receiver to help find this traffic and saw no traffic to our 9 o'clock. I continued to look for another minute or so before I checked the ADSB-IN and found that there was an aircraft at our 6 o'clock and climbing. I still did not see the aircraft. I zoomed in on the receiver and saw that the aircraft was directly under us by 400 ft. I looked below us on the left side of the cowling and saw the Caravan. I took control and started a turn to the right to make a 360 and at the same time ZZZ advised that we should make a right turn to a 360 heading. There were no further problems with the rest of the flight. I realize that I should not rely so much on Approach Control and flight following to steer clear of other aircraft. That is the job of the pilots to maintain visual separation from other aircraft. Additionally; my student kept their foggles on during this event; and now I have learned that they could have been a valuable resource for situational awareness. The Caravan was passing under us on the pilot side of the aircraft; and if I would have instructed my student to take off their foggles to help look we could have avoided this situation. Lastly; when I initially noticed the aircraft at our 6 o'clock using the ADSB. I could have made a corrective action as to not fly in the same direction as the Caravan. I will learn from this flight; and use my newfound knowledge to be a safer pilot and instructor.
Source: NASA Aviation Safety Reporting System (public domain). Reports are voluntary submissions and are not verified by NASA.