Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
BulldogLowellB

BulldogLowell

@BulldogLowell
Contest Winner
About
Posts
814
Topics
29
Shares
0
Groups
1
Followers
9
Following
1

Posts

Recent Best Controversial

  • Battery percentage on door contact sensor erratic (sent on interrupt)
    BulldogLowellB BulldogLowell

    As the analog pins share a single A2D, rapid use of it can cause the previous read to impact the next. A common workaround in this situation is to read twice on each input, ignoring the first.

    try that:

    // read analog pin
      (void) analogRead(BATTERY_SENSE_PIN);
      int sensorValue = analogRead(BATTERY_SENSE_PIN);
      // calculate battery voltage
      float vBat  = static_cast<float>(sensorValue * (V_MAX/1023));
    
    Development

  • What did you build today (Pictures) ?
    BulldogLowellB BulldogLowell

    @dbemowsk said in What did you build today (Pictures) ?:

    Seeing the falling stars at the end of the Adafruit test code made me think of rain or snow falling. Something like that might go outside the limits of the pro minis memory, but hey, never hurts to try.

    Hey Nice Work!

    I see you are using I2C, vs SPI... that may be why your display is so much slower than the demo in the Adafruit video.

    Can't wait to see the final board!

    General Discussion

  • Using object from another file
    BulldogLowellB BulldogLowell

    @mfalkvidd said in Using object from another file:

    @BulldogLowell I was hoping to avoid including ArduinoLog in all .h files, but there seems to be no way around that.

    what's the problem with adding the #include directive? It is a dependency by definition....

    Development

  • Using object from another file
    BulldogLowellB BulldogLowell

    Where is Log declared?

    it is a global and defined in the CPP file for the Logging class:

    Logging Log = Logging();
    

    so, if it is Global... why the heck can't it be accessed in the Configuration class? Well each set of files is a different translation unit...

    Have you tried adding

    #include <ArduinoLog.h>
    

    in your

    "Configuration.h"
    

    class?

    Development

  • No luck with ethernet Gateway
    BulldogLowellB BulldogLowell

    @gohan said in No luck with ethernet Gateway:

    Try latest mysensors development library, then if problem persists try a different UNO or downgrade boards definitions to 1.6.11 or 1.6.13 and see if it still has problems. Did you try to remove code for each of the sensors at a time in order to figure out if it's a specific sensor?

    take heed to this advice... did you modify the boards definition in your Arduino IDE?

    Troubleshooting

  • Why text-based communication???
    BulldogLowellB BulldogLowell

    @4Project said in Why text-based communication???:

    Does that mean all the communication is always destined/sourced to/from the controller?

    I think that is explained in the network topology.

    If you want to send a message node-to-node, you could try to manage it through your gateway or a repeater.

    Development

  • 3G Serial Bridge for Vera
    BulldogLowellB BulldogLowell

    I wanted to share a project that I did for my Vera using the Particle Electron and a Nano... I think that the MySensors skill set transfers to Particle, so I'm hopeful some of you brave souls may try to pull this off!

    It is all documented here on my Git Repo. Ideas, suggestions and contributions welcome!

    0_1505768172165_VeraMainPanel.png

    0_1505768093992_VeraControlPanel.png

    0_1505768135162_ThreeGeeRocks.png

    I have a vacation home that I use Vera to control events. I, like a lot of other folks, have been a victim of:

    1. Power is out and I don't know.... I only find out when I try to log on :angry:
    2. Vera is stalled, likewise, I only find out when I try to log on
    3. I've lost my connection the the internet. Again, how do I know that this happened? :confused:

    I've recently developed a device (hardware & . Software) that allows me to detect all of these very difficult-to-detect events, for example:

    My Device lost Internet connectivity
    In this case, the device will detect the loss of internet and send a message via 3G network, circumventing the "How do I send a message if my Internet is down" paradox.

    My device (or home) has lost power
    In this case, the device will repeatedly remind me at a fixed interval until power is restored. The device has a LiPo battery which can send messages for days, even if there is no power.

    My Vera 3G gateway is not communicating with Vera
    If this happens you can create a notification which Vera can send

    My Vera is inactive, stalled or otherwise not properly functioning.
    When this happens, the 3G gateway can automatically power-cycle my Vera after some user-defined period of inactivity. (coming soon)

    The device can send SMS messages (during events as above or ad hoc by creating your own events using scenes or PLEG) or similarly use a service like Pushover to send a notification to any mobile (or desktop). I'm using Pushover direct to my Mobile device.

    I've developed a plugin that enables a new device to be set up in minutes.

    With such a configuration, I am using a 3G SIM/plan that costs $3.00 per month... about the cost of a cup of coffee. But you can use any SIM/plan you like.

    While I built mine on my own, because of the low operating cost, I realized that others may have an interest in building such a device. I was considering developing a PCB and providing a list of all the components necessary to build a device. I may even design a 3D printable case if there is enough interest.

    So, I'm looking to see if there is any interest and based on that, provide (sell) a kit that anyone can use. So, if you have an interest please let me know by responding to this post. If you are great at PCB dev, then even better, I can use your help!

    It is cool... and just what many of forum participants have been asking for.

    My Project

  • SoCal help completing a MySensor system
    BulldogLowellB BulldogLowell

    @ensbusiness said in SoCal help completing a MySensor system:

    Then I try adding a wireless sensor using the libraries from MySensor for the Atmega328P Pro-mini's and nRF2401's I already decided to use even before I found MySensors. The problem is that I can't seem to get the Pro-mini/nRF2401 combinations to send any usable data at all, either between two test units, let alone back to a Pi

    I think you are missing the point... you won't be sending messages peer-to-peer with my sensors. Rather, each sensor communicates through the gateway.

    @ensbusiness said in SoCal help completing a MySensor system:

    Adding a sensor to the Pi is what I already have up and running. I don't need or use a Controller for that.

    Again, focus on the radio bits first and forget about your Pi connected sensor for now.

    Read the docs... and wire up the gateway and a sensor exactly like the docs explain for the Pi gateway. Then, post some photos of your rig and the exact code you are using.

    General Discussion

  • SoCal help completing a MySensor system
    BulldogLowellB BulldogLowell

    @ensbusiness

    I'm not sure you understand.

    Build the Raspberry Pi gateway, and then a single sensor. Get that working, the very clear instructions are in the MySensors docs...

    The rest (adding additional wireless nodes or connecting a sensor to your Pi) is trivial.

    General Discussion

  • SoCal help completing a MySensor system
    BulldogLowellB BulldogLowell

    @ensbusiness

    Have you started with the Raspberry Pi Gateway?

    that should be relatively easy... get your gateway working with one sensor first, and forget about the attached sensors for the time being.

    General Discussion

  • SoCal help completing a MySensor system
    BulldogLowellB BulldogLowell

    @ensbusiness

    What kind of help do you need? Are you looking for someone to help you program sensors, or are you looking for someone to program a gateway? Perhaps you can provide a little more detail.

    General Discussion

  • VH400 Moisture sensor question
    BulldogLowellB BulldogLowell

    @Rhoditis said in VH400 Moisture sensor question:

    The reading of the sensor is perfectly stable but while monitoring it, it seems that the reading on the voltmeter sticks to a value until a significant change in value is reached.

    Probably some hysteresis programming in the volt meter...

    did you try to monitor the voltage with your arduino sensor yet?

    Hardware

  • 💬 Relay
    BulldogLowellB BulldogLowell

    @amemo06

    I only wanted to raise the fact void receive(const MyMessage &message) may lead to trouble as 'message' content may change during processing of that function.

    As I already explained... message cannot change during the function, because of constness.

    The message handler is being called again from within itself (i.e. from wait()). You would then processing any new messages on that call. It looks as if the function may not be designed to perform recursively as you are trying to do in your code, so that would explain your unexpected/undefined results.

    So yes, block during the relay's holding state or use another non-blocking method (i.e. flag or timer/callback) as you mentioned. Fully process each message before allowing the library to handle subsequent message calls.

    ;)

    Announcements

  • 💬 Relay
    BulldogLowellB BulldogLowell

    @amemo06

    You should treat the message like an ISR... get in and out so that you don't have another message colliding while you are in the function.

    Get rid of that wait(). I couldn't find the source for that function but you could try to just use delay() to block while you hold the relay.

    otherwise just set a flag to handle the relay event in loop() or use a Timer/callback like the MsTimer2 Library

    example:

    #include <MsTimer2.h>
    
    const byte onButton = 5;
    
    void setup()
    {
      Serial.begin(9600);
      pinMode(13, OUTPUT);
      pinMode(onButton, INPUT_PULLUP);
    }
    
    void loop()
    {
      if(onButtonPressed())
      {
       flashLedThirteen(5000);
      }
    }
    
    bool onButtonPressed(void)
    {
      static unsigned long lastMillis = 0;
      static byte lastPress = HIGH;
      byte currentPress = digitalRead(onButton);
      if(currentPress != lastPress)
      {
        if(millis() - lastMillis < 200) return false;
        lastPress = currentPress;
        if(currentPress == LOW)
        {
          Serial.println(" button press detected!");
          lastMillis = millis();
          return true;
        }
      }
      return false;
    }
    
    void flashLedThirteen(int ledTime)
    {
      digitalWrite(13, HIGH);
      Serial.println("LED ON");
      // sets a new timer callback function
      MsTimer2::set(ledTime, [] {  // the square brackets define the start of the anonymous callback function which is executed after 5000 milliseconds in this example
        digitalWrite(13, LOW);
        Serial.println("Timer expired...");
        Serial.println("LED OFF");
        MsTimer2::stop();
      }); // the curly brace defines the end of the anonymous callback function
      MsTimer2::start();
    }
    
    Announcements

  • 💬 Relay
    BulldogLowellB BulldogLowell

    @amemo06

    void receive(const MyMessage &message)
    

    Because of the const keyword this is a const reference or said another way, a reference to a constant. The const keyword guarantees that the function may not change the object.

    So, I wonder what your real issue is....

    Announcements

  • Relay with button wihtout ackn from controller
    BulldogLowellB BulldogLowell

    @Markus.

    I think that is how your original sketch works!

    Unless the gateway isn't functioning.

    You can always leave the function in both places.

    Troubleshooting

  • Relay with button wihtout ackn from controller
    BulldogLowellB BulldogLowell

    @Markus. said in Relay with button wihtout ackn from controller:

    How can i get this working without to wait for the Controllers ack ?

    right now, the device

    1. waits for a button press
    2. sends a message to your controller with the new state
    3. waits for the message type (V_LIGHT) to acknowledge the state change and updates the relay

    if you want to change the state of the relay on the button press (isn't clear to me that you want to do that) you need to move:

    digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
    

    inside the button press state change event:

    if (value != oldValue && value==0) 
    {
      send(msg.set(state?false:true), true); // Send new state and request ack back
      digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF);
    }
    

    this would allow you to update the relay regardless of the connection to the gateway.

    Troubleshooting

  • Adding 4th dimmer. Struggle.
    BulldogLowellB BulldogLowell

    I can't test this but something like:

    #define SN "Four Fader Test"
    #define SV "0.1a"
    
    #define NUMBER_OF_DIMMERS 4
    
    //System settings
    #define MY_RADIO_NRF24
    #define MY_RF24_CE_PIN 8 //ADDED
    #define MY_NODE_ID 71
    
    #include <MySensors.h>
    #include <SPI.h>
    #include "Fade.h"
    
    MyMessage dimmer[NUMBER_OF_DIMMERS];
    MyMessage light[NUMBER_OF_DIMMERS];
    
    Fade fader[NUMBER_OF_DIMMERS];
    byte leds[NUMBER_OF_DIMMERS] = {3, 5, 6, 9};
    
    void before()
    {
      int i = 0;
      for (auto fdr : fader)
      {
        fdr = Fade(leds[i++], 10, 0, 255, MILLIS_TIMER); // led speed 5 milliseconds/step; pwm at 0 min and 255 max  (MILLIS_TIMER)
        fdr.begin();
      }
      i = 0;
      for (auto msg : dimmer)
        msg = MyMessage(i++, S_DIMMER);
      i = 0;
      for (auto msg : light)
        msg = MyMessage(i++, S_BINARY);
    }
    void presentation()
    {
      sendSketchInfo(SN, SV);
      int i = 0;
      for (auto d : dimmer)
        present(i++, S_DIMMER);
    }
    
    void setup()
    {
      Serial.begin(9600);
      Serial.println(F("Setup Complete..."));
    }
    
    void loop()
    {
      uint32_t currentMillis = millis();
      for (auto fdr : fader)
        fdr.update(currentMillis);
    }
    
    void receive(const MyMessage &message)
    {
      if (message.type == V_STATUS || message.type == V_PERCENTAGE)
      {
        int requestedLevel = atoi(message.data);
        if (message.type == V_STATUS)
          requestedLevel = requestedLevel ? 100 : 0;
        else
          requestedLevel = constrain(requestedLevel, 0, 100);
        fader[message.sensor].setTarget(map(requestedLevel, 0, 100, 0, 255));
        send(light[message.sensor].set(requestedLevel > 0 ? 1 : 0));
        send(dimmer[message.sensor].set(requestedLevel));
      }
    }
    

    I used my non-blocking Fade.h:

    #ifndef Fade_h
    #define Fade_h
    
    #include <Arduino.h>
    
    enum timer{
      MILLIS_TIMER, 
      MICROS_TIMER
    };
    
    class Fade
    {
      public:
        Fade() {};
        Fade(int pin, uint32_t timeStep = 15, uint8_t minVal = 0, uint8_t maxVal = 255, timer timerSelect = MILLIS_TIMER);
        void begin(); 
        void setTarget(int to);
        void update();
        void update(uint32_t time);
        uint8_t getMin();
        uint8_t getMax();
        uint8_t getCurrent();
        uint32_t readSpeed();
        uint32_t writeSpeed(uint32_t time);
        uint8_t getSetpoint();
      private:
        uint8_t _min;
        uint8_t _max;
        uint8_t _targetFade;
        uint8_t _pwmRate;
        uint32_t _time;
        uint32_t _last;
        uint8_t _pin;
        bool _microsTimer;
    };
    
    #endif
    

    and my Fade.cpp:

    
    #include "Fade.h"
    #include <Arduino.h>
    
    Fade::Fade(int pin, uint32_t timeStep, uint8_t minVal, uint8_t maxVal, timer timerSelect)
    {
      _pin = pin;
      _time = timeStep;
      _min = minVal;
      _max = maxVal;
      analogWrite(_pin, _min);
      _pwmRate = _min;
      _microsTimer = timerSelect;
    }
    
    void Fade::begin()
    {
      analogWrite(_pin, _min);
    }
    
    void Fade::setTarget(int to)
    {
      _targetFade = (uint8_t) constrain(to, _min, _max);
    
      this->update();
    }
    
    void Fade::update()
    {
      this->update(_microsTimer? micros() : millis());
    }
    
    void Fade::update(uint32_t time)
    {
      if (time - _time > _last)
      {
        _last = time;
        if (_pwmRate > _targetFade) analogWrite(_pin, --_pwmRate);
        if (_pwmRate < _targetFade) analogWrite(_pin, ++_pwmRate);
      }
    }
    
    uint8_t Fade::getSetpoint()
    {
      return _targetFade;
    }
    
    uint8_t Fade::getCurrent()
    {
      return _pwmRate;
    }
    
    uint32_t Fade::readSpeed()
    {
      return _time;
    }
    
    uint32_t Fade::writeSpeed(uint32_t time)
    {
      _time = time;
    }
    
    uint8_t Fade::getMin()
    {
      return _min;
    }
    
    uint8_t Fade::getMax()
    {
      return _max;
    }
    
    
    Troubleshooting

  • Adding 4th dimmer. Struggle.
    BulldogLowellB BulldogLowell

    @rejoe2 said in Adding 4th dimmer. Struggle.:

    I completely agree with @BulldogLowell : Better use arrays for nodes like yours. Good example: https://forum.mysensors.org/topic/4847/multi-button-relay-sketch/33#

    and I don't like the blocking nature of the fading. that should be refactored.

    plus, the fyi the Bounce2 library has another constructor which sets pinMode...
    instead of this:

      pinMode(BUTTON_PIN1,INPUT);
      digitalWrite(BUTTON_PIN1, HIGH);
    
    //...
    debouncer_1.attach(BUTTON_PIN1);
      debouncer_1.interval(5);
    

    just this:

    debouncer_1.attach(BUTTON_PIN1, INPUT_PULLUP);
    debouncer_1.interval(5);
    

    i'll post an alternative if I get the chance...

    Troubleshooting

  • Adding 4th dimmer. Struggle.
    BulldogLowellB BulldogLowell

    @moskovskiy82

    Sorry, I meant that your code could be extremely simplified by using arrays.

    Yours is a good example of how it is much harder to refactor in the case (like yours) where you simply need to add one more of some object.

    things like this can be problematic:

    #define DIMMER_NODE_1 0
    #define DIMMER_NODE_2 1
    #define DIMMER_NODE_3 2
    #define DIMMER_NODE_4 3 //ADDED
    

    where 1 = 0, 2 = 1, etc.... it is not very intuitive

    I cannot find the problem in your code... are you sure you are wired up correctly?

    Troubleshooting
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular