====== Distanz Sensore Sharp 2Y0A Familie ======
see cpp code in Githup[[https://github.com/zoubworldArduino/ZSharpIR]]
===== Sharp 2Y0A710K0F 100-500cm =====
Python code at [[https://tutorials-raspberrypi.de/infrarot-abstandsmessung-mit-dem-raspberry-pi-sharp-gp2y0a02yk0f/]]
Model: "100500" [100cm to 500cm]
Based on the SHARP datasheet we can calculate the linear function:
y = 137500x + 1125 which gives us: 1 / ((Volt - 1125) / 137500) = distance_in_cm (For distance > 100cm)
==== Python code ====
#!/usr/bin/python
import spidev
spi = spidev.SpiDev()
spi.open(0,0)
def readChannel(channel):
val = spi.xfer2([1,(8+channel)<<4,0])
data = ((val[1]&3) << 8) + val[2]
return data
if __name__ == "__main__":
v=(readChannel(0)/1023.0)*3.3
dist = 16.2537 * v**4 - 129.893 * v**3 + 382.268 * v**2 - 512.611 * v + 301.439
print "Distanz: %.2f cm" % dist
===== Sharp 2Y0A21YK 10-80cm =====
Formel
Model: "1080" [10cm to 80cm]
^Volt ^Distance^
|2,6|10 |
|2,1|12|
|1,85|14|
|1,65|15|
|1,5|18 |
|1,39|20|
|1,15|25|
|0,98|30|
|0,85|35|
|0,75|40|
|0,67|45|
|0,61|50|
|0,59|55|
|0,55|60|
|0,5|65 |
|0,48|70|
|0,45|75|
|0,42|80|
Using MS Excel, we can calculate function (For distance > 10cm) :
Distance = 29.988 X POW(Volt , -1.173)