I have designed a 3D printable enclosure for this and the design/STL files are available here: https://www.thingiverse.com/thing:3072244
John Oliva
@John Oliva
Best posts made by John Oliva
-
RE: 💬 Building a Raspberry Pi Gateway
-
RE: Sensor reporting after External Interrupt
I should have stated that I am using NodeManager.
-
RE: 💬 Printable MySensors Things
This one is also available: https://www.thingiverse.com/thing:3072244
Latest posts made by John Oliva
-
New enclosure for My Slim 2AA Battery Node
Here is a new enclosure for the My Slim 2AA Battery Node. Not as slim but the overall form factor is still small.
https://www.thingiverse.com/thing:3269357 -
RE: 💬 My Slim 2AA Battery Node
Here is a new enclosure for the My Slim 2AA Battery Node. Not as slim but the overall form factor is still small.
https://www.thingiverse.com/thing:3269357 -
RE: Sensor reporting after External Interrupt
@kimot, thanks for your input.
I have previously coded directly with the MySensors API quite successfully. What I like about NodeManager is that the developers have identified some common patterns in programming for MySensors and created an easier to use programming experience. NodeManager does a lot of the heavy lifting. For the most part I agree with the developer's design decisions.
This simply comes down to the perennial question of whether to build something yourself or leverage the work of others. I am at a point where I prefer to rely on the work of others (if it is of good quality) so that I can get the most done.
-
RE: Sensor reporting after External Interrupt
Having looked at the code, I am fairly certain that without FEATURE_TIME enabled (and supporting RTC or controller reporting time) that an external interrupt is treated as the end of the sleep cycle and the sleep cycle period is assumed to have passed.
-
RE: Sensor reporting after External Interrupt
First, thanks @electrik and @hard-shovel for your input.
Indeed, using the const int to hold the BAT_RPT_INTERVAL in seconds was wrong - good find @electrik.
I fixed (changed all intervals to minutes) and the sketch continued to behave as before.
I then changed the intervals:
const int SLEEP_INTERVAL_MIN = 1; const int BME280_RPT_INTERVAL = 2 * SLEEP_INTERVAL_MIN; const int BAT_RPT_INTERVAL = 3 * SLEEP_INTERVAL_MIN;
This apparently fixed the battery reporting, but I was still getting the BME280 sensor readings with each sleep cycle.
I then decided to comment out bme280.setReportIntervalMinutes(2 * SLEEP_INTERVAL_MIN) and added node.setReportIntervalMinutes(2 * SLEEP_INTERVAL_MIN) .
After this, it appeared to be operating as expected (at least as far as synchronous timed reporting).
This led me to think that perhaps the default for node.setReportIntervalMinutes() was the same as the sleep interval.
I then tried setting bme280.setReportIntervalMinutes(2 * SLEEP_INTERVAL_MIN) and added node.setReportIntervalMinutes(0) . My thought was that this might effectively disable node wide child sensor reporting. Indeed, it looks like that is what it did.
So far so good.
I then went to look at the asynchronous reporting when an external interrupt gets generated. Sometimes it would only send the change event and other times it would also send the BME280 sensor values. I noticed a pattern and believe that interrupts are being treated like sleep intervals so that 2 interrupts (e.g. in quick succession) would result in the BME280 sensor values getting sent.
I guess I better study the code.
-
RE: Sensor reporting after External Interrupt
That's great @electrik. Here is my NodeManager sketch:
/********************************** * MySensors node configuration */ // General settings #define SKETCH_NAME "SensorV1" #define SKETCH_VERSION "1.0" //#define MY_DEBUG // Nodes IDs (if not defined then uses auto node ID assignment from controller) #define NODE_TEST 5 #define MY_NODE_ID NODE_TEST // NRF24 radio settings #define MY_RADIO_NRF24 #define MY_RF24_PA_LEVEL RF24_PA_HIGH // Advanced settings #define MY_BAUD_RATE 57600 #define MY_SPLASH_SCREEN_DISABLED /*********************************** * NodeManager modules for supported sensors */ #define USE_BATTERY #define USE_INTERRUPT #define USE_BME280 /*********************************** * NodeManager built-in features */ // Enable/disable NodeManager's features #define FEATURE_DEBUG ON #define FEATURE_POWER_MANAGER OFF #define FEATURE_INTERRUPTS ON #define FEATURE_CONDITIONAL_REPORT OFF #define FEATURE_EEPROM OFF #define FEATURE_SLEEP ON #define FEATURE_RECEIVE ON #define FEATURE_TIME OFF #define FEATURE_RTC OFF #define FEATURE_SD OFF #define FEATURE_HOOKING OFF /*********************************** * Load NodeManager Library */ #include "NodeManagerLibrary.h" NodeManager node; #define PRODUCTION ON // Application constants const int CONTACT_PIN = 3; const int DEBOUNCE_MS = 500; const float BAT_MIN = 1.8; const float BAT_MAX = 3.2; #if PRODUCTION == ON const int SLEEP_INTERVAL_SEC = 60*60; // 1 hour const int BME280_RPT_INTERVAL = 1 * SLEEP_INTERVAL_SEC; const int BAT_RPT_INTERVAL = 12 * SLEEP_INTERVAL_SEC; #else // testing const int SLEEP_INTERVAL_SEC = 10; const int BME280_RPT_INTERVAL = 1 * SLEEP_INTERVAL_SEC; const int BAT_RPT_INTERVAL = 6 * SLEEP_INTERVAL_SEC; #endif /*********************************** * Add your sensors below */ // built-in sensors SensorBattery battery(node); // Attached sensors SensorDoor door(node,CONTACT_PIN); SensorBME280 bme280(node); /*********************************** * Main Sketch */ // before void before() { // setup the serial port baud rate Serial.begin(MY_BAUD_RATE); /* Configure sensors */ // debounce interrupts node.setInterruptDebounce(DEBOUNCE_MS); node.setIsMetric(false); // report battery level, set min/max voltages for % avail battery.setReportIntervalSeconds(BAT_RPT_INTERVAL); battery.setMinVoltage(BAT_MIN); battery.setMaxVoltage(BAT_MAX); // BME280 reporting bme280.setReportIntervalSeconds(BME280_RPT_INTERVAL); // set the node to sleep node.setSleepSeconds(SLEEP_INTERVAL_SEC); /* End configure sensors */ node.before(); } // presentation void presentation() { // call NodeManager presentation routine node.presentation(); } // setup void setup() { // call NodeManager setup routine node.setup(); } // loop void loop() { // call NodeManager loop routine node.loop(); } #if FEATURE_RECEIVE == ON // receive void receive(const MyMessage &message) { // call NodeManager receive routine node.receive(message); } #endif #if FEATURE_TIME == ON // receiveTime void receiveTime(unsigned long ts) { // call NodeManager receiveTime routine node.receiveTime(ts); } #endif
I would expect the following:
- Reporting of BME sensors once per hour
- Reporting of Battery once every 12 hours
- Reporting of contact closure/opening asynchronously via external interrupt.
What I actually see:
- Every hour I get the battery and the BME sensor readings.
- When a contact closure/opening occurs, I get the BME sensors and the contact change sensor event.
Thanks for your help!
-
RE: Sensor reporting after External Interrupt
I should have stated that I am using NodeManager.
-
Sensor reporting after External Interrupt
It looks like battery readings and all attached sensors readings are sent when an external interrupt occurs (e.g. when the door contact changes). Is it possible to disable them being sent? I only want the door contact event to get reported upon that interrupt.
Thanks!
-
RE: 💬 Printable MySensors Things
This one is also available: https://www.thingiverse.com/thing:3072244
-
RE: 💬 Building a Raspberry Pi Gateway
I have designed a 3D printable enclosure for this and the design/STL files are available here: https://www.thingiverse.com/thing:3072244