Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Air Quality Monitor Stand alone unit
#1

Werk
I am building a stand alone AQ unit for a friend but cannot get the LCD to display anything.
I have changed the display, (it works on another unit if i change the address in the software to suit) but not with the new build.
I have not installed the Tx socket or Tx unit and LED.
Code is attached
Regards
Jim

Code:
/*************************************************************************** WeatherDuino - Air Quality Monitor For PMS7003 and MH-Z19B Version:                  : 7.1 b004 Arduino IDE Compatilility : IDE 1.8.3 Version Release date      : 10/02/2018 Last revision date        : 10/02/2018 Licence                   : GNU GPLv3 Author                    : Werk_AG (MeteoCercal) Support Forum             : http://www.meteocercal.info/forum -------------------------------------------------------------------------------------          >>>>>>>>>>>> About Copyrights <<<<<<<<<<<<<<< ------------------------------------------------------------------------------------- License:GNU General Public License v3.0    WeatherDuino Pro2 PLUS Base Unit / RF Receiver    Copyright (C) 2017  Werk_AG - www.meteocercal.info    This program is free software: you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation, either version 3 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program.  If not, see <http://www.gnu.org/licenses/>. *************************************************************************************/ #include <RH_ASK.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> #include <Timer.h> #include "Adafruit_SHT31.h"     // library for SHT31 #include <SHT2x.h>              // library for SHT2x #include <HTU21D.h> #include <SoftwareSerial.h> #include "Config_AQI.h"         // User configurable options file const char* VersionNumber = "v7.10 b004"; // -------------------------------------------------------------------------------------- //   Hardware input/output pins // -------------------------------------------------------------------------------------- #define TX_PTT_PIN      7 #define TX_PIN          8 #define PMS7003_SetPin  9       #define PM_RX           10 #define PM_TX           11 #define CO2_RX          12 #define CO2_TX          13 #if (LCD_Display == 1) // ---- Define LCD I2C address // Only change this if your LCD don't display any data. I2C_Scanner utility may help you to find the address of your LCD display // Default address will work most of the times! #define LCD_I2C_Address 0x20 LiquidCrystal_I2C lcd(LCD_I2C_Address, 20, 4); byte heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};     // custom character: #endif // -------------------------------------------------------------------------------------- //   Usefull Macros // -------------------------------------------------------------------------------------- #define setPortHIGH(port, pin) ((port) |= (1 << (pin))) #define setPortLOW(port, pin) ((port) &= ~(1 << (pin))) // -------------------------------------------------------------------------------------- //   General variables // -------------------------------------------------------------------------------------- const char* PM_units = {" ug/m3"}; const byte Z19_readCMD[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};   // Z19 command to ask for data   const byte readInterval  = 15;     // 15 Minutes - WARNING!!! - NEVER CHANGE THIS VALUE, OR ALL CALCULATIONS WILL BE WRONG byte readCount_1H        = 0; uint16_t CO2_1H_Avg      = 0; uint16_t AQI_12H_nowCast = 0; uint16_t CO2_RAW         = 0; uint16_t CO2_instant     = 0; unsigned int Z19_Temp; unsigned int Z19_Ready   = 15000; bool Z19_Valid_read      = false; float Temperature        = 0.0; float Humidity           = 0.0; float PM25_1H_Avg        = 0.0; float PM25_12H_NowCast   = 0.0; float pm10,pm25; long last_AQIread; // Data to calc AQI index from PM2.5 (EPA Standard) const float concentrationBoundaries[7][2] = {   {0.0f,12.0f},   {12.0001f,35.499f},   {35.5f,55.499f},   {55.5f,150.499f},   {150.5f,250.499f},   {250.5f,350.499f},   {350.5f,500.499f} }; const unsigned int indexBoundaries[7][2] = {   {0,50},   {51,100},   {101,150},   {151,200},   {201,300},   {301,400},   {401,500} }; // ------------------------------------------------------------------- //      Data structure for PMS7003 // ------------------------------------------------------------------- #if (PMsensor_type == 0) struct PMS7003_datastruct {    uint8_t  frameHeader[2];    //uint16_t frameLen = MAX_FRAME_LEN;    float concPM1_0_CF1;    float concPM2_5_CF1;    float concPM10_0_CF1;    float concPM1_0_amb;    float concPM2_5_amb;    float concPM10_0_amb;    //uint16_t rawGt0_3um;    //uint16_t rawGt0_5um;    //uint16_t rawGt1_0um;    //uint16_t rawGt2_5um;    //uint16_t rawGt5_0um;    //uint16_t rawGt10_0um;    //uint8_t  version;    //uint8_t  errorCode;    uint16_t checksum; } PMS7003; #endif // -------------------------------------------------------------------------------------- //   Arrays for 1H averages and 12 hours NowCast // -------------------------------------------------------------------------------------- uint16_t CO2_1H_array[4]; float PM25_1H_array[4]; float PM25_12H_array[12]; //--------------------------------------------------------- //     Create objects //--------------------------------------------------------- #if (TH_Sensor == 1)  HTU21D TH; #endif #if (TH_Sensor == 3)  Adafruit_SHT31 sht31 = Adafruit_SHT31();   #endif  SoftwareSerial Dust_Serial(PM_RX, PM_TX);       // define serial for PM sensor #if (Use_CO2 == 1)  SoftwareSerial CO2_Serial(CO2_RX, CO2_TX);    // define serial for CO2 sensor #endif #if (TX_Mode == 1)  RH_ASK ask433(1000, -1, TX_PIN, TX_PTT_PIN); #endif   Timer t; // -------------------------------------------------------------------------------------- //   Setup things // -------------------------------------------------------------------------------------- void setup() { #if ((Debug_PM == 1) || (Debug_CO2 == 1))  Serial.begin(19200);  Serial.println(F("     WeatherDuino 4Pro"));  Serial.print(F("Air Quality Monitor "));  Serial.println(VersionNumber);  Serial.println();  Serial.println(F("Please wait..."));  Serial.println(); #endif  Dust_Serial.begin(9600);  //Create Software Serial for Dust sensor #if (Use_CO2 == 1)  CO2_Serial.begin(9600);   //Create Software Serial for CO2 sensor #endif   #if (PMsensor_type == 1) Dust_Serial.listen(); Dust_Serial.write(SLEEPCMD, 19);               // Put the sensor in sleep mode Dust_Serial.flush(); #endif Wire.begin(); //------------------------------------------------------------ // Setup PINS //------------------------------------------------------------  pinMode(TX_PIN, OUTPUT);  pinMode(TX_PTT_PIN, OUTPUT);  digitalWrite(TX_PTT_PIN, LOW);      // Set the Pin used to control the SET function on PMS7003 (LOW = sleep mode)  pinMode(PMS7003_SetPin, OUTPUT);  setPortLOW(PORTB, 1);                // Pin 9 - Used in final boards     //------------------------------------------------------------ // Setup the transmitter and transmition timers //------------------------------------------------------------  #if (TX_Mode == 1)    ask433.init();  #endif    // Init devices  #if (TH_Sensor == 1)    // TH.begin();  #endif  #if (TH_Sensor == 3)    sht31.begin(SHT31_address);      #endif  #if LCD_Display == 1    lcd.begin();    init_LCD();  #endif  #if (Use_CO2 == 1)    warmUp();                          // Warm UP MH-Z19 for 3 minutes    Setup_MH_Z19();  #endif  read_THsensor();    #if LCD_Display == 1   update_LCD();  #endif    read_AQISensors();  t.every(37000, runEvery37s);          t.every(60000 * readInterval, read_AQISensors);         } // -------------------------------------------------------------------------------------- //   Main Loop // -------------------------------------------------------------------------------------- void loop() {    t.update(); // Reboot if millis is close to rollover. RTC_Millis won't work properly if millis rolls over.  Takes 49 days to rollover //if ( now_millis > 4294000000UL ) softReset();     }

