UART-I2C Bridge Implementation: I2C Client(Client-2) Implementation using PIC16F15244 Microcoontroller
This code example is one of good use case to demonstrate uart-i2c bridge implementation using PIC16F152xx family microcontrollers. In this code example, PIC16F15244 MCU acts as I2C client 2 device. It periodically collects the data from the sensor, process the acquired data and keep the data ready to transmit to Host device over I2C interface. When the Host device requests to send the processed sensor data, then client device responds back to host request with the processed data through i2c interface. After receiving the data from the client device, host device displays the data on the terminal window.
Refer GitHub code example UART-I2C Bridge and I2C Host Implementation using PIC16F15244 Microcontroller and UART-I2C Bridge Implementation: I2C Client(Client-1) Implementation using PIC16F15244 Microcontroller for more details about the implementation and application.
- PIC16F152xx Product Family Page
- PIC16F152xx Family Code Examples on GitHub
- PIC16F15244 MCU Family Video
- PIC16F15244 MCU Product Page
- Technical Brief - Using the MSSP in I2C Master mode
- Technical Brief – Using the MSSP in I2C Slave mode
- Application Note – AN3538 A Simple Water Monitoring System with I2C Communication
In this code example, the PIC16F15244 microcontroller communicate with Data Visualizer terminal window application, running on a PC, through USART interface and receive user inputs/commands. Based on the commands received from the user, the PIC16F15244 microcontroller communicates with the I2C client devices and collect the required sensors data and, transmit to PC for displaying it on the terminal window. This way, the PIC16F15244 microcontroller acts as a EUART-I2C bridge to communicate with Data Visualizer terminal window application and acts as a I2C host device to communicate with the I2C client devices.
The code example uses two I2C clients, named as client 1 and client 2 and, they are based on PIC16F15244 microcontroller. Figure 1 shows the block diagram view of the application.
Figure 1 : Block diagram view of the application
For the purpose of demonstration, pH sensor is interfaced to client 1 and, temperature and capacitive soil moisture sensors are interfaced to client 2. Both the clients periodically collect data from the sensors, process the acquired data and keep the data ready to transmit to Host device over I2C interface.
The input commands and clients I2C address information has been displayed on the terminal window of data visualizer. The user needs to enter a client device address from where the sensor data needs to be collected. If the entered client device address is correct, then the next input command, asking the user to enter sensor information from where data needs to be collected, is displayed on the terminal window. After entering the correct sensor information, the host device establishes I2C communication with the respective client device and requests to send the processed sensor data. The client device responds back to host request with the processed sensor data. Upon receiving the sensor data, the host device transmits data to data visualizer tool through UART interface, for displaying it on the terminal window. If the user entered client address or sensor input command is incorrect, then terminal window display the supplied client address or sensor information is incorrect and requests the user to re-enter details.
- MPLAB® X IDE 6.20 or newer
- MPLAB® XC8 2.50 or newer
- MPLAB® Code Configurator (MCC) 5.7.1 or newer
- Microchip PIC16F1xxxx Series Device Support 1.25.389 or newer
- MSSP MCC Melody Core 7.0.1
- ADC MCC Melody Core 3.0.10
- TMR0 MCC Melody Core 4.0.13
- UART MCC Melody Core 1.10.0
- Curiosity Nano Base for Click boards™AC164162
- PIC16F15244 Curiosity Nano Evaluation Kit EV09Z19A
- SHT AN Click MIKROE-3984
- PH Sensor EC-4743
- Capacitive Soil Moisture Sensor V2.0 EC-5092
To know about the demo operation, refer GitHub code example UART-I2C Bridge and I2C Host Implementation using PIC16F15244 Microcontroller
