This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Support for Arduino Uno Wifi R4
Ηι, Ι try to use an Arduino UNO R4 with a sonar sensor HC-SR04.
I get this error message : Compilation error: 'currentConnections' is not a member of 'PhyphoxBLE'
I send you my code
#include <ArduinoBLE.h>
#include <phyphoxBle.h>
#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

char board_name[]="UnoUltraSonic";
unsigned long initial_time, first_time, first_difference_float ;

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
  PhyphoxBLE::minConInterval = 6; //6 = 7.5ms
  PhyphoxBLE::maxConInterval = 6; //6 = 7.5ms
  PhyphoxBLE::slaveLatency = 0; //
  PhyphoxBLE::timeout = 10; //10 = 100ms
  PhyphoxBLE::start(board_name); // Το όνομα του board μπορεί να αλλάξει στην αρχή του προγράμματος
  PhyphoxBLE::configHandler=&receivedData; // δείτε το παράδειγμα της βιβλιοθήκης Phyphox Arduino library

void receivedData(){ // δείτε το παράδειγμα της βιβλιοθήκης Phyphox Arduino library
   if (PhyphoxBLE::currentConnections == 1){
      initial_time = millis(); //ορίζει την αρχή του χρόνου

void loop() {
  delay(50);                     // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
  first_time = millis();
  first_difference_float = ((float)first_time-(float)initial_time)/1000;
  PhyphoxBLE::write(first_difference_float, sonar.ping_cm() );

Messages In This Thread
Support for Arduino Uno Wifi R4 - by kaddigat - 09-11-2023, 10:44 AM
RE: Support for Arduino Uno Wifi R4 - by HannoK - 09-14-2023, 12:52 PM
RE: Support for Arduino Uno Wifi R4 - by HannoK - 09-15-2023, 09:10 AM
RE: Support for Arduino Uno Wifi R4 - by Ekfereth - 11-19-2023, 08:38 AM

Forum Jump: