Trying to build a proximity sensor…

Play with it!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Trying to build a proximity sensor…

Post by Timay »

Hi all! I have two Cpxs’ I’ve been trying to make a wearable for an about a week where they both are sending code to each other via IR and the LEDS change depending on how close the two Cpx’s’ are to each other. But it won’t work. So I thought maybe the hardware isn’t set up to time how many millis it is between send IR and rec IR. I thought it might work with GPS sensors, but I’m not sure. Please help me!

User avatar
mikeysklar
 
Posts: 8933
Joined: Mon Aug 01, 2016 8:10 pm

Re: Trying to build a proximity sensor…

Post by mikeysklar »

Have you been able to make the basic IR communication work between CPXs with two guide examples?

https://learn.adafruit.com/infrared-ir- ... ith-remote
https://learn.adafruit.com/infrared-ir- ... cpx-to-cpx

GPS is not viable for very small distances. If you were tracking 15' or longer spaces in outside environments it could be of value.

Adafruit does sell a varity of proximity / distance sensors that could be more applicable. What is the distance / range you wish to track?

https://www.adafruit.com/?q=distance&sort=BestMatch
https://www.adafruit.com/?q=proximity&sort=BestMatch

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

I want to track the distance between the two cpx’s’. The device is going to be made into a wearable that glows (hopefully) brighter as the people wearing the devices approach each other. So imagine you’re 10-20 feet away and the necklace or whatever is very dim and as you approach another person wearing one of the same necklaces the light gets brighter, it sparkles and so on. So I don’t want the detection to be anything approaching the necklace, it only reacts to the proximity of others wearing the same tech.

User avatar
mikeysklar
 
Posts: 8933
Joined: Mon Aug 01, 2016 8:10 pm

Re: Trying to build a proximity sensor…

Post by mikeysklar »

I see. Thank you for the summary of what you would like to achieve.

IR like you started with seems viable. Were you able to run the stock example code and get communication between two CPX units?

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

Yes, when I code it to try to time the interval from send to receive it runs all the different light animations kinda like an embedded statement where it seems to only be able to receive an on/off command and not: send ir, time ir, if 0>3ms do this, if 3>6ms do that ect..

User avatar
adafruit_support_bill
 
Posts: 85006
Joined: Sat Feb 07, 2009 10:11 am

Re: Trying to build a proximity sensor…

Post by adafruit_support_bill »

At the speed of light, IR communication at 20-30 feet is going to be practically instantaneous from a software timing perspective.

You might have better luck using the raw analog readings to measure intensity which will vary by distance. https://learn.adafruit.com/adafruit-cir ... ty-2918964

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

I saw a video on the Adafruit channel where they are taking raw analog off the receiver. It was effective to about 5 inches and it was passive, that is it would measure the distance of anything. This is why I thought the gps might be the way to go. Unless the timer function can measure nanoseconds, which I thought it it might. The circuit could be like a “find my phone” thing or like those pet collars that track your dog. Or the tracker they’re using for the soccer players at the World Cup. I think those are both a gps systems

User avatar
adafruit_support_bill
 
Posts: 85006
Joined: Sat Feb 07, 2009 10:11 am

Re: Trying to build a proximity sensor…

Post by adafruit_support_bill »

I saw a video on the Adafruit channel where they are taking raw analog off the receiver. It was effective to about 5 inches and it was passive, that is it would measure the distance of anything.
That was reading the reflected IR from the on-board emitter. Direct readings of the IR from the emitter on another CPX should be good for several times that distance. And the range could be further extended by using more powerful emitters. https://www.adafruit.com/product/5639

GPS is only workable outdoors with a clear view of the sky. Conventional GPS has a resolution of a few meters. Differential GPS uses a reference receiver at a known location to improve accuracy. That is probably what they use for tracking soccer players.

'find my phone' augments standard GPS signals with relative signal strength from nearby cell towers to further refine the location.

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

Thank you so much for your time. I can’t figure out how to get an analog reading for pin A10. I can get an option to read digital IRIn in make code. Do I have to solder in a wire like in the above example?

User avatar
adafruit_support_bill
 
Posts: 85006
Joined: Sat Feb 07, 2009 10:11 am

Re: Trying to build a proximity sensor…

Post by adafruit_support_bill »

Thank you so much for your time. I can’t figure out how to get an analog reading for pin A10. I can get an option to read digital IRIn in make code.
This page shows how to do analog inputs. Just change the "A3" in the example code to "A10".
https://makecode.adafruit.com/learnsyst ... ead-analog
Do I have to solder in a wire like in the above example?
Using the on-board components, you should not need to solder anything. Using an external high-powered emitter, you will need to solder some connections.

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

It will not allow me to change to A10 specifically, if I do it in Java it won’t write produce either, unless I’m not doing something else right.

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

It shows me blocks and I can only choose A1 to A7 in makecode

User avatar
adafruit_support_bill
 
Posts: 85006
Joined: Sat Feb 07, 2009 10:11 am

Re: Trying to build a proximity sensor…

Post by adafruit_support_bill »

It may not be possible in MakeCode. Try CircuitPython or Arduino.

User avatar
Timay
 
Posts: 8
Joined: Tue Nov 22, 2022 12:49 pm

Re: Trying to build a proximity sensor…

Post by Timay »

Ok! Working on it

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground and Circuit Playground Express”