Although I’ve tinkered around a little bit so far with other sensors, I’m really new to anything else and so I’m not 100% sure how to set up my IR Distance sensor (part of the Electron Sensor kit).
The model is Sharp GP2Y0A710, and I’m using a Particle Electron with breadboard. The sensor has two GND wires, two VCC wires and an output wire. I assume the output goes to A0, and the GND wires go to the GNDs on both sides?
I tried to look for any libraries or documentation but I couldn’t find a clear-cut answer for this specific sensor.
Oh I see! I didn’t know this was a requirement. I assumed my setup was semi-working already as on some rare occurances I did get one or two (inaccurate) readings, but 98% of the time the sensor couldn’t take any readings. So I guess getting a LiPo on there, and moving the VCC wires from 3V3 to VIN should do the trick.
Thanks for the linked library, that should be very useful!
I tested the library code for an hour or two but there’s no way I can manage to get any accurate readings from the sensor. It has a tendency to severely underestimate distances (e.g. a wall 3 metres away shows up as 60cm away)or no readings at all (even with a perpendicular, non-black object between 1 to 5 metres away).
Yes I specified '100500' for the model number. The USB is plugged in my PC, so it should draw sufficient power. I haven't tried testing the sensor off the battery itself but I will try that now as well.
White jumper runs from A0 to I7. Wire runs from J7 to the sensor.
Would changing the battery to one that can support more voltage work? Which kind of voltage would be recommended for the electron in this case? I would like this sensor to be wireless for an IOT project, so a power cube unfortunately is not really an option.
@Vitesze, the default battery can’t do magic in terms of running the Electron and other peripherals for a long time. It is primarily there to supply boost current while establishing a cell connection. You will need to consider a secondary voltage source or, for example, a solar panel for recharging the battery. As for the dc-dc converter, I would recommend a higher quality one from Polulu.
Yes, I made the wiring changes you suggested. Readings are still all over the place.
I understand the battery isn’t able to sustain the sensor for a long time; my plan however is to only have the device turned on for a maximum of 1 minute a day. The rest of the day it will be in deep sleep mode. Hopefully this should allow the battery to last quite a while. Solar panel would not be possible as it will be for use indoor.
There’s a small change I may still be able to salvage a bit out of this situation though; the thing is that the sensor actually is allowed to be very inaccurate. As long as it can distinguish between objects about 3 meters away, and 1 meter away it should be sufficient. Right now it does seem to make this little distinction, with objects at 0.5-1.5 metres being 80-90cm away, and objects at 3 metres being 120-130cm away (according to sensor)
I guess something like this would be good for this project though? https://www.pololu.com/product/2565
a DC-step up from 3.7V to 5V while being able to also deliver the neccessary A
Thanks a lot for this very fruitful discussion so far, things make so much more sense to me now.
Thanks, I thought so but just wanted to make sure. I ordered the Regulator you linked and will see how this work out. Thanks a lot for all your help and advice.
@Vitesze, I am trying to understand why you are getting noisy data. Having connected the analog output of the sensor to both D5 may or may not have caused problems with the sensor. You may want to change the analog pin used (eg A1) and also change the port used in the library (if possible).
Oh I see, i tried switching to A1 but not much seems to have changed. Aiming it up towards the ceiling returns values of between 80 and 100cm (should be about 200 to 250)