Navigation

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

    choffmann

    @choffmann

    1
    Reputation
    6
    Posts
    274
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    choffmann Follow

    Best posts made by choffmann

    • RE: sending string via nrf and the other receivers making trouble - why?

      i hope that i can update my arduino tomorrow, so that i can test if this will work....

      The FHEM code you want:
      The Devices:
      define LEDRahmen MYSENSORS_DEVICE 102 ... autmatic including des Reading/Devices
      define LEDRahmenSwitch dummy -- for setting LED and Color manually
      define LEDRahmenSwitchNotify notify LEDRahmenSwitch.* { sendLEDColor($EVTPART0, $EVTPART1) }

      and the 99_myUtils.pm Mehtods:
      (NEW: i have changed the Method from send String like 0-255-0 to 000-255-000 - see Method "changeLengthTo" )

      
      sub sendLEDColor($$){
        my ($stat,$val) = @_;
        my $tmp;
        $tmp .= changeLengthTo(hexstr_to_signed32int(substr($val,0,2)),3);
        $tmp .= "-";
        $tmp .= changeLengthTo(hexstr_to_signed32int(substr($val,2,2)),3);
        $tmp .= "-";
        $tmp .= changeLengthTo(hexstr_to_signed32int(substr($val,4,6)),3);
      
        #my $m = hexstr_to_signed32int($tmp);
        #Log 1, "MeinE Testmethode";
        #Log 1, $;
        fhem("set LEDRahmen status".$stat." ".$tmp."");
      
      
      }
      
      sub changeLengthTo($$){
        my($str,$toLength) = @_;
        my $tmpstr;
        for(my $i = (length($str)+1); $i <= $toLength; $i++){
          $tmpstr.= "0";
        }
        return $tmpstr.$str;
      }
      
      sub hexstr_to_signed32int($) {
          my ($hexstr) = @_;
          die "Invalid hex string: $hexstr"
              if $hexstr !~ /^[0-9A-Fa-f]{1,8}$/;
       
          my $num = hex($hexstr);
          return $num >> 31 ? $num - 2 ** 32 : $num;
      }
      
      posted in Development
      choffmann
      choffmann

    Latest posts made by choffmann

    • RE: Version Mismatch

      Hello,

      i have the same problem that i get version mismatch

      0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0,sg=0:
      0;0;3;0;9;ver mismatch

      i have installe arduino version 1.6.5 an Mysensors librarie 1.5.4
      also i habe vhanged the channel "#define RF24_CHANNEL" from 76 to 120 and to 20!
      in Each Case i have the problem with ver mismatch.

      There are no other devices on this channel.

      i hope you can help me

      posted in Troubleshooting
      choffmann
      choffmann
    • RE: sending string via nrf and the other receivers making trouble - why?

      i hope that i can update my arduino tomorrow, so that i can test if this will work....

      The FHEM code you want:
      The Devices:
      define LEDRahmen MYSENSORS_DEVICE 102 ... autmatic including des Reading/Devices
      define LEDRahmenSwitch dummy -- for setting LED and Color manually
      define LEDRahmenSwitchNotify notify LEDRahmenSwitch.* { sendLEDColor($EVTPART0, $EVTPART1) }

      and the 99_myUtils.pm Mehtods:
      (NEW: i have changed the Method from send String like 0-255-0 to 000-255-000 - see Method "changeLengthTo" )

      
      sub sendLEDColor($$){
        my ($stat,$val) = @_;
        my $tmp;
        $tmp .= changeLengthTo(hexstr_to_signed32int(substr($val,0,2)),3);
        $tmp .= "-";
        $tmp .= changeLengthTo(hexstr_to_signed32int(substr($val,2,2)),3);
        $tmp .= "-";
        $tmp .= changeLengthTo(hexstr_to_signed32int(substr($val,4,6)),3);
      
        #my $m = hexstr_to_signed32int($tmp);
        #Log 1, "MeinE Testmethode";
        #Log 1, $;
        fhem("set LEDRahmen status".$stat." ".$tmp."");
      
      
      }
      
      sub changeLengthTo($$){
        my($str,$toLength) = @_;
        my $tmpstr;
        for(my $i = (length($str)+1); $i <= $toLength; $i++){
          $tmpstr.= "0";
        }
        return $tmpstr.$str;
      }
      
      sub hexstr_to_signed32int($) {
          my ($hexstr) = @_;
          die "Invalid hex string: $hexstr"
              if $hexstr !~ /^[0-9A-Fa-f]{1,8}$/;
       
          my $num = hex($hexstr);
          return $num >> 31 ? $num - 2 ** 32 : $num;
      }
      
      posted in Development
      choffmann
      choffmann
    • RE: sending string via nrf and the other receivers making trouble - why?

      OK,

      my Mysensors version is 1.5.3 i will update it.
      Do i have to update my Gateway too?

      In the link they talk about issues with the Getters in version 1.5.4. is this what you think that could be the problem?!

      Thanks

      posted in Development
      choffmann
      choffmann
    • RE: sending string via nrf and the other receivers making trouble - why?

      Sorry,
      what did you mean with that?
      what is a master branch?

      posted in Development
      choffmann
      choffmann
    • sending string via nrf and the other receivers making trouble - why?

      Hello,
      ich have configured an arduino nano via nrf24L01+ and a LED-Stripe. My Idea is to send a LEDNumber and a HEX-Code for the color to set the LED to Color xy...

      I use FHEM and a own Perl-Method to convert the HEX Code to an Splittable string. This i send via Network-GW to my arduino as String.
      At this moment where the code is sending other receivers like Temp-Sensors sending 12502°C as Temperatur...

      I dont find the problem.
      Can somebody help?

      The sendet code via FHEM is:
      set <NAME> status7 0-0-255

      #include <MySensor.h>
      #include <SPI.h>
      #include <EEPROM.h>
      #include <MyTransportNRF24.h>
      #include <MyHwATMega328.h>
      #include <RemoteReceiver.h>
      #include <RemoteTransmitter.h>
      #include <InterruptChain.h>
      
      #include "FastLED.h"
      #define DATA_PIN 3
      #define CLOCK_PIN 13
      #define NUM_LEDS 19
      CRGB leds[NUM_LEDS];
      
      
      #define NUMBER_OF_OUTLETS 99
      #define SN "LEDRahmenEG"
      #define SV "1.6"
      
      const byte SC_CHILD_ID = 0 ;
      //unsigned long receivedCode = 0 ;
      
      
      MySensor gw;
      MyMessage scene_on(SC_CHILD_ID, V_LEVEL);
      MyMessage scene_off(SC_CHILD_ID, V_LEVEL);
      
      void setup() {
        Serial.begin(115200);
        gw.begin(incomingMessage);
        gw.sendSketchInfo(SN, SV);
        FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
      
        //TEST
        //leds[9].g=1;
        //leds[9].b=255;
        //leds[10].r=255;
        //leds[11].b=255;
        //FastLED.show();
      
        //  Create a child device for each outlet
        for (int sensor = 1; sensor <= NUMBER_OF_OUTLETS; sensor++) {
          gw.present(sensor, S_LIGHT);
          delay(2);
        }
      }
      
      void loop() {
        gw.process();
      }
      
      String getValue(String data, char separator, int index) {
        int found = 0;
        int strIndex[] = {0, -1};
        int maxIndex = data.length() - 1;
      
        for (int i = 0; i <= maxIndex && found <= index; i++) {
          if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i + 1 : i;
          }
        }
      
        return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
      }
      
      //command has been received from gateway
      void incomingMessage(const MyMessage &message) {
        Serial.println(message.sensor);
        Serial.println(".......");
        Serial.println(message.getInt());
        if (message.type == V_LIGHT) {
          Serial.print("LED ID #: ");
          Serial.println(message.sensor);
          Serial.print("Color: ");
          Serial.println(message.getString());
      
          //receive String like 125-255-111 call getValue and split
          //.toInt() convert the String Number to int and would be assigned to the LED
          leds[message.sensor].r = getValue(message.getString(), '-', 0).toInt();
          leds[message.sensor].g = getValue(message.getString(), '-', 1).toInt();
          leds[message.sensor].b = getValue(message.getString(), '-', 2).toInt();
          FastLED.show();
      
          if (message.sensor == 99) {
            for (int i = 0; i < NUM_LEDS; ++i) {
              leds[i].r = getValue(message.getString(), '-', 0).toInt();
              leds[i].g = getValue(message.getString(), '-', 1).toInt();
              leds[i].b = getValue(message.getString(), '-', 2).toInt();
              FastLED.show();
            }
          }
        }
        delay(50);
      }
      

      The Serial-Monitor shows

      • message.sensor = 7
      • message.getString() = 0-0-255enEG

      Why is there "enEG" at the end?

      Thanks
      Christian

      posted in Development
      choffmann
      choffmann
    • Sending "Hex-Code" and converting to uint32_t problem

      hi,

      i want to send a "hex-Code" via FHEM to my arduino and convert it to an uint32_t for the FastLED-Method.

      I have tried many methods like message.getString() or getCustom() and something like that. The Arduino gets the "Code" - But everything i tried to convert to an uint32_t wont work.

      I hope you can help me with a code snippet or something like that.

      Many thanks!
      Christian

      posted in Troubleshooting
      choffmann
      choffmann