GithubHelp home page GithubHelp logo

Comments (8)

Hypfer avatar Hypfer commented on May 27, 2024 2

If you want to extend this codebase, you probably would want to do the following

Extend that state struct to also contain the data from the DHT22

struct particleSensorState_t {
unsigned long avgPM25;
unsigned long measurements[5] = {0, 0, 0, 0, 0};
int measurementIdx = 0;
};

Extend the autoconfig section to also publish temperature and humidity sensors

autoconfPayload["device"] = device.as<JsonObject>();
autoconfPayload["availability_topic"] = MQTT_TOPIC_AVAILABILITY;
autoconfPayload["state_topic"] = MQTT_TOPIC_STATE;
autoconfPayload["name"] = identifier + String(" PM 2.5");
autoconfPayload["unit_of_measurement"] = "μg/m³";
autoconfPayload["value_template"] = "{{value_json.pm25}}";
autoconfPayload["unique_id"] = identifier + String("_pm25");
autoconfPayload["icon"] = "mdi:air-filter";
serializeJson(autoconfPayload, mqttPayload);
mqttClient.publish(MQTT_TOPIC_AUTOCONF_PM25_SENSOR, mqttPayload, true);
autoconfPayload.clear();
}

Extend the MQTT publish function to add the other measurements to the published JSON

stateJson["pm25"] = state.avgPM25;
stateJson["wifi"] = wifiJson.as<JsonObject>();

And since the DHT22 requires polling afaik, extend the loop function to poll it on each publish

if (statusPublishInterval <= (millis() - statusPublishPreviousMillis)) {
statusPublishPreviousMillis = millis();
if (state.avgPM25 > 0) {
publishState();
}
}

That should be about it

from esp8266-vindriktning-particle-sensor.

Hypfer avatar Hypfer commented on May 27, 2024 1

As I personally already have a functioning bunch of zigbee temperature sensors basically everywhere, I did not try that, however it should be an easy modification software-wise.

As for hardware, it might get a bit too crammed in there.
Note that adding too much stuff in there might interfere with the airflow and therefore mess up the readings

from esp8266-vindriktning-particle-sensor.

GSzabados avatar GSzabados commented on May 27, 2024 1

Note that adding too much stuff in there might interfere with the airflow and therefore mess up the readings

Thanks for the reply. I've just had some time this morning and checked the images of the device from Twitter. I understand now what you mean regarding the airflow. Anyhow I will give it a try with a DTH22 HAT. I ordered this morning before checking the pictures. I will keep you updated how it worked out. (I might will need some help for the sketch as I don't have too much experience with it.)

from esp8266-vindriktning-particle-sensor.

matrob avatar matrob commented on May 27, 2024

The additional function of the DHT22 would be absolutely great. Is anyone already working on this?

from esp8266-vindriktning-particle-sensor.

GSzabados avatar GSzabados commented on May 27, 2024

The additional function of the DHT22 would be absolutely great. Is anyone already working on this?

I went down the ESPHome way at the end as @Habbie made a ESPHome component which is/will be part of the latest release of ESPHome.

from esp8266-vindriktning-particle-sensor.

matrob avatar matrob commented on May 27, 2024

Thank you for pointing this out. I will take a closer look at his PR esphome/esphome#2038.

from esp8266-vindriktning-particle-sensor.

unreal4u avatar unreal4u commented on May 27, 2024

Hi all!

Based on above indications of @Hypfer (hey, thanks for your work!), I created a quick-'n-dirty© commit that implements a DHT11 sensor. Please adjust accordingly if you are using the DHT22 variant :)

I connected it to D4 of the Wemos Mini, or GPIO02, adjust accordingly.

Because it is so quick and dirty, I won't create a PR: ideally I would want to define one variable in order to include all the additional information + libraries and such, but this is the first time I have played with an ESP8266 board, so I def. will have done some very wrong stuff!

The commit can be found at my fork:
unreal4u@db8ccc9

To compile, you'll need the Adafruit Unified Sensor (v1.1.4) library installed. I also installed the DHT Sensor Library (v1.4.2) but I'm not quite sure if this is needed or not.

from esp8266-vindriktning-particle-sensor.

grmcdorman avatar grmcdorman commented on May 27, 2024

I have an alternative firmware implementation, https://github.com/grmcdorman/esp8266_vindriktning; this uses an SHT31-D (an I2C device), but it shouldn't be hard to add the DHT variants to the code base from the way I've structured it. I have it working nicely with the SHT31-D.

The Vindriktning polling in that code has been gently revised; I believe it is more robust (for example, that 25 ms wait "for unknown reasons" isn't needed any more).

from esp8266-vindriktning-particle-sensor.

Related Issues (20)

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.