Skip to content

Development

Discuss Arduino programming, library tips, share example sketches and post your general programming questions.
1.5k Topics 13.5k Posts

Subcategories


  • 56 578
    56 Topics
    578 Posts
    HJ_SKH
    Hi2All! Surprising is here. After about 24hours I refresh HA and suddenly my motion sensor was integrated. There is also second entity > battery : 0 , have to look deeper into that for understanding. Need to change little in the sketch, because don't want every short time 'no movement' so only when there is motion and maybe once a hour indication sensor is alive. Meantime I found 3 other good threats: https://forum.mysensors.org/topic/11200/finally-progress-evidence-based-radio-testing-method-and-capacitors https://forum.mysensors.org/topic/1664/which-are-the-best-nrf24l01-modules/27 https://forum.mysensors.org/topic/9550/build-a-reliable-power-supply-chain Very usefull for me also finally progress because of lacking time in the past. Great jobs are done here! Thanks for this all of you guys or girls!
  • [SOLVED] ESP8266 MySensors 2.2.0 problem with static ip configuration

    1
    1 Votes
    1 Posts
    1k Views
    No one has replied
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • Safe heating with MySensors - how I use it as a smart thermostat

    1
    2 Votes
    1 Posts
    2k Views
    No one has replied
  • IR Send

    esp32 rmt
    3
    0 Votes
    3 Posts
    833 Views
    H
    Simple, Send not supported on the ESP32 See link text Supported Boards ESP32 (receive only)
  • How to change NRF52832's pins P0.00 and P0.01 destinations?

    1
    0 Votes
    1 Posts
    517 Views
    No one has replied
  • Complete shutdown of MySensors in code possible ?

    6
    0 Votes
    6 Posts
    1k Views
    D
    @GertSanders I can't know where you stand pricepoint wise, but this sounds like a 2 MCU project. One to handle the clock functions, and one to communicate with MySensors. Messages between the 2 MCU's over I2C. If the link is down, that will only clog the comms MCU.
  • Request Value from Node

    15
    0 Votes
    15 Posts
    2k Views
    rozpruwaczR
    I didn't see that before, thanks :)
  • Delay/Sleep RPi Gateway With Sensors

    3
    0 Votes
    3 Posts
    579 Views
    G
    @mfalkvidd Thanks for the assistance!
  • OLED not wroking for me

    9
    0 Votes
    9 Posts
    1k Views
    Kai BepperlingK
    Nothing more to say. Sometimes it can be that simple :sweat_smile:
  • WeMos D1 mini and NRF24

    7
    0 Votes
    7 Posts
    3k Views
    K
    @qobouky Use something like ESPeasy for connection your ESP2866 into controller.
  • MySensor nodes powering on with Dusk / Dawn Garden lights issue

    4
    0 Votes
    4 Posts
    758 Views
    Nca78N
    @richard-van-der-plas yes. Instead of making a different script for each sensor to change the delay, you can either use a random value or make node id * xxx ms and a fixed value if node id is not yet set.
  • transportPowerDown() with v2.2.0

    6
    0 Votes
    6 Posts
    1k Views
    D
    @d-smes said in transportPowerDown() with v2.2.0: transportPowerDown() Thanks guys; that worked! And if anyone else is interested, the radio automatically re-enables when you send a message. @gohan - I monitor several temperatures, water levels, and flow rates associated with a duck pond and filtration system. Things can get out of whack fairly quickly due to pump inlet blockages, full filters, equipment failures, and weather induced surprises. Need quick updates so if there's a problem, I can intervene before a pump runs dry or I lose too much water.
  • Fallback gateway node

    13
    0 Votes
    13 Posts
    2k Views
    gohanG
    Well... Usually gw should be stable on its own. Building a redundant system because of the "unstable" power source, to me is just a much more complicated patch than simply solving the root cause.
  • 1 Votes
    22 Posts
    2k Views
    gohanG
    If you configure the controller to send notifications when nodes don't report anything after 1 or 2 hours, you know that something is wrong without draining the battery in the process.
  • Using state machines for MySensors sketch

    6
    3 Votes
    6 Posts
    1k Views
    bjacobseB
    Maybe off-topic, but those that don't know about Finite State Machines could have a look at these links for a start... https://en.wikipedia.org/wiki/Event-driven_finite-state_machine https://gamedevelopment.tutsplus.com/tutorials/finite-state-machines-theory-and-implementation--gamedev-11867
  • 0 Votes
    2 Posts
    636 Views
    GertSandersG
    @gertsanders [SOLVED]: a wrong type in a declaration gave constant '0' values. Now corrected and distances is now measured correctly.
  • Relay output activates when power off/on

    8
    0 Votes
    8 Posts
    1k Views
    JoupilJ
    Hi, I solved this issue by simply commenting //setStatus(OFF); in NodeManagerLibrary.ino Thanks for all Joupil
  • Led dimmer with touch sensor

    14
    0 Votes
    14 Posts
    6k Views
    D
    File 'LightDimmer.ino' /****************************************************************************** * * * Copyright © 2018 -- DoccY's productions * * * * Auteurs/Authors: DoccY <doccy@mancheron.fr> * * * * ------------------------------------------------------------------------- * * * * Ce logiciel permet de monitorer un variateur de lumière (typiquement un * * ruban de LED) à partir d'un (ou plusieurs) capteurs sensitifs. * * * * Ce logiciel est régi par la licence CeCILL soumise au droit français et * * respectant les principes de diffusion des logiciels libres. Vous pouvez * * utiliser, modifier et/ou redistribuer ce programme sous les conditions de * * la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur * * le site "http://www.cecill.info". * * * * En contrepartie de l'accessibilité au code source et des droits de copie, * * de modification et de redistribution accordés par cette licence, il n'est * * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, * * seule une responsabilité restreinte pèse sur l'auteur du programme, le * * titulaire des droits patrimoniaux et les concédants successifs. * * * * À cet égard l'attention de l'utilisateur est attirée sur les risques * * associés au chargement, à l'utilisation, à la modification et/ou au * * développement et à la reproduction du logiciel par l'utilisateur étant * * donné sa spécificité de logiciel libre, qui peut le rendre complexe à * * manipuler et qui le réserve donc à des développeurs et des professionnels * * avertis possédant des connaissances informatiques approfondies. Les * * utilisateurs sont donc invités à charger et tester l'adéquation du * * logiciel à leurs besoins dans des conditions permettant d'assurer la * * sécurité de leurs systèmes et ou de leurs données et, plus généralement, * * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. * * * * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez * * pris connaissance de la licence CeCILL, et que vous en avez accepté les * * termes. * * * * ------------------------------------------------------------------------- * * * * This software allows to drive a light dimmer (typically a led strip) from * * one or more touch sensors. * * * * This software is governed by the CeCILL license under French law and * * abiding by the rules of distribution of free software. You can use, * * modify and/ or redistribute the software under the terms of the CeCILL * * license as circulated by CEA, CNRS and INRIA at the following URL * * "http://www.cecill.info". * * * * As a counterpart to the access to the source code and rights to copy, * * modify and redistribute granted by the license, users are provided only * * with a limited warranty and the software's author, the holder of the * * economic rights, and the successive licensors have only limited * * liability. * * * * In this respect, the user's attention is drawn to the risks associated * * with loading, using, modifying and/or developing or reproducing the * * software by the user in light of its specific status of free software, * * that may mean that it is complicated to manipulate, and that also * * therefore means that it is reserved for developers and experienced * * professionals having in-depth computer knowledge. Users are therefore * * encouraged to load and test the software's suitability as regards their * * requirements in conditions enabling the security of their systems and/or * * data to be ensured and, more generally, to use and operate it in the same * * conditions as regards security. * * * * The fact that you are presently reading this means that you have had * * knowledge of the CeCILL license and that you accept its terms. * * * ******************************************************************************/ /* * The driver functionnalities is merely inspired by the code given at: * https://forum.mysensors.org/topic/2510/led-dimmer-with-touch-sensor/3 * * Default MOSFET pin is 3 */ // Constants #define TITLE "Light Dimmer Driver for touch sensors" #define VERSION "1.0" // Libraries #include <Bounce2.h> #include "dimmer.h" #include "dimmerDriver.h" #include "extendedCapacitiveSensor.h" // Pins #define LED_PIN 3 // Pin attached to N-MOSFET Gate pin #define CS_PIN 4 // Auto alimented capacitive touch sensor pin #define CS_SEND_PIN 7 // Send pin for the extendedCapacitiveSensor #define CS_RECV_PIN 8 // Receive pin for the extendedCapacitiveSensor Bounce debouncer = Bounce(); #define EEPROM_DIM_LEVEL_SAVE 1 // set to -1 to disable EEPROM saving light level state #define EEPROM_DIM_STATE_SAVE 2 // set to -1 to disable EEPROM saving switch state Dimmer dimmer(LED_PIN, DimmerDriver::SHORT_FADE_DELAY, delay, EEPROM_DIM_LEVEL_SAVE, EEPROM_DIM_STATE_SAVE); // All but the led pin argument have default values (see dimmer.h). // 'Dimmer dimmer(LED_PIN)' is equivalent to // 'Dimmer dimmer(LED_PIN, 10ul,delay, -1, -1)' #define CS_SHORT_TOUCH_MAX_TIME 250ul #define CS_COUNTING_TIME_WINDOW 350ul DimmerDriver driver(dimmer, CS_SHORT_TOUCH_MAX_TIME, CS_COUNTING_TIME_WINDOW); // All but the dimmer argument have default values (see // dimmerDriver.h). // 'DimmerDriver driver(dimmer)' is equivalent to // 'DimmerDriver driver(dimmer, 250ul, 250ul)' #define CS_SAMPLE_SIZE 10 #define CS_RESOLUTION 20 ExtendedCapacitiveSensor cs(CS_SEND_PIN, CS_RECV_PIN, CS_SAMPLE_SIZE, CS_RESOLUTION); // All but the send and receive pins have default values (see // extendedCapacitiveSensor.h). // 'ExtendedCapacitiveSensor cs(x, y)' is equivalent to // 'ExtendedCapacitiveSensor cs(x, y, 3, 30); /* * Microcontroler initialization */ void setup() { Serial.begin(115200); while (!Serial) { delay(10); } Serial.print(TITLE); Serial.print(" (version "); Serial.print(VERSION); Serial.println(")"); Serial.println("========================"); Serial.println("Starting the Sensor Node"); // Instantiate digital pins pinMode(LED_PIN, OUTPUT); pinMode(CS_PIN, INPUT_PULLUP); cs.calibrate(100); // Restore both the switch state and the light level dimmer.load(); // Switch the leds off Serial.println("Switch the leds off"); analogWrite(LED_PIN, 0); dimmer.update(); Serial.println("Sensor Node is ready..."); Serial.println("======================="); } /* * Microcontroler loop */ void loop() { // Check if someone touch the Velleman capacitive sensor // or the home made capacitive sensor bool state = (digitalRead(CS_PIN) == HIGH) || cs.next(); if (state) { driver.activate(); } else { driver.deactivate(); } // Update the Light Level dimmer.update(); } // Local Variables: // mode:c++ // End: File 'MySensorsLightDimmer.ino' /* The MySensors Arduino library handles the wireless radio link and protocol between your home built sensors/actuators and HA controller of choice. The sensors forms a self healing radio network with optional repeaters. Each repeater and gateway builds a routing tables in EEPROM which keeps track of the network topology allowing messages to be routed to nodes. Created by Henrik Ekblad <henrik.ekblad@mysensors.org> Copyright (C) 2013-2015 Sensnology AB Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors Documentation: http://www.mysensors.org Support Forum: http://forum.mysensors.org */ /****************************************************************************** * * * Copyright © 2018 -- DoccY's productions * * * * Auteurs/Authors: DoccY <doccy@mancheron.fr> * * * * ------------------------------------------------------------------------- * * * * Ce logiciel permet de monitorer un variateur de lumière (typiquement un * * ruban de LED) à partir d'un (ou plusieurs) capteurs sensitifs comme d'un * * serveur MySensors. * * * * Ce logiciel est régi par la licence CeCILL soumise au droit français et * * respectant les principes de diffusion des logiciels libres. Vous pouvez * * utiliser, modifier et/ou redistribuer ce programme sous les conditions de * * la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur * * le site "http://www.cecill.info". * * * * En contrepartie de l'accessibilité au code source et des droits de copie, * * de modification et de redistribution accordés par cette licence, il n'est * * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, * * seule une responsabilité restreinte pèse sur l'auteur du programme, le * * titulaire des droits patrimoniaux et les concédants successifs. * * * * À cet égard l'attention de l'utilisateur est attirée sur les risques * * associés au chargement, à l'utilisation, à la modification et/ou au * * développement et à la reproduction du logiciel par l'utilisateur étant * * donné sa spécificité de logiciel libre, qui peut le rendre complexe à * * manipuler et qui le réserve donc à des développeurs et des professionnels * * avertis possédant des connaissances informatiques approfondies. Les * * utilisateurs sont donc invités à charger et tester l'adéquation du * * logiciel à leurs besoins dans des conditions permettant d'assurer la * * sécurité de leurs systèmes et ou de leurs données et, plus généralement, * * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. * * * * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez * * pris connaissance de la licence CeCILL, et que vous en avez accepté les * * termes. * * * * ------------------------------------------------------------------------- * * * * This software allows to drive a light dimmer (typically a led strip) from * * one or more touch sensors as well as from a MySensors server. * * * * This software is governed by the CeCILL license under French law and * * abiding by the rules of distribution of free software. You can use, * * modify and/ or redistribute the software under the terms of the CeCILL * * license as circulated by CEA, CNRS and INRIA at the following URL * * "http://www.cecill.info". * * * * As a counterpart to the access to the source code and rights to copy, * * modify and redistribute granted by the license, users are provided only * * with a limited warranty and the software's author, the holder of the * * economic rights, and the successive licensors have only limited * * liability. * * * * In this respect, the user's attention is drawn to the risks associated * * with loading, using, modifying and/or developing or reproducing the * * software by the user in light of its specific status of free software, * * that may mean that it is complicated to manipulate, and that also * * therefore means that it is reserved for developers and experienced * * professionals having in-depth computer knowledge. Users are therefore * * encouraged to load and test the software's suitability as regards their * * requirements in conditions enabling the security of their systems and/or * * data to be ensured and, more generally, to use and operate it in the same * * conditions as regards security. * * * * The fact that you are presently reading this means that you have had * * knowledge of the CeCILL license and that you accept its terms. * * * ******************************************************************************/ /* * The driver functionnalities is merely inspired by the code given at: * https://forum.mysensors.org/topic/2510/led-dimmer-with-touch-sensor/3 * * Default MOSFET pin is 3 * * REVISION HISTORY * Version 1.0 - Developed by Bruce Lacey and GizMoCuz (Domoticz) * Version 1.1 - Modified by hek to incorporate a rotary encode to adjust * light level locally at node * Version 1.2 - Modified FreakOfNature to replace rotary encode with touch dim * Version 1.3 - Complete rewrite and update to MySensors v.2 */ // Constants #define TITLE "MySensors Light Dimmer /w touch sensors" #define VERSION "1.3" // Enable debug prints to serial monitor //#define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 // Libraries #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> #include "dimmer.h" #include "dimmerDriver.h" #include "extendedCapacitiveSensor.h" // Pins #define LED_PIN 3 // Pin attached to N-MOSFET Gate pin #define CS_PIN 4 // Auto alimented capacitive touch sensor pin #define CS_SEND_PIN 7 // Send pin for the extendedCapacitiveSensor #define CS_RECV_PIN 8 // Receive pin for the extendedCapacitiveSensor Bounce debouncer = Bounce(); #define EEPROM_DIM_LEVEL_SAVE 1 // set to -1 to disable EEPROM saving light level state #define EEPROM_DIM_STATE_SAVE 2 // set to -1 to disable EEPROM saving switch state Dimmer dimmer(LED_PIN, DimmerDriver::SHORT_FADE_DELAY, delay, EEPROM_DIM_LEVEL_SAVE, EEPROM_DIM_STATE_SAVE); // All but the led pin argument have default values (see dimmer.h). // 'Dimmer dimmer(LED_PIN)' is equivalent to // 'Dimmer dimmer(LED_PIN, 10ul,delay, -1, -1)' #define CS_SHORT_TOUCH_MAX_TIME 250ul #define CS_COUNTING_TIME_WINDOW 350ul DimmerDriver driver(dimmer, CS_SHORT_TOUCH_MAX_TIME, CS_COUNTING_TIME_WINDOW); // All but the dimmer argument have default values (see // dimmerDriver.h). // 'DimmerDriver driver(dimmer)' is equivalent to // 'DimmerDriver driver(dimmer, 250ul, 250ul)' #define CS_SAMPLE_SIZE 10 #define CS_RESOLUTION 20 ExtendedCapacitiveSensor cs(CS_SEND_PIN, CS_RECV_PIN, CS_SAMPLE_SIZE, CS_RESOLUTION); // All but the send and receive pins have default values (see // extendedCapacitiveSensor.h). // 'ExtendedCapacitiveSensor cs(x, y)' is equivalent to // 'ExtendedCapacitiveSensor cs(x, y, 3, 30); #define CHILD_ID_LIGHT 1 MyMessage switchStateMsg(CHILD_ID_LIGHT, V_STATUS); MyMessage lightLevelMsg(CHILD_ID_LIGHT, V_PERCENTAGE); /* * MySensors Initialization */ void presentation() { // Send the Sketch Version Information to the Gateway #ifdef MY_DEBUG Serial.print("Presenting the sensor to MySensors gateway: "); Serial.print(SN); Serial.print(" version "); Serial.println(SV); #endif present(CHILD_ID_LIGHT, S_DIMMER); sendSketchInfo(TITLE, VERSION); } /* * MySensors node receive operation */ void receive(const MyMessage &message) { if (message.type == V_STATUS) { // Incoming on/off command sent from controller ("1" or "0") if (message.getBool()) { dimmer.ON(); } else { dimmer.OFF(); } } else { if (message.type == V_DIMMER) { // Incoming dim-level command sent from controller (or ack message) dimmer.setFadingDelay(DimmerDriver::SHORT_FADE_DELAY); dimmer = message.getUInt(); } } } /* * Send light level and switch state to MySensors server */ void sendDimmerInfos() { switchStateMsg.set((bool) dimmer); send(switchStateMsg); lightLevelMsg.set(dimmer.getLevel(Dimmer::CURRENT)); send(lightLevelMsg); } /* * Microcontroler initialization */ void setup() { Serial.begin(115200); while (!Serial) { delay(10); } Serial.print(TITLE); Serial.print(" (version "); Serial.print(VERSION); Serial.println(")"); Serial.println("==========================="); Serial.println("Starting the MySensors Node"); // Instantiate digital pins pinMode(LED_PIN, OUTPUT); pinMode(CS_PIN, INPUT_PULLUP); cs.calibrate(100); // Restore both the switch state and the light level dimmer.load(); // Switch the leds off Serial.println("Switch the leds off"); analogWrite(LED_PIN, 0); dimmer.update(); // Send informations to MySensors sendDimmerInfos(); Serial.println("MySensors Node is ready..."); Serial.println("=========================="); } /* * Microcontroler loop */ void loop() { // Check if someone touch the Velleman capacitive sensor // or the home made capacitive sensor bool state = (digitalRead(CS_PIN) == HIGH) || cs.next(); if (state) { driver.activate(); } else { driver.deactivate(); } // Update the Light Level dimmer.update(); // Send informations to MySensors sendDimmerInfos(); } // Local Variables: // mode:c++ // End:
  • [help wanted] Encryption for RFM95

    1
    2 Votes
    1 Posts
    868 Views
    No one has replied
  • The dust sensor is now finally working

    14
    1 Votes
    14 Posts
    6k Views
    alexsh1A
    @NeverDie Please see this thread re pollen count: https://forum.mysensors.org/topic/3603/pollen-sensor-for-hay-fever-alert/6 I did not realise, but it has been two years now since I looked into this....

8

Online

11.7k

Users

11.2k

Topics

113.0k

Posts