UART-I2C Bridge Implementation: I2C Client(Client-1) Implementation Using the PIC16F15244 Microcontroller
This code example is a good use case to demonstrate UART-I2C bridge implementation using the PIC16F152xx family microcontrollers. In this code example, PIC16F15244 MCU acts as an I2C client as device 1. It periodically collects the data from the sensor, process the acquired data and keep the data ready to transmit to the Host device over the I2C interface. When the Host device requests to send the processed sensor data, then the client device responds back to the host request with the processed data through the I2C interface. After receiving the data from the client device, the host device displays the data on the terminal window.
Refer to the GitHub code example UART-I2C Bridge and I2C Host Implementation using PIC16F15244 Microcontroller and UART-I2C Bridge Implementation: I2C Client(Client-2) Implementation using PIC16F15244 Microcontroller for more details about the 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 the Data Visualizer terminal window application, running on a PC, through the USART interface and receives user inputs/commands. Based on the commands received from the user, the PIC16F15244 microcontroller communicates with the I2C client devices and collects the required sensors data and transmit to PC for displaying it on the terminal window. Thus, the PIC16F15244 microcontroller acts as a EUART-I2C bridge to communicate with the 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 Client 1 and Client 2, which are based on the PIC16F15244 microcontroller. Figure 1 shows the block diagram view of the application.
Figure 1 : Block diagram view of the application
For demonstration purposes, the pH sensor is interfaced to Client 1 and, temperature and capacitive soil moisture sensors are interfaced to Client 2. Both clients periodically collect data from the sensors, process the acquired data and keep the data ready to transmit to the Host device over the I2C interface.
The input commands and I2C client address information have been displayed on the terminal window of the 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 the host request with the processed sensor data. Upon receiving the sensor data, the host device transmits data to the Data Visualizer tool through the UART interface, for displaying it on the terminal window. If the client address or sensor input command entered by the user is incorrect, then terminal window display supplied by the client address or the sensor information is incorrect and requests the user to re-enter more details.
- MPLAB® X IDE 6.25 or newer
- MPLAB® XC8 3.00 or newer
- MPLAB® Code Configurator (MCC) 5.6.2 or newer
- Microchip PIC16F1xxxx Series Device Support 1.27.418 or newer
- MSSP MCC Melody Core 7.0.3
- ADC MCC Melody Core 4.0.0
- TMR0 MCC Melody Core 5.1.0
- UART MCC Melody Core 1.10.2
- 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