MPU6050 Interfacing with Raspberry Pi using ‘C’


  • MPU6050 sensor module is an integrated 6-axis Motion tracking device.
  • It has a 3-axis Gyroscope, 3-axis Accelerometer, Digital Motion Processor and a Temperature sensor, all in a single IC.
  • It can accept inputs from other sensors like 3-axis magnetometer or pressure sensor using its Auxiliary I2C bus.
  • If external 3-axis magnetometer is connected, it can provide complete 9-axis Motion Fusion output.
  • A microcontroller can communicate with this module using I2C communication protocol. Various parameters can be found by reading values from addresses of certain registers using I2C communication.
  • Gyroscope and accelerometer reading along X, Y and Z axes are available in 2’s complement form.
  • Gyroscope readings are in degrees per second (dps) unit; Accelerometer readings are in g unit.

For more information about MPU6050 Sensor Module and how to use it, refer the topic MPU6050 Sensor Module in the sensors and modules section.

Read More

Raspberry Pi I2C (Synchronous Serial Communication)


  • I2C (Inter Integrated Circuit) is a synchronous serial protocol that communicates data between two devices.
  • It is a master-slave protocol which may have one master or many master and many slaves whereas SPI has only one master.
  • It is generally used for communication over short distance.
  • The I2C device has 7-bit or 10-bit unique address. So, to access these devices, master should address them by the 7-bit or 10-bit unique address.
  • I2C is used in many applications like reading RTC (Real time clock), accessing external EEPROM memory. It is also used in sensor modules like gyro, magnetometer etc.
  • It is also called as Two Wire Interface (TWI) protocol.

Read More

Raspberry Pi UART Communication Using Python And C

UART (Universal Asynchronous Receiver/Transmitter) is a serial communication protocol in which data is transferred serially i.e. bit by bit. Asynchronous serial communication is widely used for byte oriented transmission. In Asynchronous serial communication, a byte of data is transferred at a time.

UART serial communication protocol uses a defined frame structure for their data bytes. Frame structure in Asynchronous communication consists:

  • START bit: It is a bit with which indicates that serial communication has started and it is always low.
  • Data bits packet: Data bits can be packets of 5 to 9 bits. Normally we use 8-bit data packet, which is always sent after the START bit.
  • STOP bit: This usually is one or two bits in length. It is sent after data bits packet to indicate the end of frame. Stop bit is always logic high.

Read More

Raspberry Pi PWM Generation using Python and C

PWM (Pulse Width Modulation) is a modulation technique by which the width of pulse is varied while keeping the frequency constant. Through PWM technique, we can control the power delivered to the load by using ON-OFF signal. The PWM signals can be used for applications such as controlling the speed of DC motors, changing intensity of an LED, controlling Servo motors, etc.

Raspberry Pi PWM:

Raspberry Pi has two PWM channels i.e. PWM0 and PWM1.

PWM pins for the two PWM channels on 40-pin P1 header are as follows:



Read More

Raspberry Pi GPIO Access

GPIO (General Purpose Input Output) pins can be used as input or output and allows raspberry pi to connect with general purpose I/O devices.

  • Raspberry pi 3 model B took out 26 GPIO pins on board.
  • Raspberry pi can control many external I/O devices using these GPIO’s.
  • These pins are a physical interface between the Pi and the outside world.
  • We can program these pins according to our needs to interact with external devices. For example, if we want to read the state of a physical switch, we can configure any of the available GPIO pins as input and read the switch status to make decisions.  We can also configure any GPIO pin as an output to control LED ON/OFF.
  • Raspberry Pi can connect to the Internet using on-board Wi-Fi or Wi-Fi USB adapter. Once the Raspberry Pi is connected to the Internet then we can control devices, which are connected to the Raspberry Pi, remotely.

Read More

Do NOT follow this link or you will be banned from the site!