How to setup external i2c on 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 Arduino or ESP32 based PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez


INTRODUCTION

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

In this blog, we are going to show you how to test the external I2C on a M-Duino PLC by using an accelerometer which works by I2C.

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 industrial PLC via WiFi

Read 


 Connections

In order to connect the Adafruit MMA8451 accelerometer to our Arduino or ESP32 based PLC, we are going to wire the cables as shown in the picture below:

Odoo • Image and Text

 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 for also downloading the Adafruit Unified Sensor library. Install it.

Odoo • Image and Text

 Test

1. Once the libraries are rightly installed, 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!

Odoo • Image and Text
How to setup external i2c on Arduino or ESP32 based PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
20 September, 2021
Share this post
Archive

Looking for your ideal PLC?

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!