Boss lady
Boss lady
DIIDevHeads IoT Integration Server
Created by Boss lady on 7/1/2024 in #middleware-and-os
Help Needed: Error in Real-Time Data Acquisition Using I2C on BeagleBone Black
Hello guys, am settling up the BeagleBone Black for real-time data acquisition using I2C on an embedded Linux OS? I have tried setting up the BeagleBone Black with the embedded Linux OS, configured the I2C protocol on the BeagleBone Black, connected the I2C device to the BeagleBone Black, implemented the necessary code to communicate with the I2C device, attempted to acquire real-time data from the I2C device. But keep getting the error Failed to acquire bus access and/or talk to slave. This is my code
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/i2c-dev.h>

int main()
{
int file;
char filename[40];
int addr = 0x68; // I2C device address

snprintf(filename, sizeof(filename), "/dev/i2c-1"); // I2C bus
file = open(filename, O_RDWR);
if (file < 0) {
printf("Failed to open the I2C bus\n");
return 1;
}

if (ioctl(file, I2C_SLAVE, addr) < 0) {
printf("Failed to acquire bus access and/or talk to slave\n");
return 1;
}

// Code to communicate with the I2C device and acquire real-time data

close(file);
return 0;
}
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/i2c-dev.h>

int main()
{
int file;
char filename[40];
int addr = 0x68; // I2C device address

snprintf(filename, sizeof(filename), "/dev/i2c-1"); // I2C bus
file = open(filename, O_RDWR);
if (file < 0) {
printf("Failed to open the I2C bus\n");
return 1;
}

if (ioctl(file, I2C_SLAVE, addr) < 0) {
printf("Failed to acquire bus access and/or talk to slave\n");
return 1;
}

// Code to communicate with the I2C device and acquire real-time data

close(file);
return 0;
}
Can anyone help me with documentations or steps I can use or study to solve my current predicament @Middleware & OS @Helper
9 replies