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
20 September, 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, we are going to show you 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 our open source controller Arduino or ESP32 based PLC, we are going to 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 we are going to do is to download the Adafruit_MMA8451 Library in order to be able 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
How to setup external i2c on industrial Arduino or ESP32 based PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
20 September, 2021
Share this post
Archive

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 >>>

Do you want more information?

Just fill the form!

Tell me more!