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!
  • Change the password after the Pi Gateway is already compiled?

    4
    0 Votes
    4 Posts
    673 Views
    gohanG
    You could distribute not compiled and use a script that changes the password and then compiles the gateway
  • Make node look for new/better parent without restarting

    8
    0 Votes
    8 Posts
    2k Views
    H
    Sorry I haven't gotten back to you, been a busy week. The MY_TRANSPORT_MAX_TX_FAILURES seems to do the job perfectly, I adjusted it down to 1 for the node, and resend the message a couple of times if it fails. Thank you for your support :) Also thanks to berkseo, your code also works for me, but I do prefer the built in way now that I know of it. Less code for me to write and maintain :)
  • Relay Actuator - send periodic status as heart beat.

    3
    0 Votes
    3 Posts
    3k Views
    D
    Hi, yout post is quit old but I changed your code a bit. Now it sends the status of both relays: long double last_heartbeat_time = millis(); long double HEARTBEAT_TIME = 30000; int oldValue = 0; bool state; MyMessage msg1a(1, V_STATUS); MyMessage msg1b; MyMessage msg2a(2, V_STATUS); MyMessage msg2b; void before() { for (int sensor = 1, pin = RELAY_1; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor) ? RELAY_ON : RELAY_OFF); } } void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay", "1.0"); for (int sensor = 1, pin = RELAY_1; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } } void loop() { long double temp = (millis() - last_heartbeat_time); if (temp > HEARTBEAT_TIME) { // If it exceeds the heartbeat time then send a heartbeat sendHeartbeat(); send(msg1a.set(msg1b.getBool() ? 1 : 0)); send(msg2a.set(msg2b.getBool() ? 1 : 0)); last_heartbeat_time = millis(); Serial.println("Sent heartbeat" ); } } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type == V_STATUS) { // Change relay state digitalWrite(message.sensor - 1 + RELAY_1, message.getBool() ? RELAY_ON : RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); if (message.sensor == 1) { msg1b = message; } if (message.sensor == 2) { msg2b = message; } } } rg Denis
  • wait microseconds available?

    3
    0 Votes
    3 Posts
    702 Views
    skywatchS
    @Nca78 That makes perfect sense! - Thanks for the clarification.....Onwards and upwards! ;)
  • [SOLVED] MySensors and DHT22 - difficoulties in getting started

    8
    0 Votes
    8 Posts
    4k Views
    mfalkviddM
    @neo-mod said in [SOLVED] MySensors and DHT22 - difficoulties in getting started: I'm using a NRF24L01+PA+LNA and with BME280 I had an overlapping pin ( I followed the "How to connect the radio" official page). I'll open a new thread asking for advice, quite clearly I'm missing something. I checked my code, and I'm using the BME280 in i2c mode. The i2c pins on Pro Mini are different from the SPI pins so there is no overlap. On esp8266, D1 and D2 are used for i2c which means the CE pin must be moved using MY_RF24_CE_PIN but if you do that it should work.
  • Design question about using interrupts or not

    3
    0 Votes
    3 Posts
    731 Views
    G
    Thanks @mfalkvidd for your quick reply. Indeed it isn't battery powered. I already have a millis() delay loop so checking the swithes is easy then. Thanks again!
  • Serial Gateway w/ MQTT using nodeJS

    6
    3 Votes
    6 Posts
    4k Views
    @electrik There are already plenty of instructions on how you install Node.js and it would be beyond the scope of this topic to do so here. There are so many variables such as operating systems and so on to take into account. After installing Node.js you need to install the Node serialport and Node mqtt. pm2 is a very nice process manager for Node.js that you can use to make sure that your node scripts always is running. It's highly recommended and will make your life easier. In my own installation, I created a sub directory ~/node_modules/serialgwmqtt/ where I saved the app.js script file. Then cd ~/node_modules/serialgwmqtt/ followed by node app.js to make sure that everything works fine. When it does (works fine) you should make it autostart. I added my script to pm2 with the following command: pm2 start app.js --name "serialgwmqtt" (while still in the same directory). check hat it's working by issuing pm2 list I might have been running npm installor something similar also. I'm actually not so clever with these things and I'm sure my instructions can be simplified. The script should also be uploaded so some place to make it available for installing with a simple command. Maybe someone else more node.js-talented person want's to help here. I hope I have't forgotten anything, it's quite straight forward. Things are running rock solid here.
  • is there a #define symbol for the first really free EEPROM address ?

    3
    0 Votes
    3 Posts
    1k Views
    alowhumA
    @mfalkvidd said in is there a #define symbol for the first really free EEPROM address ?: https://github.com/mysensors/MySensors/issues/379 I would like to store some strings in eeprom. The nodes will also use the awesome simple security feature (signing, encryption). I suspect those also write some things to eeprom (I did research this just now, but I wasn't able to find anything on it). Combining all that: would it be smart to just start the storage of these string 'further down', like at 256? As far as I can tell all arduino's have at least 512bytes of eeprom, so then MySensors can still expand into the first 256 in the future, but my code will still be fine?
  • 0 Votes
    5 Posts
    3k Views
    N
    Thank you so much! You just saved me (a certified n00b, I know xD) from countless hours of headache! @mfalkvidd said in ESP8266 MQTT Gateway: Can't Subscribe from Domoticz with Mosquitto running on Pi 3: Just a guess: maybe all you need is to use the rpi3 ip instead of the esp8266 ip?
  • Multiple messages to same node, seems to miss one.

    17
    1
    0 Votes
    17 Posts
    3k Views
    electrikE
    @yveaux Did you find some time already to have a look at this? :-)
  • sha204 library questions

    6
    0 Votes
    6 Posts
    3k Views
    dbagioni77D
    I really dont want to do anything special per se....im just trying to find out if the newer library includes the "return_codes.h" as part of it, do i need a seperate #include statement?
  • signing future

    3
    0 Votes
    3 Posts
    849 Views
    rozpruwaczR
    thank, I will read that :)
  • Multiple sensors

    16
    0 Votes
    16 Posts
    3k Views
    B
    @bogus-exception What do you mean by a HE? Human Engineering? Heavy equipment? High End (system)? Happy Ending :joy: ? BR, Boozz
  • Changing a node not captured by gateway

    8
    0 Votes
    8 Posts
    2k Views
    hakha4H
    You're absolutely right. Should be MyMessage msgC(SSR_C_ID, V_STATUS); Sometimes you get blind when looking for typos. Thank's
  • How to reduce program size

    8
    0 Votes
    8 Posts
    2k Views
    rozpruwaczR
    wow, didn't expect such a response :) thanks. every think is working as expected. I was mislead by some functions from the APDS9930 library that I was not using, but the library was using them in its init function. I solved my problem by reducing size of my code and additionally I removed some functions from the APDS9930 library. So, bottom line. The Arduino IDE uses -fprogram-sections and -Wl,--gc-sections switches during compilation. Those switches remove the unused parts of the compiled objects from the resulting binary.
  • DimmableLED+Relay problem

    4
    0 Votes
    4 Posts
    993 Views
    mfalkviddM
    @mysz0n it is actually the combination that causes the problem. In the library examples, the message is never looked at after send() is called, so overwriting the message is not a problem. But still, it would be nice if someone could spend the time and effort required to change the examples to make them safe to combine.
  • MultiRelayExpanderWithToggleSwitch unstable

    3
    0 Votes
    3 Posts
    1k Views
    A
    Hello I wanted to understand are you using 2 PCF8574? one for input and another for output? also in the code which entries are to add the relays and assign a specific button? the code if inserted on wemos d1 works? sorry for the many questions because I have to put 8 relays controlled with 8 buttons and interface with domoticz thank you
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • esp8266 updating firmware on another esp8266

    3
    1 Votes
    3 Posts
    862 Views
    gohanG
    You could also consider the approach of iotappstory.con
  • Genuino/Arduino 101

    3
    0 Votes
    3 Posts
    1k Views
    marceltrapmanM
    I now have an Udoo x86 as well and I like it. Before I start testing myself, did you manage to get the MySensors Gateway to work?

14

Online

11.8k

Users

11.2k

Topics

113.2k

Posts