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!
  • Integrate with ThingsBoard

    gateway
    6
    1 Votes
    6 Posts
    45 Views
    mfalkviddM
    @chamroeun-ou said in Integrate with ThingsBoard: If I use Thingsboard gateway, I will have to deploy Mysensors gateway anyway in order to intercept the incoming RF24 data, right? Yes
  • ArduinoShrink

    5
    0 Votes
    5 Posts
    86 Views
    skywatchS
    @bjacobse I was surprised too as like you I had seen that they would not work with mysensors and definitely not with debug output - with 2 switches I was able to use debug output, but not after adding the htu21d (which I expected to fail, but after a little code change worked well). We live, We learn! :)
  • What really sleep() do please ?

    5
    1
    1 Votes
    5 Posts
    42 Views
    D
    Ok great :-) Thanks a lot again Denis
  • RFM69 - Get 433Mhz RF RSSI present in the air.

    1
    0 Votes
    1 Posts
    26 Views
    No one has replied
  • Personalize the MQTT topics

    7
    0 Votes
    7 Posts
    70 Views
    D
    Practically I receive the MQTT topics from the MySensors Gateway. Then in Node-Red I have make a function that translate the MySensors MQTT topics in a personalized MQTT topics, in order to have clear names of the sensors value. In Node-Red you make a flow like this: [image: 1617521270781-d6af473c-7ae1-4977-834e-04fcf8f98b26-image.png] Then in the function node you make something like this... but personalized: // add timestamp to every sensor reads var dt = new Date(); var hh = dt.getHours(); var mm = dt.getMinutes(); var ss = dt.getSeconds(); var yy = dt.getFullYear(); var mo = dt.getMonth() + 1; // want 1 more var dd = dt.getDate(); //var daynum = date.getDay(); timeST = (dd < 10 ? "0" : "") + dd + "-" + (mo < 10 ? "0" : "") + mo + "-" + yy + " " + (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss; /* sensors ID id SensGaraj: 11 id SensCame1: id SensCame2: id SensCame3: id SensCucin: id SensSerra: 12 id SensFuori: id SensSalon: type Temp : 51 type Hum : 52 type Press : 53 type BatVol: 54 type BatLev: 255 */ ret = 0; // send the return or not // sensor id (topic:MySensors-out/xx/) var parts = msg.topic.split("/"); id = parts[1]; type = parts[2]; val = msg.payload; if (id == 11 ){sname = "SensGaraj";ret = 1;} if (id == 12 ){sname = "SensSerra";ret = 1;} // if etc... if (ret == 1){ if (type == 51 ){stype = "Temp"; } if (type == 52 ){stype = "Hum";} if (type == 53 ){stype = "Press";} if (type == 54 ){stype = "BattVol";} if (type == 255){stype = "BattLev";} msg = {}; //initialize msg object msg.measurement = "sensors"; // tabella/file > influxdb msg.topic = "MySensors/" + sname + "/" + stype; msg.payload = {value: val, timeST: timeST} node.status({fill:"green",shape:"ring",text:sname}); return msg; } ////////////////////////////////////////////////////////////// If you need more help just let me know :-) Denis
  • MYSBootloader for atmega168

    mysbootloader atmega168 fota
    9
    1 Votes
    9 Posts
    96 Views
    skywatchS
    @pillarama I don't know about FOTA, but I see no reason why it would not work. I guess it depends what you do with it! ;) I like being able to burn bootloader from within arduino ide and not having to swap to avrdudess et al - now I can boot load and program in the same window. I was amazed at how easy it is to install and use. No need for fuse calculators, just choose clock speed, internal or external and brownout and click burn. I do hope to try FOTA in April (real life allowing) and so will comment more then.... Only snag is it dosn;t work with the ardudriod on android, I have contacted the dev of that app and sent the error message but as yet no solution. Maybe it will be possible in the future to do all this from phone and needing PC..... It is very close.
  • sleep(0) not working when Gateway is down

    2
    0 Votes
    2 Posts
    26 Views
    mfalkviddM
    @Snyfir what is the return value of the sleep call? What does the debug output say? Those pieces of information will help a lot when trying to understand what is happening and why. What type of Arduino you are using would also be useful.
  • Re-presenting a node during run time

    6
    1 Votes
    6 Posts
    77 Views
    TheoLT
    @skywatch my 50 cents is that you might want to achieve to much. Having 2 different networks is not a problem. But one device in 2 networks, not sure if it will solve your problem.
  • [RFC] Improve package delivery for RF24 modules

    15
    3 Votes
    15 Posts
    219 Views
    V
    Hi @Necromant, thank you for your comments regarding the RPD feature of the nRF24+. I have done some experiments with it. The result is a new tool TrafficDetectorRF24, which is available in my MySensors.Tools repository. The tool scans a single channel and outputs the current status via a debug pin. This can be used to connect a LED or better an input of a logic analyser. At first I tried to use the RPD feature based on the MySensors example PassiveNode. Unfortunately, that didn't work at all for me. I then adapted the code from Rolf Henkel Poor Man's Wireless 2.4GHz Scanner for my purposes. The detector works quite accurately (resolution approx. 140us) so that you can usually detect the transmitted telegram and the ACK response of the receiver individually: [image: 1615674196199-2021-03-13-23_16_23-clipboard.png] I hope you have more success in your attempts with the RPD feature.
  • Use FreeRTOS?

    12
    0 Votes
    12 Posts
    142 Views
    C
    Yes, the pin change intgerrupt gives me what I want. The sleep call also wakes up on this interrupt, I thought it would only wake up in INT0 or INT1. So for now my experiments with FreeRTOS end. @electrik thanks for the hint!
  • How to manage dynamic number of sensors?

    6
    0 Votes
    6 Posts
    61 Views
    T
    In case someone is interested in the code for mysensors mqtt gateway using the DS2482.h library from https://github.com/paeaetech/paeae. The temperature conversion code is from example. I am omitting the mysensors setup. ... #include <DS2482.h> #include <Ethernet.h> #include <MySensors.h> #include <Wire.h> DS2482 ds( 0 ); //channels ds2482-800 is 0 to 7, DS2482-100 is just set 0 byte dsData[8]; //holding for onewire capture byte dsAddr[8]; //1wire wire address and CRC MyMessage msgAddr( 0, V_ID ); MyMessage msgTemp( 0, V_TEMP ); void setup() { //Uses Wire library to communicate with DS2482 so be sure to call Wire.begin() before using the library. Wire.begin(); ds.reset(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo( SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER ); } void loop() { #ifdef MY_DEBUG Serial.println( "DBG: loop start" ); #endif ds.wireResetSearch(); ds.wireReset(); ds.wireSkip(); //need to send high power to bus?? Adding 5 volts to devices makes it work. ds.wireWriteByte( 0x44 ); //convert temperature on all devices delay( 1000 ); byte sensorId = 0; while( ds.wireSearch( dsAddr ) ) { #ifdef MY_DEBUG Serial.print( sensorId ); Serial.print( " : " ); #endif char sensorAddr[17]; //eg. 280838211713012D for( int i = 0; i < 8; i++ ) { sensorAddr[i*2] = ( dsAddr[i] >> 4 ) + 0x30; if ( sensorAddr[i*2] > 0x39 ) { sensorAddr[i*2] += 7; } sensorAddr[i*2+1] = ( dsAddr[i] & 0x0f ) + 0x30; if ( sensorAddr[i*2+1] > 0x39 ) { sensorAddr[i*2+1] += 7; } } sensorAddr[16] = '\0'; //always zero terminate string #ifdef MY_DEBUG Serial.print( sensorAddr ); Serial.print( "\n" ); #endif send( msgAddr.setSensor( sensorId ).set( sensorAddr ) ); #ifdef MY_DEBUG Serial.print( sensorId ); Serial.print( " : " ); #endif if ( ds.crc8( dsAddr, 7 ) != dsAddr[7] ) { Serial.print( "CRC is not valid!" ); return; } /* //test if device code DS18B20 if ( dsAddr[0]==0x28 ) { //test if device code MAX31850 if ( dsAddr[0]==0x3B ) { */ //read temperature data. ds.wireReset(); //ds.reset(); ds.selectChannel( 0 ); //necessary on -800 ds.wireSelect( dsAddr ); ds.wireWriteByte( 0xbe ); // Read Scratchpad command //display hex values of scratchpad for ( int i = 0; i < 9; i++ ) { // we need 9 bytes dsData[i] = ds.wireReadByte(); #ifdef MY_DEBUG if ( dsData[i] < 16 ) { Serial.print( "0" ); } Serial.print( dsData[i], HEX ); #endif } //convert to decimal temperature int LowByte = dsData[0]; int HighByte = dsData[1]; int TReading = ( HighByte << 8 ) + LowByte; int SignBit = TReading & 0x8000; // test most sig bit if ( SignBit ) // negative { TReading = ( TReading ^ 0xffff ) + 1; // 2's comp } float Tc_100 = (double) TReading * 0.0625; if ( SignBit ) { // If its negative Tc_100 = 0 - Tc_100; } //print temp for each device #ifdef MY_DEBUG Serial.print( " : " ); Serial.println( Tc_100 ); #endif send ( msgTemp.setSensor( sensorId ).set( Tc_100, 2 ) ); sensorId++; } #ifdef MY_DEBUG Serial.println( "DBG: loop end" ); #endif delay( 60000 ); } I am of course happy for any feedback. Especially if I am doing anything stupid as I am no programmer :)
  • only sleep NRF24L01

    2
    0 Votes
    2 Posts
    32 Views
    scalzS
    Hello, yes this is possible, here it is https://www.mysensors.org/apidocs/group__RF24grp.html#gae6a732b8f49a8eb99ef65ae159c65e9c and you may need to reinit transport layer at some point, https://www.mysensors.org/apidocs/group__MyTransportgrp.html https://www.mysensors.org/apidocs/index.html
  • LoRa Gpio serial gateway

    1
    0 Votes
    1 Posts
    18 Views
    No one has replied
  • watchdog 2021

    5
    0 Votes
    5 Posts
    98 Views
    skywatchS
    @virtualmkr That is useflul to know - thanks! - As it happens I think I had my first wdt 'kick' early this morning as the Gateway with the wdt on was showing as up for 3 hours instead of the 4 days I was expecting, so it restarted and all is still working ;)
  • Arduino Mega to Raspberry Pi 3 gateway over serial problems

    4
    0 Votes
    4 Posts
    60 Views
    Melih KuligM
    I finally got it working reading through google searches. I'd like to provide how I did it for anyone that may run into a similar issue in the future. While looking for this solution, I saw at least one person who had the exact same issue and their problem went unresolved. Raspberry Pi 3 is connected to Arduino Mega through regular serial link. Raspberry pi uses uart pins that map to Serial0 in raspbian. On Arduino Mega I use Serial2 pins (16,17). There's a voltage divider circuit between the two that reduces 5v to 3.3 for the pi. I compiled my gateway on pi with below: ./configure --my-transport=rs485 --my-rs485-serial-port=/dev/serial0 --my-rs485-baudrate=9600 On Arduino I have these define lines: #define MY_DEBUG #define MY_DEBUGDEVICE Serial #define MY_RS485 #define MY_RS485_HWSERIAL Serial2 #define MY_NODE_ID 1 #define MY_RS485_BAUD_RATE 9600 #define MY_RS485_DE_PIN -1 I'm not an expert on this by any means, but out of everything I tried, this is what worked for me. There are still some remaining issues: Possibly due to line noise or voltage being low on Arduino, I've had one crash that made Arduino print gibberish on serial and it stopped transmitting anything at all. I use Home Assistant and it seems to give up on MySensors if it doesn't receive anything in a while. Requires restart of HA core. Not very reliable. I still welcome any insight into this process and any alternatives/recommendations. I'd like to make this as reliable as possible, but my knowledge of these systems and electronics is limited.
  • Anything needed to do before sending Message after a long sleep ?

    8
    0 Votes
    8 Posts
    86 Views
    H
    Thank you @sundberg84 ! Well the node's been working for a whole day without loosing any message, and it reports its battery so everything seems fine. By the way, i have my first RFm69 node based on easyPCB now working :-) (a sonar to measure fuel tank) connected to the gateway of @Gerator : works great
  • [SOLVED] RS485 node with STM32

    4
    0 Votes
    4 Posts
    61 Views
    V
    @karlheinz2000 sounds great that you found the bug. It's always difficult to tell if it is a HW or SW bug on MCUs. From your first description it seems like a SW one to me.
  • What's the best way to set up lots of binary sensors on a single Arduino?

    15
    1 Votes
    15 Posts
    171 Views
    Melih KuligM
    Thanks ordered these from amazon, hoping to get a functional gateway out of them. I'll try to build it tomorrow according to specs and see if I can finally get some results. 50pcs 100uf 50V Radial Electrolytic Capacitor 8x12mm ENC28J60 Ethernet LAN Network Module for Arduino SPI 51 AVR PIC LPC STM32 Makerfire 10pcs Arduino NRF24L01+ 2.4GHz Wireless RF Transceiver Module New ELEGOO UNO Project Basic Starter Kit with UNO R3
  • Waking up on timer AND interrupt

    7
    0 Votes
    7 Posts
    121 Views
    skywatchS
    @BearWithBeard Thank you for sharing this great tip! - It works great and maybe finally I get my lightning detector working! Thanks @mfalkvidd For putting this in with the docs where it will hopefully help others. We need more examples like this in a knowledge base to save time reading through lots of posts that are many years old.
  • A class to Measure the Battery

    1
    1 Votes
    1 Posts
    41 Views
    No one has replied

20

Online

11.7k

Users

11.2k

Topics

113.0k

Posts