How to setup external i2c on industrial Arduino or ESP32 based PLC

Learn how to test the external I2C on an Arduino or ESP32 based PLC using an accelerometer
September 20, 2021 by
How to setup external i2c on industrial Arduino or ESP32 based PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

Industrial Shields PLC controllers have multiple external communications like I2C, SPI, RS-248, among others, for industrial automation and several industrial applications. These are very practical for industrial uses since this is how most of the sensors and almost any electronic devices work.

In this post, you will learn how to test the external I2C on an M-Duino PLC (a Family of industrial PLC Arduino) by using an accelerometer that works by I2C for Arduino automation.

 Related Links

How to

Read Dallas temperature sensor and datalog in µSD Card

Read 

How to

Connect temperature sensor to Raspberry PLC

Read 

How to

Parse the temperature with Node-RED

Read 

How to

Control temperature with Dallas DS18B20 sensor and Arduino PLC

Read 

How to

Get the temperature with a Raspberry PLC

Read 

How to

Program the 10 I/Os ESP32 PLC via WiFi

Read 


 Connections

In order to connect the Adafruit MMA8451 accelerometer to your open source controller Arduino or ESP32 based PLC, you should wire the cables as shown in the picture below:

Wire Arduino PLC to Adafruit MMA8451 - Connections - How to setup external i2c on Arduino or ESP32 based PLC

 Adafruit_MMA8451 Library

The first thing you should do is downloading the Adafruit_MMA8451 Library in order to run the examples.

1. So, open the Arduino IDE > Sketch > Include Library > Manage Libraries... 

2. In the library manager, filter your search by typing: Adafruit MMA8451. By installing this library, you will be asked to also download the Adafruit Unified Sensor Library. Install it.

Adafruit_MMA8451 Library - How to setup external i2c on Arduino or ESP32 based PLC

 Test

1. Once the libraries are installed rightly, go to:

File > Examples > Adafruit MMA8451 Library > Open the "MMA8451 demo"

2. Now, go to Tools > Select your board, model and port and update your sketch.

3. Open the Serial Monitor to be able to read the data from your accelerometer!

Test- How to setup external i2c on Arduino or ESP32 based PLC

​Search in our Blog

How to setup external i2c on industrial Arduino or ESP32 based PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez September 20, 2021

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>