Code:
-------------------------------------------------------------------------------------- //   WeatherDuino - Air Quality Monitor v7.10 b004 //                  User Configurable Options // -------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------- //   Define ID and TX unit number // -------------------------------------------------------------------------------------- #define StationID  0xA1      // Must be equal to your RX Unit (Value from 0x00 to 0xFF)   // -------------------------------------------------------------------------------------- //   Define type of PM sensor // -------------------------------------------------------------------------------------- #define PMsensor_type   0    // 0= PMS7003 // -------------------------------------------------------------------------------------- //   For the PMS7003 define data set // -------------------------------------------------------------------------------------- #define PMS7003_dataSet 1    // 0= CF1, 1= Ambiente (You should always use this data set) // -------------------------------------------------------------------------------------- //   CO2 (MH-Z19) Settings //   Note: For outside use, the MH-Z19B model produces more accurate results // -------------------------------------------------------------------------------------- #define Use_CO2         1    // 0= Not instaled, 1= Instaled #define Z19_model       2    // 1= Model A, 2= Model B  (ATTENTION: Make sure you select the correct model)                             // Set measure range                               #define Z19_range       5    // Don't change (Keeps default factory range 0..5000 ppm)                             // Valid values for Model A: 1= 1000ppm, 2= 2000ppm, 3= 3000ppm, 5=5000ppm                             // Valid values for Model B: 2= 2000ppm, 5= 5000ppm int16_t CO2_OffSet   = 0;    // Fine adjust to compensate sensor error (This value should be determined case by case. Values between -50 and 50) // -------------------------------------------------------------------------------------- //   Define type of Temperature / Humidity sensor // -------------------------------------------------------------------------------------- #define TH_Sensor    1       // 1= HTU21D, 2= SHT2x, 3=SHT3x   // -------------------------------------------------------------------------------------- //   Enable / Disable RF data transmission // -------------------------------------------------------------------------------------- #define TX_Mode     0       // 0= No data will be transmitted via RF, 1= Transmit Data // -------------------------------------------------------------------------------------- //   Enable / Disable LCD Display // -------------------------------------------------------------------------------------- #define LCD_Display  1       // 0= Disable Display, 1= Enable Display // -------------------------------------------------------------------------------------- //   Enable / Disable PM sensor Debug on Serial Monitor // -------------------------------------------------------------------------------------- #define Debug_PM     1      // 0= Disable 1= Enable // -------------------------------------------------------------------------------------- //   Enable / Disable CO2 sensor Debug on Serial Monitor // -------------------------------------------------------------------------------------- #define Debug_CO2    1      // 0= Disable 1= Enable // -------------------------------------------------------------------------------------- //   SHT31 I2C Address - Default address will work most of the times! // -------------------------------------------------------------------------------------- #define SHT31_address 0x44       // Default value is 0x44, but it can be changed to 0x45
Reply


Messages In This Thread
Air Quality Monitor Stand alone unit - by Barrow4491 - 12-02-2018, 04:29
RE: AQ_Stand alone unit - by werk_ag - 12-02-2018, 19:05
RE: AQ_Stand alone unit - by Barrow4491 - 13-02-2018, 22:15
RE: AQ_Stand alone unit - by hornychz - 14-02-2018, 00:28
RE: AQ_Stand alone unit - by f4aii - 14-02-2018, 08:09
RE: AQ_Stand alone unit - by hornychz - 14-02-2018, 09:04
RE: AQ_Stand alone unit - by werk_ag - 14-02-2018, 19:33
RE: AQ_Stand alone unit - by Barrow4491 - 14-02-2018, 23:45
RE: AQ_Stand alone unit - by f4aii - 16-02-2018, 04:37
RE: Air Quality Monitor Stand alone unit - by MikeM - 19-02-2018, 08:08



Users browsing this thread: 1 Guest(s)