Code Monkey home page Code Monkey logo

esp32-weather-station's Introduction

esp32-weather-station

esp32 with DHT22 and GP2Y1010AU0F

board: https://www.amazon.de/Diymore-Wireless-Bluetooth-Batterie-Entwicklung/dp/B077D7PVFC

Dust Sensor: https://www.waveshare.com/wiki/Dust_Sensor

Since the internal ADC of the ESP32 did not work with the sensor, this code uses an ADS1115 connected to SDA 21, SCL 22.

From the dust sensor manual:

It is applied to detect of dust in the air, such as the applications of Air Purifier, Air Monitor and PM2.5 Detector.

  • Enable the internal infrared emitting diode by setting the pin ILED to HIGH.

  • Wait 0.28ms, then the external controller starts to sample the voltage from the pin AOUT of the module. Notes that the output wave will take 0.28ms to reach steady state after the internal infrared emitting diode is enabled, as Figure 2 shows.

  • There is a period of 0.04ms for sampling. When finished, set the pin ILED to LOW to disable the internal infrared emitting diode.

  • Calculate the dust concentration according to the relationship between output voltage and dust concentration. For more detailed information, please refer to the relative Demos. Note: The output voltage has been divided (see schematic), so that the voltage measurement should x 11 to get the actual voltage.

Important

The onboard voltage divider takes the output of the Sharp dust sensor (range: 0V..4V) and divides it by 11. Thus, the Waveshare board outsputs 0mV..400mV.

The default configuration of the esp32 Arduino core according to https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-adc.h is:

  • analogReadResolution(12)
  • analogSetWidth(12)
  • analogSetCycles(8)
  • analogSetSamples(1)
  • analogSetClockDiv(1)
  • analogSetAttenuation(ADC_11db)

The main problems are the high attenuation of 11dB and the non-linear behaviour of the ADC at 12-bit. So we need to change it to:

  • analogSetAttenuation(ADC_0db)
  • analogReadResolution(10)

WE DON'T USE THE INTERNAL ADC ANYMORE, but added an external ADS1115

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.