New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Ikea Vindriktning #4361
Comments
Found a link to the datasheet (English content) that also briefly describes the particle data it will return, and the command to send to get it send that data. |
tried to open the datasheet, but "cannot be downloaded safely"... |
Seems like it is "signed" but not with a commonly known CA. This is the document printed to PDF, so it removes those, including any scripts if they were present. |
Got it. |
That was also mentioned in the blog. |
Hi, I am playing around with ESPeasy for some time and wrote a plugin for the Vindriktning. I am still unsure how to share this plugin. I opened the box and added a Wemos D1. Hooked it up to power and the Tx of the sensor. The Vindriktning CPU is still doing the polling, but the Wemos is snooping the answer. |
@flashmark Can you share the relevant code here? |
Not sure how to do this. First time using github. |
copy paste (not too large) chunks of code can be pasted in a message here. |
Main trick, borrowed from others // Function P240_process_rx
// Handles a single character received from the PM1006 in the Vindrikning
// It expects a response to the poll message sent by the Vindriknings own CPU
// 0x16 <len> <data> <chksum>
// <len> = size of <data> in char [1 char]
// <data> = message payload, array of <len> chars
// <csum> = checksum, 256-(sum of all received characters) [1 char]
bool P240_process_rx(char c)
{
switch (rxState) {
case PM1006_HEADER:
rxChecksum = c;
if (c == 0x16) {
rxState = PM1006_LENGTH;
}
break;
case PM1006_LENGTH:
rxChecksum += c;
if (c <= bufferSize) {
_rxlen = c;
_index = 0;
rxState = (_rxlen > 0) ? PM1006_DATA : PM1006_CHECK;
} else {
rxState = PM1006_HEADER;
}
break;
case PM1006_DATA:
rxChecksum += c;
serialRxBuffer[_index++] = c;
if (_index == _rxlen) {
rxState = PM1006_CHECK;
}
break;
case PM1006_CHECK:
rxChecksum += c;
rxState = PM1006_HEADER;
#ifdef PLUGIN_240_DEBUG
P240_dump();
#endif
return ((rxChecksum&0xFF) == 0);
default:
rxState = PM1006_HEADER;
break;
}
return false;
} |
Backticks are these: ` |
I am using a simple state machine as parser of the incoming characters. Characters are gathered "ten per second' typedef enum {
PM1006_HEADER,
PM1006_LENGTH,
PM1006_DATA,
PM1006_CHECK
} pm1006_state_t; And some global storage // Global variables TODO: attach them to the task to allow multiple instances
ESPeasySerial *easySerial = nullptr;
const int bufferSize = 20;
char serialRxBuffer[bufferSize];
char debugBuffer[3*bufferSize];
int rxBufferPtr = 0;
int rxChecksum = 0;
int _index = 0;
int _rxlen = 0;
int pm25 = 0;
pm1006_state_t rxState = PM1006_HEADER; |
Plugin is around 375 lines of code, half of it comment. Main issue to move the global variables in something that is bound to the plugin instance. The sensor is working, but a bit boring at my home with only high rates when you fool it with burning matches. I should try to upload it to my github clone |
I took the liberty to edit your posts to show the correct backticks. |
Thanks, learned new tricks today :-) Next is to share the code through github. I took the free P240, used the template and reverse engineered serial link sensors like MHZ19. |
We have a Developers guide, here Part of those steps you have already done, like forking the ESPEasy repo. |
Missing part: case PLUGIN_TEN_PER_SECOND:
{
// code to be executed 10 times per second. Tasks which require fast response can be added here
// be careful on what is added here. Heavy processing will result in slowing the module down!
bool new_data = false;
while ((easySerial->available() > 0) && !new_data)
{
new_data = P240_process_rx(easySerial->read());
if (new_data)
{
pm25 = float((serialRxBuffer[3] << 8) + serialRxBuffer[4]);
String log = F("P240 : Data ");
log += pm25;
addLogMove(LOG_LEVEL_INFO, log);
}
}
success = true;
} |
@tonhuisman Will pick it up coming days. |
I think you're also missing a |
Thanks, break was missing, but not affecting the functionality. Tried a pull request first time, not sure the code fulfills all requirements. I don't have reviewers at home. |
I'm interested too to use the Vindriktning :) |
There is a lot of interest for this device, in several app-groups that I am part of.
Not surprising, since it is relatively cheap to buy and offers a nice looking case for those extra sensors...
Hans Man
Op do., nov. 17, 2022 om 22:37, fly74 ***@***.***> schreef:
I'm interested too to use the Vindriktning :)
—
Reply to this email directly, view it on GitHub (#4361 (comment)), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AB25MUGNZOWDSMUF5SDXWI3WI2QRFANCNFSM6AAAAAAR7ZSRLY).
You are receiving this because you commented.Message ID: ***@***.***>
|
@TD-er PM1006K : |
Thanks. It shows at least it shares its protocol with the PM1006. |
Note that the plugin I wrote is dedicated to the Ikea Vindriktning. The original Ikea CPU is talking to the sensor and driving the three LEDs. The plugin is listening only to the answers of the sensor and translates them to ESPeasy plugin values. If you wish to take control the Ikea CPU shall be removed and the plugin also has to send queries the sensor. I think this is easily possible as long as the protocol is indeed as given above. |
Here a german article about the inside https://www.heise.de/ratgeber/Ikea-Feinstaubsensor-Vindriktning-zum-IoT-Device-aufbohren-6164149.html |
Is there an action build for testing ? |
@tonhuisman @flashmark @TD-er Hey not bad a for a first try! |
ESP_Easy_mega_20221128_collection_E_ESP32_4M316k works with ESP32 but not ESP_Easy_mega_20221128_collection_E_ESP8266_4M1M with ESP8266 - value is zero all the time |
What serial port do you use on ESP8266? |
Serial1 on ESP8266 is useless. It is read from left to right, from the viewpoint of the ESP. |
@TD-er I'm a little confused. D4 = GPIO2 https://microcontrollerslab.com/wp-content/uploads/2019/05/ESP8266-12E-Wemos-D1-Mini-pinout.jpg |
You selected "HW Serial1"
This means HW serial1 on ESP8266 is utterly useless. (well, maybe for outputting logs it may be useful...) HW Serial0 is default on GPIO 1 & 3 (I will not name the D-notation as I always have to check it as it makes no sense, even though boards like NodeMCU and Wemos D1 mini use it on their silk screen) This means that if you want to connect the sensor to pins other than GPIO 1 & 3, you should select "SW Serial" and pick the right pins. |
@TD-er Hi Gijs, it's a little tricky and work now with: But why the device must be set GPIO<TX and the devicelist shows it as RX: GPIO-4 (D2)? |
I tried to make it as unambiguous as possible, so please tell me where it is inconsistent? Only thing I can think of for serial is to change the label into "GPIO (RX) <- TX" |
I can live with it. But for me it would be the clearest to set an "GPIO (#) <- REST Pin Sensor". But don't let us splitting hairs :) |
I made a clip for fixing the ESP inside, if anyone is interested and able to print 3D. |
Another Question the values are only shown if the plugin interval is set less than 10 seconds. I'm using the generic http controller to push values to a database usually every 300 seconds. Can I use a rule to push values every 300s even if the sensor is getting it every 10s? |
Hmm that sounds like a bug... |
Works great. THX. |
That does really surprise me. |
I will have an eye on it, but the constant rpm change is annoying to me. |
Maybe you can also experiment with its orientation? If the fan is slightly tilted, maybe the fan noise is less annoying? |
The annoying thing the constant spin up and spin down from the measure cycle. |
Yep, I understand. |
I bought 2 of them and it's the same for both. |
Add support for Ikea Vindriktning (#4361)
@TD-er is it going to official build? |
Now that it's merged it will be included in the next Release 😃 |
Yep, but not yet a new build right now. |
Wich builds will include the plugin? Only the collection_E? |
Also the "climate" and "max" builds. |
What about the new model of AIR Quality sensor from IKEA ??? |
Ikea link: https://www.ikea.com/nl/nl/p/vindriktning-luchtkwaliteitsensor-70498242/
Some blog post describing the sensor: https://style.oversubstance.net/2021/08/diy-use-an-ikea-vindriktning-air-quality-sensor-in-home-assistant-with-esphome/
Forum topic: https://www.letscontrolit.com/forum/viewtopic.php?p=60972#p60972
The text was updated successfully, but these errors were encountered: