Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Adi 009
Published

VisionWave: Smart Assistive Goggles

VisionWave: Empowering the visually impaired with real-time, audio-guided navigation through advanced smart goggles

IntermediateWork in progressOver 2 days343
VisionWave: Smart Assistive Goggles

Things used in this project

Story

Read more

Schematics

Sensor

Raspberry pi

Blues Swan

Notecarrier-A

Code

Obstacle Detection and Feedback

C/C++
Code to be uploaded to the Blues Swan board
#include <Wire.h>
#include <Notecard.h>

// Create a Notecard instance
Notecard notecard;

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);

  // Initialize the Notecard using the I2C interface
  Wire.begin();
  notecard.begin();

  // Set the Notecard mode
  J *req = notecard.newRequest("hub.set");
  if (req != NULL) {
    JAddStringToObject(req, "mode", "periodic");
    JAddStringToObject(req, "product", "com.your-company.your-product");  // Replace with your product UID
    notecard.sendRequest(req);
  }

  // Set the initial location mode
  req = notecard.newRequest("location.mode");
  if (req != NULL) {
    JAddStringToObject(req, "mode", "periodic");
    notecard.sendRequest(req);
  }
}

void loop() {
  // Example: Sending sensor data to the Notecard
  long distance = getDistance(trigPin1, echoPin1);  // Assuming trigPin1 and echoPin1 are defined

  // Create a note to send
  J *req = notecard.newRequest("note.add");
  if (req != NULL) {
    JAddStringToObject(req, "file", "sensors.qo");  // File to send data to
    J *body = JCreateObject();
    if (body != NULL) {
      JAddNumberToObject(body, "distance", distance);
      JAddItemToObject(req, "body", body);
      notecard.sendRequest(req);
    }
  }

  delay(60000);  // Send data every 60 seconds
}

// Function to get the distance from the ultrasonic sensor
long getDistance(int trigPin, int echoPin) {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the echo signal and convert it to distance
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;  // Convert to centimeters
  return distance;
}

platformio.iniArduino

Plain text
Code to be uploaded to the Blues Swan board
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:bw_swan_r5]
platform = ststm32
board = bw_swan_r5
upload_protocol = dfu
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
monitor_speed = 115200
lib_deps = 
	Wire
	blues/Blues Wireless Notecard@^1.4.5
	blues/Blues Wireless Notecard Pseudo Sensor@^1.1.0
	robtillaart/DHT20@^0.2.3

Communication with Blues Wireless Notecard via Notecarrier A

C/C++
Initialization and Sending Data
#include <Wire.h>
#include <Notecard.h>

// Create a Notecard instance
Notecard notecard;

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);

  // Initialize the Notecard using the I2C interface
  Wire.begin();
  notecard.begin();

  // Set the Notecard mode
  J *req = notecard.newRequest("hub.set");
  if (req != NULL) {
    JAddStringToObject(req, "mode", "periodic");
    JAddStringToObject(req, "product", "com.your-company.your-product");  // Replace with your product UID
    notecard.sendRequest(req);
  }

  // Set the initial location mode
  req = notecard.newRequest("location.mode");
  if (req != NULL) {
    JAddStringToObject(req, "mode", "periodic");
    notecard.sendRequest(req);
  }
}

void loop() {
  // Example: Sending sensor data to the Notecard
  long distance = getDistance(trigPin1, echoPin1);  // Assuming trigPin1 and echoPin1 are defined

  // Create a note to send
  J *req = notecard.newRequest("note.add");
  if (req != NULL) {
    JAddStringToObject(req, "file", "sensors.qo");  // File to send data to
    J *body = JCreateObject();
    if (body != NULL) {
      JAddNumberToObject(body, "distance", distance);
      JAddItemToObject(req, "body", body);
      notecard.sendRequest(req);
    }
  }

  delay(60000);  // Send data every 60 seconds
}

// Function to get the distance from the ultrasonic sensor
long getDistance(int trigPin, int echoPin) {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the echo signal and convert it to distance
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;  // Convert to centimeters
  return distance;
}

GPS Integration

C/C++
If you want to include GPS data, you can use the following snippet
void setupGPS() {
  J *req = notecard.newRequest("card.location");
  if (req != NULL) {
    JAddBoolToObject(req, "start", true);
    JAddStringToObject(req, "mode", "continuous");
    notecard.sendRequest(req);
  }
}

void loop() {
  // Fetch GPS location from Notecard
  J *req = notecard.newRequest("card.location");
  if (req != NULL) {
    JAddBoolToObject(req, "start", false);
    J *rsp = notecard.requestAndResponse(req);
    if (rsp != NULL) {
      double latitude = JGetNumber(rsp, "lat");
      double longitude = JGetNumber(rsp, "lon");
      Serial.print("Latitude: ");
      Serial.println(latitude);
      Serial.print("Longitude: ");
      Serial.println(longitude);
      notecard.deleteResponse(rsp);
    }
  }

  delay(60000);  // Fetch GPS data every 60 seconds
}

Mobile App Integration

C/C++
To integrate with a mobile app, you would typically use Bluetooth. Below is a snippet to send data via Bluetooth
#include <SoftwareSerial.h>

// Bluetooth Serial pins
SoftwareSerial BTSerial(10, 11);  // RX, TX

void setup() {
  Serial.begin(9600);  // For debugging
  BTSerial.begin(9600);  // Bluetooth communication

  // Initial message
  BTSerial.println("Goggles Initialized");
}

void loop() {
  long distance = getDistance(trigPin1, echoPin1);  // Example sensor reading
  BTSerial.print("Distance: ");
  BTSerial.println(distance);
  delay(1000);
}

Credits

Adi 009

Adi 009

1 project • 2 followers

Comments