Skip to content
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 Interval to PMS5003 sensor to extend lifetime. #8128

Merged
merged 13 commits into from
Apr 12, 2020

Conversation

gururise
Copy link
Contributor

@gururise gururise commented Apr 11, 2020

Description:

User has option to take readings either continuously (current default) or at WAKEUP intervals of between 60-65535 seconds. If the sensor is set to take reading at intervals, it will be put to sleep and woken up 30 seconds prior to the reading being taken (the WARMUP period), then the reading will be taken and the sensor put back to sleep until 30 seconds prior to the next reading. To use this interval feature, TX pin must be connected. If user only sets up RX pin, the default ACTIVE sensor mode will be used.

NOTE: I used an existing setting variable (mcp230xx_int_timer) for the PMS5003 interval period because I am not familiar enough with the settings variables to create a new variable and update the version scheme properly. Would appreciate advice/help on creating a new uint16_t to hold the wakeup interval in seconds.

Related issue (if applicable): fixes #
Enhancement #8097

Checklist:

  • The pull request is done against the latest dev branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR.
  • The code change is tested and works on core Tasmota_core_stage
  • The code change pass travis tests. Your PR cannot be merged unless tests pass
  • I accept the CLA.

@arendst
Copy link
Owner

arendst commented Apr 11, 2020

Current implementation will break gpio numbering.

@arendst arendst added the on hold by dev team Result - Feature request put on hold by member of development team label Apr 11, 2020
@gururise
Copy link
Contributor Author

Current implementation will break gpio numbering.

Thanks for the feedback. I'm brand new to Tasmota and am still trying to wrap my head around your gpio numbering methodology and the settings variables.

