Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod DPG1 with Arduino Uno

Application notes for Pmod DPG1 and Arduino Uno. In this app, the pressure will be displayed on the serial monitor.

EasyProtip1 hour504
Using the Pmod DPG1 with Arduino Uno

Things used in this project

Hardware components

Pmod DPG1
Digilent Pmod DPG1
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Adafruit 8-channel Bi-directional Logic Level Converter - TXB0108
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Pmod DPG1 and Arduino Uno Code

Arduino
Using this code will display the pressure on the serial monitor.
/************************************************************************
*
* Test of Pmod DPG1
*
*************************************************************************
* Description: Pmod_DPG1
* The pressure is displayed on the serial monitor.
*
*
* Material
* 1. Arduino Uno
* 2. Pmod DPG1
* 3. Adafruit module TXB0108
*
* Shématic
* Module<----------> TXB0108 <-----------> Arduino
* J1 broche 6 3.3 V
* J1 broche 5 GND
* J1 broche 4 13
* J1 broche 3 12
* J1 broche 1 10
*
************************************************************************/

#define CS 10 // Assignment of the CS pin

#include <SPI.h> // call library

int i;
byte recu[3]; // Storage of module data
int valeur;
float pression;

void setup()
{
 Serial.begin(9600); // initialization of serial communication
 SPI.begin(); // initialization of SPI port
 SPI.setDataMode(SPI_MODE0); // configuration of SPI communication in mode 0
 SPI.setClockDivider(SPI_CLOCK_DIV16); // configuration of clock at 1MHz
 pinMode(CS, OUTPUT);
}

void loop()
{
 digitalWrite(CS, LOW); // activation of CS line
 delayMicroseconds(20);
 for (i=0;i<2;i=i+1)
    {
    recu[i] = SPI.transfer(0); // Sending 2 data to retrieve the value of the two -byte conversion
    delayMicroseconds(20);
    }
 digitalWrite(CS, HIGH); // deactivation of CS line
 valeur = (recu[0] << 8|recu[1]);
 for (i=0;i<2;i=i+1) // Send in serial monitor
    {
    Serial.print("i");
    Serial.print(i);
    Serial.print("=");
    Serial.print(recu[i]);
    Serial.print('\t'); // tabulation
    }
 pression=(valeur/4096.0-0.08)/0.09; // The form given by the documentation
 Serial.print("Pression=");
 Serial.print(pression);
 Serial.println(" kPa");
 delay(1000);
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 5 followers
Alex Wong

Alex Wong

5 projects • 13 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments

Add projectSign up / Login