Description
This sensor has 4 pins:
- VIN: Module power supply – 3.3-5 V
- GND: Ground
- SLC: I2C Clock
- OUT: Digital output data
Interafacing with arduino:
Require materials:
- Arduino Uno R3 x 1
- Pressure sensor x 1
- Jumper wires x 4
Connection diagram:
The following circuit shows how you should connect Arduino to the module. Connect wires accordingly.
Arduino code:
Install the following library on Arduino.
Upload the following code to your Arduino
/*
on Sep 21, 2020
by MohammedDamirchi
Home
*/
#include <Q2HX711.h>
#include <Average.h>
const byte MPS_OUT_pin = 2; // OUT data pin
const byte MPS_SCK_pin = 3; // clock data pin
int avg_size = 10; // #pts to average over
Q2HX711 MPS20N0040D(MPS_OUT_pin, MPS_SCK_pin); // start comm with the HX710B
Average<long> ave(avg_size);
void setup() {
Serial.begin(9600); // start the serial port
}
void loop() {
ave.push(MPS20N0040D.read());
Serial.println(ave.mean());
}
After running the code, you will see the following image in the serial monitor.