static-sites/bases/do-blog/resources/documents/hardware/weather-station.org

4.4 KiB
Raw Blame History

Weather Station

Venus hottest planet in the solar system due to co2

docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto

Amount of oxygen in the atmosphere 20.95%

😄, 😊, 😐, 😟, 😩

250-350 ppm | normal outdoor air level 350-1,000 ppm | Indoor good air exchange 1,000-2,000 ppm | Complaints of drowsiness and poor air 2,000-5,000 ppm | level associated with headaches, sleepiness, and stagnant, stale, stuffy air; poor concentration, loss of attention, increased heart rate and slight nausea may also be present. >5,000 ppm | This indicates unusual air conditions where high levels of other gases also could be present. Toxicity or oxygen deprivation could occur. This is the permissible exposure limit for daily workplace exposures.

Product Model MH-Z19B
Target Gas CO2
Working voltage 4.5~ 5.5 V DC
Average current < 60mA(@5V)
Peak current 150mA (@5V)
Interface leve l3.3 V(Compatiblewith 5V)
Measuring range refer to Table 2
Output signal UART(TTL 3.3V) PWMDAC(default 0.4-2V)
Preheat time 3 min
Response Time T90< 120 s
Working temperature 0 ~ 50 °C
Working humidity 0~ 90% RH(No condensation)
Dimension 33 mm×20 mm×9 mm(L×W×H)
Weight 5g
Lifespan > 5years

Duty cycle

The duty cycle is the length of the on in relation to the off percentage of on over off,

MHZ19

https://diyprojects.io/publish-co2-concentration-mh-z19-sensor-domoticz-arduino-code-compatible-esp32-esp8266/#.XG3HIKOnyV4 https://diyprojects.io/product/deal-self-calibrated-co2-sensor-mh-z19-uart-output-pwm-5000ppm/#.XG3HAaOnyV4

Static values used below instead of using magic numbers which mean nothing to some looking over the code.

// Values from the dataheet
const unsigned long mhz19_ppm_range = 5000;
const unsigned long mhz19_pwm_cycle = 1000;
const unsigned long mhz19_pwm_middle_cycle = 1004;

The below function will read a value from the MHZ19 sensor using pwm and calculate the CO2 based on the datasheet below. https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf

  unsigned long mhz19_sensor()
  {
    // Wait for the next pulse In
    do {
      // Work out for how long the pulse was set high
      pin_high_time = pulseIn(D6, HIGH, 1004000) / mhz19_pwm_cycle;
    } while (pin_high_time == 0);

    // work out how long the pulse was set low, by taking high from total length
    pin_low_time = mhz19_pwm_middle_cycle - pin_high_time;

    // Calculate parts per million from formula in spec sheet
    // CO2levelppm=2000×(time_high-2ms)/(time_high+time_low-4ms)
    ppm = mhz19_ppm_range * (pin_high_time-2)/(pin_high_time+pin_low_time-4);

    return ppm;
  }

Mosquitto server

docker run -d -it -p 1883:1883 -p 9001:9001 -v /var/www/mqtt:/mosqu/config/  eclipse-mosquitto

SPS30

I2C connection

Connect the SDA pin to D2 pin and SCL pin to d1 on the wemos to use I2C mode.

UART connection

Connect the RX and TX pins on the SPS30 to the RX TX pins on the wemos.

The following UART settings haveto be used: Baud Rate: 115200 bit/s Data Bits: 8 Parity: None Stop Bit: 1

Further information

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&cad=rja&uact=8&ved=2ahUKEwj3i7CtjN_hAhXCMewKHS2iCb0Q0PADMAR6BAgAEAU&url=https%3A%2F%2Fvancouversun.com%2Fnews%2Flocal-news%2Frising-co2-on-declining-nutrition-in-food-is-big-issue-ted-talk-hears&usg=AOvVaw0GijmobCE9pyIRmQTWTLFe