Hope you can provide a bit of guidance with two issues:

  1. I need to add a TX pin for the PMS sensor. In order to not break GPIO numbering, should the TX pin (which currently doesn't exist in the tasmota_template.h) be added to the end of the template instead?

  2. I also need to add a new uint16_t in settings.h file to handle the interval time. Doing so would appear to cause issue with the version numbering scheme. What is the proper way to go about this?

@arendst
Copy link
Owner

arendst commented Apr 11, 2020

  1. yes
  2. add uint16_t at line 508 and decrement free_f18[132] to 130

@gururise
Copy link
Contributor Author

gururise commented Apr 11, 2020

Tested code changes on core with PMS5003 sensor and everything works (should also work for the PMS3003 and PMS7003, but I don't have them to test). The default behavior is current functionality (RX only, read data while sensor is in ACTIVE mode) of continuous sensor readings and only requires the connection of the RX pin.

New functionality allows user to set a read interval to prolong the life of the sensor by putting the sensor to sleep between reads. This will require connecting both the RX & TX pins and changing the setting:
Sensor18 <read interval in seconds>

30 seconds prior to the read interval (aka the WARMUP period) the sensor will turn on to allow it to warm up and take a reading. The read interval can vary from 60 to 65535 seconds. A read interval less than 60 will default to continuous readings (ie active mode).

Hope this is useful for people!

@gururise gururise marked this pull request as ready for review April 11, 2020 22:14
@arendst arendst merged commit 0d2287d into arendst:development Apr 12, 2020
arendst added a commit that referenced this pull request Apr 12, 2020
Add interval to PMS5003 sensor to extend lifetime (#8128)
@barbudor
Copy link
Contributor

When teleperiod is different from 10 or 300, the DeepSleep will occur at the 2nd tele period
Example with teleperiod 35 and DeepSleepTime 120 (just for the purpsose of the test).

ONe possibility could be to discard the 1st tele, leaving the time for the sensor to warmup, then measure is taken, SENSOR sent and back to sleep.
So the warm-up time would be spent awaken.

00:00:00 Project tasmota dev-4119 Version 8.2.0.3(bsensors)-STAGE
00:00:00 WIF: Connecting to AP1 BNETWLAN Channel 1 BSSId 50:D4:F7:C0:2E:B0 in mode 11N as dev-4119...
00:00:01 WIF: Connected
00:00:01 HTP: Web server active on dev-4119 with IP address 192.168.168.199
20:56:04 MQT: Attempting connection...
20:56:04 MQT: Connected
20:56:04 MQT: tele/dev-4119/LWT = Online (retained)
20:56:04 MQT: cmnd/dev-4119/POWER = 
20:56:04 MQT: stat/dev-4119/RESULT = {"POWER":"OFF"}
20:56:04 MQT: stat/dev-4119/POWER = OFF
20:56:08 MQT: tele/dev-4119/STATE = {"Time":"2020-04-13T20:56:08+02:00","Uptime":"0T00:00:09","UptimeSec":9,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"BNETWLAN","BSSId":"50:D4:F7:C0:2E:B0","Channel":1,"RSSI":84,"Signal":-58,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:56:08 MQT: tele/dev-4119/SENSOR = {"Time":"2020-04-13T20:56:08+02:00","Switch1":"ON","ANALOG":{"Range":35}}
20:56:43 MQT: tele/dev-4119/STATE = {"Time":"2020-04-13T20:56:43+02:00","Uptime":"0T00:00:44","UptimeSec":44,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":20,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"BNETWLAN","BSSId":"50:D4:F7:C0:2E:B0","Channel":1,"RSSI":82,"Signal":-59,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:56:43 MQT: tele/dev-4119/SENSOR = {"Time":"2020-04-13T20:56:43+02:00","Switch1":"ON","ANALOG":{"Range":35}}
20:56:43 MQT: stat/dev-4119/RESULT = {"DeepSleep":{"Time":"2020-04-13T20:58:00","Epoch":1586804280}}
20:56:46 APP: Sleeping

@wwiill
Copy link

wwiill commented Jun 12, 2020

Tested code changes on core with PMS5003 sensor and everything works (should also work for the PMS3003 and PMS7003, but I don't have them to test). The default behavior is current functionality (RX only, read data while sensor is in ACTIVE mode) of continuous sensor readings and only requires the connection of the RX pin.

New functionality allows user to set a read interval to prolong the life of the sensor by putting the sensor to sleep between reads. This will require connecting both the RX & TX pins and changing the setting:
Sensor18 <read interval in seconds>

30 seconds prior to the read interval (aka the WARMUP period) the sensor will turn on to allow it to warm up and take a reading. The read interval can vary from 60 to 65535 seconds. A read interval less than 60 will default to continuous readings (ie active mode).

Hope this is useful for people!

Hi, sorry for the noob question but how do you configure the read interval from the Tasmota web interface?

@murraythegoz
Copy link

murraythegoz commented Jul 3, 2020

Tested code changes on core with PMS5003 sensor and everything works (should also work for the PMS3003 and PMS7003, but I don't have them to test). The default behavior is current functionality (RX only, read data while sensor is in ACTIVE mode) of continuous sensor readings and only requires the connection of the RX pin.
New functionality allows user to set a read interval to prolong the life of the sensor by putting the sensor to sleep between reads. This will require connecting both the RX & TX pins and changing the setting:
Sensor18 <read interval in seconds>
30 seconds prior to the read interval (aka the WARMUP period) the sensor will turn on to allow it to warm up and take a reading. The read interval can vary from 60 to 65535 seconds. A read interval less than 60 will default to continuous readings (ie active mode).
Hope this is useful for people!

Hi, sorry for the noob question but how do you configure the read interval from the Tasmota web interface?

You have to open a command line from the web interface (not sure where the menu entry for command line is, look around in menus) and send the command 'Sensor18 <read interval in seconds>'

@Lassska
Copy link

Lassska commented May 23, 2024

Hello, if we had only one sensor, we consider it to be correctly calibrated. Of the two adjacent sensors, the newer one shows the lower values I searched for offset at Tasmota but there are no commands. How could I correct the read values ​​in Home Assistant?
Screenshot_20240523_155940_Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold by dev team Result - Feature request put on hold by member of development team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants