Quantcast
Channel: banana pi single board computer open source project official forum BPI team - Latest posts
Viewing all articles
Browse latest Browse all 43631

BPI-M2+ Weather station:Air pressure sensor, temperature sensor,light intensity sensor arduino lib

$
0
0

BPI-M2+ Weather station_07_CO2 sensor arduino lib(MH-Z14A/MH-Z19B)

CO2 sensor support read from UART and PWM at the same time:

PWM :

#include "MH_Z1X.h"
MH_Z1X co2;
#define pin 11

void setup() {
  Serial.begin(9600);      
}

void loop() {
  co2.read_PWM(pin);     // pin
  Serial.print("CO2=");
  Serial.print(co2.co2);
  Serial.println();
  delay(1000);
}

UART:

#include "MH_Z1X.h"
#ifdef MH_Z1X_USE_SOFTWARE_SERIAL
#include "SoftwareSerial.h"
SoftwareSerial mySerial(4, 5); // MEAG TX:10, RX:11
MH_Z1X co2(mySerial);
#else
MH_Z1X co2(Serial1);
#endif
void setup() {
  Serial.begin(9600);      
}

void loop() {
  co2.read();
  Serial.print("CO2=");
  Serial.print(co2.co2);
  Serial.println();
  delay(1000);
}

MH-Z14A / MH-Z19B lib download link:

https://drive.google.com/file/d/0B4PAo2nW2KfnRXlnbWp6bGwtdk0/view?usp=sharing


Viewing all articles
Browse latest Browse all 43631

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>