How to set up an IR Distance sensor?

@Vitesze, disconnect the white wire from the board and measure the voltage between the sensor (white wire) and ground. Point the sensor at different targets and see what the voltage is doing.

When placing a flat-surfaced black object at about 80cm away the multimeter would read about 2.6V. When removing the object (nearest object is a wall 3 meters away) it would read about 1.45V. Voltage took a couple of seconds to stabilize but after that didnā€™t normally deviate for more than about 0.1V. Voltage sometimes spikes up a bit but overall there definitely seems to be a correlation between the voltage and distance

Just to make sure im doing this correctly: on my multimeter Iā€™m using the DCV option, with the red wire going to the white output pin of the sensor, and the black wire going to the GND on the Electron board

@Vitesze, your setup is perfect. The multimeter samples slowly and will average readings so you wonā€™t see the same noise as on the Electron. Whatā€™s important is the voltage does change with distance. I suggest you take the time and plot the measured voltage against distance over the working range of the sensor just to be sure it matches expectations. I will take a second look at the sampling algorithm in your code to see if I can pick out any issues.

Thanks peekay, I really appreciate your help. I will do some more testing and figure out the exact correlation between distance and voltage.

Looking at the exact same setup however, the readings in the serial monitor seem to be all over the place. Either somethingā€™s wrong with the code, or something is going wrong with the voltage in the Electron.

As for the DC Step-up, it has a Vin, Gnd and Vout pin. Would the following setup be needed?:

Electron VIN to DC VIN
DC VOUT to Sensor VCC
DC GND, not sure what to do with this? To the second Electron GND?

In cae anyone wonders, hereā€™s the measured distance, voltages, the results they should have given, and the result they actually give:
50cm - 3.05V - 71cm - between 80 and 90cm
100cm - 2.45V - 104cm - between 110 and 120cm
150cm - 1.85V - 189cm - between 80 and 90cm
250cm - 1.65V - 262 cm - between 130cm and 150cm

EDIT: On second thought, given that the readings are so wild and seem to change even between objects both at an equal distance, Iā€™m guessing some of the lighting on the ceiling and/or computer screen (should both be out of view cone of the sensor) may be altering the results a bit

EDIT: hereā€™s my setup with the DC step-up. Doesnā€™t seem to generate any voltage though, any thoughts?