Amin KhateebKhaled al KadrihusseinBashar1581
Created December 10, 2023

Smart City Solutions with AVR-IoT

Modern cities rely on public transit as a crucial component of urban infrastructure, facilitating the daily movement of millions. However, m

Smart City Solutions with AVR-IoT

Things used in this project

Story

Read more

Custom parts and enclosures

circuit

Schematics

circuit

Code

code

C/C++
copy the code to Arduino IDE, upload it to the microcontroller, and finally run the circuit
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <Adafruit_GPS.h>

// Define pins for sensors
const int vibrationPin = 2;  // Digital pin for vibration sensor
const int temperaturePin = A0;  // Analog pin for temperature sensor
const int pressurePin = 4;  // Digital or analog pin for pressure sensor

// Create instances of sensor classes
Adafruit_BNO055 bno = Adafruit_BNO055();
Adafruit_GPS GPS(&Serial1);

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);

  // Initialize sensors
  if (!bno.begin()) {
    Serial.println("Failed to initialize BNO055 sensor!");
    while (1);
  }

  // Initialize GPS
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
}

void loop() {
  // Read sensor data
  int vibrationValue = digitalRead(vibrationPin);
  float temperatureValue = analogRead(temperaturePin) * 0.00488;  // Convert analog value to voltage
  int pressureValue = digitalRead(pressurePin);

  // Get GPS data
  GPS.read();

  // Print sensor data
  Serial.print("Vibration: ");
  Serial.println(vibrationValue);
  Serial.print("Temperature: ");
  Serial.println(temperatureValue);
  Serial.print("Pressure: ");
  Serial.println(pressureValue);

  // Print GPS data
  Serial.print("Latitude: ");
  Serial.println(GPS.latitudeDegrees);
  Serial.print("Longitude: ");
  Serial.println(GPS.longitudeDegrees);

  delay(1000);  // Adjust delay based on your data collection frequency
}

Credits

Amin Khateeb

Amin Khateeb

1 project • 1 follower
Khaled al Kadri

Khaled al Kadri

0 projects • 1 follower
hussein

hussein

0 projects • 0 followers
i am working in electronic
Bashar1581

Bashar1581

0 projects • 0 followers

Comments