Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. kk02067
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by kk02067

    • RE: High current

      The pinchange interupt works fine.

      I found the offending things on my board. It was a combination of a couple of things. First it was the BME280 that was constantly active. Change to forced mode dropped the consumption from 0.4mA to 0.1 mA. I stopped using the internal pullup for my windspeedsensor which is based on a reedswitch. I noticed when the switch was open the consumption dropped to 0.04mA so I mounted a 1Mohm resistor instead of the internal pullup. Turning off the ADC dropped a about 10-20 uA. And lastly it seems that my nimh batterys where bad. They could not keep the charge. Changed to 2 x aaa and now it looks better.

      Current now on average 0.035 mA in sleepmode

      I will buy new nimh's to see if my solar panel circuit will work as expected. I hope to keep it running for about 5 years without changing the battery.
      Only time will tell now.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: High current

      @scalz

      The snippet of code in my previous post isn't the whole code. This is a bit more of the code (the loop section),

      
        while(!isTransportReady){   //kolla om allt ok för "sleep"
          _process();               //om inte så kör processen som styr biblioteket
        }
      
        transportPowerDown();   //Stäng ner radion
      //  Serial.print("Gonatt :");
        asm("cli");
        sleepcounter++;
        asm("sei");
      //  Serial.println(sleepcounter);
        Serial.flush ();    //vänta på serial skall bli klar
        WDTCSR=0b00011000;  //Starta watchdog timer interupt på 1s
        WDTCSR=0b01000110;
        SMCR=0b00000101;    //Välj powerdown mode
      sleep:
        asm("sleep");
        if (pinchange){     //Om pinchange är anledningen till vakna så sov igen
          pinchange=false;
          goto sleep;
        }
      // Här har det gått en sekund skicka nya data om det behövs
      
        asm("cli");
        TCNT1=0;            //Nollställ cykelräknaren 
        asm("sei");
        sendwind();
        sendbattery();
        sendtemp();
        sendrain();
        sendsolar();
        sendfail();
        asm("cli");
        cycle=TCNT1;
        asm("sei");
      //  Serial.print("Cykeltid: ");
      //  Serial.println(cycle*8);
      
      

      But it seems to consume to much power.

      The pinchange interupt fires fairly often but the mcu is mostly awake for about 120 cycles every second. So a drop of 0.2 Volts in battery in under 18 hours seems a bit high. This on a 3.3v pro mini at 8MHz.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: High current

      @mfalkvidd
      I will look into using your suggestions when I have the time.

      Regarding using my code in the library I don't see it beeing an option. The reason is that I'm an amateur programmer and as such I dont know all the "rules" on how code should look. In swedish as you know we have the term "spagettikod" and thats kind of how my code looks. I'm from an assembler background and and there I'm used to "slap some thing together", poking in registers directly and such.

      posted in Troubleshooting
      kk02067
      kk02067
    • High current

      I'm having trouble with high current consumption in an battery operated node. I suspect the NRF beeing the offending part. How can I be sure I have put the radio to sleep? I don't use the sleep() command because I use pinchange interupt instead of INT0 or INT1. I put the cpu to sleep with my own code. But how can I be sure that the radio has been put to sleep?
      In the code as it is now I use,

      transportPowerDown();
      asm("SLEEP");
      

      But I'm not sure that the radio is put to sleep.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: MYSBootloader 1.3.0-beta.3

      Excuse me for beeing an idiot. But how do you compile the bootloader from source? Do you do it from Atmel studio or from Arduino IDE. And how is it done? When I compile it in Atmel studio it gets an base adress of 0x0000 which is wrong.

      I am used to program in assembler in Atmel studio and when I program in C i don't touch anyting else than the .c file. So some form of tutorial kind of thing would be helpful.

      Thank you

      posted in Development
      kk02067
      kk02067
    • RE: Error sending switch command, check device/hardware !

      @novicit If I remember correctly i put it here: https://github.com/mysensors/MySensors/blob/master/core/MyTransport.cpp#L463
      just to test that it worked. Then I removed the change to keep the library source original.

      I turned on debug again to get it working again.. The reason why I wanted to have debuging disabled was to keep the hexfile size down so the OTA update wouldn't take so long time. I hope this issue will be fixed in a more elegant manner in a future release.

      posted in Domoticz
      kk02067
      kk02067
    • RE: MYSBootloader 1.3pre2 testing

      I have also problem with speed of the upload. I get about 1 packet per 3 seconds. Is there a something in the code for the bootloader that has a waitingtime of 3 seconds? And if so, because of what? From that info we might be able to tell if it's a reception problem of the node or the gateway.

      posted in Development
      kk02067
      kk02067
    • RE: Error sending switch command, check device/hardware !

      @mfalkvidd After Little more investigating and experimenting I am pretty sure I have found a bug in the library. I found that when debug is active all is working as expected. But if I commented out debug it starts to not work. I tried it about 10 times, once with debug and then without. And everytime debug is active it works, no debug it fails.
      I opened the transport sourcefile and added a delay(100) at the procedure where the debug message is sent. With that change it works everytime with or without debug. It seems that if the ackmessage is sent to quick it gets missed by the gateway. Any thoughts on this?

      posted in Domoticz
      kk02067
      kk02067
    • RE: Error sending switch command, check device/hardware !

      Having checked the serial output from the new node at my computer I see that the library returns the command when a ACK i requested. I also looked in the sourcecode for the library and it seems that it handles the ackmessage.
      So it seems that the ACK message get missed in the recieving node. Why, is the next question.

      Investigation continues...

      posted in Domoticz
      kk02067
      kk02067
    • RE: Error sending switch command, check device/hardware !

      I put together another node exactly the same but keeping it at my workbench roughly the same distance from the gateway. It works without any troubles so far. The only change in the sketch is the node id and no ds18b20 temperature reading.
      The log from myscontroller show that it works even if the node doesn't send back the same status as the command. Domoticz doesn't complain as it does with the first node. This behaviour was last night.

      Now this morning the replys from the new nodes is also present. They weren't last night. At least not in the logs from MYScontroller.

      When domoticz sends a switchcommand to the gateway it does so with with ACK flag set. Does mysensors library automatically reply?
      I haven't programmed in a replyfunction in my sketch so it seems like it. But in that case why doesn't my first node reply every time?

      Strange. Have to investigate this further.

      posted in Domoticz
      kk02067
      kk02067
    • RE: Error sending switch command, check device/hardware !

      @mfalkvidd No. I'm controling a ledstrip with ws2812b led's. The radio is powered from one of those small adapterboards with integrated regulator and capacitor. All driven from a 15W 5V switchmode powersupply.

      It seems that Domoticz is expecting a reply from the node with the same status as the command. Every time it works there is a reply from the node. And when I get the error Idont get that reply. I have not programmed in any replyprocedures in the sketch, so when it works it must be the library that send that reply from the node. But if thats the case, why not every time.

      I tried to modify the sketch to count any failed transmission and send that value back to the gateway to see if I have problems with the transmission. But the value is still Zero. Maybe my sketch is coded wrong but I dont think so.
      And even when domoticz says it failed the node still executes what was ordered.

      So the problem I think lies in the fact that domoticz seems to be waiting for an answer back with the new status from the node. The node send that status sometimes but more often not.

      This is the sketch:

      #define MY_RADIO_NRF24
      #define MY_NODE_ID 200
      #define MY_REPEATER_FEATURE
      //#define MY_DEBUG
      
      #include <MySensors.h>
      #include <SPI.h>
      #include "FastLED.h"
      #include <OneWire.h>
      #include <avr/pgmspace.h>
      
      
      #define DATA_PIN    2
      #define LED_TYPE    WS2812B
      #define COLOR_ORDER GRB
      #define NUM_LEDS    232
      #define BRIGHTNESS  96
      CRGB leds[NUM_LEDS];
      
      char actRGBvalue[] = "FFFFFF";               // Current RGB value
      uint16_t actRGBbrightness = 0xFF ;         // Controller Brightness
      int actRGBonoff = 0;                      // OnOff flag
      
      
      MyMessage msg(1, V_RGB);
      MyMessage msgtemp(2, V_TEMP);
      MyMessage msgcputemp(3, V_TEMP);
      MyMessage msgcpuvolt(4, V_VOLTAGE);
      MyMessage msgfailcount(5, V_VAR1);
      
      
      
      void SendColor2AllLEDs(const CRGB lcolor)
      {
        for (int i = 0 ; i < NUM_LEDS ; i++) {
          leds[i] = lcolor;
        }
      }
      
      OneWire ds(8);
      
      void setup() {
        wait(3000); // 3 second delay for recovery
      
        pinMode(7, OUTPUT);
        digitalWrite(7, HIGH);
      
        // tell FastLED about the LED strip configuration
        FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
        //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
      
        // set master brightness control
        FastLED.setBrightness(BRIGHTNESS);
      
        SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
      
      }
      
      
      
      void presentation()
      {
      
        present(1, S_RGB_LIGHT, "200 RGB Led");
        wait(1000);
        present(2, S_TEMP, "200 Temperatur altan");
        wait(1000);
        present(3, S_TEMP, "200 Temperatur CPU");
        wait(1000);
        present(4, S_MULTIMETER, "200 Spänning CPU");
        wait(1000);
        present(5, S_CUSTOM, "200 Failcount");
        wait(1000);
        sendSketchInfo("Nod 200 - Altan", "V1.6");
        wait(1000);
      
      
      }
      
      
        unsigned int fail;
        
      void loop()
      {
      
      
        
        if(!send(msgtemp.set(getTemp(), 2)))
          {
          fail++;
          }
           
        wait(1000);
        if(!send(msgcputemp.set(GetTempCpu(),2)))
          {
          fail++;
          }
        
        wait(1000);
      
        if(!send(msgcpuvolt.set(readVcc(),3)))
          {
          fail++;
          }
        
        wait(30000);
      
        send(msgfailcount.set(fail));
      
        wait(1000);
      
      
      }
      
      
      void receive(const MyMessage &message)
      {
        if (message.type == V_RGB) {
          strcpy(actRGBvalue, message.getString());    // get the payload
          SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
          Serial.println(F("RGB"));
          Serial.println(actRGBvalue);
        }
        else if (message.type == V_DIMMER) {
          actRGBbrightness = message.getByte();
          FastLED.setBrightness( actRGBbrightness );
          FastLED.show();
          Serial.println(F("DIMMER"));
          Serial.println(actRGBbrightness);
        }
        else if (message.type == V_STATUS) {           // if on/off type, toggle brightness
          actRGBonoff = message.getInt();
          FastLED.setBrightness((actRGBonoff == 1) ? actRGBbrightness : 0);
          FastLED.show();
          Serial.println(F("STATUS"));
          Serial.println(actRGBonoff);
        }
        //  FastLED.show();
      }
      
      
      float getTemp() {
        //returns the temperature from one DS18S20 in DEG Celsius
      
        byte data[12];
        byte addr[8];
      
        if ( !ds.search(addr)) {
          //no more sensors on chain, reset search
          ds.reset_search();
          return -1000;
        }
      
        if ( OneWire::crc8( addr, 7) != addr[7]) {
          Serial.println(PSTR("CRC is not valid!"));
          return -1000;
        }
      
        if ( addr[0] != 0x10 && addr[0] != 0x28) {
          Serial.print(PSTR("Device is not recognized"));
          return -1000;
        }
      
        ds.reset();
        ds.select(addr);
        ds.write(0x44, 1); // start conversion, with parasite power on at the end
      
        byte present = ds.reset();
        ds.select(addr);
        ds.write(0xBE); // Read Scratchpad
      
      
        for (int i = 0; i < 9; i++) { // we need 9 bytes
          data[i] = ds.read();
        }
      
        ds.reset_search();
      
        byte MSB = data[1];
        byte LSB = data[0];
      
        float tempRead = ((MSB << 8) | LSB); //using two's compliment
        float TemperatureSum = tempRead / 16;
      
        return TemperatureSum;
      
      }
      
      double GetTempCpu(void)
      {
        unsigned int wADC;
        double t;
      
        // The internal temperature has to be used
        // with the internal reference of 1.1V.
        // Channel 8 can not be selected with
        // the analogRead function yet.
      
        // Set the internal reference and mux.
        ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
        ADCSRA |= _BV(ADEN);  // enable the ADC
      
        wait(20);            // wait for voltages to become stable.
      
        ADCSRA |= _BV(ADSC);  // Start the ADC
      
        // Detect end-of-conversion
        while (bit_is_set(ADCSRA,ADSC));
      
        // Reading register "ADCW" takes care of how to read ADCL and ADCH.
        wADC = ADCW;
      
        // The offset of 324.31 could be wrong. It is just an indication.
        t = (wADC - 324.31 ) / 1.22;
      
        // The returned temperature is in degrees Celsius.
        return (t);
      }
      
      float readVcc() {
        // Read 1.1V reference against AVcc
        // set the reference to Vcc and the measurement to the internal 1.1V reference
        #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
          ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
          ADMUX = _BV(MUX5) | _BV(MUX0);
        #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
          ADMUX = _BV(MUX3) | _BV(MUX2);
        #else
          ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        #endif  
      
        wait(20); // Wait for Vref to settle
        ADCSRA |= _BV(ADSC); // Start conversion
        while (bit_is_set(ADCSRA,ADSC)); // measuring
      
        uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
        uint8_t high = ADCH; // unlocks both
      
        float result = (high<<8) | low;
      
        result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
        result=result/1000;
        return result; // Vcc in millivolts
      }
      
      
      
      posted in Domoticz
      kk02067
      kk02067
    • Error sending switch command, check device/hardware !

      I have got a new problem that I haven't had before.

      When I try to switch a node on or off from domoticz I see in MYSController that the command gets sent to the node. But domoticz says "Error sending switch command, check device/hardware !"
      I also see that domoticz sends the command at least twice.
      If I try the switch a couple of times more the same thing happens. But sometimes it works, and when that happens I see in MYSController that I that time also get a response from the node.

      When it don't work it looks like this:

      14888	2016-09-30 16:47:08	TX	200	1 - 200 RGB Led	C_SET	YES	V_LIGHT	0
      
      14889	2016-09-30 16:47:10	TX	200	1 - 200 RGB Led	C_SET	YES	V_LIGHT	0
      

      When it works it looks like this:

      14957	2016-09-30 16:49:25	TX	200	1 - 200 RGB Led	C_SET	YES	V_LIGHT	0
      
      14958	2016-09-30 16:49:25	RX	200	1 - 200 RGB Led	C_SET	YES	V_LIGHT	0
      

      The node also sends some status values regulary. Voltage of the mcu, Temperature of a ds18b20 and temperature of the mcu. All those messages get received without problems. So it doesn't seem to be a problem of the radios.

      When I change the status of a switch in domoticz, does it expect a response from the node? And if so, does the mysensors library send the response automatically? It seems like it does from the logs. And if the library sends the response why doesn't the response get received as it should? The statusvalues doesn't seem to get missed.

      posted in Domoticz
      kk02067
      kk02067
    • RE: MYSBootloader 1.3 pre-release & MYSController 1.0.0beta

      In the "firmware_config.csv" file, on the first line it says:

      Type,Name,Version,File,Comments
      

      I know that it is there to explain how to add new lines to the file.
      But I don't know what "Type" is used for.
      The two examples have the numbers 10 and 20. I added a 30 and it seems to work but I would like to know what it's for.

      Thanks

      posted in Development
      kk02067
      kk02067
    • RE: Placing strings in flash

      @AWI thanks for clarifying. I will read up on the subject. Strings i C is not my favourite subject.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: Placing strings in flash

      @mfalkvidd
      The string in the gateway becomes unreadable.

      posted in Troubleshooting
      kk02067
      kk02067
    • Placing strings in flash

      Hi.

      This line in a sketch:

      sendSketchInfo("Nod 200 - Altan", "V1.3");
      
      

      places the string both in flash and in ram. And when doing this:

      sendSketchInfo(PSTR("Nod 200 - Altan"), "V1.3");
      

      Places the string only in flash but it don't seem to work.

      the line:

      #include <avr/pgmspace.h>
      

      is in the begining of the sketch.

      Would like to save the ramspace

      Any ideas?

      posted in Troubleshooting
      kk02067
      kk02067
    • Switchcases?

      Hi.

      I need a little advice on where I can get cases similar to these:

      http://se.rs-online.com/web/p/products/0583432/

      Cheaper would be better. If I get these cases the complete switching module gets as expensive as generic z-wave device. And then there is almost no point in making them myself.

      posted in Hardware
      kk02067
      kk02067
    • RE: [Solved] MySensors 2.0 Ethernet gateway (ENC28J60) restart / IP issue

      @tekka Updated arduino to latest version 1.6.11 and downgraded to boarddefs 1.6.11 and now it seems fixed, at least with softspi for the radio.
      I have to try it with hwspi some other day. Have to stop for today.

      The version of arduino 1.6.9 would not let me downgrade to boarddefs 1.6.11, thats why it did not work when I tryed it before.

      Thanks for all your help.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] MySensors 2.0 Ethernet gateway (ENC28J60) restart / IP issue

      @tekka I found a sketch that identify the bootloader when googleing a bit. It reports bootloader as:

      CRC 2048b @ 0x7800 = 489C
      Boot loader: Duemilanove

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] MySensors 2.0 Ethernet gateway (ENC28J60) restart / IP issue

      @tekka Don't know. Cheap chinese clone of arduino nano

      How do I check?
      This is what the arduino IDE spits out when uploading to the nano:

      avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
               Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
               Copyright (c) 2007-2009 Joerg Wunsch
      
               System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
      
               Using Port                    : COM6
               Using Programmer              : arduino
               Overriding Baud Rate          : 57600
               AVR Part                      : ATmega328P
               Chip Erase delay              : 9000 us
               PAGEL                         : PD7
               BS2                           : PC2
               RESET disposition             : dedicated
               RETRY pulse                   : SCK
               serial program mode           : yes
               parallel program mode         : yes
               Timeout                       : 200
               StabDelay                     : 100
               CmdexeDelay                   : 25
               SyncLoops                     : 32
               ByteDelay                     : 0
               PollIndex                     : 3
               PollValue                     : 0x53
               Memory Detail                 :
      
                                        Block Poll               Page                       Polled
                 Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                 ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                 eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
                 flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                 lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                 hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                 efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                 lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                 calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                 signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
      
               Programmer Type : Arduino
               Description     : Arduino
               Hardware Version: 2
               Firmware Version: 1.16
               Vtarget         : 0.0 V
               Varef           : 0.0 V
               Oscillator      : Off
               SCK period      : 0.1 us
      
      avrdude: AVR device initialized and ready to accept instructions
      
      Reading | ################################################## | 100% 0.00s
      
      avrdude: Device signature = 0x1e950f
      avrdude: reading input file "C:\Users\Tony\AppData\Local\Temp\build12bf64d7a85151b4ee71a15dfecff5f5.tmp/GatewayW5100.ino.hex"
      avrdude: writing flash (26964 bytes):
      
      Writing | ################################################## | 100% 7.51s
      
      avrdude: 26964 bytes of flash written
      avrdude: verifying flash memory against C:\Users\Tony\AppData\Local\Temp\build12bf64d7a85151b4ee71a15dfecff5f5.tmp/GatewayW5100.ino.hex:
      avrdude: load data flash data from input file C:\Users\Tony\AppData\Local\Temp\build12bf64d7a85151b4ee71a15dfecff5f5.tmp/GatewayW5100.ino.hex:
      avrdude: input file C:\Users\Tony\AppData\Local\Temp\build12bf64d7a85151b4ee71a15dfecff5f5.tmp/GatewayW5100.ino.hex contains 26964 bytes
      avrdude: reading on-chip flash data:
      
      Reading | ################################################## | 100% 5.58s
      
      avrdude: verifying ...
      avrdude: 26964 bytes of flash verified
      
      avrdude done.  Thank you.
      
      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] MySensors 2.0 Ethernet gateway (ENC28J60) restart / IP issue

      I have just found this thread and are having the exact same problem. Arduino nano and en enc28j60 shield.

      I don't think its a supply problem.

      I had to drive the radio with softspi to get that working only to get the "reboot" issue.

      I put this in the setup section of the sketch to catch whats reseting the mcu:

       Serial.println(MCUSR);
       MCUSR=0;
      

      This produces this result:

      0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSM:RADIO:OK
      0;255;3;0;9;TSM:GW MODE
      0;255;3;0;9;TSM:READY
      IP: 192.168.0.72
      2        <------------ this is when I push the reset button
      0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSM:RADIO:OK
      0;255;3;0;9;TSM:GW MODE
      0;255;3;0;9;TSM:READY
      IP: 192.168.0.72
      0        <------------  this is the cpu restarting the sketch because of something unknown
      0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSM:RADIO:OK
      0;255;3;0;9;TSM:GW MODE
      0;255;3;0;9;TSM:READY
      IP: 192.168.0.72
      0
      0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSM:RADIO:OK
      0;255;3;0;9;TSM:GW MODE
      0;255;3;0;9;TSM:READY
      IP: 192.168.0.72
      0
      
      

      So it seems its not the mcu thats resets. The mcu either executes the nops inte unused flash space and wraps around to adress $0000 and starts over again, or there is a bug in the mysensors or the uipethernet files.

      Any thoughts on this?

      This is the complete sketch,

      /**
       * 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 - Henrik EKblad
       * Contribution by a-lurker and Anticimex,
       * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
       * Contribution by Tomas Hozza <thozza@gmail.com>
       *
       *
       * DESCRIPTION
       * The EthernetGateway sends data received from sensors to the ethernet link.
       * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
       *
       * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
       *
       * LED purposes:
       * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
       * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
       * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
       * - ERR (red) - fast blink on error during transmission error or recieve crc error
       *
       * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
       *
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      #define MY_RF24_CHANNEL 1
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Enable gateway ethernet module type 
      #define MY_GATEWAY_ENC28J60
      
      // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
      //#define MY_W5100_SPI_EN 4  
      
      // 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.
      
        #define MY_SOFTSPI
        #define MY_SOFT_SPI_SCK_PIN 7
        #define MY_SOFT_SPI_MISO_PIN 8
        #define MY_SOFT_SPI_MOSI_PIN 9
        
      
      // 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
      
      // Enable to UDP          
      //#define MY_USE_UDP
      
      #define MY_IP_ADDRESS 192,168,0,72   // 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, 0xFE, 0xDD
      
      // Flash leds on rx/tx/err
      //#define MY_LEDS_BLINKING_FEATURE
      // 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  8  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  9  // the PCB, on board LED
      
      #include <SPI.h>
      
      #if defined(MY_USE_UDP)
        #include <EthernetUdp.h>
      #endif
      //#include <Ethernet.h>
      #include <UIPEthernet.h>
      #include <MySensors.h>
      
      
      void setup()
      {
        Serial.println(MCUSR);
        MCUSR=0;
      }
      
      void loop() {
        
      }
      
      posted in Troubleshooting
      kk02067
      kk02067
    • Gateway and repeater

      Hello.

      Are the gateway acting as a repeater for nodes that communicate with each other, or do I have to specify repeatermode for the gateway also?

      posted in General Discussion
      kk02067
      kk02067
    • RE: requesting info from other node

      I Think I got it working. Does a node need to have a presentation section even if it's not going to communicate with the gateway? These nodes I'm trying to build only needs info from other nodes.

      posted in Development
      kk02067
      kk02067
    • RE: requesting info from other node

      I understand that. But is it possible to request data from another random node without doing any programming in the node thats being requested? And is it enough to keep the requesting node awake just the time to get the response?

      posted in Development
      kk02067
      kk02067
    • requesting info from other node

      Hi again. So many questions.

      I have build a node that transmit the status of my alarmsystem to my domoticz controller. Armed or disarmed.
      Is it possible for a different node to request the same info from the previous node? I would like to build a battery powered node that requests info from the first node once every minute, and then blink a led if the alarm is armed. These nodes would be placed at all exits from the house so I can see if the alarmsystem is armed. Kind of a warning that the doors are armed.

      posted in Development
      kk02067
      kk02067
    • RE: [Solved] Node not reconnecting

      I have now implemented the changes discussed here. It now seems to work flawlessly. I tested the node to see its behaviour when i powered down the gateway. As it said in the thread the node tried to reconnect after a couple of failed transmissions. And when I powered up the gateway again the node reconnected and started to go to sleep again.

      Thanks for the help on this.

      A Quick question a bit of topic Before I go build new nodes. If I want to run the cpu at only 1 MHz, do I have to do something else other then define the cpu frequency in the sketch? Is it possible to set the cpuclk prescaler at runtime?

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] Node not reconnecting

      @tekka Thanks for the info, I will now rework the sketch after this new information.

      My understanding of the library grows with every question.

      This is so fun. So much to build, so little time.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] Node not reconnecting

      Ok. Will try something like that.

      Is mysensors libraryfunctions interuptdriven? If so I understand why my sketch fails. Is there a complete list of useful functions besides going thru the sourcecode?

      Thanks alot for your support.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] Node not reconnecting

      I'm having trouble to log the node since it is in a remote place when it stops working.

      Can you please explain a little more what you mean with "send the node to sleep before the communication is fully re-established"?

      I'm a bit lost in all this it seems. I must have missed someting when reading about sending new values to the controller. But I thought that when the "send()" is executed the program is waiting here until Everything is finished for that transmission and we can move on to the transmission.

      Is there something I must do before sending the cpu to sleep?

      Sorry for my slow understanding.

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: [Solved] Node not reconnecting

      I have read that thread Before but it doesn't explain what:

      !TSP:SEND:TNR => Transport:SEND:Transport Not Ready

      really means. What has happend and what needs to be done.

      I have corrected my sketch regarding the autoreset of the node. I hope that helps to keep the node communicating.

      #include <SoftReset.h>
      
      /******************************************************************************
      I2C_ReadAllData.ino
      BME280 Arduino and Teensy example
      Marshall Taylor @ SparkFun Electronics
      May 20, 2015
      https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
      
      This sketch configures the BME280 to read all measurements.  The sketch also
      displays the BME280's physical memory and what the driver perceives the
      calibration words to be.
      
      Resources:
      Uses Wire.h for I2C operation
      Uses SPI.h for SPI operation
      
      Development environment specifics:
      Arduino IDE 1.6.4
      Teensy loader 1.23
      
      This code is released under the [MIT License](http://opensource.org/licenses/MIT).
      Please review the LICENSE.md file included with this example. If you have any questions 
      or concerns with licensing, please contact techsupport@sparkfun.com.
      Distributed as-is; no warranty is given.
      ******************************************************************************/
      
      #include <stdint.h>
      #include "SparkFunBME280.h"
      //Library allows either I2C or SPI, so include both.
      #include "Wire.h"
      #include "SPI.h"
      
      #define MY_DEBUG
      #define MY_DEBUG_VERBOSE_RF24
      #define MY_RADIO_NRF24
      #include <MySensors.h>
      
      #define SKETCH_NAME "Min väderstation"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "1"
      #define CHILD_ID_1 1
      #define CHILD_ID_2 2
      #define CHILD_ID_3 3
      
      
      //Global sensor object
      BME280 Sensor;
      
      
      MyMessage msg1(CHILD_ID_1, V_TEMP);
      MyMessage msg2(CHILD_ID_2, V_HUM);
      MyMessage msg3(CHILD_ID_3, V_PRESSURE);
      
      
      void setup()
      {
      	//***Driver settings********************************//
      	//commInterface can be I2C_MODE or SPI_MODE
      	//specify chipSelectPin using arduino pin names
      	//specify I2C address.  Can be 0x77(default) or 0x76
      	
      	//For I2C, enable the following and disable the SPI section
      	Sensor.settings.commInterface = I2C_MODE;
      	Sensor.settings.I2CAddress = 0x76;
      	
      	//For SPI enable the following and dissable the I2C section
      	//Sensor.settings.commInterface = SPI_MODE;
      	//Sensor.settings.chipSelectPin = 10;
      
      
      	//***Operation settings*****************************//
      	
      	//renMode can be:
      	//  0, Sleep mode
      	//  1 or 2, Forced mode
      	//  3, Normal mode
      	Sensor.settings.runMode = 3; //Normal mode
      	
      	//tStandby can be:
      	//  0, 0.5ms
      	//  1, 62.5ms
      	//  2, 125ms
      	//  3, 250ms
      	//  4, 500ms
      	//  5, 1000ms
      	//  6, 10ms
      	//  7, 20ms
      	Sensor.settings.tStandby = 5;
      	
      	//filter can be off or number of FIR coefficients to use:
      	//  0, filter off
      	//  1, coefficients = 2
      	//  2, coefficients = 4
      	//  3, coefficients = 8
      	//  4, coefficients = 16
      	Sensor.settings.filter = 0;
      	
      	//tempOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.tempOverSample = 1;
      
      	//pressOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
          Sensor.settings.pressOverSample = 1;
      	
      	//humidOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.humidOverSample = 1;
      	
      //	Serial.begin(57600);
      	Serial.print("Program Started\n");
      	Serial.print("Starting BME280... result of .begin(): 0x");
      	
      	//Calling .begin() causes the settings to be loaded
      	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
      	Serial.println(Sensor.begin(), HEX);
      
      	Serial.print("Displaying ID, reset and ctrl regs\n");
      	
      	Serial.print("ID(0xD0): 0x");
      	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
      	Serial.print("Reset register(0xE0): 0x");
      	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
      	Serial.print("ctrl_meas(0xF4): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
      	Serial.print("ctrl_hum(0xF2): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
      
      	Serial.print("\n\n");
      
      	Serial.print("Displaying all regs\n");
      	uint8_t memCounter = 0x80;
      	uint8_t tempReadData;
      	for(int rowi = 8; rowi < 16; rowi++ )
      	{
      		Serial.print("0x");
      		Serial.print(rowi, HEX);
      		Serial.print("0:");
      		for(int coli = 0; coli < 16; coli++ )
      		{
      			tempReadData = Sensor.readRegister(memCounter);
      			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
      			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
      			Serial.print(" ");
      			memCounter++;
      		}
      		Serial.print("\n");
      	}
      	
      	
      	Serial.print("\n\n");
      	
      	Serial.print("Displaying concatenated calibration words\n");
      	Serial.print("dig_T1, uint16: ");
      	Serial.println(Sensor.calibration.dig_T1);
      	Serial.print("dig_T2, int16: ");
      	Serial.println(Sensor.calibration.dig_T2);
      	Serial.print("dig_T3, int16: ");
      	Serial.println(Sensor.calibration.dig_T3);
      	
      	Serial.print("dig_P1, uint16: ");
      	Serial.println(Sensor.calibration.dig_P1);
      	Serial.print("dig_P2, int16: ");
      	Serial.println(Sensor.calibration.dig_P2);
      	Serial.print("dig_P3, int16: ");
      	Serial.println(Sensor.calibration.dig_P3);
      	Serial.print("dig_P4, int16: ");
      	Serial.println(Sensor.calibration.dig_P4);
      	Serial.print("dig_P5, int16: ");
      	Serial.println(Sensor.calibration.dig_P5);
      	Serial.print("dig_P6, int16: ");
      	Serial.println(Sensor.calibration.dig_P6);
      	Serial.print("dig_P7, int16: ");
      	Serial.println(Sensor.calibration.dig_P7);
      	Serial.print("dig_P8, int16: ");
      	Serial.println(Sensor.calibration.dig_P8);
      	Serial.print("dig_P9, int16: ");
      	Serial.println(Sensor.calibration.dig_P9);
      	
      	Serial.print("dig_H1, uint8: ");
      	Serial.println(Sensor.calibration.dig_H1);
      	Serial.print("dig_H2, int16: ");
      	Serial.println(Sensor.calibration.dig_H2);
      	Serial.print("dig_H3, uint8: ");
      	Serial.println(Sensor.calibration.dig_H3);
      	Serial.print("dig_H4, int16: ");
      	Serial.println(Sensor.calibration.dig_H4);
      	Serial.print("dig_H5, int16: ");
      	Serial.println(Sensor.calibration.dig_H5);
      	Serial.print("dig_H6, uint8: ");
      	Serial.println(Sensor.calibration.dig_H6);
      		
      	Serial.println();
      
              pinMode(8,OUTPUT);  //pin8 as output for battcheck
              digitalWrite(8,LOW); //see to that pin is low to save power
              analogReference(INTERNAL);  //internal 1.1V reference for battcheck
      
              
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
      
        // Register binary input sensor to sensor_node (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID_1, S_TEMP);  
        present(CHILD_ID_2, S_HUM);  
        present(CHILD_ID_3, S_BARO);  
      
      }
      
      
      
              double  temperature;
              double  humidity;
              double  pressure;
              double  oldtemperature;
              double  oldhumidity;
              double  oldpressure;
              unsigned char fail;
      
      
      void loop()
      {
      	//Each loop, take a reading.
      	//Start with temperature, as that data is needed for accurate compensation.
      	//Reading the temperature updates the compensators of the other functions
      	//in the background.
      
      
      
              float  batt;
      
      
              digitalWrite(8,HIGH);
              delay(10);
             	
              batt=analogRead(0);
              batt=batt-900;
              batt=batt/1.23;
             
             
              Serial.print("Batt%: ");
             	Serial.println(batt);
             digitalWrite(8,LOW);
             
              sendBatteryLevel(batt);
             
              temperature=Sensor.readTempC();
              humidity=Sensor.readFloatHumidity();
              pressure=Sensor.readFloatPressure()/100;
      
              if(temperature != oldtemperature){
              
              if(!send(msg1.set(temperature,2))){fail++;}
                else{ fail=0;}
              oldtemperature=temperature;     
      
              }
      
              if(humidity != oldhumidity){
      
              if(!send(msg2.set(humidity,2))){fail++;}
                else{ fail=0; }
              oldhumidity=humidity;
              
              }
      
              if(pressure != oldpressure){
      
              if(!send(msg3.set(pressure,2))){fail++;}
                else{ fail=0; }
              oldpressure=pressure;
              
              }
           
              if (fail>6){fail=0; Serial.print("Transmit error, Reseting!");soft_restart();}
      
              Serial.print("Number of errors before reset: "); Serial.println(fail);
      
           sleep(30000);
      
      }
      
      posted in Troubleshooting
      kk02067
      kk02067
    • [Solved] Node not reconnecting

      I have a node that is causing problems for me. When I have the node and the gateway in the same room all works fine. But when I move them apart the node stops sending the messages after a random couple of hours. This I think is because of the range. But if I move the node closer to the gatway again it doesn't reconnect. And the debug from the node outputs:

      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      RF24:write register, reg=0, value=12
      RF24:power down
      

      and repeats until I reset the node.

      It seems that my auto reset of the nod fails also.

      The sketch looks like this:

      #include <SoftReset.h>
      
      /******************************************************************************
      I2C_ReadAllData.ino
      BME280 Arduino and Teensy example
      Marshall Taylor @ SparkFun Electronics
      May 20, 2015
      https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
      
      This sketch configures the BME280 to read all measurements.  The sketch also
      displays the BME280's physical memory and what the driver perceives the
      calibration words to be.
      
      Resources:
      Uses Wire.h for I2C operation
      Uses SPI.h for SPI operation
      
      Development environment specifics:
      Arduino IDE 1.6.4
      Teensy loader 1.23
      
      This code is released under the [MIT License](http://opensource.org/licenses/MIT).
      Please review the LICENSE.md file included with this example. If you have any questions 
      or concerns with licensing, please contact techsupport@sparkfun.com.
      Distributed as-is; no warranty is given.
      ******************************************************************************/
      
      #include <stdint.h>
      #include "SparkFunBME280.h"
      //Library allows either I2C or SPI, so include both.
      #include "Wire.h"
      #include "SPI.h"
      
      #define MY_DEBUG
      #define MY_DEBUG_VERBOSE_RF24
      #define MY_RADIO_NRF24
      #include <MySensors.h>
      
      #define SKETCH_NAME "Min väderstation"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "1"
      #define CHILD_ID_1 1
      #define CHILD_ID_2 2
      #define CHILD_ID_3 3
      
      
      //Global sensor object
      BME280 Sensor;
      
      
      MyMessage msg1(CHILD_ID_1, V_TEMP);
      MyMessage msg2(CHILD_ID_2, V_HUM);
      MyMessage msg3(CHILD_ID_3, V_PRESSURE);
      
      
      void setup()
      {
      	//***Driver settings********************************//
      	//commInterface can be I2C_MODE or SPI_MODE
      	//specify chipSelectPin using arduino pin names
      	//specify I2C address.  Can be 0x77(default) or 0x76
      	
      	//For I2C, enable the following and disable the SPI section
      	Sensor.settings.commInterface = I2C_MODE;
      	Sensor.settings.I2CAddress = 0x76;
      	
      	//For SPI enable the following and dissable the I2C section
      	//Sensor.settings.commInterface = SPI_MODE;
      	//Sensor.settings.chipSelectPin = 10;
      
      
      	//***Operation settings*****************************//
      	
      	//renMode can be:
      	//  0, Sleep mode
      	//  1 or 2, Forced mode
      	//  3, Normal mode
      	Sensor.settings.runMode = 3; //Normal mode
      	
      	//tStandby can be:
      	//  0, 0.5ms
      	//  1, 62.5ms
      	//  2, 125ms
      	//  3, 250ms
      	//  4, 500ms
      	//  5, 1000ms
      	//  6, 10ms
      	//  7, 20ms
      	Sensor.settings.tStandby = 5;
      	
      	//filter can be off or number of FIR coefficients to use:
      	//  0, filter off
      	//  1, coefficients = 2
      	//  2, coefficients = 4
      	//  3, coefficients = 8
      	//  4, coefficients = 16
      	Sensor.settings.filter = 0;
      	
      	//tempOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.tempOverSample = 1;
      
      	//pressOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
          Sensor.settings.pressOverSample = 1;
      	
      	//humidOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.humidOverSample = 1;
      	
      //	Serial.begin(57600);
      	Serial.print("Program Started\n");
      	Serial.print("Starting BME280... result of .begin(): 0x");
      	
      	//Calling .begin() causes the settings to be loaded
      	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
      	Serial.println(Sensor.begin(), HEX);
      
      	Serial.print("Displaying ID, reset and ctrl regs\n");
      	
      	Serial.print("ID(0xD0): 0x");
      	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
      	Serial.print("Reset register(0xE0): 0x");
      	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
      	Serial.print("ctrl_meas(0xF4): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
      	Serial.print("ctrl_hum(0xF2): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
      
      	Serial.print("\n\n");
      
      	Serial.print("Displaying all regs\n");
      	uint8_t memCounter = 0x80;
      	uint8_t tempReadData;
      	for(int rowi = 8; rowi < 16; rowi++ )
      	{
      		Serial.print("0x");
      		Serial.print(rowi, HEX);
      		Serial.print("0:");
      		for(int coli = 0; coli < 16; coli++ )
      		{
      			tempReadData = Sensor.readRegister(memCounter);
      			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
      			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
      			Serial.print(" ");
      			memCounter++;
      		}
      		Serial.print("\n");
      	}
      	
      	
      	Serial.print("\n\n");
      	
      	Serial.print("Displaying concatenated calibration words\n");
      	Serial.print("dig_T1, uint16: ");
      	Serial.println(Sensor.calibration.dig_T1);
      	Serial.print("dig_T2, int16: ");
      	Serial.println(Sensor.calibration.dig_T2);
      	Serial.print("dig_T3, int16: ");
      	Serial.println(Sensor.calibration.dig_T3);
      	
      	Serial.print("dig_P1, uint16: ");
      	Serial.println(Sensor.calibration.dig_P1);
      	Serial.print("dig_P2, int16: ");
      	Serial.println(Sensor.calibration.dig_P2);
      	Serial.print("dig_P3, int16: ");
      	Serial.println(Sensor.calibration.dig_P3);
      	Serial.print("dig_P4, int16: ");
      	Serial.println(Sensor.calibration.dig_P4);
      	Serial.print("dig_P5, int16: ");
      	Serial.println(Sensor.calibration.dig_P5);
      	Serial.print("dig_P6, int16: ");
      	Serial.println(Sensor.calibration.dig_P6);
      	Serial.print("dig_P7, int16: ");
      	Serial.println(Sensor.calibration.dig_P7);
      	Serial.print("dig_P8, int16: ");
      	Serial.println(Sensor.calibration.dig_P8);
      	Serial.print("dig_P9, int16: ");
      	Serial.println(Sensor.calibration.dig_P9);
      	
      	Serial.print("dig_H1, uint8: ");
      	Serial.println(Sensor.calibration.dig_H1);
      	Serial.print("dig_H2, int16: ");
      	Serial.println(Sensor.calibration.dig_H2);
      	Serial.print("dig_H3, uint8: ");
      	Serial.println(Sensor.calibration.dig_H3);
      	Serial.print("dig_H4, int16: ");
      	Serial.println(Sensor.calibration.dig_H4);
      	Serial.print("dig_H5, int16: ");
      	Serial.println(Sensor.calibration.dig_H5);
      	Serial.print("dig_H6, uint8: ");
      	Serial.println(Sensor.calibration.dig_H6);
      		
      	Serial.println();
      
              pinMode(8,OUTPUT);  //pin8 as output for battcheck
              digitalWrite(8,LOW); //see to that pin is low to save power
              analogReference(INTERNAL);  //internal 1.1V reference for battcheck
      
              
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
      
        // Register binary input sensor to sensor_node (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID_1, S_TEMP);  
        present(CHILD_ID_2, S_HUM);  
        present(CHILD_ID_3, S_BARO);  
      
      }
      
      
      
              double  temperature;
              double  humidity;
              double  pressure;
              double  oldtemperature;
              double  oldhumidity;
              double  oldpressure;
              unsigned char fail;
      
      
      void loop()
      {
      	//Each loop, take a reading.
      	//Start with temperature, as that data is needed for accurate compensation.
      	//Reading the temperature updates the compensators of the other functions
      	//in the background.
      
      /*	Serial.print("Temperature: ");
      	Serial.print(Sensor.readTempC(), 2);
      	Serial.println(" degrees C");
      
      	Serial.print("Temperature: ");
      	Serial.print(Sensor.readTempF(), 2);
      	Serial.println(" degrees F");
      
      	Serial.print("Pressure: ");
      	Serial.print(Sensor.readFloatPressure(), 2);
      	Serial.println(" Pa");
      
      	Serial.print("Altitude: ");
      	Serial.print(Sensor.readFloatAltitudeMeters(), 2);
      	Serial.println("m");
      
      	Serial.print("Altitude: ");
      	Serial.print(Sensor.readFloatAltitudeFeet(), 2);
      	Serial.println("ft");	
      
      	Serial.print("%RH: ");
      	Serial.print(Sensor.readFloatHumidity(), 2);
      	Serial.println(" %");
      	
      	Serial.println();
      	
      	delay(1000);
      */
      
              float  batt;
      
      
              digitalWrite(8,HIGH);
              delay(10);
             	
              batt=analogRead(0);
              batt=batt-900;
              batt=batt/1.23;
             
             
              Serial.print("Batt%: ");
             	Serial.print(batt);
             digitalWrite(8,LOW);
             
              sendBatteryLevel(batt);
             
              temperature=Sensor.readTempC();
              humidity=Sensor.readFloatHumidity();
              pressure=Sensor.readFloatPressure()/100;
      
              if(temperature != oldtemperature){
              
              if(!send(msg1.set(temperature,2))){fail++;};
              oldtemperature=temperature;
              
              }
      
              if(humidity != oldhumidity){
      
              if(!send(msg2.set(humidity,2))){fail++;};
              oldhumidity=humidity;
      
              }
      
              if(pressure != oldpressure){
      
              if(!send(msg3.set(pressure,2))){fail++;};
              oldpressure=pressure;
              }
           
              if (fail>6){fail=0; Serial.print("Transmit error, Reseting!");soft_restart();}
      
              fail=0;
      
           sleep(30000);
      

      What does the message:

      !TSP:SEND:TNR

      mean and how do I handle it?

      posted in Troubleshooting
      kk02067
      kk02067
    • RE: Last seen?

      @AWI

      Thanks for your reply and tips to a beginner.

      I experimented with a couple of things in the sketch and after a little digging I seem to have got it working.

      The problem seem to be that if the values sent to the gateway is not in the correct format it wont work. If I send just one value in integer it works. But if I send alla three values as integer it stops working. If I send all three as "double" with two decimals it works as it should.

      The sketch when it functions as it should:

      /******************************************************************************
      I2C_ReadAllData.ino
      BME280 Arduino and Teensy example
      Marshall Taylor @ SparkFun Electronics
      May 20, 2015
      https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
      
      This sketch configures the BME280 to read all measurements.  The sketch also
      displays the BME280's physical memory and what the driver perceives the
      calibration words to be.
      
      Resources:
      Uses Wire.h for I2C operation
      Uses SPI.h for SPI operation
      
      Development environment specifics:
      Arduino IDE 1.6.4
      Teensy loader 1.23
      
      This code is released under the [MIT License](http://opensource.org/licenses/MIT).
      Please review the LICENSE.md file included with this example. If you have any questions 
      or concerns with licensing, please contact techsupport@sparkfun.com.
      Distributed as-is; no warranty is given.
      ******************************************************************************/
      
      #include <stdint.h>
      #include "SparkFunBME280.h"
      //Library allows either I2C or SPI, so include both.
      #include "Wire.h"
      #include "SPI.h"
      
      #define MY_DEBUG 
      #define MY_RADIO_NRF24
      #include <MySensors.h>
      
      #define SKETCH_NAME "Environment Sensor"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "0"
      #define CHILD_ID_1 1
      #define CHILD_ID_2 2
      #define CHILD_ID_3 3
      
      
      //Global sensor object
      BME280 Sensor;
      
      
      MyMessage msg1(CHILD_ID_1, V_TEMP);
      MyMessage msg2(CHILD_ID_2, V_HUM);
      MyMessage msg3(CHILD_ID_3, V_PRESSURE);
      
      
      void setup()
      {
      	//***Driver settings********************************//
      	//commInterface can be I2C_MODE or SPI_MODE
      	//specify chipSelectPin using arduino pin names
      	//specify I2C address.  Can be 0x77(default) or 0x76
      	
      	//For I2C, enable the following and disable the SPI section
      	Sensor.settings.commInterface = I2C_MODE;
      	Sensor.settings.I2CAddress = 0x77;
      	
      	//For SPI enable the following and dissable the I2C section
      	//Sensor.settings.commInterface = SPI_MODE;
      	//Sensor.settings.chipSelectPin = 10;
      
      
      	//***Operation settings*****************************//
      	
      	//renMode can be:
      	//  0, Sleep mode
      	//  1 or 2, Forced mode
      	//  3, Normal mode
      	Sensor.settings.runMode = 3; //Normal mode
      	
      	//tStandby can be:
      	//  0, 0.5ms
      	//  1, 62.5ms
      	//  2, 125ms
      	//  3, 250ms
      	//  4, 500ms
      	//  5, 1000ms
      	//  6, 10ms
      	//  7, 20ms
      	Sensor.settings.tStandby = 5;
      	
      	//filter can be off or number of FIR coefficients to use:
      	//  0, filter off
      	//  1, coefficients = 2
      	//  2, coefficients = 4
      	//  3, coefficients = 8
      	//  4, coefficients = 16
      	Sensor.settings.filter = 0;
      	
      	//tempOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.tempOverSample = 1;
      
      	//pressOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
          Sensor.settings.pressOverSample = 1;
      	
      	//humidOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.humidOverSample = 1;
      	
      //	Serial.begin(57600);
      	Serial.print("Program Started\n");
      	Serial.print("Starting BME280... result of .begin(): 0x");
      	
      	//Calling .begin() causes the settings to be loaded
      	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
      	Serial.println(Sensor.begin(), HEX);
      
      	Serial.print("Displaying ID, reset and ctrl regs\n");
      	
      	Serial.print("ID(0xD0): 0x");
      	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
      	Serial.print("Reset register(0xE0): 0x");
      	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
      	Serial.print("ctrl_meas(0xF4): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
      	Serial.print("ctrl_hum(0xF2): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
      
      	Serial.print("\n\n");
      
      	Serial.print("Displaying all regs\n");
      	uint8_t memCounter = 0x80;
      	uint8_t tempReadData;
      	for(int rowi = 8; rowi < 16; rowi++ )
      	{
      		Serial.print("0x");
      		Serial.print(rowi, HEX);
      		Serial.print("0:");
      		for(int coli = 0; coli < 16; coli++ )
      		{
      			tempReadData = Sensor.readRegister(memCounter);
      			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
      			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
      			Serial.print(" ");
      			memCounter++;
      		}
      		Serial.print("\n");
      	}
      	
      	
      	Serial.print("\n\n");
      	
      	Serial.print("Displaying concatenated calibration words\n");
      	Serial.print("dig_T1, uint16: ");
      	Serial.println(Sensor.calibration.dig_T1);
      	Serial.print("dig_T2, int16: ");
      	Serial.println(Sensor.calibration.dig_T2);
      	Serial.print("dig_T3, int16: ");
      	Serial.println(Sensor.calibration.dig_T3);
      	
      	Serial.print("dig_P1, uint16: ");
      	Serial.println(Sensor.calibration.dig_P1);
      	Serial.print("dig_P2, int16: ");
      	Serial.println(Sensor.calibration.dig_P2);
      	Serial.print("dig_P3, int16: ");
      	Serial.println(Sensor.calibration.dig_P3);
      	Serial.print("dig_P4, int16: ");
      	Serial.println(Sensor.calibration.dig_P4);
      	Serial.print("dig_P5, int16: ");
      	Serial.println(Sensor.calibration.dig_P5);
      	Serial.print("dig_P6, int16: ");
      	Serial.println(Sensor.calibration.dig_P6);
      	Serial.print("dig_P7, int16: ");
      	Serial.println(Sensor.calibration.dig_P7);
      	Serial.print("dig_P8, int16: ");
      	Serial.println(Sensor.calibration.dig_P8);
      	Serial.print("dig_P9, int16: ");
      	Serial.println(Sensor.calibration.dig_P9);
      	
      	Serial.print("dig_H1, uint8: ");
      	Serial.println(Sensor.calibration.dig_H1);
      	Serial.print("dig_H2, int16: ");
      	Serial.println(Sensor.calibration.dig_H2);
      	Serial.print("dig_H3, uint8: ");
      	Serial.println(Sensor.calibration.dig_H3);
      	Serial.print("dig_H4, int16: ");
      	Serial.println(Sensor.calibration.dig_H4);
      	Serial.print("dig_H5, int16: ");
      	Serial.println(Sensor.calibration.dig_H5);
      	Serial.print("dig_H6, uint8: ");
      	Serial.println(Sensor.calibration.dig_H6);
      		
      	Serial.println();
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
      
        // Register binary input sensor to sensor_node (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID_1, S_TEMP);  
        present(CHILD_ID_2, S_HUM);  
        present(CHILD_ID_3, S_BARO);  
      
      }
      
      void loop()
      {
      	//Each loop, take a reading.
      	//Start with temperature, as that data is needed for accurate compensation.
      	//Reading the temperature updates the compensators of the other functions
      	//in the background.
      
      /*	Serial.print("Temperature: ");
      	Serial.print(Sensor.readTempC(), 2);
      	Serial.println(" degrees C");
      
      	Serial.print("Temperature: ");
      	Serial.print(Sensor.readTempF(), 2);
      	Serial.println(" degrees F");
      
      	Serial.print("Pressure: ");
      	Serial.print(Sensor.readFloatPressure(), 2);
      	Serial.println(" Pa");
      
      	Serial.print("Altitude: ");
      	Serial.print(Sensor.readFloatAltitudeMeters(), 2);
      	Serial.println("m");
      
      	Serial.print("Altitude: ");
      	Serial.print(Sensor.readFloatAltitudeFeet(), 2);
      	Serial.println("ft");	
      
      	Serial.print("%RH: ");
      	Serial.print(Sensor.readFloatHumidity(), 2);
      	Serial.println(" %");
      	
      	Serial.println();
      	
      	delay(1000);
      */
      
              double  temperature;
              double  humidity;
              double  pressure;
              
              temperature=Sensor.readTempC();
              humidity=Sensor.readFloatHumidity();
              pressure=Sensor.readFloatPressure()/100;
      
      
             send(msg1.set(temperature,2));
      
             send(msg2.set(humidity,2));
      
             Serial.print(humidity, 2);
      
             send(msg3.set(pressure,2));
           
           sleep(10000);
      
      }```
      posted in Domoticz
      kk02067
      kk02067
    • Last seen?

      Hello,

      I have a problem with a sensor that is not updating in the dashboard. In the hardware setup page for mysensors gateway v2.0 I see "last seen" update every 10 sec. But under device I can see the device but it doesn't update more then once. "Last seen" in device page doesn't update. So the temperature doesn't update in the dashboard. What am I doing wrong? I'm kind of new at this.

      The sketch looks like this:

      /******************************************************************************
      I2C_ReadAllData.ino
      BME280 Arduino and Teensy example
      Marshall Taylor @ SparkFun Electronics
      May 20, 2015
      https://github.com/sparkfun/SparkFun_BME280_Arduino_Library

      This sketch configures the BME280 to read all measurements. The sketch also
      displays the BME280's physical memory and what the driver perceives the
      calibration words to be.

      Resources:
      Uses Wire.h for I2C operation
      Uses SPI.h for SPI operation

      Development environment specifics:
      Arduino IDE 1.6.4
      Teensy loader 1.23

      This code is released under the MIT License.
      Please review the LICENSE.md file included with this example. If you have any questions
      or concerns with licensing, please contact techsupport@sparkfun.com.
      Distributed as-is; no warranty is given.
      ******************************************************************************/

      #include <stdint.h>
      #include "SparkFunBME280.h"
      //Library allows either I2C or SPI, so include both.
      #include "Wire.h"
      #include "SPI.h"

      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #include <MySensors.h>

      #define SKETCH_NAME "Environment Sensor"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "0"
      #define CHILD_ID_1 1
      #define CHILD_ID_2 2
      #define CHILD_ID_3 3

      //Global sensor object
      BME280 Sensor;

      MyMessage msg1(CHILD_ID_1, V_TEMP);
      MyMessage msg2(CHILD_ID_2, V_HUM);
      MyMessage msg3(CHILD_ID_3, V_PRESSURE);

      void setup()
      {
      //Driver settings*****************************//
      //commInterface can be I2C_MODE or SPI_MODE
      //specify chipSelectPin using arduino pin names
      //specify I2C address. Can be 0x77(default) or 0x76

      //For I2C, enable the following and disable the SPI section
      Sensor.settings.commInterface = I2C_MODE;
      Sensor.settings.I2CAddress = 0x77;
      
      //For SPI enable the following and dissable the I2C section
      //Sensor.settings.commInterface = SPI_MODE;
      //Sensor.settings.chipSelectPin = 10;
      
      
      //***Operation settings*****************************//
      
      //renMode can be:
      //  0, Sleep mode
      //  1 or 2, Forced mode
      //  3, Normal mode
      Sensor.settings.runMode = 3; //Normal mode
      
      //tStandby can be:
      //  0, 0.5ms
      //  1, 62.5ms
      //  2, 125ms
      //  3, 250ms
      //  4, 500ms
      //  5, 1000ms
      //  6, 10ms
      //  7, 20ms
      Sensor.settings.tStandby = 5;
      
      //filter can be off or number of FIR coefficients to use:
      //  0, filter off
      //  1, coefficients = 2
      //  2, coefficients = 4
      //  3, coefficients = 8
      //  4, coefficients = 16
      Sensor.settings.filter = 0;
      
      //tempOverSample can be:
      //  0, skipped
      //  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      Sensor.settings.tempOverSample = 1;
      
      //pressOverSample can be:
      //  0, skipped
      //  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      Sensor.settings.pressOverSample = 1;
      
      //humidOverSample can be:
      //  0, skipped
      //  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      Sensor.settings.humidOverSample = 1;
      

      // Serial.begin(57600);
      Serial.print("Program Started\n");
      Serial.print("Starting BME280... result of .begin(): 0x");

      //Calling .begin() causes the settings to be loaded
      delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
      Serial.println(Sensor.begin(), HEX);
      
      Serial.print("Displaying ID, reset and ctrl regs\n");
      
      Serial.print("ID(0xD0): 0x");
      Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
      Serial.print("Reset register(0xE0): 0x");
      Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
      Serial.print("ctrl_meas(0xF4): 0x");
      Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
      Serial.print("ctrl_hum(0xF2): 0x");
      Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
      
      Serial.print("\n\n");
      
      Serial.print("Displaying all regs\n");
      uint8_t memCounter = 0x80;
      uint8_t tempReadData;
      for(int rowi = 8; rowi < 16; rowi++ )
      {
      	Serial.print("0x");
      	Serial.print(rowi, HEX);
      	Serial.print("0:");
      	for(int coli = 0; coli < 16; coli++ )
      	{
      		tempReadData = Sensor.readRegister(memCounter);
      		Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
      		Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
      		Serial.print(" ");
      		memCounter++;
      	}
      	Serial.print("\n");
      }
      
      
      Serial.print("\n\n");
      
      Serial.print("Displaying concatenated calibration words\n");
      Serial.print("dig_T1, uint16: ");
      Serial.println(Sensor.calibration.dig_T1);
      Serial.print("dig_T2, int16: ");
      Serial.println(Sensor.calibration.dig_T2);
      Serial.print("dig_T3, int16: ");
      Serial.println(Sensor.calibration.dig_T3);
      
      Serial.print("dig_P1, uint16: ");
      Serial.println(Sensor.calibration.dig_P1);
      Serial.print("dig_P2, int16: ");
      Serial.println(Sensor.calibration.dig_P2);
      Serial.print("dig_P3, int16: ");
      Serial.println(Sensor.calibration.dig_P3);
      Serial.print("dig_P4, int16: ");
      Serial.println(Sensor.calibration.dig_P4);
      Serial.print("dig_P5, int16: ");
      Serial.println(Sensor.calibration.dig_P5);
      Serial.print("dig_P6, int16: ");
      Serial.println(Sensor.calibration.dig_P6);
      Serial.print("dig_P7, int16: ");
      Serial.println(Sensor.calibration.dig_P7);
      Serial.print("dig_P8, int16: ");
      Serial.println(Sensor.calibration.dig_P8);
      Serial.print("dig_P9, int16: ");
      Serial.println(Sensor.calibration.dig_P9);
      
      Serial.print("dig_H1, uint8: ");
      Serial.println(Sensor.calibration.dig_H1);
      Serial.print("dig_H2, int16: ");
      Serial.println(Sensor.calibration.dig_H2);
      Serial.print("dig_H3, uint8: ");
      Serial.println(Sensor.calibration.dig_H3);
      Serial.print("dig_H4, int16: ");
      Serial.println(Sensor.calibration.dig_H4);
      Serial.print("dig_H5, int16: ");
      Serial.println(Sensor.calibration.dig_H5);
      Serial.print("dig_H6, uint8: ");
      Serial.println(Sensor.calibration.dig_H6);
      	
      Serial.println();
      

      }

      void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);

      // Register binary input sensor to sensor_node (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      present(CHILD_ID_1, S_TEMP);
      present(CHILD_ID_2, S_HUM);
      present(CHILD_ID_3, S_BARO);

      }

      void loop()
      {
      //Each loop, take a reading.
      //Start with temperature, as that data is needed for accurate compensation.
      //Reading the temperature updates the compensators of the other functions
      //in the background.

      /* Serial.print("Temperature: ");
      Serial.print(Sensor.readTempC(), 2);
      Serial.println(" degrees C");

      Serial.print("Temperature: ");
      Serial.print(Sensor.readTempF(), 2);
      Serial.println(" degrees F");
      
      Serial.print("Pressure: ");
      Serial.print(Sensor.readFloatPressure(), 2);
      Serial.println(" Pa");
      
      Serial.print("Altitude: ");
      Serial.print(Sensor.readFloatAltitudeMeters(), 2);
      Serial.println("m");
      
      Serial.print("Altitude: ");
      Serial.print(Sensor.readFloatAltitudeFeet(), 2);
      Serial.println("ft");	
      
      Serial.print("%RH: ");
      Serial.print(Sensor.readFloatHumidity(), 2);
      Serial.println(" %");
      
      Serial.println();
      
      delay(1000);
      

      */

          int  temperature;
          int  humidity;
          long  pressure;
          
          temperature=Sensor.readTempC();
          humidity=Sensor.readFloatHumidity();
          pressure=Sensor.readFloatPressure();
      
      
       send(msg1.set(temperature));
       send(msg2.set(humidity));
       send(msg3.set(pressure));
       
       sleep(10000);
      

      }

      posted in Domoticz
      kk02067
      kk02067