HC-SR04 ultrasonic sensor 2G-IOT
Using an OPi 2G-IOT,running Ubuntu 2G-IOT GSM OS.Struggling to get any form of reading on this sensor, I followed this : https://www.piprojects.xyz/ultrasonic-distance-sensor/
and changed the the Trigger pin to Pin 12, but when I run the program , all I get is a distance of 0 cm.
I used a 1Kohm and 2Kohm resistor as mentioned in the thread.
Has any one got this sensor to work with the 2G-IOT ?
'''
Pin#7:GPIO(56, "in/out")
Pin#16:GPIO(101,"in/out")
Pin#18:GPIO(121,"in/out")
Pin#19:GPIO(4, "in/out")
Pin#21:GPIO(3, "in/out")
Pin#23:GPIO(2, "in/out")
Pin#24:GPIO(5,"in/out")
Pin#26:GPIO(6,"in/out")
Pin#27:GPIO(1, "in/out")
Pin#28:GPIO(0,"in/out")
Pin#29:GPIO(122, "in/out")
Pin#31:GPIO(123, "in/out")
Pin#33:GPIO(124, "in/out")
Pin#35:GPIO(125, "in/out")
Pin#37:GPIO(126, "in/out")
'''
from periphery import GPIO
import time
import datetime
def getCM():
#Send trig pulse
gpio_trig.write(True)
time.sleep(20/1000000.0)
gpio_trig.write(False)
#time.sleep(10/1000000.0)
#Wait for echo start
while(gpio_echo.read() == 0):
pass
#Wait for echo end
now = datetime.datetime.now()
startTime = now.microsecond
while(gpio_echo.read() == 1):
pass
now = datetime.datetime.now()
travelTime = now.microsecond- startTime;
distance = travelTime / 58;
return distance
gpio_echo = GPIO(125, "in")
gpio_trig = GPIO(126, "out")
gpio_trig.write(False)
time.sleep(0.03)
while(1):
dist = getCM()
print dist
time.sleep(1.0)
orangepi@OrangePi:~/test$ sudo python ./hc-sr04.py
12
14
16
18
19
21
21
23
23
23
Hi nopnop2002, Thanks for your input.
I assume youv'e installed periphery python ? I currently have WiringOpi installed.
Do you think I should remove it. ? nix666 replied at 2018-6-5 21:52
Hi nopnop2002, Thanks for your input.
I assume youv'e installed periphery python ? I currently have ...
No
You don't have to remove WiringOP.
Dukane Seacom TS500 ULB Ultrasonic Test Set is a quality machine that is easy to use if you are an expert. Why couldn't I have the same or similar opinions as you? T^T I hope you also visit my blog and give us a good opinion.safetoto
geometry dash world is a 2D platform game in which you control a square that has to get to the end of each level while avoiding a lot of hazards. Your little square keeps moving forward, so all you have to do to avoid the different hazards is jump at the right time
page:
[1]