Six
Posts: 10
Joined: Wed Dec 23, 2015 7:05 pm

scratch ultrasonic sensor

Tue Aug 16, 2016 2:47 pm

hi guys! I've got some problem with scratch and ultrasonic sensor. I use rpi3 and I've installed jessie on it. I've wired the sensor http://simplesi.net/scratchgpio/addon-b ... ic-sensor/ and it work fine with python code, but when I use scratch 1.4 or scratch gpio7 the cat return me just "1". It doesn't any measure . Can anyone help me? it's a Scratch problem?

Forris
Posts: 170
Joined: Fri Jan 06, 2012 7:46 pm

Re: scratch ultrasonic sensor

Thu Aug 18, 2016 6:46 pm

Are you using ScratchGPIO or the 'built-in' Scratch, and what script are you using?

Six
Posts: 10
Joined: Wed Dec 23, 2015 7:05 pm

Re: scratch ultrasonic sensor

Fri Aug 19, 2016 4:26 pm

Hi Forris!
On mi rpi3 i've installed the SCRATCHGPIO 7 and i've tried to use both the bult-in version 1.4 both the gpio 7 version. The script that I 've used is simple. It is in this page on sonar voice.
http://simplesi.net/scratchgpio/visual-command-guide/

timrowledge
Posts: 1068
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: scratch ultrasonic sensor

Fri Aug 19, 2016 4:56 pm

The most recent NuScratch on Raspbian supports the generic HR04 ultrasonic sensors directly. Wire them up in the simple 4-wire manner like this -
Pi-ultrasonic-wiring.jpg
Pi-ultrasonic-wiring.jpg (58.25 KiB) Viewed 2784 times
In Scratch, open the 'examples' folder and then 'sensors and motors' and load 'gpio-ultrasonicDemo'

Simon's code expects the sensor to be wired a bit differently and you can't mix them up!
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

Six
Posts: 10
Joined: Wed Dec 23, 2015 7:05 pm

Re: scratch ultrasonic sensor

Sun Aug 21, 2016 10:44 pm

hi timrowledge!
I've find the folder and the file that you wrote me. I'm waiting for the right resistor to wire as you show in the jpg. I hope it work :D

Six
Posts: 10
Joined: Wed Dec 23, 2015 7:05 pm

Re: scratch ultrasonic sensor

Tue Aug 30, 2016 1:16 pm

hi timrowledge!
I've wired and used the gpio-ultrasonicDemo as you describe and it work fine! thanks a lot, but I've another problem with the sensor. The distance that the sensor return me is 50-60 cm. Do you have some suggestion? the generic ultrasonic sensor should return the distance till 4-5 meter!
thanks

timrowledge
Posts: 1068
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: scratch ultrasonic sensor

Thu Sep 01, 2016 5:32 pm

Sorry, can't offer much help on this; my SR04 seems to work well out to about 300 cm and down to maybe 4cm.

Is there any possible obstruction in front of your sensor? I know that if I place mine just wrong it gets a reflection from the case which messes things up.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

tom18664
Posts: 1
Joined: Tue Sep 26, 2017 7:30 am

Re: scratch ultrasonic sensor

Tue Sep 26, 2017 7:35 am

Hi
The simplsi page is incorrect. Using broadcast ultra in scratch uses physical pin numbers not BCM GPIO numbers. So in their example, to use GPIO23, which is on pin 16, you need to broadcast ultra16.

Return to “Scratch”

Who is online

Users browsing this forum: No registered users and 1 guest