Navigation

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

    micah

    @micah

    30
    Reputation
    63
    Posts
    1143
    Profile views
    0
    Followers
    2
    Following
    Joined Last Online

    micah Follow

    Best posts made by micah

    • Basement Monitor

      Hi everyone.

      Been wanting to implement some mysensors goodness for awhile now, and I finally got around to building the first node for my home automation project.

      I'm learning as I go, so things aren't pretty yet.

      Before I continue, I wanted to start by thanking everyone on here, I've learned so much by reading your posts.

      This first node is called "BasementMonitor". It'll eventually be mounted to the wall under the stairs in the basement. It's purpose is to scan the following and report them to my (soon to be built) Raspberry Pi OpenHAB.

      • Temperature
      • Humidity
      • Gas (CO2)
      • Ambient light (to know if the lights were left on)
      • Flame
      • Water (on the floor)

      Since this is my first build it's not pretty... basically stuff hot glued into a tupperware container. I'll pretty it up once I'm done all my testing.

      My Node
      My Node view 2

      Here is my sketch so far. It's still pretty raw and I've got a bunch more things to implement, but it works 🙂

      #define MY_NODE_ID 2
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_LIGHT 2
      #define CHILD_ID_FLAME 3
      #define CHILD_ID_WATER 4
      #define CHILD_ID_GAS 5
      
      #include <SPI.h>
      #include <MySensor.h>  
      #include <DHT.h>  
      
      #define HUMIDITY_SENSOR_DIGITAL_PIN 5
      #define LIGHT_SENSOR_ANALOG_PIN A2
      #define FLAME_SENSOR_DIGITAL_PIN 3
      #define WATER_SENSOR_ANALOG_PIN A0
      #define GAS_SENSOR_ANALOG_PIN A1
      
      MySensor gw;
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      MyMessage msgFlame(CHILD_ID_FLAME, V_STATUS);
      MyMessage msgWater(CHILD_ID_WATER, V_LEVEL);
      MyMessage msgGas(CHILD_ID_GAS, V_LEVEL);
      
      unsigned long pMillis_Photo = 0;
      unsigned long pMillis_WS = 0;
      unsigned long pMillis_DHT = 0;
      unsigned long pMillis_GS = 0;
      unsigned long pMillis_FS = 0;
      long sCheck_Photo = 60000;
      long sCheck_WS = 60000;
      long sCheck_DHT = 60000;
      long sCheck_GS = 20000;
      long sCheck_FS = 20000;
      int lastLightLevel;
      int lastFlameLevel;
      int lastWaterLevel;
      int lastGasLevel;
      
      void setup(){ 
        gw.begin(NULL, MY_NODE_ID, true);
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      
        gw.sendSketchInfo("Basement Monitor", "1.0");
      
        gw.present(CHILD_ID_HUM, S_HUM);
        gw.present(CHILD_ID_TEMP, S_TEMP);
        gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
        gw.present(CHILD_ID_FLAME, S_LIGHT);
        gw.present(CHILD_ID_WATER, S_MOISTURE);
        gw.present(CHILD_ID_GAS, S_AIR_QUALITY);
        
        metric = gw.getConfig().isMetric;
      }
      void loop(){
        unsigned long currentMillis = millis();
        
        // Check Temp and Humidity
        if (currentMillis - pMillis_DHT >= sCheck_DHT){
          pMillis_DHT = currentMillis;
          
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
              Serial.println("Failed reading temperature from DHT");
          } else if (temperature != lastTemp) {
            lastTemp = temperature;
            if (!metric) {
              temperature = dht.toFahrenheit(temperature);
            }
            gw.send(msgTemp.set(temperature, 1));
            Serial.print("T: ");
            Serial.println(temperature);
          }
          
          float humidity = dht.getHumidity();
          if (isnan(humidity)) {
              Serial.println("Failed reading humidity from DHT");
          } else if (humidity != lastHum) {
              lastHum = humidity;
              gw.send(msgHum.set(humidity, 1));
              Serial.print("H: ");
              Serial.println(humidity);
          }
        }
        // Check light level
        if (currentMillis - pMillis_Photo >= sCheck_Photo){
          pMillis_Photo = currentMillis;
          
          //int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; 
          int lightLevel = analogRead(LIGHT_SENSOR_ANALOG_PIN); 
          Serial.print("L: ");
          Serial.println(lightLevel);
          if (lightLevel != lastLightLevel) {
            gw.send(msgLight.set(lightLevel));
            lastLightLevel = lightLevel;
          }
        }
        // Check Flame
        if (currentMillis - pMillis_FS >= sCheck_FS){
          pMillis_FS = currentMillis;
          // 1=no fire  0=fire
          int flameLevel = digitalRead(FLAME_SENSOR_DIGITAL_PIN);
          Serial.print("F: ");
          Serial.println(digitalRead(FLAME_SENSOR_DIGITAL_PIN));
          if (flameLevel != lastFlameLevel) {
            gw.send(msgFlame.set(flameLevel));
            lastFlameLevel = flameLevel;
          }
        }
        //Check water
        if (currentMillis - pMillis_WS >= sCheck_WS){
          pMillis_WS = currentMillis;
          //under 10 ignore   up to 70 = 1 drop   over 300 = really wet
          int waterLevel = analogRead(WATER_SENSOR_ANALOG_PIN);
          Serial.print("W: ");
          Serial.println(waterLevel);
          if (waterLevel != lastWaterLevel) {
            gw.send(msgWater.set(waterLevel));
            lastWaterLevel = waterLevel;
          }
        }
        // Check gas
        if (currentMillis - pMillis_GS >= sCheck_GS){
          pMillis_GS = currentMillis;
      
          int gasLevel = analogRead(GAS_SENSOR_ANALOG_PIN);
          Serial.print("G: ");
          Serial.println(gasLevel);
          if (gasLevel != lastGasLevel) {
            gw.send(msgWater.set(gasLevel));
            lastGasLevel = gasLevel;
          }
        }
      }
      
      posted in My Project
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      I've finally settled on an enclosure design for my first (of 3) clock. This one is for my 10 year old son, I think he's going to love it.

      I originally found this on pintrest....

      fake bomb clock
      Fake bomb clock

      I'm going to use the bomb idea but modify it to fit all my existing design elements.

      I'm currently awaiting some parts from aliexpress and I'm still trying to find materials for the dynamite sticks. Hopefully I'll have everything I need soon so I can start to build it

      posted in OpenHardware.io
      micah
      micah
    • RE: What did you build today (Pictures) ?

      Here is a project I finished this weekend.... 5m LED strip controller (the cover is off for the photo)
      0_1508764628331_IMG_20170317_175657100.jpg

      I think you can say I've come quite far since my first ever arduino build... lol
      0_1508764679200_2016-02-09-21h05m49-[DSC_0001].jpg

      posted in General Discussion
      micah
      micah
    • RE: RGB LED strip

      @maghac Great project.

      I've made something similar, Arduino Pro Mini 5v, 5m LED strip (non-addressable), nrf24L01+ and MOSTFETs

      I know it took me awhile to find code examples, so I figured I would share my code incase it helps anyone else.

      I use Domoticz as a controller. This code talks to:

      • Switch - to control turning my color cycle fade effect on
      • Dimmer - to control the speed of the color cycle fade effect
      • RGB switch - to control having only a single color turned on and the brightness of the string.

      Much of my code is standard stuff, using FastLED analogue, but I'm particularly proud of the brightness part, since I bashed my head against the keyboard several times trying to figure it out

      //## INCLUDES ##
      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_NODE_ID 20
      
      #include <MySensors.h>
      #include <SPI.h>
      #include <FastLED.h>
      
      #define cID_RGB_SELECTOR 0
      #define cID_CYCLE_EFFECT 1
      #define cID_CYCLE_EFFECT_SPEED 2
      
      #define PIN_RED   5
      #define PIN_GREEN 6
      #define PIN_BLUE  3
      
      //## VARIABLES ##
      // MySensors
      #define MySensors_SketchName      "RGB LED Strip"
      #define MySensors_SketchVersion   "v0.3"
      MyMessage MySensors_MSG_Last_Color(cID_RGB_SELECTOR,V_VAR1);
      MyMessage MySensors_MSG_RGB_Selector(cID_RGB_SELECTOR, V_LIGHT);
      MyMessage MySeonsors_MSG_CYCLE_EFFECT(cID_CYCLE_EFFECT, V_LIGHT);
      MyMessage MySensors_MSG_CYCLE_EFFECT_SPEED(cID_CYCLE_EFFECT_SPEED, V_DIMMER);
      bool MySensors_RequestACK = false;
      // Single color
      int Solid_RGB_Active=0;
      char Solid_RGB_Color[] = "000000";
      uint16_t Solid_RGB_Brightness = 0xFF;
      // Cycle effect
      int Cycle_Effect_Active=0;
      unsigned long Cycle_Effect_pMillis = 0;
      long Cycle_Effect_Speed = 20;
      static uint8_t Cycle_Effect_Current_Hue;
      // Supporting
      bool Status_Change = false;
      bool Print_Debug = false;
      
      // ## Primary flow control
      void setup() {
        Serial.begin(115200);
        while (!Serial) ;
        Serial.print("compiled: ");Serial.print(__DATE__);Serial.println(__TIME__);
      
        pinMode(PIN_RED,   OUTPUT);
        pinMode(PIN_GREEN, OUTPUT);
        pinMode(PIN_BLUE,  OUTPUT);
      
        Event_ColorTestBars();
      
        request(cID_RGB_SELECTOR, V_VAR1);
        request(cID_RGB_SELECTOR, V_LIGHT);
        request(cID_CYCLE_EFFECT, V_LIGHT);
        request(cID_CYCLE_EFFECT_SPEED, V_DIMMER);
      }
      void loop() {
        if (Cycle_Effect_Active == 1){
          unsigned long currentMillis = millis();
          Event_RunCycleEffect(currentMillis);
        } else if (Status_Change){
          Status_Change = false;
            #ifdef MY_DEBUG
              if (Print_Debug) {Serial.println("STATUS CHANGE");}
            #endif
          if (Solid_RGB_Active == 0){
            Event_SetLEDColors( CRGB::Black );
          }else if (Solid_RGB_Active == 1){
            CHSV colorHSV = rgb2hsv_approximate(str2CRGB(Solid_RGB_Color));
            Event_SetLEDColors(CHSV(colorHSV.h, colorHSV.s, Solid_RGB_Brightness));
          }
        }
      }
      // ## MySensors Methods
      void presentation()  {
        sendSketchInfo(MySensors_SketchName, MySensors_SketchVersion);
      
        present(cID_RGB_SELECTOR, S_RGB_LIGHT, "RGB Color Selector", MySensors_RequestACK);
        present(cID_CYCLE_EFFECT, S_LIGHT, "RGB Cycle Effect", MySensors_RequestACK);
        present(cID_CYCLE_EFFECT_SPEED, S_DIMMER, "RGB Cycle Effect Speed", MySensors_RequestACK);
      }
      void receive(const MyMessage &message){
        #ifdef MY_DEBUG
          if (message.isAck()){
            Serial.println("Got ack from gateway");
          }
        #endif
        if (message.type == V_LIGHT){
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_light");}
          #endif
          int current_Light_State = message.getString()[0] == '1';// Incoming on/off command sent from controller ("1" or "0")
          if (message.sensor==cID_CYCLE_EFFECT){// is Cycle Message
            if (current_Light_State==1){//turn cycle on
              Event_LightCycle(true, true, false);
              Event_SolidColor(false, false, true);
            } else {//turn cycle off
              Event_LightCycle(false, true, false);
              Event_SolidColor(false, false, true);
            }
          } else if (message.sensor==cID_RGB_SELECTOR){// is RGB Message
            if (current_Light_State==1){//turn RGB on
              Event_SolidColor(true, true, false);
              Event_LightCycle(false, false, true);
            } else {//turn RGB off
              Event_SolidColor(false, true, false);
              Event_LightCycle(false, false, true);
            }
          } else {
            #ifdef MY_DEBUG
              Serial.print("UNKNOWN Light - Message:");
              Serial.print(message.getString());
              Serial.print(" - Sensor:");
              Serial.println(message.sensor);
            #endif
          }
        } else if (message.type == V_RGB){
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_rgb");}
          #endif
          String szMessage=message.getString();
          strcpy(Solid_RGB_Color, getValue(szMessage,'&',0).c_str());
          Solid_RGB_Active = 1;
        }else if (message.type == V_DIMMER) {// if DIMMER type, adjust brightness
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_dimmer");}
          #endif
          if (message.sensor==cID_RGB_SELECTOR){// is single Message
            if (Solid_RGB_Active==1){//turn RGB on
              Event_SolidColor(true, true, false);
              Event_LightCycle(false, false, true);
            } else {//turn RGB off
              Event_SolidColor(false, true, false);
              Event_LightCycle(false, false, true);
            }
            Solid_RGB_Brightness = map(message.getLong(), 0, 100, 0, 255);
            CRGB colorRGB = str2CRGB(Solid_RGB_Color);
            CHSV colorHSV = rgb2hsv_approximate(colorRGB);
            colorHSV = CHSV(colorHSV.h, colorHSV.s, Solid_RGB_Brightness);
            Event_SetLEDColors(colorHSV);
            #ifdef MY_DEBUG
              if (Print_Debug) {
                Serial.print("colorHSV.h:");
                Serial.println(colorHSV.h);
                Serial.print("colorHSV.s:");
                Serial.println(colorHSV.s);
                Serial.print("colorHSV.v:");
                Serial.println(colorHSV.v);
              }
            #endif
            Event_SendLastColor();
          } else if (message.sensor==cID_CYCLE_EFFECT_SPEED){// is Speed dimmer Message
            Cycle_Effect_Speed = map(message.getLong(), 0, 100, 1, 202);
            #ifdef MY_DEBUG
              if (Print_Debug) {
                Serial.print("Cycle_Effect_Speed: ");
                Serial.println(Cycle_Effect_Speed);
              }
            #endif
          }
        }else if (message.type == V_STATUS) {           // if on/off type, toggle brightness
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_status");}
          #endif
          Solid_RGB_Active = message.getInt();
          Cycle_Effect_Active = 0;
          if (Solid_RGB_Active == 0){
            if (Print_Debug) {Serial.println("Strip OFF");}
            Event_SetLEDColors( CRGB::Black );
          }else{
            if (Print_Debug) {Serial.println("Strip ON");}
            Event_SetLEDColors(strtol(Solid_RGB_Color, NULL, 16));
          }
          //Event_SendLastColor();
        }else if (message.type==V_VAR1) {            // color status
          String szMessage=message.getString();
          #ifdef MY_DEBUG
            if (Print_Debug) {
              Serial.println("message v_var1");
              Serial.println(szMessage);
            }
          #endif
          strcpy(Solid_RGB_Color, getValue(szMessage,'&',0).c_str());
          Solid_RGB_Active = 1;
          Cycle_Effect_Active = 0;
        }
        Status_Change = true;
      }
      // ## Events
      void Event_LightCycle(bool t, bool s, bool u) {
        Cycle_Effect_Active = (t) ? 1 : 0;
        if (u){
          send(MySeonsors_MSG_CYCLE_EFFECT.set(Cycle_Effect_Active),MySensors_RequestACK);
        }
      }
      void Event_SolidColor(bool t, bool s, bool u) {
        Solid_RGB_Active = (t) ? 1 : 0;
        if (u){
          send(MySensors_MSG_RGB_Selector.set(Solid_RGB_Active),MySensors_RequestACK);
        }
      }
      void Event_SetLEDColors( const CRGB& rgb){
        analogWrite(PIN_RED,   rgb.r );
        analogWrite(PIN_GREEN, rgb.g );
        analogWrite(PIN_BLUE,  rgb.b );
      }
      void Event_SendLastColor(){
        String current_status=Solid_RGB_Color+String("&")+String(Solid_RGB_Brightness)+String("&")+String(Solid_RGB_Active);
        send(MySensors_MSG_Last_Color.set(current_status.c_str()),MySensors_RequestACK);
      }
      void Event_RunCycleEffect(unsigned long theMills){
        if (theMills - Cycle_Effect_pMillis >= Cycle_Effect_Speed){
          Cycle_Effect_pMillis = theMills;
          Cycle_Effect_Current_Hue = Cycle_Effect_Current_Hue + 1;
          Event_SetLEDColors( CHSV( Cycle_Effect_Current_Hue, 255, 255) );
        }
      }
      void Event_ColorTestBars(){// Event_ColorTestBars: flashes Red, then Green, then Blue, then Black. Helpful for diagnosing if you've mis-wired which is which.
        Event_SetLEDColors( CRGB::Red );   delay(500);
        Event_SetLEDColors( CRGB::Green ); delay(500);
        Event_SetLEDColors( CRGB::Blue );  delay(500);
        Event_SetLEDColors( CRGB::Black ); delay(500);
      }
      // ## Helper Functions
      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]) : "";
      }
      int x2i(char *s) {
        int x = 0;
        for(;;) {
          char c = *s;
          if (c >= '0' && c <= '9') {
            x *= 16;
            x += c - '0';
          }else if (c >= 'A' && c <= 'F') {
            x *= 16;
            x += (c - 'A') + 10;
          }else {
            break;
          }
          s++;
        }
        return x;
      }
      char* str2char(String command){
          if(command.length()!=0){
              char *p = const_cast<char*>(command.c_str());
              return p;
          }
      }
      CRGB str2CRGB(String s){
        String r = str2char(s.substring(0,2));
        String g = str2char(s.substring(2,4));
        String b = str2char(s.substring(4,6));
        uint8_t red = x2i(r.c_str());
        uint8_t green = x2i(g.c_str());
        uint8_t blue = x2i(b.c_str());
        #ifdef MY_DEBUG
          if (Print_Debug) {
            Serial.print("r:");
            Serial.println(r);
            Serial.print("g:");
            Serial.println(g);
            Serial.print("b:");
            Serial.println(b);
            Serial.print("red:");
            Serial.println(red);
            Serial.print("green:");
            Serial.println(green);
            Serial.print("blue:");
            Serial.println(blue);
          }
        #endif
        CRGB colorRGB = CRGB(red, green, blue);
        return colorRGB;
      }
      

      Hopefully this proves useful to someone 🙂

      posted in My Project
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      @hek
      thanks!!!!

      I've got a bunch of other things I want to add to it...

      I'm really excited about adding @petewill 's Bed-Occupancy-Sensor... I've got two kids (and I'm planning on building them both a clock)... and they are at my house 50% of the time... so I want the alarms to go off on school days, but only when they are at my house.

      So I plan on using the bed occupancy sensor to cancel the alarm if no one is in the bed.

      On the flip side, if the kid turns off the alarm, but doesn't get out of bed within a set amount of time, I want the alarm to go off again... kinda like a forced snooze.

      I also want to add an SD card and mini amplifier (LM386) so I can play their favorite song as the wake-up music... but I've got to wait for my aliexpress order of the LM386 to arrive (in 30 to 60 days...lol)

      posted in OpenHardware.io
      micah
      micah
    • Raspberry Pi is frustrating and I wanted to vent

      ERGGGGG!!!!!!!!!

      I spent 5 hours last night trying to get my new Raspberry Pi 2 setup. I don't mean the fancy MySensors integration stuff, I mean literally 5 hours trying to install Raspian!!!!!!

      At this point I'm leaning towards a somehow broken micro SD that I got from AliExpress. I'll probably head to the computer store to buy a new one and try again.

      It's so frustrating to waste so much time on a part or the process that should have been easy.

      I didn't really write this post for help, although that's always welcome, it was more just as a place to vent. When I try and explain this kind of stuff to my friends their eyes just glaze over and they have no idea what I'm talking about.... I think I need to find some new friends who are technologically competent 😛

      Thanks for listening to my complaining, I feel better already 🙂

      posted in General Discussion
      micah
      micah
    • Arduino + Motorcycle

      I'm dying up here in Canada waiting for the real spring to start so I can get my motorcycle out.

      So in the meantime I've been dreaming about the cool arduino things I could do to my bike (although I'm way to busy to ever get around to it).

      I know it's not MySensors related, but I found two really cool arduino + motorcycle projects and I though you guys might enjoy checking them out.

      Arduino Shift Light + Tachometer from Chippernut
      Link to site
      Youtube Link

      Motorcycle Blind-Spot Detection System
      YouTube Link

      posted in General Discussion
      micah
      micah
    • RE: Raspberry Pi is frustrating and I wanted to vent

      SUCCESS!!!!

      My new card worked, and my RPi is up and running. Now I just need to install OpenHAB onto it

      0_1460121223196_DSC_0016.JPG

      posted in General Discussion
      micah
      micah
    • RE: My NRF24 Gateway and Nodes were working fine for 2 days then everything stopped!!!

      @sundberg84 thanks for the tips.

      I just got my "decoupling capacitor of 4.7uF" in the mail today, installed them, and nothing.

      Other than that I've tried everything:

      • Different UNOs
      • Different radios
      • Re-downloaded mysensors dev
      • Using usb cables directly into my Mac
      • Re-uploaded code
      • Tried with just a standard serialgateway script (with proper wiring)
      • The nodes are 1 feet apart

      Here is what my current testbed looks like:

      • Mac > Uno > NRF24L01+ with standard wiring and a 4.7uF (as gateway)
      • Mac > Uno > NRF24L01+ with standard wiring and a 4.7uF (as node)

      First I ran the following on both boards

      #include <EEPROM.h>
      void setup() {
        // initialize the LED pin as an output.
        pinMode(13, OUTPUT);
        for (int i = 0 ; i < EEPROM.length() ; i++) {
          EEPROM.write(i, 0);
        }
        // turn the LED on when we're done
        digitalWrite(13, HIGH);
      }
      void loop() {
      }
      

      Then on the node board I ran the following

      #define MY_CORE_ONLY
      #include <MySensor.h>
      #define NEW_NODE_ID 42 // Change 42 to the new node ID you want
      void setup(){
        Serial.begin(MY_BAUD_RATE);
        Serial.print("Old node ID: ");
        Serial.println(hwReadConfig(EEPROM_NODE_ID_ADDRESS));
        Serial.println("Writing new ID");
        hwWriteConfig(EEPROM_NODE_ID_ADDRESS, NEW_NODE_ID);
        Serial.print("New node ID: ");
        Serial.println(hwReadConfig(EEPROM_NODE_ID_ADDRESS));
      }
      void loop(){
      }
      

      Then I loaded the standard serialgateway code from the 2.0 dev branch which I downloaded yesterday

      #define MY_DEBUG 
      #define MY_RADIO_NRF24
      #define MY_RF24_PA_LEVEL RF24_PA_LOW
      #define MY_GATEWAY_SERIAL
      #define MY_LEDS_BLINKING_FEATURE
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      #define MY_INCLUSION_MODE_FEATURE
      #define MY_INCLUSION_BUTTON_FEATURE
      #define MY_INCLUSION_MODE_DURATION 60 
      #define MY_INCLUSION_MODE_BUTTON_PIN  3 
      #include <SPI.h>
      #include <MySensor.h>  
      void setup() { 
      }
      void presentation() {
      }
      void loop() { 
      }
      

      Then I loaded this test script onto the node

      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #include <SPI.h>
      #include <MySensor.h>  
      #include <DHT.h>  
      #define CHILD_ID_TEMP 1
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      void setup(){ 
      }
      void presentation(){ 
        sendSketchInfo("TEST - Fake Temp", "0.1");
        present(CHILD_ID_TEMP, S_TEMP);
      }
      void loop(){
        send(msgTemp.set(20, 1));
        delay(500);
      }
      

      and here is my result
      Gateway Serial

      0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
      0;255;3;0;9;Radio init successful.
      0;255;3;0;14;Gateway startup complete.
      0;255;3;0;9;Init complete, id=0, parent=0, distance=0
      0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
      42;1;1;0;0;20.0
      0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
      42;1;1;0;0;20.0
      0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
      42;1;1;0;0;20.0
      0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
      42;1;1;0;0;20.0
      0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
      42;1;1;0;0;20.0
      0;255;3;0;9;read and forward: 42-42-255 s=255,c=3,t=7,pt=0,l=0,sg=0
      0;255;3;0;9;send: 0-0-42-42 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0
      

      Node Serial

      Starting sensor (RNNNA-, 2.0.0-beta)
      Radio init successful.
      send: 42-42-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=fail:
      send: 42-42-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=fail:2.0.0-beta
      send: 42-42-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
      send: 42-42-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=fail:TEST - Fake Temp
      send: 42-42-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:0.1
      send: 42-42-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=fail:
      find parent
      send: 42-42-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
      Init complete, id=42, parent=0, distance=255
      send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
      send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
      send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
      send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
      send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
      send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
      find parent
      send: 42-42-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
      

      I'm stumped

      Is there anything else that could be causing it, or that I could try.

      I doubt this is relevant but the only thing that changed the evening that it broke was that I brought home a new iPhone.... I'm sure it's not relevant but thought I should mention it.

      Also I just ran across this post http://forum.mysensors.org/topic/3608/issues-with-setting-up-my-arduino-nano-serialgateway and thing that it sounds very similar to my issue.

      posted in Troubleshooting
      micah
      micah
    • RE: Step-by-step procedure to connect the NRF24L01+ to the GPIO pins and use the Raspberry as a Serial Gateway (MySensors 1.x)

      @mfalkvidd said:

      I'm unfortunately at about the same level as you. I can compile stuff and do basic troubleshooting, but merging the dev branch with the gateway code is way out of my league.

      There is no way you are at 3.275% knowledge like me... I've seen many of your posts on here and you are at least a 4.532%... lol.... no honestly I've liked your posts and you seem very knowledgeable. You've got to be at least a 84.5% 😉

      posted in Hardware
      micah
      micah

    Latest posts made by micah

    • RE: 💬 Smart Alarm Clock

      Another thing that I've thought of is removing the RTC module completely since we can query the time from the server periodically.

      This would save components and pins, but it would limit the clock to only working with the controller, whereas the current design allows it to run independently

      posted in OpenHardware.io
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      The method Check_KeyPad (Line 300) handles the buttons.
      Currently my buttons do the following

      • show/program alarm
      • hour
      • minute
      • turn alarm on and off
      • turn on or off nightlight
      posted in OpenHardware.io
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      @dbemowsk
      To use a 24 hour clock switch the following bool

      bool Screen_HourFormat24 = false;
      

      I think I used the colon to signify that an alarm was set, I think I flashed it on and off. in the Update_Screen method

         if ((Alarm1_Enabled) && (!Keys_ShowAlarmOnScreen)){
            if(Screen_ClockPoint)ledScreen.point(POINT_ON);
            else ledScreen.point(POINT_OFF);
          } else
            ledScreen.point(POINT_ON);
      
      posted in OpenHardware.io
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      I often wish our fancy mysensor nRF chips only used 1 arduino wire 😞

      posted in OpenHardware.io
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      I found a library online.... #include <AnalogMatrixKeypad.h>

      I made some modifications (although I can't quite remember what they were), I think about the number of buttons, or combinations, or target values.

      But generally the library provided the 1 wire, resistor ladder and debouncing functionality I needed

      posted in OpenHardware.io
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      @Nca78
      exactly correct.

      I originally went with the same resistor value so that it was easy. But then when I thought about how many button combinations I wanted (thinking about a real clock where you hold down the alarm set button then press the hour button) I went with different values.

      My implementation still isn't perfect, since I'm a bloody amateur... lol. I think 1 or 2 of the combinations I never got working.

      But for the most part it accomplished what I wanted... provided many buttons and combinations on a single input pin, since I was quickly running out of them

      posted in OpenHardware.io
      micah
      micah
    • RE: What did you build today (Pictures) ?

      Here is a project I finished this weekend.... 5m LED strip controller (the cover is off for the photo)
      0_1508764628331_IMG_20170317_175657100.jpg

      I think you can say I've come quite far since my first ever arduino build... lol
      0_1508764679200_2016-02-09-21h05m49-[DSC_0001].jpg

      posted in General Discussion
      micah
      micah
    • RE: RGB LED strip

      Here is a photo of my actual device with the cover off

      0_1508763006582_IMG_20170317_175657100.jpg

      posted in My Project
      micah
      micah
    • RE: RGB LED strip

      @maghac Great project.

      I've made something similar, Arduino Pro Mini 5v, 5m LED strip (non-addressable), nrf24L01+ and MOSTFETs

      I know it took me awhile to find code examples, so I figured I would share my code incase it helps anyone else.

      I use Domoticz as a controller. This code talks to:

      • Switch - to control turning my color cycle fade effect on
      • Dimmer - to control the speed of the color cycle fade effect
      • RGB switch - to control having only a single color turned on and the brightness of the string.

      Much of my code is standard stuff, using FastLED analogue, but I'm particularly proud of the brightness part, since I bashed my head against the keyboard several times trying to figure it out

      //## INCLUDES ##
      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_NODE_ID 20
      
      #include <MySensors.h>
      #include <SPI.h>
      #include <FastLED.h>
      
      #define cID_RGB_SELECTOR 0
      #define cID_CYCLE_EFFECT 1
      #define cID_CYCLE_EFFECT_SPEED 2
      
      #define PIN_RED   5
      #define PIN_GREEN 6
      #define PIN_BLUE  3
      
      //## VARIABLES ##
      // MySensors
      #define MySensors_SketchName      "RGB LED Strip"
      #define MySensors_SketchVersion   "v0.3"
      MyMessage MySensors_MSG_Last_Color(cID_RGB_SELECTOR,V_VAR1);
      MyMessage MySensors_MSG_RGB_Selector(cID_RGB_SELECTOR, V_LIGHT);
      MyMessage MySeonsors_MSG_CYCLE_EFFECT(cID_CYCLE_EFFECT, V_LIGHT);
      MyMessage MySensors_MSG_CYCLE_EFFECT_SPEED(cID_CYCLE_EFFECT_SPEED, V_DIMMER);
      bool MySensors_RequestACK = false;
      // Single color
      int Solid_RGB_Active=0;
      char Solid_RGB_Color[] = "000000";
      uint16_t Solid_RGB_Brightness = 0xFF;
      // Cycle effect
      int Cycle_Effect_Active=0;
      unsigned long Cycle_Effect_pMillis = 0;
      long Cycle_Effect_Speed = 20;
      static uint8_t Cycle_Effect_Current_Hue;
      // Supporting
      bool Status_Change = false;
      bool Print_Debug = false;
      
      // ## Primary flow control
      void setup() {
        Serial.begin(115200);
        while (!Serial) ;
        Serial.print("compiled: ");Serial.print(__DATE__);Serial.println(__TIME__);
      
        pinMode(PIN_RED,   OUTPUT);
        pinMode(PIN_GREEN, OUTPUT);
        pinMode(PIN_BLUE,  OUTPUT);
      
        Event_ColorTestBars();
      
        request(cID_RGB_SELECTOR, V_VAR1);
        request(cID_RGB_SELECTOR, V_LIGHT);
        request(cID_CYCLE_EFFECT, V_LIGHT);
        request(cID_CYCLE_EFFECT_SPEED, V_DIMMER);
      }
      void loop() {
        if (Cycle_Effect_Active == 1){
          unsigned long currentMillis = millis();
          Event_RunCycleEffect(currentMillis);
        } else if (Status_Change){
          Status_Change = false;
            #ifdef MY_DEBUG
              if (Print_Debug) {Serial.println("STATUS CHANGE");}
            #endif
          if (Solid_RGB_Active == 0){
            Event_SetLEDColors( CRGB::Black );
          }else if (Solid_RGB_Active == 1){
            CHSV colorHSV = rgb2hsv_approximate(str2CRGB(Solid_RGB_Color));
            Event_SetLEDColors(CHSV(colorHSV.h, colorHSV.s, Solid_RGB_Brightness));
          }
        }
      }
      // ## MySensors Methods
      void presentation()  {
        sendSketchInfo(MySensors_SketchName, MySensors_SketchVersion);
      
        present(cID_RGB_SELECTOR, S_RGB_LIGHT, "RGB Color Selector", MySensors_RequestACK);
        present(cID_CYCLE_EFFECT, S_LIGHT, "RGB Cycle Effect", MySensors_RequestACK);
        present(cID_CYCLE_EFFECT_SPEED, S_DIMMER, "RGB Cycle Effect Speed", MySensors_RequestACK);
      }
      void receive(const MyMessage &message){
        #ifdef MY_DEBUG
          if (message.isAck()){
            Serial.println("Got ack from gateway");
          }
        #endif
        if (message.type == V_LIGHT){
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_light");}
          #endif
          int current_Light_State = message.getString()[0] == '1';// Incoming on/off command sent from controller ("1" or "0")
          if (message.sensor==cID_CYCLE_EFFECT){// is Cycle Message
            if (current_Light_State==1){//turn cycle on
              Event_LightCycle(true, true, false);
              Event_SolidColor(false, false, true);
            } else {//turn cycle off
              Event_LightCycle(false, true, false);
              Event_SolidColor(false, false, true);
            }
          } else if (message.sensor==cID_RGB_SELECTOR){// is RGB Message
            if (current_Light_State==1){//turn RGB on
              Event_SolidColor(true, true, false);
              Event_LightCycle(false, false, true);
            } else {//turn RGB off
              Event_SolidColor(false, true, false);
              Event_LightCycle(false, false, true);
            }
          } else {
            #ifdef MY_DEBUG
              Serial.print("UNKNOWN Light - Message:");
              Serial.print(message.getString());
              Serial.print(" - Sensor:");
              Serial.println(message.sensor);
            #endif
          }
        } else if (message.type == V_RGB){
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_rgb");}
          #endif
          String szMessage=message.getString();
          strcpy(Solid_RGB_Color, getValue(szMessage,'&',0).c_str());
          Solid_RGB_Active = 1;
        }else if (message.type == V_DIMMER) {// if DIMMER type, adjust brightness
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_dimmer");}
          #endif
          if (message.sensor==cID_RGB_SELECTOR){// is single Message
            if (Solid_RGB_Active==1){//turn RGB on
              Event_SolidColor(true, true, false);
              Event_LightCycle(false, false, true);
            } else {//turn RGB off
              Event_SolidColor(false, true, false);
              Event_LightCycle(false, false, true);
            }
            Solid_RGB_Brightness = map(message.getLong(), 0, 100, 0, 255);
            CRGB colorRGB = str2CRGB(Solid_RGB_Color);
            CHSV colorHSV = rgb2hsv_approximate(colorRGB);
            colorHSV = CHSV(colorHSV.h, colorHSV.s, Solid_RGB_Brightness);
            Event_SetLEDColors(colorHSV);
            #ifdef MY_DEBUG
              if (Print_Debug) {
                Serial.print("colorHSV.h:");
                Serial.println(colorHSV.h);
                Serial.print("colorHSV.s:");
                Serial.println(colorHSV.s);
                Serial.print("colorHSV.v:");
                Serial.println(colorHSV.v);
              }
            #endif
            Event_SendLastColor();
          } else if (message.sensor==cID_CYCLE_EFFECT_SPEED){// is Speed dimmer Message
            Cycle_Effect_Speed = map(message.getLong(), 0, 100, 1, 202);
            #ifdef MY_DEBUG
              if (Print_Debug) {
                Serial.print("Cycle_Effect_Speed: ");
                Serial.println(Cycle_Effect_Speed);
              }
            #endif
          }
        }else if (message.type == V_STATUS) {           // if on/off type, toggle brightness
          #ifdef MY_DEBUG
            if (Print_Debug) {Serial.println("message v_status");}
          #endif
          Solid_RGB_Active = message.getInt();
          Cycle_Effect_Active = 0;
          if (Solid_RGB_Active == 0){
            if (Print_Debug) {Serial.println("Strip OFF");}
            Event_SetLEDColors( CRGB::Black );
          }else{
            if (Print_Debug) {Serial.println("Strip ON");}
            Event_SetLEDColors(strtol(Solid_RGB_Color, NULL, 16));
          }
          //Event_SendLastColor();
        }else if (message.type==V_VAR1) {            // color status
          String szMessage=message.getString();
          #ifdef MY_DEBUG
            if (Print_Debug) {
              Serial.println("message v_var1");
              Serial.println(szMessage);
            }
          #endif
          strcpy(Solid_RGB_Color, getValue(szMessage,'&',0).c_str());
          Solid_RGB_Active = 1;
          Cycle_Effect_Active = 0;
        }
        Status_Change = true;
      }
      // ## Events
      void Event_LightCycle(bool t, bool s, bool u) {
        Cycle_Effect_Active = (t) ? 1 : 0;
        if (u){
          send(MySeonsors_MSG_CYCLE_EFFECT.set(Cycle_Effect_Active),MySensors_RequestACK);
        }
      }
      void Event_SolidColor(bool t, bool s, bool u) {
        Solid_RGB_Active = (t) ? 1 : 0;
        if (u){
          send(MySensors_MSG_RGB_Selector.set(Solid_RGB_Active),MySensors_RequestACK);
        }
      }
      void Event_SetLEDColors( const CRGB& rgb){
        analogWrite(PIN_RED,   rgb.r );
        analogWrite(PIN_GREEN, rgb.g );
        analogWrite(PIN_BLUE,  rgb.b );
      }
      void Event_SendLastColor(){
        String current_status=Solid_RGB_Color+String("&")+String(Solid_RGB_Brightness)+String("&")+String(Solid_RGB_Active);
        send(MySensors_MSG_Last_Color.set(current_status.c_str()),MySensors_RequestACK);
      }
      void Event_RunCycleEffect(unsigned long theMills){
        if (theMills - Cycle_Effect_pMillis >= Cycle_Effect_Speed){
          Cycle_Effect_pMillis = theMills;
          Cycle_Effect_Current_Hue = Cycle_Effect_Current_Hue + 1;
          Event_SetLEDColors( CHSV( Cycle_Effect_Current_Hue, 255, 255) );
        }
      }
      void Event_ColorTestBars(){// Event_ColorTestBars: flashes Red, then Green, then Blue, then Black. Helpful for diagnosing if you've mis-wired which is which.
        Event_SetLEDColors( CRGB::Red );   delay(500);
        Event_SetLEDColors( CRGB::Green ); delay(500);
        Event_SetLEDColors( CRGB::Blue );  delay(500);
        Event_SetLEDColors( CRGB::Black ); delay(500);
      }
      // ## Helper Functions
      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]) : "";
      }
      int x2i(char *s) {
        int x = 0;
        for(;;) {
          char c = *s;
          if (c >= '0' && c <= '9') {
            x *= 16;
            x += c - '0';
          }else if (c >= 'A' && c <= 'F') {
            x *= 16;
            x += (c - 'A') + 10;
          }else {
            break;
          }
          s++;
        }
        return x;
      }
      char* str2char(String command){
          if(command.length()!=0){
              char *p = const_cast<char*>(command.c_str());
              return p;
          }
      }
      CRGB str2CRGB(String s){
        String r = str2char(s.substring(0,2));
        String g = str2char(s.substring(2,4));
        String b = str2char(s.substring(4,6));
        uint8_t red = x2i(r.c_str());
        uint8_t green = x2i(g.c_str());
        uint8_t blue = x2i(b.c_str());
        #ifdef MY_DEBUG
          if (Print_Debug) {
            Serial.print("r:");
            Serial.println(r);
            Serial.print("g:");
            Serial.println(g);
            Serial.print("b:");
            Serial.println(b);
            Serial.print("red:");
            Serial.println(red);
            Serial.print("green:");
            Serial.println(green);
            Serial.print("blue:");
            Serial.println(blue);
          }
        #endif
        CRGB colorRGB = CRGB(red, green, blue);
        return colorRGB;
      }
      

      Hopefully this proves useful to someone 🙂

      posted in My Project
      micah
      micah
    • RE: 💬 Smart Alarm Clock

      Hey everyone.

      Sorry, had a computer crash and file loss issue a few months ago.

      I can't find my final code file, but I did find an older version (incomplete) called ClockRebuild.ino and I uploaded it to the project.

      Hopefully that helps

      One day I'll come back and truly finish this project, life just keeps getting in the way

      posted in OpenHardware.io
      micah
      micah