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!
  • One adruino four soil moisture sensors

    8
    0 Votes
    8 Posts
    4k Views
    Tim76T
    @damien Is there an update for this sketch to use in V2?
  • [SOLVED] How to detect power current with Arduino Pro Mini in a doorbell?

    3
    0 Votes
    3 Posts
    1k Views
    ronnyandreR
    Thanks @gohan it works perfectly using a digital pin and the door sensor example.
  • ESP8266 failing with pm open,type:2 0

    8
    0 Votes
    8 Posts
    5k Views
    mppM
    See this remark: @tekka said in MySensors 2.0.0 Released: @mpp said in MySensors 2.0.0 Released: pm open,type:2 0 This is a message emitted by the ESP8266 core, not MySensors related. I suggest you add the following to enable debugging on the serial interface: #define MY_DEBUG Also tripple check your wiring, it seems to make the ESP very unstable if there's a loose/bad connection. TSM:FAIL:CNT could indicate a problem with the radio/transmission.
  • Where does MySensor store in EEPROM

    14
    0 Votes
    14 Posts
    5k Views
    ?
    thank you!
  • New non-blocking temperature sensor code

    13
    4 Votes
    13 Posts
    6k Views
    alowhumA
    I've also created some code for use with the much nicer BME280 sensor. It's on the github, under MySensors examples, as a pull request. Hopefully it will become a part of those examples.
  • Need a bid of help...

    15
    0 Votes
    15 Posts
    3k Views
    alowhumA
    Try this code: https://github.com/flatsiedatsie/MySensorsArduinoExamples/blob/5c84100098352bab6db4b9c86e76db79842131ec/examples/WeatherStationSensor/WeatherStationSensor.ino
  • Byte clock [8] error

    4
    0 Votes
    4 Posts
    811 Views
    AWIA
    @Victor You can't expect the community to run and find possible causes of problems with posting only a reference to a sketch. Please use the guideline on how to ask for help.
  • MyMessage with bool value from relay state to controller (fhem)?

    3
    0 Votes
    3 Posts
    885 Views
    dirkcD
    @gohan I don't know. I also tried V_STATUS, doesn't work either ... edit: V_STATUS works, was a wrong configuration in FHEM
  • MQ Sensor Curve

    2
    0 Votes
    2 Posts
    732 Views
    gohanG
    My guess is that the supplier got the data from manufacturer and made the sample sketch, so hopefully they knew it better
  • Soil Mosisture Sensor: Battery Issue

    6
    0 Votes
    6 Posts
    2k Views
    M
    Does your Arduino board have a power led? Is it on during sleep?
  • RFID Log

    4
    0 Votes
    4 Posts
    1k Views
    dpcrD
    @martins It worked out well, I had to tweak it a bit for my situation, but all is well. Thanks for pointing me in the right direction.
  • Relay not reacting first 3 seconds

    4
    0 Votes
    4 Posts
    1k Views
    rejoe2R
    @derksuh For information which version of the board defs you use (and for up- and downgrading also): Within the Arduino IDE you can just use the boardmanager (Tools menue, as far as I remember) to do this...
  • KEBA sensor

    1
    0 Votes
    1 Posts
    867 Views
    No one has replied
  • MySensors 1.6 availability?

    13
    0 Votes
    13 Posts
    4k Views
    mppM
    This wasn't clear to me either, I was expecting to see setup() & loop(). Perhaps a note or some documentation why this is empty would be useful.
  • DHT11 Arduino pro mini no temp readings

    13
    0 Votes
    13 Posts
    4k Views
    gohanG
    Just use any mqtt client and subscribe to topic # , you will be able to see all messages and pick the one you are looking for
  • Sending Sensor data to Cloud with GSM module

    8
    0 Votes
    8 Posts
    5k Views
    gohanG
    Being gateway you don't need node ID
  • Combining DHT and Binary sensor update issue

    4
    0 Votes
    4 Posts
    1k Views
    rejoe2R
    @Bryden It's not rocket science, just inserting an additional variable and putting the dht measuring part in some if (){}-functionality. You may try... #include <ESP8266WiFi.h> #include <MySensors.h> #include <SPI.h> #include <Bounce2.h> #include <DHT.h> // DHT22 // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 12 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 60000; // Force sending an update of the temperature after n sensor reads, so a controller showing the // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that // the value didn't change since; // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 4 #define CHILD_ID_TEMP 5 float lastTemp; float lastHum; //this is needed to store some time info = last time we got DHT values in millis uint16_t lastDHTTime = 0; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; // Setting multiple child ID's for each switch and it's GPIO pin //Switch 1 #define CHILD_ID_1 1 #define BUTTON_PIN_1 4 // Arduino Digital I/O pin for button/reed switch //Switch 2 #define CHILD_ID_2 2 #define BUTTON_PIN_2 5 // Arduino Digital I/O pin for button/reed switch //Switch 3 #define CHILD_ID_3 3 #define BUTTON_PIN_3 10 // Arduino Digital I/O pin for button/reed switch //Switch 1 Bounce debouncer_1 = Bounce(); int oldValue_1=-1; //Switch 2 Bounce debouncer_2 = Bounce(); int oldValue_2=-1; //Switch 3 Bounce debouncer_3 = Bounce(); int oldValue_3=-1; // Setting mysensor message string (ChildID, V type) MyMessage msg1(CHILD_ID_1,V_TRIPPED); MyMessage msg2(CHILD_ID_2,V_TRIPPED); MyMessage msg3(CHILD_ID_3,V_TRIPPED); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; //Presenting each child ID void presentation() { // Register binary input sensor to gw (they will be created as child devices) //Switch present(CHILD_ID_1, S_DOOR); present(CHILD_ID_2, S_DOOR); present(CHILD_ID_3, S_DOOR); //DHT present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); metric = getControllerConfig().isMetric; } //Setting up each GPIO pin as an input and turning on internal pull up resistor void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); // Setup button 1 pinMode(BUTTON_PIN_1,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN_1,HIGH); // After setting up the button, setup debouncer debouncer_1.attach(BUTTON_PIN_1); debouncer_1.interval(5); // Setup button 2 pinMode(BUTTON_PIN_2,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN_2,HIGH); // After setting up the button, setup debouncer debouncer_2.attach(BUTTON_PIN_2); debouncer_2.interval(5); // Setup button 3 pinMode(BUTTON_PIN_3,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN_3,HIGH); // After setting up the button, setup debouncer debouncer_3.attach(BUTTON_PIN_3); debouncer_3.interval(5); } void loop() { //DHT // Force reading sensor, so it works also after sleep() if (millis() - lastDHTTime > UPDATE_INTERVAL) { lastDHTTime=millis(); dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } } // Switch 1 debouncer_1.update(); // Get the update value int value_1 = debouncer_1.read(); if (value_1 != oldValue_1) { // Send in the new value send(msg1.set(value_1==HIGH ? 1 : 0)); oldValue_1 = value_1; } // Switch 2 debouncer_2.update(); // Get the update value int value_2 = debouncer_2.read(); if (value_2 != oldValue_2) { // Send in the new value send(msg2.set(value_2==HIGH ? 1 : 0)); oldValue_2 = value_2; } // Switch 3 debouncer_3.update(); // Get the update value int value_3 = debouncer_3.read(); if (value_3 != oldValue_3) { // Send in the new value send(msg3.set(value_3==HIGH ? 1 : 0)); oldValue_3 = value_3; } // Sleep for a while to save energy //wait(UPDATE_INTERVAL); //replaced by if (millis() ...) }
  • MQ DHT and Relai receive not working

    4
    0 Votes
    4 Posts
    1k Views
    ?
    i have found the post. But i don't now how i implement it... i'm just a beginner and make copy and paste :blush: if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) { myservo.detach(); attachedServo = false; }`````` can you help me?
  • Mega 2560 RGBW PWM problem

    4
    0 Votes
    4 Posts
    1k Views
    gundark2G
    Thanks for the response, I forgot to mention that was one of the things i tried. Still only strait on or off. void loop { analogWrite(8, 0); delay(3000); analogWrite(8, 127); delay(3000); analogWrite(8, 255); delay(3000); } This code gives me approx 6 seconds of OFF and 3 of ON. I have to think something is wrong with the TIMERS, though at least some of them have to be working because the radio works just fine, openhab and all its functions work.... unless I misunderstand I thought the radio uses PWM for some of the pins.
  • Binary switch not working

    4
    0 Votes
    4 Posts
    1k Views
    AWIA
    enable debug and put some print() statements in to see what happens.

13

Online

11.7k

Users

11.2k

Topics

113.1k

Posts