CubeCell - issues with ultrasonic sensor

Hello everyone

I am trying to get familiar with the new CubeCell board and have some issues to do so.
I have tried to get an ultrasonic sensor working, but failed by using the “pulseIn” function. So i have tried to setup an interrupt pin and got the pin (GPIO3) connected to the “echo” pin of the ultrasonic sensor, but the “attachInterrupt” function also doesnt work.

I allways get the error message “… was not declared in this scope”

Any suggestions how i could get the ultrasonic sensor work correctly?

got the attachInterrupt working. Found the right example in “Factory_Test_AM01”

pinMode(GPIO1, INPUT);
attachInterrupt(GPIO1, interruptHandler1, RISING);

It is a bit like talking to my self in this thread, but i have to ask this last one question …

if i use the esp32 or a arduino board i am able to use “micros()” but with the CubeCell it dont work. i am trying to catch the runtime of the ultrasonic.
“millis()” works fine but the resolution is to low for ultrasonic measurements :slight_smile:
Is there Anyone who got an ultrasonic sensor works with the cubecell?

@ vino2300,

please confirm what ultrasonic sensor you are testing?

May want to duplicate your test

Cheers

GB

Hello Gipsyblues

It is the common HC-SR04 sensor.
I need to know how to use “micros()” with the new cubecell.
“millis()” works fine but ultrasonic travels 34cm in 1ms therefore it is a bit too coarse.

thanks a lot for your help!

vino2300

my apologies for the delay.

I had ordered samples of bothe capsules and boards earlier and I was hoping to have received the shipment by now.

Unfortunately my order is still not here. I suspect the capsule version may be holding things back.

Will revisit the topic once my shipment gets here

Cheers

GB

Hello,

i have took a look in the “ASR_Arduino.h” library located in the cubecell core.
In there are all commands like “pinMode()”, “delay()”, “delayMicroseconds()”, “millis()” and so on are declared, but there is no “micros()” or “pulseIn()”.
Is it possible to add this commands by my own? Is there something i should take care of? which librarys i have to modify additionally?

I have not tried the HC-SR04 using the CubeCell, but I have used this library on other Arduinos
https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home

However, talking of millis(), have you tried using the LoRaWan example ?
There the millis() stops counting, just wondering why…

@vino2300

I’m currently working on a river level monitoring system with ultrasonic sensors and the cube cell dev board. Did you manged to to get the code working with “attachinterrupt”? I’m using a JSN-SR04 and currently struggling.

Hi, i dropped the CubeCell for now and i am trying to get familiar with the stm32 MCUs and LL programming by using the Keil IDE.

“attachinterrupt” works fine but you need a timer with microseconds resolution for ultra sonic sensors.
“micros()” didnt work for me and i had no clue how to set up an timer.

Hi,Like other members that have fed this thread, in my case the error of the micros () function persists. Even when executing the examples of the library. I am using a CubeCell HTCC-AB01 and trying to execute the AT commands example.

Arduino / libraries / Adafruit_NeoPixel / Adafruit_NeoPixel.h: 234: 48: note: suggested alternative: ‘millis’
bool canShow (void) const {return (micros () - endTime)> = 300L; }
^ ~~~~~
Millis

do you have a ultrasonic sensor type? or can you update a picture?

We will update a library for that

Support for these sensors would be great:
JSN-SR04T
HC-SR04

Consider using a GY-US42

This sensor uses iic communication.

@vino2300 @rsmedia @Supporter
library for ultrasonic sensor available now?

Which ultrasonic sensor did you use?

Please upload a picture or the sensor type. We will have a try.

I use this sensor: ultrasonic-sensor-hc-sr04 details are shown in link. Thank you for reply

@Supporter

If you can do without GPIO2, then you could use the PWM1 counter timer for sub uS resolution.

Could you show source code for it?

@johnarnoldbrown

What sort of time interval are you looking for?