Navigation

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

    dakipro

    @dakipro

    82
    Reputation
    187
    Posts
    1730
    Profile views
    0
    Followers
    1
    Following
    Joined Last Online

    dakipro Follow

    Best posts made by dakipro

    • RE: What did you build today (Pictures) ?

      My wife said "I do not want to see "those things""...
      Challenge accepted!

      0_1544224086865_TV LED display 1 - 20181207_171500.jpg

      1_1544224086867_TV LED display 2 - 20181207_183612.jpg

      0_1544224266422_MVI_5770.00_00_03_13.Still001.jpg

      (see the gif in action here https://ibb.co/BCbS2Dc )

      posted in General Discussion
      dakipro
      dakipro
    • RE: What did you build today (Pictures) ?

      not built today, but someone mentioned fumes extractor, so this is what I built for soldering, light and fume extractor are powered by a small usb rechargeable powerbank. Fan has a active carbon filter behind it and works great for small to medium-ish projects I work on

      0_1520939158367_Third-Eighth hand soldering help-1 - IMG_0023_1024.jpg

      1_1520939158367_Third-Eighth hand soldering help-3 - IMG_0039_1024.jpg

      2_1520939158367_Third-Eighth hand soldering help-4 - IMG_0045_1024.jpg

      posted in General Discussion
      dakipro
      dakipro
    • RE: What did you build today (Pictures) ?

      Built case for soldering tools, to easily move them out of the way.

      0_1525033392218_Soldering tools holder 2 - IMG_2292_1024.jpg

      0_1525033398349_Soldering tools holder 1 - IMG_2260_1024.jpg

      Not really, bought it on banggood and asked wife to assemble it (she likes those type of projects, especially if the office might look a tiny bit cleaner) https://www.banggood.com/DIY-Self-assemble-RC-Model-Tools-Case-Screwdriver-Box-Gripper-Package-Plier-Stand-Retro-Style-p-1257252.html?cur_warehouse=CN

      Laser cut plywood(or something), looks quite nice I think. I will order few more when they appear in stock.

      posted in General Discussion
      dakipro
      dakipro
    • Water leakage sensor using thin ribbon cable (testing reliability)

      Here is a quick'n'dirty sensor I made using 2m long thin ribbon cable from ebay/aliexpress ($2-3) as a leakage sensor to monitor thumble dryer. Sometimes baby would take out the rubber on the doors, or I would not connect the condenser properly after cleaning and it would leak quite a lot of water on the floor.

      Almost invisible under the appliance

      0_1506373053923_Water leakage sensor 1 - IMG_0713_1024.jpg

      0_1506373074866_Water leakage sensor 2 - IMG_0715_1024.jpg

      0_1506373131763_Water leakage sensor 3 - IMG_0380_1024.jpg

      Used the Easy/Newbie pcb as the base, i really get bored of soldering the radio. Also used the little magnets as battery contacts, then the batteries do fit into the small box.
      For the sensor/contact itself I "polished" out the insulation on the ribbon using dremel polishing bit every feww centimeters (it is very easy to damage the copper line, so if you plan to reproduce this one, test with few bits). It looks ugly as hell but it is under the dryer so... functionality beats aesthetics here by far.
      I connected every second line with one contact, and every second with second contact, which gave me a sensor that would detect smallest drop of water (probably not needed but... playing around).

      0_1506373748875_Water leakage sensor 5 - IMG_0369_1024.jpg

      0_1506373421203_Water leakage sensor 4 - IMG_0375_1024.jpg

      This is the code I am using, quickly modified the code that @RobKuipers shared (thanks again!) here https://forum.mysensors.org/topic/4827/soil-moisture-sensor/13

      I just removed some not needed code and played around with sensitivity. It is checking for value every two minutes and sensitivity value around 50 works fine for me (if case before sending the moisture around line 149).
      I also flashed 1mhz bootloader with BOD lowered to 1.8v, so it runs a bit longer on batteries without power stepup module

      Here is the code that runs it

      /*
       Name:		MYS_MoistureSensor.ino
       Created:	5/25/2017 1:04:35 PM
       Author:	Rob
      
       Soil moisture measuring by using stainless steel rods (or any other conductor).
       Probably the simplest project ever, since only a MySensors-node and some wire is needed to set things up.
       
       The sketch alternates current during measuring to prevent corrosion of the rods due to electrolyses.
       Odd readings may occur when starting (eg. increasing soil moisture for no apparent reason), please just allow the electrodes to settle down in the soil.
       No extra hardware needed. 
       
       I use an Arduino Mini 3V3, powered on two AA cells. It is suggested you set the fuses for a lower Brown Out Detection (BOD). But anything goes.
      
       Just tie D4 and A0 together to one rod, and D5 and A1 to another rod. This is sensor one.
       For the second sensor tie D6 and A2 together to one rod, and D7 and A3 to another rod.
       Connect a pushbutton between GND and D3 if you need a button that makes the node report immediately (can be omitted)
      
       Measurement are taken every minute and send to the gateway if different from the previous reading.
       In case of no changes, the node reports itself every four hours.
       The output is between 0 (dry) and 100 (wet).
      
       Can also be used as a depth moisture sensor with three sensor zones; in that case use one (common) long rod and three smaller sensors along
       the height of the rod and configure the sketch accordingly.
      	 sensors[0] = { 4, A0, 5, A1, -1, false };
      	 sensors[1] = { 4, A0, 6, A2, -1, false };
      	 sensors[2] = { 4, A0, 7, A3, -1, false };
      
      */
      
      #include "Header.h"
      
      // Enable debug Serial.prints to serial monitor
      #define MY_DEBUG 
      
      #if defined MY_DEBUG
      #define Sprintln(a) (Serial.println(a))
      #define Sprint(a) (Serial.print(a))
      #else 
      #define Sprintln(a)
      #define Sprint(a)
      #endif
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      // Use PA_LOW for RF24+PA (Power Amplifier)
      //#define MY_RF24_PA_LEVEL RF24_PA_LOW
      //#define MY_RF24_PA_LEVEL RF24_PA_MAX
      
      #define MY_NODE_ID 42
      
      #include <MySensors.h>
      
      #define ACK 0        // = false
      #define CHILD_ID 1
      #define REPORTNOWSWITCH_PIN 3    // Arduino Digital I/O pin for button/reed switch (must be an interrupt pin!)
      
      #define NUM_MOISTURE_SENSORS 1
      #define CHILD_ID_TEMPERATURE (CHILD_ID+NUM_MOISTURE_SENSORS+1)
      
      #define SENSOR1_ROD1_DIGITAL 4
      #define SENSOR1_ROD1_ANALOG A0
      #define SENSOR1_ROD2_DIGITAL 5
      #define SENSOR1_ROD2_ANALOG A1
      
      
      #define SLEEP_IN_MS 120000		// every minute a new measurement
      #define EVERY_15_MINUTES (3600000/4/SLEEP_IN_MS)
      #define EVERY_4_HOURS (3600000*4/SLEEP_IN_MS) 
      #define NUM_READS (int)5		// Number of sensor reads for filtering
      
      int countLoops;
      int8_t interruptedBy = -1;
      int oldBatLevel;
      float oldTemperature;
      
      int output_value;
      
      /// Included in Header.h:
      //typedef struct {
      //	int digital_input_a;
      //	int analog_input_a;
      //	int digital_input_b;
      //	int analog_input_b;
      //	int level;
      //	bool connected;
      //} sensorWiring;
      
      sensorWiring sensors[NUM_MOISTURE_SENSORS];
      
      MyMessage msgMoistureSensor(CHILD_ID, V_TRIPPED);
      //MyMessage msgChipTemp(CHILD_ID_TEMPERATURE, V_TEMP);
      
      
      void before()
      {
      	// All buttons as input-pullup as per ATMEGA recommendation to use less power (and more safety) 
      	// (http://electronics.stackexchange.com/questions/43460/how-should-unused-i-o-pins-be-configured-on-atmega328p-for-lowest-power-consumpt)
      	for (int i = 1; i <= 8; i++)
      	{
      		pinMode(i, INPUT_PULLUP);
      	}
      
      	// Now explicity set pins as needed
      
      	// Setup report-now switch, activate internal pull-up
      	//pinMode(REPORTNOWSWITCH_PIN, INPUT_PULLUP);
      
      	// Initialize sensor variables
      
      	// Connect Digital pin 4 to Analog input A0 and a metal rod
      	// Connect Digital pin 5 to Analog input A1 and another metal rod.
      	sensors[0] = { SENSOR1_ROD1_DIGITAL, SENSOR1_ROD1_ANALOG, SENSOR1_ROD2_DIGITAL, SENSOR1_ROD2_ANALOG, -1, false };
      
      
      	for  (int i = 0; i<NUM_MOISTURE_SENSORS; i++)
      		sensors[i].connected = testSensorConnections(sensors[i]);
      }
      
      void setup()
      {
      
      }
      
      
      void presentation() {
      	sendSketchInfo("Water Leak Sensor no42", "1.1", ACK);
      
      	for (int i = 0; i < NUM_MOISTURE_SENSORS; i++)
      	{
      		if (sensors[i].connected) present(CHILD_ID+i, S_WATER_LEAK , ACK);
      	}
      	//present(CHILD_ID_TEMPERATURE, S_TEMP);
      }
      
      void loop()
      {
      	
      
      	for (int i = 0; i < NUM_MOISTURE_SENSORS; i++)
      	{
      		if (sensors[i].connected)
      		{
      			output_value = measure(sensors[i]);
      			
      			Sprint(F("output_value is "));
      			Sprintln(output_value);
      			if ((sensors[i].level != output_value) && output_value > 50)
      			{
      				sensors[i].level = output_value;
      				send(msgMoistureSensor.setSensor(CHILD_ID+i).set(1), ACK);
      			}
      		}
      	}
      
      	// Every fifteen minutes; poll temperature
      	if (countLoops%EVERY_15_MINUTES==0) 
      	{
      
      		int batLevel = getBatteryLevel();
      		if ((oldBatLevel != batLevel)) // ...but only when changed, or when button is pressed; 
      		{
      			sendBatteryLevel(batLevel, ACK);
      			oldBatLevel = batLevel;
      		}
      	}
      
      	// So you know I'm alive
      	if (countLoops == EVERY_4_HOURS)
      	{
      		sendHeartbeat(ACK);
      		countLoops = 0;
      	}
      
      	countLoops++;
      
      	interruptedBy = sleep(SLEEP_IN_MS);
      }
      
      // Connect Digital pin 'digital_input_a' to Analog input 'analog_input_a' and a metal rod,
      // do the same for b
      long measure(sensorWiring sensor)
      {
      	long total = 0;
      	int reading_a = 0;
      	int reading_b = 0;
      
      	for (int i = 0; i<NUM_READS; i++) {
      		// Left to right
      		reading_a = measureOneDirection(sensor.digital_input_a, sensor.digital_input_b, sensor.analog_input_a);
      		// Right to left
      		reading_b = measureOneDirection(sensor.digital_input_b, sensor.digital_input_a, sensor.analog_input_b);
      
      		total += reading_a + reading_b;
      	}
      	return map(total / (2 * NUM_READS), 1023, 0, 0, 100);
      }
      
      long measureOneDirection(int digital_input_1, int digital_input_2, int analog_input_1)
      {
      	pinMode(digital_input_2, OUTPUT);
      	digitalWrite(digital_input_2, LOW);
      	pinMode(digital_input_1, INPUT_PULLUP);
      	delayMicroseconds(100);
      	long reading = analogRead(analog_input_1);
      	//delayMicroseconds(25);
      	pinMode(digital_input_1, INPUT);     // High impedance                 
      	pinMode(digital_input_2, INPUT);     // High impedance                 
      	delay(1);
      
      	Sprint(F("measureOneDirection - Reading "));
      	Sprintln(reading);
      
      	return reading;
      }
      
      // test the connections of both rods of a sensor
      boolean testSensorConnections(sensorWiring moistureSensor)
      {
      	return (testSensorConnection(moistureSensor.digital_input_a, moistureSensor.analog_input_a) && testSensorConnection(moistureSensor.digital_input_b, moistureSensor.analog_input_b));
      }
      
      //  test if digital pin is connected to correct analog pin
      boolean testSensorConnection(int digital_input, int analog_input)
      {
      	pinMode(digital_input, OUTPUT);
      	digitalWrite(digital_input, HIGH);                        
      	delayMicroseconds(100);
      	long reading_1 = analogRead(analog_input);   
      	digitalWrite(digital_input, LOW);                      
      	delayMicroseconds(100);
      	long reading_2 = analogRead(analog_input);   
      	pinMode(digital_input, INPUT);     // High impedance                 
      	delay(1);
      
      	Sprint(F("testSensorConnection - Reading1 "));
      	Sprintln(reading_1);
      	Sprint(F("testSensorConnection - Reading2 "));
      	Sprintln(reading_2);
      
      	bool correct = ((reading_1 == 1023) && (reading_2 == 0));
      	return correct;
      }
      
      
      long readMUX(uint8_t aControl) 
      {
      	long result;
      
      	ADMUX = aControl;
      	delay(20); // Wait for Vref to settle
      	noInterrupts();
      	// start the conversion
      	ADCSRA |= _BV(ADSC) | _BV(ADIE);
      	set_sleep_mode(SLEEP_MODE_ADC);    // sleep during sample
      	interrupts();
      	sleep_mode();
      	// reading should be done, but better make sure
      	// maybe the timer interrupt fired 
      	while (bit_is_set(ADCSRA, ADSC));
      	// Reading register "ADCW" takes care of how to read ADCL and ADCH.
      	result = ADCW;
      
      	return result;
      
      }
      
      
      // Battery measure
      int getBatteryLevel()
      {
      	int results = (readVcc() - 2000) / 10;
      
      	if (results > 100)
      		results = 100;
      	if (results < 0)
      		results = 0;
      	return results;
      } // end of getBandgap
      
      // when ADC completed, take an interrupt 
      EMPTY_INTERRUPT(ADC_vect);
      
      long readVcc() {
      	long result;
      	// Read 1.1V reference against AVcc
      	result = readMUX(_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1));
      
      	result = 1126400L / result; // Back-calculate AVcc in mV (1024 steps times 1100 mV (1.1V) = 1126400L)
      
      	return result;
      }
      
      
      // Utter nonsense, but needed for attaching an interrupt to...
      void debounce() {
      }
      
      

      Now the only question is: How long will copper wire detect the water before corroding? I understand that the code has polarity change to avoid electrolytic effect, but still moisture from the air will certainly corrode exposed wires. If it holds a year that would be ok, everything above that would be great 🙂
      If it doesn't work long enough, then I will just buy some more robust sensor and replace the ribbon strip with it.

      posted in My Project
      dakipro
      dakipro
    • RE: What did you build today (Pictures) ?

      My friend had a leakage from the water heater, luckily he was around (and renting) so not much damage was made, so inspired by the incident I made another water leakage sensor for water heater (reusing the code from my previous "ribbon cable sensor" )

      0_1522788478283_Water leak - water heater-1_1024.jpg

      1_1522788478283_Water leak - water heater-2_1024.jpg

      Then I have an "alarm" flow in node-red (via openhab) which blinks all lights in the house, sends notification to mobile phones with high priority etc. Which brings me a lot of joy when all works fine (and annoys my wife, as usual)...

      They are so easy to made that I might as well make a few of them just for convenience and "feeling rich with sensors" if you guys know what I mean 🙂

      posted in General Discussion
      dakipro
      dakipro
    • RE: 💬 Easy/Newbie PCB for MySensors

      @sundberg84 just to update success of the story, I cut the vcc trace and connected mini directly to battery, burned the fuses based on your advice here https://forum.mysensors.org/topic/7296/burning-fuses/8, and now the sensor goes down to 2.0v 🙂
      Booster is still used but only for dht22, radio and pro mini run directly from the battery.

      Thank you very much guys for help, now I have a foundation (and the knowledge) for more awesome sensors! 🙂

      posted in OpenHardware.io
      dakipro
      dakipro
    • RE: Are folks here happy with Domoticz?

      Exactly the same as @stefaanv and many others, I started with Domoticz and used it for few years, but after a while it was a bit too much "this script for this", and "this hack for that", and this in python and seven virtual switches for that hack... So I was looking into a more robust solution, and I was sold on presentations that leading people of OpenHAB held online, showing the architecture, the reasons and plans, having clear roadmap and long term plan for the system. I feel I understand how and why openhab works the way it does, why it is organized in such a fashion. And that is very important with any software, to have a good documentation (technical, not just for the users).
      With domoticz, almost no idea about how it was internally organized, why and what the future plans are. It was always somehow "well this is what we have, it works, and here are the workarounds... with bunch of hidden difficult to find virtual switches and rest api"

      When I started making more "abstracted" rules about events and logic, then lua showed quite a few challenges, but it was mainly having 30-40-50 virtual switches, a pain in the ** keeping track them all, making rules for each of them (f.eks. switches for datetime: isSunrise, isMorning, isAfternoon, isEvening, isNighttime, isDaytime..... isSomeoneHome, isMeHome, isWifeHome,... ) And this was actually the biggest issue I had with domoticz, handling and organizing the automation part and virtual switches. At the end I had like 6-7 times more virtual switches then physical ones.

      Then I moved in another apartment and decided to try openhab2. It is just way more robust. It didn't took me a long time to get up and running, and having items defined in a text file is a blessing as you can just do a backup, organize them in multiple files, use git (or backup) for versioning. Writing comments also helps A LOT when you come back to the item after few months/years.

      Only thing I was struggling a bit is the RFlink, whose binding is not quite ready yet. But I managed to install and use rflink->mqtt "gateway" and all works as expected.
      I am also using node-red for logic as @Fabien which I am still learning, but so far it looks much much better and easier to debug.

      Not all challenges from above are domoticz related, some are also "me a rookie" related, so not to downspeak on domoticz, it works great! As long as you are comfortable with all above and dont plan to overgrow it. My goal is to make "smarter home", more then just basic rules and remote home. (about remote home, my.domoticz.com for remote access never actually worked for me, noone could/tried to solve it, so I felt it didn't work)

      And that is where the community comes in place, it feels that the people on the openhab are more technical, and generally have great technical discussions about best solutions and approaches. F.eks. only for persisting values, you can have multiple completely different database systems, using the advantage of each of them. And each is very easy to install, as they all comply to some "technical rules and documentation". Now that is a downside, as you need to know that you need persistence strategy at all, I wish some would come predefined, but...
      I am not developing anything, but I feel there are "big boys" who think hard about issues and then develop a long term and best solution for the problem. And I want a stable and long term solution for my home automation, and waf 🙂

      On the other side, openhab is a bit more technical, but I think that someone who can change mysensors sketches and make that work, can make openhab work as well. They are very focused on "non-technical" user these days, and it shows with every update. I guess home-assistant is pushing its way forward.

      (a novel about my life and divorce with domoticz will be published someday, snippet above is just the preview, I have too much caffeine cannot sleep help)

      posted in Domoticz
      dakipro
      dakipro
    • RE: 💬 Dollhouse

      Awesome project, I wish I made something like this.
      (I actually wanted to make something like this when I was in school)
      Very clean and nice presentation and realization, with a lot of attention to details. All is very realistic, I can imagine that it took quite some time making it.
      Thanks for sharing the details!

      posted in Announcements
      dakipro
      dakipro
    • RE: How to burn fuses so that pro mini 3.3v would go down to 1.8v [SOLVED]

      Success! I fallowed your advice @sundberg84 and just changed boards.txt and got it to work! Simple and without custom bootloaders etc.
      I will certainly forget how to do this again after few months, so here is how to burn fuses so that pro mini 3.3v would go down to 1.8v:
      I just changed the boards.txt file that I found in folder c:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt

      What I did is duplicate lines defining existing pro mini. So I searched the file for "pro mini", and there I found 4 "groups" of lines defining different pro mini boards/processors. I copied one of the groups defining Pro Mini (3.3V, 8 MHz) w/ ATmega328 and changed the name of the group from 8MHzatmega328 to (f.eks.) 8MHzatmega328bod1v8. Then change extended_fuses to 0x06 for 1.8v BOD limit. Also changed the title of the board type. The complete block looks like

      
      ## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 BOD at 1.7v
      ## --------------------------------------------------
      pro.menu.cpu.8MHzatmega328bod1v8=ATmega328 (3.3V, 8 MHz, 1v7 BOD)
      
      pro.menu.cpu.8MHzatmega328bod1v8.upload.maximum_size=30720
      pro.menu.cpu.8MHzatmega328bod1v8.upload.maximum_data_size=2048
      pro.menu.cpu.8MHzatmega328bod1v8.upload.speed=57600
      
      pro.menu.cpu.8MHzatmega328bod1v8.bootloader.low_fuses=0xFF
      pro.menu.cpu.8MHzatmega328bod1v8.bootloader.high_fuses=0xDA
      pro.menu.cpu.8MHzatmega328bod1v8.bootloader.extended_fuses=0x06
      pro.menu.cpu.8MHzatmega328bod1v8.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
      
      pro.menu.cpu.8MHzatmega328bod1v8.build.mcu=atmega328p
      pro.menu.cpu.8MHzatmega328bod1v8.build.f_cpu=8000000L
      
      

      And in my boards.txt file it starts on line 735

      This is the old line for extended_fuses that we are updating/replacing
      #pro.menu.cpu.8MHzatmega328bod1v8.bootloader.extended_fuses=0xFD

      After restarting Arduino IDE you should see new type of the "processor" of the board in IDE Tools menu. Select the new one we just created "ATmega328 (3.3V, 8 MHz, 1v7 BOD)" and burn the bootloader on the pro mini.
      I used Arduino as ISP to burn bootloader, and there are tutorials for that on arduino.cc. If you have real ISP, then it is a bit easier, but you need to figure out your method of uploading bootloader. Check PeteB's video mentioned bellow.

      After that you can check that the fuzes are changed properly, by using Avrdude in the method explained in PeteB's video here https://www.mysensors.org/about/fota . You can also just try to power the mini with 2.0v and see if it works 🙂

      This is the only time we use this newly created processor, it is not used in uploading sketches. So after bootloader is uploaded, you will be able to program pro mini "as if nothing happened", meaning you just connect FTDI and compile. But (this is very important!) dont forget to select the regular processor when uploading sketches, the "Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328", not the new one we just created. If you try using new processor, I think it will stop at compile process, so just change to regular processor.

      Now you can connect the pro mini directly to batteri and have it run down to 1.8v (in theory, radio goes down to 1.9 if all is "perfect")
      I just tested one sensor and it goes down to 2.0v without complaining, that is much better then 2.7 from before 🙂

      posted in OpenHardware.io
      dakipro
      dakipro
    • RE: Sleeping while waiting for double click (delayed sleep)

      Thanks, i managed to fix it with a hardware "Another debouncer" from this page
      http://playground.arduino.cc/Main/RotaryEncoders

      Here is the code that supports click, double click as well as hold (not the prettiest code but hey... works for now 🙂 )

      /*
       This is a sample sketch to show how to use the OneButtonLibrary
       to detect click events on 2 buttons in parallel. 
       The library internals are explained at
       http://www.mathertel.de/Arduino/OneButtonLibrary.aspx
       
       Setup a test circuit:
       * Connect a pushbutton to pin A1 (ButtonPin) and ground.
       * Connect a pushbutton to pin A2 (ButtonPin) and ground.
       * The Serial interface is used for output the detected button events.
       
       The Sketch shows how to setup the library and bind 2 buttons to their functions.
       In the loop function the button1.tick and button2.tick functions have to be called as often as you like.
       */
      
      // 01.03.2014 created by Matthias Hertel
      // ... and working.
      
      /* Sample output:
      
      Starting TwoButtons...
      Button 1 click.
      Button 2 click.
      Button 1 doubleclick.
      Button 2 doubleclick.
      Button 1 longPress start
      Button 1 longPress...
      Button 1 longPress...
      Button 1 longPress...
      Button 1 longPress stop
      Button 2 longPress start
      Button 2 longPress...
      Button 2 longPress...
      Button 2 longPress stop
      */
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Vcc.h>                                    // library for internal reference Vcc reading
      
      
      // Reference values for ADC and Battery measurements
      const float VccMin          = 1.0*2.5 ;             // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion.
      const float VccMax          = 1.0*3.0 ;             // Maximum expected Vcc level, in Volts.
      //const float VccMin        = 2.0*0.6 ;             // Minimum expected Vcc level, in Volts. for 2xAA Alkaline.
      //const float VccMax        = 2.0*1.5 ;             // Maximum expected Vcc level, in Volts.for 2xAA Alkaline.
      const float VccCorrection   = 3.30/3.42 ;           // Measured Vcc by multimeter divided by reported Vcc
      Vcc vcc(VccCorrection);                             // instantiate internal voltage measurement lib
      
      int oldBatteryPcnt = 0;
      
      
      #define SKETCH_NAME "DoubleLightClickSwitch"
      #define SKETCH_MAJOR_VER "2"
      #define SKETCH_MINOR_VER "0"
      
      
      #define LIGHT_SWITCH_PIN 2   // Arduino Digital I/O pin for button/reed switch
      #define SECOND_LIGHT_SWITCH_PIN 3 // Arduino Digital I/O pin for button/reed switch
      int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
      
      #define PRIMARY_CHILD_ID 3
      #define SECONDARY_CHILD_ID 4
      
      #if (LIGHT_SWITCH_PIN < 2 || LIGHT_SWITCH_PIN > 3)
      #error LIGHT_BUTTON_PIN must be either 2 or 3 for interrupts to work
      #endif
      #if (SECOND_LIGHT_SWITCH_PIN < 2 || SECOND_LIGHT_SWITCH_PIN > 3)
      #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
      #endif
      #if (LIGHT_SWITCH_PIN == SECOND_LIGHT_SWITCH_PIN)
      #error LIGHT_BUTTON_PIN and BUTTON_PIN2 cannot be the same
      #endif
      #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID)
      #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same
      #endif
      
      MySensor sensor_node;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
      MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);
      
      #include "OneButton.h"
      
      // Setup a new OneButton on pin A1.  
      OneButton button1(LIGHT_SWITCH_PIN, true);
      // Setup a new OneButton on pin A2.  
      OneButton button2(SECOND_LIGHT_SWITCH_PIN, true);
      
      unsigned long previousMillis = 0;        // will store last time LED was updated
      unsigned long currentMillis = 0;        // will store last time LED was updated
      // constants won't change :
      const long interval = 10000;           // interval at which to sleep (milliseconds)
      
      // setup code here, to run once:
      void setup() {
      	
      	sensor_node.begin(NULL, 31); // Light switches are nodes 30+
      
      	// Setup the buttons
      	pinMode(LIGHT_SWITCH_PIN, INPUT);
      	pinMode(SECOND_LIGHT_SWITCH_PIN, INPUT);
      
      	// Activate internal pull-ups
      	digitalWrite(LIGHT_SWITCH_PIN, HIGH);
      	digitalWrite(SECOND_LIGHT_SWITCH_PIN, HIGH);
       
      	// Send the sketch version information to the gateway and Controller
      	sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
      
      	// Register binary input sensor to sensor_node (they will be created as child devices)
      	// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
      	// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      	sensor_node.present(PRIMARY_CHILD_ID, S_DOOR);
      	sensor_node.present(SECONDARY_CHILD_ID, S_DOOR);
      
      	// link the button 1 functions.
      	button1.attachClick(click1);
      	button1.attachDoubleClick(doubleclick1);
      	button1.attachLongPressStart(longPressStart1);
      	button1.attachLongPressStop(longPressStop1);
      	button1.attachDuringLongPress(longPress1);
      
      	// link the button 2 functions.
      	button2.attachClick(click2);
      	button2.attachDoubleClick(doubleclick2);
      	button2.attachLongPressStart(longPressStart2);
      	button2.attachLongPressStop(longPressStop2);
      	button2.attachDuringLongPress(longPress2);
      
      } // setup
      
      
      // main code here, to run repeatedly: 
      void loop() {
      	currentMillis = millis();
      	
      	// keep watching the push buttons:
      	button1.tick();
      	button2.tick();
      	
      	
      	int batteryPcnt = vcc.Read_Perc(VccMin, VccMax, true);
      	
      	if (oldBatteryPcnt != batteryPcnt) {
      		// Power up radio after sleep
      		sensor_node.sendBatteryLevel(vcc.Read_Perc(VccMin, VccMax, true));
      		
      		oldBatteryPcnt = batteryPcnt;
      	}
      	
      	
      	// Sleep until buttons pressed
      	
      	if (currentMillis - previousMillis >= interval) {
      		Serial.println("we go sleep");
      		previousMillis = currentMillis;
      		
      		sensor_node.sleep(LIGHT_SWITCH_PIN-2, CHANGE, SECOND_LIGHT_SWITCH_PIN-2, CHANGE, 0);
      	}
      } // loop
      
      // ----- button 1 callback functions
      
      // This function will be called when the button1 was pressed 1 time (and no 2. button press followed).
      void click1() {
      	Serial.println("Button 1 click.");
      	sensor_node.send(msg.set(HIGH));
      	previousMillis = millis(); //this is somehow buggy, so it becomes a feature
      } // click1
      
      
      // This function will be called when the button1 was pressed 2 times in a short timeframe.
      void doubleclick1() {
      	Serial.println("Button 1 doubleclick.");
      	sensor_node.send(msg.set(HIGH));
      	previousMillis = millis(); //this is somehow buggy, so it becomes a feature
      } // doubleclick1
      
      
      // This function will be called once, when the button1 is pressed for a long time.
      void longPressStart1() {
      	Serial.println("Button 1 longPress start");
      } // longPressStart1
      
      
      // This function will be called often, while the button1 is pressed for a long time.
      void longPress1() {
      	Serial.println("Button 1 longPress...");
      } // longPress1
      
      
      // This function will be called once, when the button1 is released after beeing pressed for a long time.
      void longPressStop1() {
      	Serial.println("Button 1 longPress stop");
      	sensor_node.send(msg.set(HIGH));
      	previousMillis = millis(); //this is somehow buggy, so it becomes a feature
      } // longPressStop1
      
      
      // ... and the same for button 2:
      
      void click2() {
      	Serial.println("Button 2 click.");
      	sensor_node.send(msg2.set(HIGH));
      	previousMillis = millis(); //this is somehow buggy, so it becomes a feature
       	
      } // click2
      
      
      void doubleclick2() {
      	Serial.println("Button 2 doubleclick.");
      	sensor_node.send(msg2.set(HIGH));
      	previousMillis = millis(); //this is somehow buggy, so it becomes a feature
      } // doubleclick2
      
      
      void longPressStart2() {
      	Serial.println("Button 2 longPress start");
      } // longPressStart2
      
      
      void longPress2() {
      	Serial.println("Button 2 longPress...");
      } // longPress2
      
      void longPressStop2() {
      	Serial.println("Button 2 longPress stop");
      	sensor_node.send(msg2.set(HIGH));
      	previousMillis = millis(); //this is somehow buggy, so it becomes a feature
      } // longPressStop2
      
      
      // End
      e
      

      Here are some photos of the switch
      0_1471104103802_IMG_1710_1024.jpg

      1_1471104103803_IMG_1717_1024.jpg

      2_1471104103803_IMG_1723_1024.jpg

      (I know I should not just solder the batteries directly, but... i've done it several times before and none of them complained (duracells take 3-4s with a cheap soldering iron and hold very nice)

      Board is the fantastic Easy/Newbie that warms my hart each time I use it
      https://www.openhardware.io/view/4/EasyNewbie-PCB-for-MySensors

      The switch is not the smallest one (nexa's are waaay more pretier and slimmer) but for what I want to make next, I think MySensors version could work fine.

      What would be the best way now to send double click, and eventually "hold" action?
      Code can send events on "Button 1 longPress start" and it can send code all the way while you hold the button like bunch of
      "
      Button 1 longPress...
      Button 1 longPress...
      Button 1 longPress...
      "
      and it can send code as "Button 1 longPress stop"

      Should I register 4 more CHILD_ID maybe on the switch, and then send CHILD_ID 1 on click, CHILD_ID 2 on double click, CHILD_ID 3 on hold and similar for second button?

      posted in Development
      dakipro
      dakipro

    Latest posts made by dakipro

    • RE: 💬 OpenHAB

      Some time passed by but I just wanted to thank you @guillermo-schimmel , I've finally managed to connect sensors properly (at least one of them).

      I had to do some changes based on official documentation, so what I did is I just installed mqtt binding from paperUI, and then added one mysensors.things file with fallowing

      
      
      Bridge mqtt:broker:mosqbroker "Work Broker" [ host="192.168.1.ip", port="1883", secure=false, username="myuser", password="mypassword", clientID="OPENHAB", startupCheckEnabled=false  ]
      
      Thing mqtt:topic:mosqbroker:ChargingStation_Switch4h_raw_thing "Charging station button" (mqtt:broker:mosqbroker) @ "Home" {
          Channels:
              Type string : ChargingStation_Switch4h_raw_button "Charging station 4h button" [ stateTopic="mygateway1-out/31/4/1/0/16"]
      }
      
      

      and then in my items file I had this

      
      String ChargingStation_Switch4h_raw_converted       "ChargingStation Switch4h"           { channel="mqtt:topic:mosqbroker:ChargingStation_Switch4h_raw_thing:ChargingStation_Switch4h_raw_button"}
      
      

      and I get the value of the item properly (note I have string for testing, number might be more appropriate here, but that will be fixed another day)

      posted in Announcements
      dakipro
      dakipro
    • RE: 💬 EFEKTA Temp&Hum sensor(ver. nRF52 )+E-Ink display

      hey @berkseo these look amazing, any estimate when they might be available again as assembled unit?
      Any estimate on how long the battery lasts, with lats say update every 15min?
      Could these be updated OTA somehow (or directly perhaps)?
      I would like to have option to change layout, or perhaps add some other values to it maybe.
      They look amazing, I would like several of these in each room for various things displayed

      posted in OpenHardware.io
      dakipro
      dakipro
    • RE: 💬 Easy/Newbie PCB for MySensors

      @apl2017 care to share? 🙂

      posted in OpenHardware.io
      dakipro
      dakipro
    • RE: 💬 OpenHAB

      @guillermo-schimmel said in 💬 OpenHAB:

      The 1.b. route: MQTT using new MQTT 2.x binding
      The 1.b route. It also works fine, you define the broker via Paper UI and/or files, and you then define every channel by hand, the easier way is via PaperUI.
      This is awful.

      It looks that I was using 1.a, as this is how I already have items defined from before, f.eks.
      Number Temp_03 "Temperatura [%.1f °C]" {mqtt="<[mosquito:mygateway1-out/3/1/1/0/0:state:default]"}

      but I do agree, this is a bit... time consuming to figure out which value should be sent when.

      To migrate from this to 1.b, I would have to define every channel in the things file?
      I am not a fan of PaperUi , and would like to have a official bindings when possible. It is always annoying to update openhab, and I would like to keep it as less complicated as possible.

      Do you have an example (or give some tips) on how to go with 1.b route, either via PaperUi, or things file? What do I write there for one, f.eks. temperature-humidity sensor?

      I like having good control over each node, so defining each channel should be fine for me, I am just struggling to get started, then I can copy-paste from there 🙂

      Thanks!

      posted in Announcements
      dakipro
      dakipro
    • RE: 💬 OpenHAB

      thanks @Guillermo-Schimmel , what I have so far is
      MQTT Binding from paperUi
      MQTT Broker - added from paperUI where I input my ip adress
      Then I should add channels from PaperUi as well?
      If I try that, only option I have is Publish Trigger. There should I put topic i guess?
      Or should I just add Things as you described and something new appears?

      I can wait for tutorial if that is easier for you, I have just a few non-vital devices in mysensors.
      Thanks again!

      posted in Announcements
      dakipro
      dakipro
    • RE: 💬 OpenHAB

      hi @Guillermo-Schimmel thanks for the info, I searched for a while but didn't understod what to do with channels. Do you have an example or perhaps a list of the channels that should be added, and what the values are?
      Thanks!

      posted in Announcements
      dakipro
      dakipro
    • RE: What did you build today (Pictures) ?

      @nca78 I used white decorative self adhesive wallpaper, so not sure which plastic you are planing to use, but you can easily test that before mounting I think. If you go for paper/foil, put some one-peace plastic in front of the displays as they (mine) are not perfectly soldered in line, so they are noticeable sa foil will glue to them. Not a big deal for me, but would love "the perfection". But yeah, plastic or some harder material would work awesome I think.

      All in all, not difficult project and a very high wow-factor/time-spent value (and waf)

      posted in General Discussion
      dakipro
      dakipro
    • RE: What did you build today (Pictures) ?

      My wife said "I do not want to see "those things""...
      Challenge accepted!

      0_1544224086865_TV LED display 1 - 20181207_171500.jpg

      1_1544224086867_TV LED display 2 - 20181207_183612.jpg

      0_1544224266422_MVI_5770.00_00_03_13.Still001.jpg

      (see the gif in action here https://ibb.co/BCbS2Dc )

      posted in General Discussion
      dakipro
      dakipro
    • RE: 💬 Easy/Newbie PCB for MySensors

      Ooops, my bad then 😞 I was pretty sure I checked readme.md file, but apparently I got confused.
      Thanks a million!

      posted in OpenHardware.io
      dakipro
      dakipro
    • RE: 💬 Easy/Newbie PCB for MySensors

      Thanks @hek it is certainly helpful. However the most powerful information is actually in the description page, about how to use the board, how to wire it up for different use cases etc. I suppose a previous version of the information tab is not available?
      If it could be archived (maybe even linked somewhere) it would be really helpful!

      posted in OpenHardware.io
      dakipro
      dakipro