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!
  • RFM69 sensitivity vs packet loss

    12
    0 Votes
    12 Posts
    161 Views
    NeverDieN
    @canique said in RFM69 sensitivity vs packet loss: The bold part of your statement is plain wrong. RxReady means that enough preamble (or any other data like noise) has been received to read RSSI and optionally tune AGC/AFC. [This is why -if you set the wrong RSSI Threshold- you permanently get RxReady interrupts.] The preamble is there to help adjust the AGC/AFC. That's the purpose of the preamble. So your preamble must be sent before the RxReady interrupt, not after it like you claim. Of course you can send the preamble after the RxReady interrupt (like you can pour soup over your salad) but then you have a potentially wrong AGC/AFC setting. It's just not meant to be. Yes ,good clarification. I didn't say it right. The desired scenario would be where the preamble signal strength is much higher than the background noise and the RSSI threshold is set high enough that only the preamble triggers the rxReady, not the background noise. By the way, why are there two RSSI sampling phases back-to-back (each of length Trssi)? What role doe the second RSSI sampling serve?
  • sending two messages one after another

    7
    0 Votes
    7 Posts
    1k Views
    A
    Hello all, is this solution added to the standard MySensor library? If so, in which version is it implemented? I want to be sure there are no missing messages when having a list of messages to be sent. many thanks in advance
  • Specific register setting fo NRF24 with PA-LNA

    13
    0 Votes
    13 Posts
    98 Views
    C
    @skywatch May be you right - the distance between node and gateway so small.. But how can i solve the problem of unstable link with node on distance about 5m and more with wall between node and gateway?
  • Senserbender gateway problem dtostrf.h

    sensebender gateway dtostrf.h
    7
    0 Votes
    7 Posts
    64 Views
    G
    @BearWithBeard thank you for the solution. I downgraded Arduino SAMD to 1.8.9. This solved the problem. Many thanks.
  • Starting my PC with a 3.3v arduino pro mini?

    15
    1
    0 Votes
    15 Posts
    131 Views
    K
    So, I finally got this done and it works just like I want it to. I used my initial schematics (plus radio, of course) and this code: /** * 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 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Yveaux * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a Si7021 sensor. * * For more information, please visit: * http://www.mysensors.org/build/humiditySi7021 * */ // Enable debug prints #define MY_DEBUG #define MY_OWN_DEBUG #ifndef MY_OWN_DEBUG //disable serial in production compile, potentially saves few uA in sleep mode #define MY_DISABLED_SERIAL #endif // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_NEW_DRIVER #define MY_NODE_ID 5 #define CHILD_ID_TXT 0 #define OUTPIN 8 #include <MySensors.h> #define SKETCH_NAME "media_pc_switch" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" static bool metric = true; MyMessage msgTxt(CHILD_ID_TXT, V_TEXT); void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); present(CHILD_ID_TXT, S_INFO); } void setup() { pinMode(OUTPIN, OUTPUT); // digitalWrite(OUTPIN, LOW); #ifdef MY_OWN_DEBUG Serial.print("Starting: "); #endif send(msgTxt.set("Ready")); } void receive(const MyMessage &msg) { uint16_t ms; Serial.print("Received a message: "); Serial.println(msg.getString()); send(msgTxt.set(msg.getString())); ms = msg.getUInt(); if (ms > 10000 || ms < 1){return;} send(msgTxt.set("Received")); Serial.println("Pulling pin high"); digitalWrite(OUTPIN, HIGH); Serial.print("Waiting for "); Serial.println(ms); delay(ms); Serial.println("Switching off"); digitalWrite(OUTPIN, LOW); Serial.println("Delaying a few seconds to ignore message resends."); send(msgTxt.set("Sleeping")); delay(10000); send(msgTxt.set("Ready")); } Now I can use this sequence in HA to start my PC even when the power was cut: wzimmer_ms_start_htpc: alias: Use mysensors node 5 to start the mediapc in the living room sequence: repeat: sequence: #don't run if htpc already running - condition: not conditions: - condition: state entity_id: binary_sensor.htpc state: 'on' #send start signal to mysensors - service: notify.mysensors data: target: "media_pc_switch 5 0" message: 1000 #wait for timeout seconds whether a message has been received - wait_for_trigger: - platform: state entity_id: sensor.media_pc_switch_5_0 to: "Received" timeout: '00:00:04' until: # Did it work? - condition: state entity_id: sensor.media_pc_switch_5_0 state: Received Thank you, @cabat for your help and your patience!!! :)
  • Enabling interrupt on the radio for actuators

    6
    0 Votes
    6 Posts
    60 Views
    TheoLT
    Just for the record. Using a lipo charger doesn't work as a ups. So if the battery is below a certain trashhold, and a circuit is connected to it. It will no recharge if the circuit draws over 600 ma (I believe that is for 5v. so I guess it's more for 3.3v). Andreas Spies posted a youtube video on this last Sunday. I'm keeping my eye on his progress. I think he will design a UPS for ESP and Atmel based boards. Also design note: I use a rotary encoder as user input. It just gives a better UX for dimable lights. But - haven't measured - the rotary encoder seems to draw quite a lot of current. I read it could be up to 60ma. I have some of those magnet based encoders laying around. But not sure if I want to use one. They are quite expensive, so I have better projects in mind for those. But they draw just a couple of micro amps. An alternative could be to switch of the encoder circuit with a fet. But I need to experiment some more with this.
  • Handling NACKs

    44
    0 Votes
    44 Posts
    456 Views
    sundberg84S
    @evb - yes, that is correct, here is a complete sketch with a GW (Nrf24 - ethernet) // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_RF24_PA_LEVEL RF24_PA_MAX // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endif // When W5100 is connected we have to move CE/CSN pins for NRF radio #ifndef MY_RF24_CE_PIN #define MY_RF24_CE_PIN 5 #endif #ifndef MY_RF24_CS_PIN #define MY_RF24_CS_PIN 6 #endif #define MY_IP_ADDRESS 192,168,1,8 // If this is disabled, DHCP is used to retrieve address // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x08 //AF-A0-F2-15-3B-1C // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Enable inclusion mode //#define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) //#define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button //#define MY_INCLUSION_MODE_BUTTON_PIN 3 // Uncomment to override default HW configurations #define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin #define MY_DEFAULT_RX_LED_PIN 9 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 8 // the PCB, on board LED #define MY_INDICATION_HANDLER static uint32_t txOK = 0; static uint32_t txERR = 0; #define REPORT_INTERVAL 300000 // Report every 5 minutes #define CHILD_ID_TX_OK 0 #define CHILD_ID_TX_ERR 1 #include <SPI.h> #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensors.h> MyMessage txOKmsg(CHILD_ID_TX_OK, V_CUSTOM); MyMessage txERRmsg(CHILD_ID_TX_ERR, V_CUSTOM); void indication(indication_t ind) { switch (ind) { case INDICATION_TX: txOK++; break; case INDICATION_ERR_TX: txERR++; break; } } void presentation() { //Send the sensor node sketch version information to the gateway sendSketchInfo("Gateway #1", "1.0"); present(CHILD_ID_TX_OK, S_CUSTOM); present(CHILD_ID_TX_ERR, S_CUSTOM); } void setup() { } void loop() { static unsigned long last_send = 0; if (millis() - last_send > REPORT_INTERVAL) { send(txOKmsg.set(txOK)); send(txERRmsg.set(txERR)); last_send = millis(); } } In Home Assistant you need to create a sensor that breaks down the incrementing number to each intervall you want. I use a utility_meter. utility_meter: hourly_ok_gw: source: sensor.gateway_1_0_0 cycle: hourly hourly_err_gw: source: sensor.gateway_1_0_1 cycle: hourly This sensors will be sent to Grafana each hour just like any other sensor and you can create a graph there: [image: 1609751753619-2556f0fa-a34b-49da-bac6-e0a8aadbd633-image.png]
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • 1 Votes
    1 Posts
    38 Views
    No one has replied
  • PlatformIO - Zephyr SSD1306 on nRF52840 dongle & STM411CE Black Pill

    1
    0 Votes
    1 Posts
    25 Views
    No one has replied
  • Improvement Xiaomi smart kettle (I need help!)

    10
    0 Votes
    10 Posts
    4k Views
    M
    @vladimir Hello, are there any kettles to buy, that have on/off function enabled via bluetooth? Xiaomis newer models maybe?
  • listen to 3th party device

    6
    0 Votes
    6 Posts
    91 Views
    YveauxY
    @mfalkvidd probably, but the search range (channel, baudrate) will be large. I would start by just sniffing the spi communication to the nrf24 using a logic analyzer, to get the comms parameters and the data. Then configure another nrf24 to receive this data and work from there.
  • Node to Node communication

    22
    0 Votes
    22 Posts
    222 Views
    A
    @BearWithBeard Thank you! I am really embarrassed with my, let's say, luck of understanding. But you made it clear again. Everything works as required!
  • ECHO problems when sending with no payload

    20
    0 Votes
    20 Posts
    172 Views
    karlheinz2000K
    I've opened an issue for that. https://github.com/mysensors/MySensors/issues/1452 According to API payload is same on ECHO message. I feel this should be handled/fixed in lib, but I have no idea how to do... If it is not possible to fix in lib, it shall not be allowed to send message with no payload anymore, which controller has to make sure then. @rejoe2 Regarding FHEM, at the moment we should keep it as it is. No payload is not the normal use case. I flashed gateway with 2.2.0 and this fixed the problem for me.
  • Message Payload type

    7
    0 Votes
    7 Posts
    46 Views
    R
    @frits Thank you for catching that. I was just reworking and now it's sending proper values. :)
  • How to start build MySensors

    2
    0 Votes
    2 Posts
    59 Views
    N
    Ok, i'm resplying to myself: Just remove library from Arduino library folder. Then clone github repo into it. Library manager will tell you that it is not installed but it should be working fine
  • Functional Guide

    guide
    2
    1 Votes
    2 Posts
    51 Views
    skywatchS
    @APL2017 I agree, a 'current best practice' page with the latest recommendations would save weeks searching the forum looking for the hidden gem.
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • MQTT RETAIN messages work a little strangely

    5
    0 Votes
    5 Posts
    42 Views
    C
    I do not use signed messages, so I used the Signed flag in the MySensors packet header to implement selective MQTT retain state. Gateway is ESP2866 - no specific code. Code send from client: template<typename T> void reportMsg(const uint8_t & id, const mysensors_data_t & tag, const T & val, const bool retain) { MyMessage msg(id, tag); msg.setSigned(retain); send(msg.set(val), true); } Lite patch MyGatewayTransportMQTTClient.cpp: bool gatewayTransportSend(MyMessage &message) { ... bool retain = message.getSigned(); message.setSigned(false); ....
  • difference between encryption with personalization and simple password

    17
    0 Votes
    17 Posts
    105 Views
    SuperNinjaS
    @Anticimex , @Anduril Thanks for this response @evb great job, here is an easy to understand summary for beginners like me. Thanks

18

Online

11.7k

Users

11.2k

Topics

113.0k

Posts