Navigation

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

    Daniel Oliveira

    @Daniel Oliveira

    16
    Reputation
    48
    Posts
    1251
    Profile views
    1
    Followers
    9
    Following
    Joined Last Online
    Location Switzerland

    Daniel Oliveira Follow

    Best posts made by Daniel Oliveira

    • RE: [solved] MySensorWrapper - Wrapping sensor libraries for MySensors 2.0.x - need help

      Hi!

      I accomplish to do what I wanted thanks to the help of you all, so I'm sharing the results 🙂

      I ended up with this very simple MySensorGeneric.ino that is able to manage a DHT and a BH1750

      /**
      * Name:		MySensorGeneric.ino
      * Created:	20-Aug-16 22:47:51
      * Author:	Daniel
      *
      *******************************
      *
      * REVISION HISTORY
      * Version 0.1 - Development
      *
      */
      
      #include "MySensorConfig.h"
      #include <MySensors.h>
      
      #include "MySensorWrapperDHT.h"
      #include "MySensorWrapperBH1750.h"
      
      #define CHILD_ID_LIGHT 2
      #define CHILD_ID_TEMP  1
      #define CHILD_ID_HUM   0
      #define HUMIDITY_SENSOR_DIGITAL_PIN 3
      
      MySensorWrapperBH1750 SensorBH1750(CHILD_ID_LIGHT);
      MySensorWrapperDHT    SensorDHT(CHILD_ID_TEMP, CHILD_ID_HUM, HUMIDITY_SENSOR_DIGITAL_PIN);
      
      void setup()
      {
        SensorBH1750.Setup();
        SensorDHT.Setup();
      }
      
      void presentation() {
        sendSketchInfo("My Generic Sensor", "0.11");
        SensorBH1750.Present();
        SensorDHT.Present();
      }
      
      void loop()
      {
        SensorBH1750.UpdateSensorValue();
        SensorDHT.UpdateSensorValue();
        wait(SLEEP_TIME);
      }
      

      I've created a class to manage the BH1750:
      MySensorWrapperBH1750.h

      // MySensorWrapperBH1750.h
      
      #ifndef _MYSENSORWRAPPERBH1750_h
      #define _MYSENSORWRAPPERBH1750_h
      
      //Need to add to project Version.h and MyEepromAdresses.h
      #include "MySensorsCore.h"
      
      #include <BH1750.h>
      
      class MySensorWrapperBH1750
      {
      public:
        MySensorWrapperBH1750(uint8_t sensor_id);
        ~MySensorWrapperBH1750();
        void Setup();
        void Present();
        void UpdateSensorValue();  
      
      private:
        uint8_t _sensor_id;
        uint16_t _lastValue;
        BH1750 _sensor;
        MyMessage _msg;
      };
      
      #endif
      
      
      

      MySensorWrapperBH1750.cpp

      /**
      * Name:		MySensorWrapperBH1750
      * Created:	20-Aug-16 22:47:51
      * Author:	Daniel
      * Version 0.1 - Draft
      *
      *******************************
      *
      * MySensors Wrapper for BH1750 sensor.
      * Wiring (I2C):
      * Sensor -> Arduino
      *  GND   -> GND
      *  ADD   -> NC
      *  SDA   -> A4
      *  SCL   -> A5
      *  VCC   -> +5V
      *
      */
      
      
      #include "MySensorWrapperBH1750.h"
      
      MySensorWrapperBH1750::MySensorWrapperBH1750(uint8_t sensor_id)
      {
        _sensor_id = sensor_id;
        MyMessage _msg(_sensor_id, V_LEVEL);
      }
      
      MySensorWrapperBH1750::~MySensorWrapperBH1750()
      {
      }
      
      void MySensorWrapperBH1750::Setup()
      {
        // TODO: Set initialization mode
        // Default mode:
        // Start measurement at 1lx resolution. Measurement time is approx 120ms.
        // #define BH1750_CONTINUOUS_HIGH_RES_MODE  0x10
        // Start measurement at 1lx resolution. Measurement time is approx 120ms.
        // Device is automatically set to Power Down after measurement.
        // #define BH1750_ONE_TIME_HIGH_RES_MODE  0x20
      
        _sensor.begin();
      }
      
      void MySensorWrapperBH1750::Present()
      {
        present(_sensor_id, S_LIGHT_LEVEL);
      }
      
      void MySensorWrapperBH1750::UpdateSensorValue()
      {
        // Fetch light in Lux from BH1750 sensor
        uint16_t newValue = _sensor.readLightLevel();// Get Lux value
        if (isnan(newValue)) {
          #ifdef MY_DEBUG
              Serial.println("Failed reading Light from BH1750");
          #endif
        }
        else if (newValue != _lastValue) {
          #ifdef MY_DEBUG
            Serial.print("Lux: ");
            Serial.println(newValue);
          #endif
          send(_msg.set(newValue));
          _lastValue = newValue;
        }
      }
      

      And for the DHT I've created the following class:
      MySensorWrapperDHT.h

      // MySensorWrapperDHT.h
      
      #ifndef _MYSENSORWRAPPERDHT_h
      #define _MYSENSORWRAPPERDHT_h
      
      //Need to add to project Version.h and MyEepromAdresses.h
      #include "MySensorsCore.h"
      
      #include "DHT.h"
      
      class MySensorWrapperDHT
      {
      public:
        MySensorWrapperDHT(uint8_t sensor_temp_id, uint8_t sensor_humd_id, uint8_t sensor_pin = 3);
        ~MySensorWrapperDHT();
        void Setup();
        void Present();
        void UpdateSensorValue();
      
      private:
        uint8_t _sensorTempId;
        uint8_t _sensorHumdId;
        uint8_t _sensorPin;
        DHT _sensor;
        MyMessage _msgTemp;
        MyMessage _msgHumd;
        float _lastTempValue;
        float _lastHumdValue;
      };
      
      #endif
      
      

      MySensorWrapperDHT.cpp

      /**
      * Name:		MySensorWrapperDHT
      * Created:	20-Aug-16 22:47:51
      * Author:	Daniel
      * Version 0.1 - Draft
      *
      *******************************
      *
      * MySensors Wrapper for DHT sensor.
      * Wiring ():
      * Sensor -> Arduino
      *  GND   -> GND
      *  OUT   -> D3
      *  VCC   -> +5V
      *
      * NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
      * to 3.3V instead of 5V!
      * Connect pin 2 of the sensor to whatever your DHTPIN is
      * Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
      * https://github.com/adafruit/DHT-sensor-library/blob/master/examples/DHTtester/DHTtester.ino
      */
      
      #include "MySensorWrapperDHT.h"
      
      MySensorWrapperDHT::MySensorWrapperDHT(uint8_t sensor_temp_id, uint8_t sensor_humd_id, uint8_t sensor_pin)
      {
        _sensorTempId = sensor_temp_id;
        _sensorHumdId = sensor_humd_id;
        _sensorPin = sensor_pin;
        MyMessage _msgTemp(_sensorTempId, V_TEMP);
        MyMessage _msgHumd(_sensorHumdId, V_HUM);
      }
      
      MySensorWrapperDHT::~MySensorWrapperDHT()
      {
      }
      
      void MySensorWrapperDHT::Setup()
      {
        _sensor.setup(_sensorPin, DHT::DHT22);
      }
      
      void MySensorWrapperDHT::Present()
      {
        present(_sensorTempId, S_TEMP);
        present(_sensorHumdId, S_HUM);
      }
      
      void MySensorWrapperDHT::UpdateSensorValue()
      {
        // TODO: really needed?
        wait(_sensor.getMinimumSamplingPeriod());
        
        // Reading temperature or humidity takes about 250 milliseconds!
        // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
        float currentTempValue = _sensor.getTemperature();
        float currentHumdValue = _sensor.getHumidity();
      
        // Check if any reads failed and exit early (to try again).
        if (isnan(currentTempValue) || isnan(currentHumdValue) ){
          Serial.println("Failed to read from DHT sensor!");
        }
        else {
          // Update temperature from DHT sensor
          if (currentTempValue != _lastTempValue) {
            _lastTempValue = currentTempValue;
            send(_msgTemp.set(currentTempValue, true));
            #ifdef MY_DEBUG
              Serial.print("Temp: ");
              Serial.println(currentTempValue);
            #endif
          }
          // Update humidity from DHT sensor
          if (currentHumdValue != _lastHumdValue) {
            _lastHumdValue = currentHumdValue;
            send(_msgHumd.set(currentHumdValue, 1));
            #ifdef MY_DEBUG
              Serial.print("Hum: ");
              Serial.println(currentHumdValue);
            #endif
          }
        }
      }
      

      And to my surprise the footprint after compiling is even smaller, 18,374 bytes (59%) of program storage space and 913 bytes (44%) of dynamic memory with a single .ino versus 17,748 bytes (58%) of program storage space and 857 bytes (42%) of dynamic memory the above project in VisualMicro. Both results with MY_DEBUG defined.

      Next step is to create classes to manage switches, relays and LEDs.

      Once again thank you all for the help and fell free to share your opinions about the way I'm trying to do things.

      Best regards

      posted in Development
      Daniel Oliveira
      Daniel Oliveira
    • RE: Free MySensors 2.0 workshop, Friday 9 September in Amersfoort (The Netherlands)

      Making a video of that workshop available as an introduction material for the MySensors website would be a 2nd best thing 🙂

      posted in General Discussion
      Daniel Oliveira
      Daniel Oliveira
    • RE: ESP8266 OTA (SOLVED)

      Hello all,

      Just to share my experience with OTA for the ESP8266 and VisualMicro for future reference, I think that there is no need to create a new topic as the search button works pretty well 🙂

      I've followed the toturials:
      http://esp8266.github.io/Arduino/versions/2.2.0-rc1/doc/ota_updates/readme.html
      http://www.visualmicro.com/page/esp8266.aspx

      Setting the IP of the ESP8266 works pretty well but I was not able to make the bonjour service to work maybe because of windows 10 ou Kaspersky firewall.

      The Issue that I've faced was after uploading the sketch, the ESP8266 did just stuck at boot or entered a bootloop and I've got this message "rst cause:4, boot mode:(3,6)"

      If you're facing the same or a similar issue I recommend checking your power source, I've added a 470uF capacitor between Vin and GND and start using a proper power supply even when connected to USB and the problem is gone.

      Source: https://github.com/esp8266/Arduino/issues/1328

      lhcavalcanti created this issue in esp8266/Arduino

      closed [Problem] ets Jan 8 2013,rst cause:4, boot mode:(3,7) #1328

      posted in Troubleshooting
      Daniel Oliveira
      Daniel Oliveira
    • [WIP] Best practices to power your nodes

      Hello all,

      I think that good quality power source is a very important aspect to have a stable MySensors network or any other projects.
      In this forum there are a lot of people facing problems that are solved by improving how they power their projects, but despite that I think that all related information is scattered in the forum and not always easy to find or to relate.

      So, why not bring this amazing community together and point here some good practices on how to power our nodes? 🙂
      I would like to start this by addressing first two topics, "approved" power adaptors and bypass capacitors.

      Power adaptors:

      • Cellphone chargers
      • HLK PM01 (toAddLink)
      • ToBeCompleted

      Bypass Capacitors:
      (What is a bypass capacitor: http://www.learningaboutelectronics.com/Articles/What-is-a-bypass-capacitor.html)

      • NRF24L01: To discuss in this thread
      • ESP8266: 470uF as close as possible to Vin and GND pins

      Please add your opinions and knowledge about this topic, my goal is to keep this post up to date with shared information.

      For example, what are the values that you recommend for the NRF24L01 and why? I saw people mentioning 4.5uF, 10uF and 47uF. Personally I'm using the latter and I have no issues.

      Thank you all.

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: Alternative to ArduinoIDE

      @drock1985 said:

      This is a good thread; been recently contemplating changing IDE's myself.

      Visual Studio seems to be the most complete - I think I will give this one a try. Anyone have any tips for how to use this coming from the Arduino IDE (with no previous programming experience?)

      Thanks,

      Hi,

      Being using it from some hours and indeed it seems to be a great alternative, it even has a dark skin 😄
      You can use it to program in a more pure C++ way (my goal here), but it also support projects with .ino files so you can use your existing ArduinoIDE projects.

      To get used to Visual Studio/Micro I'm following their User guide, you can find it HERE

      Feel free to continue sharing your experiences

      posted in General Discussion
      Daniel Oliveira
      Daniel Oliveira
    • [solved] MySensorWrapper - Wrapping sensor libraries for MySensors 2.0.x - need help

      Hello all,

      I'm trying to write a some classes to help me wrapping some sensors in a user friendly way.
      The goal is to keep the .ino file as simple as possible so I can easily manage different sketches with different hardware configuration.
      And also to avoid updating all my sketches each time I want to update a single parameter or a sensor configuration.

      To achieve that I'm using VisualMicro as IDE and I've created a header file where a put all the #defines that are common to all my sketches and class files where I have my wrapper.

      The problem is that I don't know what I need to do to have access to MySensors methods like present or the to MyMessage object from the wrapper. So I would like to have your help on that 🙂
      My C++ skils for the moment are limited and I don't even know if that is possible.

      So here is my .ino file (MySensorGeneric.ino):

      /**
      * Name:		MySensorGeneric.ino
      * Created:	20-Aug-16 22:47:51
      * Author:	Daniel
      *
      *******************************
      *
      * REVISION HISTORY
      * Version 0.1 - Development
      *
      */
      
      #include "MySensorConfig.h"
      #include <MySensors.h>
      #include "MySensorWrapperBH1750.h"
      
      #define CHILD_ID_LIGHT 2
      
      MySensorWrapperBH1750 lightSensor(CHILD_ID_LIGHT);
      
      void setup()
      {
        lightSensor.Setup();
      }
      
      void presentation() {
        sendSketchInfo("Light Lux Sensor", "0.11");
        
        lightSensor.Present();
      }
      
      void loop()
      {
        lightSensor.UpdateSensorValue();
        sleep(SLEEP_TIME);
      }
      

      Here the header file with the #defines to share between sketches (MySensorConfig.h):

      // MySensorConfig.h
      
      #ifndef _MYSENSORCONFIG_h
      #define _MYSENSORCONFIG_h
      
      #define MY_BAUD_RATE 9600
      #define MY_RADIO_NRF24
      
      #define SLEEP_TIME 5000
      
      #endif
      

      And finally my wrapper class files (MySensorWrapperBH1750.h and MySensorWrapperBH1750.cpp):

      // MySensorWrapperBH1750.h
      
      #ifndef _MYSENSORWRAPPERBH1750_h
      #define _MYSENSORWRAPPERBH1750_h
      
      #include <BH1750.h>
      
      #if defined(ARDUINO) && ARDUINO >= 100
      	#include "arduino.h"
      #else
      	#include "WProgram.h"
      #endif
      
      class MySensorWrapperBH1750
      {
      public:
        MySensorWrapperBH1750(uint8_t sensor_id);
        ~MySensorWrapperBH1750();
        void Setup();
        void Present();
        void UpdateSensorValue();  
      
      private:
        uint8_t _sensor_id;
        uint16_t _lastValue;
        BH1750 _sensor;
        MyMessage _msg;
      };
      
      #endif
      
      /**
      * Name:		MySensorWrapperBH1750
      * Created:	20-Aug-16 22:47:51
      * Author:	Daniel
      * Version 0.1 - Draft
      *
      *******************************
      *
      * MySensors Wrapper for BH1750 sensor.
      * Wiring (I2C):
      * Sensor -> Arduino
      *  GND   -> GND
      *  ADD   -> NC
      *  SDA   -> A4
      *  SCL   -> A5
      *  VCC   -> +5V
      *
      */
      
      #include "MySensorWrapperBH1750.h"
      
      MySensorWrapperBH1750::MySensorWrapperBH1750(uint8_t sensor_id)
      {
        _sensor_id = sensor_id;
        MyMessage _msg(_sensor_id, V_LEVEL);
      }
      
      MySensorWrapperBH1750::~MySensorWrapperBH1750()
      {
      }
      
      void MySensorWrapperBH1750::Setup()
      {
        // TODO: Set initialization mode
        // Default mode:
        // Start measurement at 1lx resolution. Measurement time is approx 120ms.
        // #define BH1750_CONTINUOUS_HIGH_RES_MODE  0x10
        // Start measurement at 1lx resolution. Measurement time is approx 120ms.
        // Device is automatically set to Power Down after measurement.
        // #define BH1750_ONE_TIME_HIGH_RES_MODE  0x20
        _sensor.begin();
      }
      
      void MySensorWrapperBH1750::Present()
      {
        present(_sensor_id, S_LIGHT_LEVEL);
      }
      
      void MySensorWrapperBH1750::UpdateSensorValue()
      {
        // Fetch light in Lux from BH1750 sensor
        uint16_t newValue = _sensor.readLightLevel();// Get Lux value
        if (isnan(newValue)) {
          #ifdef MY_DEBUG
              Serial.println("Failed reading Light from BH1750");
          #endif
        }
        else if (newValue != _lastValue) {
          #ifdef MY_DEBUG
            Serial.print("Lux: ");
            Serial.println(newValue);
          #endif
          send(_msg.set(newValue));
          _lastValue = newValue;
        }
      }
      

      I've attached the VisualMicro project is you're interested:
      MySensorGeneric.zip

      Sorry for the long post and the noob questions.

      Thank you all for the help

      posted in Development
      Daniel Oliveira
      Daniel Oliveira
    • RE: 💬 AC-DC double solid state relay module

      I would like to suggest to move the termal fuse and the varistor.

      I would move the temp fuse to where the SB fuse is, the latter to where the varistor is. And finally the varistor to where the "My Sensors Board" inscription is.

      This would remove the mains trace from the middle of the PCB away from the ds18b20 and the connector for the switches.

      It would also allow to move the NRF24 and the switched connector closer to the HLK and thus further from the mains connector.

      Best regards

      posted in OpenHardware.io
      Daniel Oliveira
      Daniel Oliveira
    • RE: MH-Z19 CO2 sensor

      @mfalkvidd said in MH-Z19 CO2 sensor:

      @daniel-oliveira isn't this sufficient? If not, what is missing?

       *  MH-Z19 CO2 sensor
       *  It communicates with your board over serial at 9600 speed.
      ---
      SoftwareSerial mySerial(10, 11);                  // RX, TX . You can choose other pins if you prefer.
      

      Missed that one, got confused due to the multiple possible ways to connect this sensor. (UART, PWM, etc)

      So TX, RX, GND and Vin sould be enough?

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: Humidity+Relay with button node

      Hi @thecko,

      To answer you, yes it is totally possible. But to be able to help you more can you please share your sketch instead? The one that you added the relay code, with that we can help you find what is wrong.

      Regards

      posted in Development
      Daniel Oliveira
      Daniel Oliveira

    Latest posts made by Daniel Oliveira

    • RE: MH-Z19 CO2 sensor

      Hello,

      I finally got this sensor to work but instead I use this lib: https://github.com/nara256/mhz19_uart
      Another very useful source of information is this: https://revspace.nl/MHZ19#command_0x62_.28device_name_.2F_id.29

      Take note that is the MH-Z19B the methods isWarming() and getStatus() do not work.

      Can you please share the values that you are getting? I'm getting around 1500ppm and it is alarming by these website standards:
      https://www.engineeringtoolbox.com/co2-comfort-level-d_1024.html
      https://www.kane.co.uk/knowledge-centre/what-are-safe-levels-of-co-and-co2-in-rooms

      I didn't have the opportunity yet to get the sensor outdoors.

      Thank you in advance

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: MH-Z19 CO2 sensor

      @mfalkvidd said in MH-Z19 CO2 sensor:

      @daniel-oliveira isn't this sufficient? If not, what is missing?

       *  MH-Z19 CO2 sensor
       *  It communicates with your board over serial at 9600 speed.
      ---
      SoftwareSerial mySerial(10, 11);                  // RX, TX . You can choose other pins if you prefer.
      

      Missed that one, got confused due to the multiple possible ways to connect this sensor. (UART, PWM, etc)

      So TX, RX, GND and Vin sould be enough?

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: MH-Z19 CO2 sensor

      Hi!

      Thank you for sharing, can you please point me out how do I wire this thing up? 🙂

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: 💬 PiDome

      Is this project dead? Can't reach homepage

      posted in Announcements
      Daniel Oliveira
      Daniel Oliveira
    • RE: Prevent Relay from triggering on power loss or broker reboot

      Hi,

      I'm not an expert and honestly I didn't read all the comments, but to avoid the relay to change status on reboots would not be a simpler solution to add a "flip-flop" mechanism that will "save" the last sate for some minutes?

      Best regards

      posted in Troubleshooting
      Daniel Oliveira
      Daniel Oliveira
    • RE: 💬 MDMSNode "Lighting"

      Hi,

      Can you please give a reference for the MDMS series devices? I'm not aware of it neither was able to find any reference in the forum. But I'm curious.

      posted in OpenHardware.io
      Daniel Oliveira
      Daniel Oliveira
    • [WIP] Best practices to power your nodes

      Hello all,

      I think that good quality power source is a very important aspect to have a stable MySensors network or any other projects.
      In this forum there are a lot of people facing problems that are solved by improving how they power their projects, but despite that I think that all related information is scattered in the forum and not always easy to find or to relate.

      So, why not bring this amazing community together and point here some good practices on how to power our nodes? 🙂
      I would like to start this by addressing first two topics, "approved" power adaptors and bypass capacitors.

      Power adaptors:

      • Cellphone chargers
      • HLK PM01 (toAddLink)
      • ToBeCompleted

      Bypass Capacitors:
      (What is a bypass capacitor: http://www.learningaboutelectronics.com/Articles/What-is-a-bypass-capacitor.html)

      • NRF24L01: To discuss in this thread
      • ESP8266: 470uF as close as possible to Vin and GND pins

      Please add your opinions and knowledge about this topic, my goal is to keep this post up to date with shared information.

      For example, what are the values that you recommend for the NRF24L01 and why? I saw people mentioning 4.5uF, 10uF and 47uF. Personally I'm using the latter and I have no issues.

      Thank you all.

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: WS2811 RGB strip lights up in groups of three

      Well... I'm sorry for you, but at least now everyone that reads this thread will be aware.

      Cheers

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira
    • RE: 💬 AC-DC double solid state relay module

      Can someone please point me out the software used to design the PCB?
      If I got some time I would like to try out the improvements that I've mentioned before.
      It makes more or less 10 years the last time that I've did some PCB design with Eagle, nostalgia.... 🙂

      posted in OpenHardware.io
      Daniel Oliveira
      Daniel Oliveira
    • RE: WS2811 RGB strip lights up in groups of three

      Just found this in the product description : "LED Type: 1 WS2811 IC control 3 LED Chip,"

      posted in Hardware
      Daniel Oliveira
      Daniel Oliveira