<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Using WiringPi in Qt and Raspberry Pi problem]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I want to use WiringPi library. I want to port below C program to Qt but an error appeared in</p>
<pre><code>MPU6050_Init();		                 /* Initializes MPU6050 */
	
</code></pre>
<p dir="auto">line. Complete code is:</p>
<pre><code>/*
	MPU6050 Interfacing with Raspberry Pi
	http://www.electronicwings.com
*/

#include &lt;wiringPiI2C.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;wiringPi.h&gt;

#define Device_Address 0x68	/*Device Address/Identifier for MPU6050*/

#define PWR_MGMT_1   0x6B
#define SMPLRT_DIV   0x19
#define CONFIG       0x1A
#define GYRO_CONFIG  0x1B
#define INT_ENABLE   0x38
#define ACCEL_XOUT_H 0x3B
#define ACCEL_YOUT_H 0x3D
#define ACCEL_ZOUT_H 0x3F
#define GYRO_XOUT_H  0x43
#define GYRO_YOUT_H  0x45
#define GYRO_ZOUT_H  0x47

int fd;

void MPU6050_Init(){
	
	wiringPiI2CWriteReg8 (fd, SMPLRT_DIV, 0x07);	/* Write to sample rate register */
	wiringPiI2CWriteReg8 (fd, PWR_MGMT_1, 0x01);	/* Write to power management register */
	wiringPiI2CWriteReg8 (fd, CONFIG, 0);		/* Write to Configuration register */
	wiringPiI2CWriteReg8 (fd, GYRO_CONFIG, 24);	/* Write to Gyro Configuration register */
	wiringPiI2CWriteReg8 (fd, INT_ENABLE, 0x01);	/*Write to interrupt enable register */

	} 
short read_raw_data(int addr){
	short high_byte,low_byte,value;
	high_byte = wiringPiI2CReadReg8(fd, addr);
	low_byte = wiringPiI2CReadReg8(fd, addr+1);
	value = (high_byte &lt;&lt; 8) | low_byte;
	return value;
}

void ms_delay(int val){
	int i,j;
	for(i=0;i&lt;=val;i++)
		for(j=0;j&lt;1200;j++);
}

int main(){
	
	float Acc_x,Acc_y,Acc_z;
	float Gyro_x,Gyro_y,Gyro_z;
	float Ax=0, Ay=0, Az=0;
	float Gx=0, Gy=0, Gz=0;
	fd = wiringPiI2CSetup(Device_Address);   /*Initializes I2C with device Address*/
	MPU6050_Init();		                 /* Initializes MPU6050 */
	
	while(1)
	{
		/*Read raw value of Accelerometer and gyroscope from MPU6050*/
		Acc_x = read_raw_data(ACCEL_XOUT_H);
		Acc_y = read_raw_data(ACCEL_YOUT_H);
		Acc_z = read_raw_data(ACCEL_ZOUT_H);
		
		Gyro_x = read_raw_data(GYRO_XOUT_H);
		Gyro_y = read_raw_data(GYRO_YOUT_H);
		Gyro_z = read_raw_data(GYRO_ZOUT_H);
		
		/* Divide raw value by sensitivity scale factor */
		Ax = Acc_x/16384.0;
		Ay = Acc_y/16384.0;
		Az = Acc_z/16384.0;
		
		Gx = Gyro_x/131;
		Gy = Gyro_y/131;
		Gz = Gyro_z/131;
		
		printf("\n Gx=%.3f °/s\tGy=%.3f °/s\tGz=%.3f °/s\tAx=%.3f g\tAy=%.3f g\tAz=%.3f g\n",Gx,Gy,Gz,Ax,Ay,Az);
		delay(500);
		
	}
	return 0;
}
</code></pre>
<p dir="auto">Regards,<br />
Mucip:)</p>
]]></description><link>https://forum.qt.io/topic/109058/using-wiringpi-in-qt-and-raspberry-pi-problem</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Jul 2026 08:36:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/109058.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Nov 2019 18:16:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using WiringPi in Qt and Raspberry Pi problem on Wed, 20 Nov 2019 18:19:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
What error ?</p>
]]></description><link>https://forum.qt.io/post/563033</link><guid isPermaLink="true">https://forum.qt.io/post/563033</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 20 Nov 2019 18:19:17 GMT</pubDate></item><item><title><![CDATA[Reply to Using WiringPi in Qt and Raspberry Pi problem on Wed, 20 Nov 2019 20:56:38 GMT]]></title><description><![CDATA[<p dir="auto">Dear <a class="plugin-mentions-user plugin-mentions-a" href="/user/aha_1980">@<bdi>aha_1980</bdi></a> ,<br />
It's pitty for me infact. I forgot the create fınction when I copy it from C to Qt.</p>
<p dir="auto">Sorry... :)</p>
<pre><code>void MPU6050_Init(){
	
	wiringPiI2CWriteReg8 (fd, SMPLRT_DIV, 0x07);	/* Write to sample rate register */
	wiringPiI2CWriteReg8 (fd, PWR_MGMT_1, 0x01);	/* Write to power management register */
	wiringPiI2CWriteReg8 (fd, CONFIG, 0);		/* Write to Configuration register */
	wiringPiI2CWriteReg8 (fd, GYRO_CONFIG, 24);	/* Write to Gyro Configuration register */
	wiringPiI2CWriteReg8 (fd, INT_ENABLE, 0x01);	/*Write to interrupt enable register */

	} 
</code></pre>
<p dir="auto">Regards,<br />
Mucip:)</p>
]]></description><link>https://forum.qt.io/post/563062</link><guid isPermaLink="true">https://forum.qt.io/post/563062</guid><dc:creator><![CDATA[Mucip]]></dc:creator><pubDate>Wed, 20 Nov 2019 20:56:38 GMT</pubDate></item><item><title><![CDATA[Reply to Using WiringPi in Qt and Raspberry Pi problem on Wed, 20 Nov 2019 20:53:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mucip">@<bdi>Mucip</bdi></a> Then don't forget to mark this topic as SOLVED too.</p>
<p dir="auto">Even better would be to tell us what went wrong and how you fixed it. We are curios :)</p>
]]></description><link>https://forum.qt.io/post/563060</link><guid isPermaLink="true">https://forum.qt.io/post/563060</guid><dc:creator><![CDATA[aha_1980]]></dc:creator><pubDate>Wed, 20 Nov 2019 20:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to Using WiringPi in Qt and Raspberry Pi problem on Wed, 20 Nov 2019 19:07:16 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
Please forgive me. I solved it. Thanks...</p>
<p dir="auto">Regards,<br />
Mucip:)</p>
]]></description><link>https://forum.qt.io/post/563045</link><guid isPermaLink="true">https://forum.qt.io/post/563045</guid><dc:creator><![CDATA[Mucip]]></dc:creator><pubDate>Wed, 20 Nov 2019 19:07:16 GMT</pubDate></item><item><title><![CDATA[Reply to Using WiringPi in Qt and Raspberry Pi problem on Wed, 20 Nov 2019 18:19:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
What error ?</p>
]]></description><link>https://forum.qt.io/post/563033</link><guid isPermaLink="true">https://forum.qt.io/post/563033</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 20 Nov 2019 18:19:17 GMT</pubDate></item></channel></rss>