Cov txheej txheem:

Arduino AMS5812_0050-D-B Siab & Kub Sensor Qhia: 4 Kauj Ruam
Arduino AMS5812_0050-D-B Siab & Kub Sensor Qhia: 4 Kauj Ruam

Video: Arduino AMS5812_0050-D-B Siab & Kub Sensor Qhia: 4 Kauj Ruam

Video: Arduino AMS5812_0050-D-B Siab & Kub Sensor Qhia: 4 Kauj Ruam
Video: Particle Photon - AMS5812_0050-D-B Pressure & Temperature Sensor Tutorial 2024, Kaum ib hlis
Anonim
Image
Image

AMS5812 Amplified Pressure Sensor nrog Analog thiab Digital Outputs yog lub ntsuas qhov ntsuas siab nrog qhov tso tawm qhov hluav taws xob analog thiab digital I2C interface. Nws ua ke lub piezoresistive sensing element nrog lub teeb pom kev zoo rau nws txoj haujlwm. Nov yog nws qhov ua qauv qhia nrog arduino nano.

Kauj Ruam 1: Yam Koj Xav Tau..

Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!

1. Arduino Nano

2. AMS5812_0050-D-B

3. I²C Cable

4. I2C Shield rau Arduino Nano

Kauj Ruam 2: Kev Sib Txuas:

Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas

Siv daim I2C daim thaiv rau Arduino Nano thiab maj mam thawb nws hla tus pin ntawm Nano.

Tom qab ntawd txuas ib qho kawg ntawm I2C cable rau AMS5812_0050-D-B sensor thiab lwm qhov kawg rau I2C daim ntaub thaiv.

Kev sib txuas tau qhia hauv daim duab saum toj no.

Kauj ruam 3: Code:

Txoj Cai
Txoj Cai

Tus lej Arduino rau AMS5812_0050-D-B tuaj yeem rub tawm los ntawm peb GitHub chaw cia khoom-Dcube Store.

Nov yog qhov txuas rau tib yam:

github.com/DcubeTechVentures/AMS5812-0050-D-B

Peb suav nrog tsev qiv ntawv Wire.h los pab txhawb I2c kev sib txuas lus ntawm lub sensor nrog Arduino board.

Koj tseem tuaj yeem luam cov cai los ntawm no, nws tau muab raws li hauv qab no:

// Faib nrog daim ntawv tso cai yuav dawb.

// Siv nws txhua txoj hauv kev uas koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm ua haujlwm.

TIAB SA 58812

// Cov cai no tau tsim los ua haujlwm nrog AMS5812_I2CS_0050-D-B I2C Mini Module muaj nyob hauv Dcube Store.

#suav nrog

// AMS5812 I2C chaw nyob yog 0x78 (120)

#Txiav txim siab Addr 0x78

void teeb tsa ()

{

// Pib I2C kev sib txuas lus li MASTER

Hlau.begin ();

// Initialise serial communication, teeb baud tus nqi = 9600

Serial.begin (9600);

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [4];

ncua (500);

// Thov 4 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 4);

// Nyeem 4 bytes ntawm cov ntaub ntawv

// siab msb, siab lsb, temp msb, temp lsb

yog (Wire.available () == 4)

{

cov ntaub ntawv [0] = Wire.read ();

cov ntaub ntawv [1] = Wire.read ();

cov ntaub ntawv [2] = Wire.read ();

cov ntaub ntawv [3] = Wire.read ();

}

// Hloov cov ntaub ntawv

ntab siab = ((cov ntaub ntawv [0] & 0xFF) * 256 + (cov ntaub ntawv [1] & 0xFF));

ntab temp = ((data [2] & 0xFF) * 256 + (data [3] & 0xFF));

siab = ((siab - 3277.0) / ((26214.0) / 10.0)) - 5.0;

ntab cTemp = ((temp - 3277.0) / ((26214.0) / 110.0)) - 25.0;

ntab fTemp = (cTemp * 1.8) + 32;

// Cov ntaub ntawv tso tawm rau tus saib xyuas

Serial.print ("Siab:");

Serial.print (siab);

Serial.println ("PSI");

Serial.print ("Kub hauv Celsius:");

Serial.print (cTemp);

Serial.println ("C");

Serial.print ("Kub hauv Fahrenheit:");

Serial.print (fTemp);

Serial.println ("F");

ncua (500);

}

Kauj Ruam 4: Cov ntawv thov:

AMS5812 yog lub zog ntsuas qhov ntsuas siab thiab nws tuaj yeem ua haujlwm hauv cov kab ke uas ntsuas qhov ntsuas zoo li qub thiab muaj zog thiab ntsuas ntsuas ntsuas siab. Nws ua lub luag haujlwm tseem ceeb hauv kev saib xyuas lub tshuab nqus tsev, Kev ntsuas roj ntws, ntsuas ntsuas dej nrog rau kev ntsuas kev kho mob.

Pom zoo: