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!
  • help to pass version 2 mysensors

    4
    0 Votes
    4 Posts
    830 Views
    zrom69Z
    @gohan you can check i add module rain // Example sketch för a "light switch" where you can control light or something // else from both vera and a local physical button (connected between digital // pin 3 and GND). // This node also works as a repeader for other nodes // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 2 #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC #include <MySensors.h> #include <SPI.h> #include <DHT.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) //pin sensori #define PIR_PIN 6 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define HUMIDITY_TEMPERATURE_PIN 3 // sensore temperatura umidita #define RELAY_PIN 4 // relay pin #define DIGITAL_INPUT_RAIN_SENSOR 5 int BATTERY_SENSE_PIN = A1; // Pin carica batteria o pannello solare int FOTORESIST_SENSE_PIN = A2; // Pin fotoresistenza //interupt per sleep arduino #define INTERRUPT PIR_PIN-6 // Usually the interrupt = pin -2 (on uno/nano anyway) #define INTERRUPT DIGITAL_INPUT_RAIN_SENSOR-2 //id per vera #define CHILD_ID_RELE 1 // Id relay #define CHILD_ID_HUM 2 // id temperatura #define CHILD_ID_TEMP 3 // id umidita #define CHILD_ID_PIR 4 // Id pir #define CHILD_ID_LIGHT 5 // Id luminosita (fotoresistenza) #define CHILD_ID_RAIN 6 //definizione per nodo vera #define NODE_ID 10 #define SN "meteo station" #define SV "1.4" //variabili bool state_relay; //stato relay float batt_valore; //dichiaro la variabile valore che memorizzerà il valore della batteria dal pin analogico float batt_volt; //volt batteria float batt_charged_percent; //percentuale carica batteria float last_batt_charged_percent; //percentuale carica batteria precedente float batt_min_voltage = 0.5; //tensione minima batteria float batt_max_voltage = 5; //tensione massima batteria float fotoresistenza_valore; //dichiaro la variabile valore che memorizzerà il valore della fotoresistenza dal pin analogico float last_fotoresistenza_valore; //dichiaro la variabile valore precedente int lastRainValue = -1; int nRainVal; boolean bIsRaining = false; String strRaining = "NO"; int lux_vera; //valore luminosita da inviare a vera // sensore temperatura umidita DHT dht_int; float lastTemp_int = -1; float lastHum_int = -1; boolean metric = true; MyMessage msgRelay(CHILD_ID_RELE,V_LIGHT); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL); MyMessage msgRain(CHILD_ID_RAIN, V_TRIPPED); void setup() { metric = getControllerConfig().isMetric; // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); pinMode(DIGITAL_INPUT_RAIN_SENSOR, INPUT); //PIR pinMode(PIR_PIN, INPUT); state_relay = 0; //GestisciRelay(); digitalWrite(RELAY_PIN, LOW); send(msgRelay.set(state_relay)); } void presentation() { sendSketchInfo(SN, SV); //Sensore umidita temperatura dht_int.setup(HUMIDITY_TEMPERATURE_PIN); present(CHILD_ID_RELE, S_LIGHT); //light vera present(CHILD_ID_HUM, S_HUM); //umidity vera present(CHILD_ID_TEMP, S_TEMP); // temp vera present(CHILD_ID_PIR, S_MOTION); // motion vera present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); //light level (fotoresistenza) present(CHILD_ID_RAIN, S_MOTION, "WS Rain"); } void loop() { //sensore temperatura umidita delay(dht_int.getMinimumSamplingPeriod()); float temperature_int = dht_int.getTemperature(); if (isnan(temperature_int)) { lastTemp_int = -1; Serial.println("Failed reading temperature from DHT"); } else if (temperature_int != lastTemp_int) { lastTemp_int = temperature_int; if (!metric) { temperature_int = dht_int.toFahrenheit(temperature_int); } send(msgTemp.set(temperature_int, 1)); Serial.print("T int: "); Serial.println(temperature_int); } float humidity_int = dht_int.getHumidity(); if (isnan(humidity_int)) { lastHum_int = -1; Serial.println("Failed reading humidity from DHT"); } else if (humidity_int != lastHum_int) { lastHum_int = humidity_int; send(msgHum.set(humidity_int, 1)); Serial.print("H int: "); Serial.println(humidity_int); } //sensore temperatura umidita //fotoresistenza for(int i=0;i<150;i++) { fotoresistenza_valore += analogRead(FOTORESIST_SENSE_PIN); //read the input voltage from battery or solar panel delay(2); } fotoresistenza_valore = fotoresistenza_valore / 150; Serial.print ("fotoresistenza: "); Serial.println(fotoresistenza_valore); if (fotoresistenza_valore != last_fotoresistenza_valore) { lux_vera = (int) fotoresistenza_valore; send(msgLux.set(lux_vera)); last_fotoresistenza_valore = fotoresistenza_valore; } //fotoresistenza //pir relay // Read digital motion value boolean tripped = digitalRead(PIR_PIN) == HIGH; Serial.println("pir:"); Serial.println(tripped); send(msgPir.set(tripped?"1":"0")); // Send tripped value to gw //accende la luce con il buio if (fotoresistenza_valore < 200) //poca luce { if (tripped == 1) { state_relay = 1; } else { state_relay = 0; } } //accende la luce con il buio GestisciRelay(); //pir relay //battery for(int i=0;i<150;i++) { batt_valore += analogRead(BATTERY_SENSE_PIN); //read the input voltage from battery or solar panel delay(2); } batt_valore = batt_valore / 150; Serial.print ("batt_valore: "); Serial.println(batt_valore); batt_volt = (batt_valore / 1024) * batt_max_voltage; Serial.print ("batt_volt: "); Serial.println(batt_volt); //////////////////////////////////////////////// //The map() function uses integer math so will not generate fractions // so I multiply battery voltage with 10 to convert float into a intiger value // when battery voltage is 6.0volt it is totally discharged ( 6*10 =60) // when battery voltage is 7.2volt it is fully charged (7.2*10=72) // 6.0v =0% and 7.2v =100% //batt_charged_percent = batt_volt*10; //batt_charged_percent = map(batt_volt*10, 60 , 72, 0, 100); batt_charged_percent = batt_volt * 10; batt_charged_percent = map(batt_volt * 10, batt_min_voltage * 10 , batt_max_voltage * 10, 0, 100); //batt_charged_percent = (batt_volt / batt_max_voltage) * 100; Serial.print ("batt_charged_percent: "); Serial.println(batt_charged_percent); if (last_batt_charged_percent != batt_charged_percent) { sendBatteryLevel(batt_charged_percent); last_batt_charged_percent = batt_charged_percent; } bIsRaining = !(digitalRead(DIGITAL_INPUT_RAIN_SENSOR)); if(bIsRaining){ strRaining = "YES"; } else{ strRaining = "NO"; } //Serial.print("Raining?: "); //Serial.print(strRaining); //Serial.print("\t Moisture Level: "); //Serial.println(nRainVal); //http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-rain-sensor-module-guide-and-tutorial/ send(msgRain.set(bIsRaining, 1)); //battery delay(50); // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(INTERRUPT, CHANGE, SLEEP_TIME); } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_LIGHT) { // Change relay state_relay state_relay = message.getBool(); GestisciRelay(); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } void GestisciRelay() { //Serial.print(" GestisciRelay state_relay:"); //Serial.println(state_relay); if (state_relay == 0) { digitalWrite(RELAY_PIN, LOW); send(msgRelay.set(state_relay)); //Serial.println("SPENTO RELAY"); } else { digitalWrite(RELAY_PIN, HIGH); send(msgRelay.set(state_relay)); //Serial.println("ACCESO RELAY"); } }
  • heartbeat? monitor?

    raspberry gateway monitoring
    3
    0 Votes
    3 Posts
    1k Views
    CrankyCoderC
    any idea how often heartbeat messages would be sent?
  • Repeater Node and DHT11

    7
    0 Votes
    7 Posts
    1k Views
    W
    I'm not sure whats happened... But i think its working now. I try to investigate why it works now! If i find the reason i will post here. Thanks for help.
  • HM-10 BLE node SoftSerial issues

    1
    0 Votes
    1 Posts
    578 Views
    No one has replied
  • How to tell if mysensors library starts up successfully?

    7
    0 Votes
    7 Posts
    2k Views
    Lars DeutschL
    @boots33 said in How to tell if mysensors library starts up successfully?: #define MY_TRANSPORT_WAIT_READY_MS 3000 Hi, thank you very much ! I am using the latest 2.2.rc2 version. Will give the preprocessor statement above a try ... thank you very much, Lars
  • Multiple motion/door sketch

    2
    2 Votes
    2 Posts
    2k Views
    rejoe2R
    @bluezr1 Good progress! In case you are interested in how to shorten this kind of code and be more flexible in assigning PINs, you may have a look at this post here: https://forum.mysensors.org/topic/4847/multi-button-relay-sketch/33# by @korttoma Just delete the relay part...
  • Adaptive sleep time

    7
    0 Votes
    7 Posts
    2k Views
    mfalkviddM
    @gohan so it's actually you who needs a set sleep time based on energy levels? ;-)
  • gateway serial and dimmer example

    23
    0 Votes
    23 Posts
    4k Views
    M
    (if some one can explain how Insert Code Here works, that could be fine too... no laughs please!
  • Support for SI4432 chips

    2
    0 Votes
    2 Posts
    805 Views
    tbowmoT
    @pmat There is no driver for the radio, so someone needs to write that. Currently it is not on the roadmap to support other radio chipsets than Nordic and Hope RF. But if you see a need for it, then we are willing to look at PR's that include new radios. :)
  • I_LOG_MESSAGE & OTALogPrint()

    1
    0 Votes
    1 Posts
    506 Views
    No one has replied
  • Ethernet Gateway debug to LCD

    10
    0 Votes
    10 Posts
    3k Views
    W
    @dbemowsk Nah it's better, I run around with a Surface tablet and look like I'm on %random_forensic_crime_drama% How much more Hollywood can one get? I did split the serial and send it both to the NodeMCU and the TFT screen, but the TFT kept missing lines as it couldn't keep up (rather the Arduino Pro Mini couldn't keep up) so while it'd look nice, was useless for debugging purposes.
  • Gateway echoing to specific node

    2
    0 Votes
    2 Posts
    594 Views
    mfalkviddM
    @boozz node-red can forward the serial data to any number of places. Domoticz, log file on the rpi, tcp and more. See https://forum.mysensors.org/post/79671 for some nodered references.
  • LogOTANode & LogOTAGateway

    1
    0 Votes
    1 Posts
    583 Views
    No one has replied
  • Setting up my Arduinos & Raspberry

    4
    1
    0 Votes
    4 Posts
    968 Views
    gohanG
    The data are printed on the serial port as you should have noticed with the mysensors protocol. You can run multiple controllers but I don't think you can use serial gateway, you need an ethernet gateway. You can wire the radio directly on the rpi and compile the ethernet gateway (just follow the guide). Given you are new I'd start from an easier controller than Openhab
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Debug to a sd-card module?

    Locked
    28
    0 Votes
    28 Posts
    7k Views
    sundberg84S
    Please use this thread for further discussion: https://forum.mysensors.org/topic/8040/the-logger-machine-short-and-long-term-serial-logging
  • Cant get the data in serial monitor in serial gateway from a sensor node

    6
    0 Votes
    6 Posts
    987 Views
    rejoe2R
    @sachin-rana said in Cant get the data in serial monitor in serial gateway from a sensor node: @rejoe2 ok i will use raspberry pi but i want to send data on the cloud server ,via http post request plz help me i want to send node sensor data to cloud firebase Sorry, but I'm complete noob in http protocols - this is why I like MySensors and serial GW's. Additionally I also dislike the idea to have personal data made available outside my own network sphere, so I don't have any experience here either. You may use MQTT (LAN or WIFI-GW) as a protocoll to get things "in the cloud" or the means provided by your controller.
  • Can a Node subscribe to messages from another node?

    4
    0 Votes
    4 Posts
    881 Views
    rejoe2R
    @pcs @rejoe2 said in Can a Node subscribe to messages from another node?: Sending data directly to other nodes is also possible, please look for node to node communication, then you will find some few examples to follow. It's not subscribing but active sending from node to node: send(msgXXX.setDestination(target node)...)
  • How can I include MyMessage object in my own class?

    5
    0 Votes
    5 Posts
    2k Views
    G
    You are great guys! It compile already, later I will also check the functionality ;-)
  • Presentation (S_*) and set, req (V_*) limitations

    3
    0 Votes
    3 Posts
    1k Views
    Meshx86M
    yea i ended up using V_VAR1 - V_VAR5, V_CUSTOM, V_TEXT and presenting both S_INFO and S_CUSTOM. i am currently reading it through Wemos D1 Mini + MAX RS485 converter (working without logic converter just fine).

19

Online

11.8k

Users

11.2k

Topics

113.2k

Posts