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.
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:
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.
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!