Navigation

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

    Matt

    @Matt

    27
    Reputation
    75
    Posts
    881
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online

    Matt Follow

    Best posts made by Matt

    • 433mhz transmitter

      Its kinda kludgy (of course- I made it!) but it works. As usual full of bits pinched from elsewhere....
      I am using this to control 4 effergy wall outlets. I already have mains switching ability but it's made by me and I am nervous about fire, so I figured this was a good compromise.
      I have some cheap 433 transmitters and receivers. Used the RCSwitch library to capture the codes. I have only got one switch functional at the moment but to add the rest is trivial. My coding Im sure is crap but it works.
      I have soldered a wee wire to the transmitter 12CM long and have no issues with range. I like the 'repeat command x times' function in the RCSwitch library, kinda makes not having feedback a non issue.

      // Enable debug prints to serial monitor
      //#define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Enable repeater functionality for this node
      // #define MY_REPEATER_FEATURE
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <RCSwitch.h>
      
      #define NUMBER_OF_PLUGS 4 // Total number of attached plugs
      
      #define CODE_1On 1290271
      #define CODE_1Off 1290263
      #define CODE_2On 1290267
      #define CODE_2Off 1290259
      #define CODE_3On 1290269
      #define CODE_3Off 1290261
      #define CODE_4On 1290270
      #define CODE_4Off 1290262
      
      RCSwitch mySwitch = RCSwitch();
      
      void setup() {
        mySwitch.enableTransmit(4);
        mySwitch.setRepeatTransmit(15);
      }
      
      void presentation()  
      {   
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("433mhz switch", "1.0");
      
        for (int sensor=1 ; sensor<=NUMBER_OF_PLUGS;sensor++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_LIGHT);
        }
      }
      
      
      void loop() 
      {
        
      }
      
      void receive(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
        int incomingLightState =  message.getBool(); 
        int incomingOutlet = message.sensor;
        
        Serial.print("Outlet #: ");
        Serial.println(message.sensor);
        Serial.print("Command: ");
        Serial.println(message.getBool());
       
       if (incomingOutlet==1) {
       if (incomingLightState==1) {
          // Turn on  socket 1
          Serial.println("Turn on Socket 1");
       mySwitch.send(CODE_1On, 24); // These codes are unique to each outlet
       delay(50); 
       }
       if (incomingLightState==0)  {
          // Turn off socket 1
       Serial.println("Turn off Socket 1");
      mySwitch.send(CODE_1Off, 24);
      delay(50); 
       }
       }
       if (incomingOutlet==2) {
       if (incomingLightState==1) {
          // Turn on  socket 2
          Serial.println("Turn on Socket 2");
      mySwitch.send(CODE_2On, 24);
       delay(50); 
       }
       if (incomingLightState==0)  {
          // Turn off socket 2
       Serial.println("Turn off Socket 2");
      mySwitch.send(CODE_2Off, 24);
      delay(50); 
       }
       }
       if (incomingOutlet==3) {
       if (incomingLightState==1) {
          // Turn on  socket 3
          Serial.println("Turn on Socket 3");
      mySwitch.send(CODE_3On, 24);
       delay(50); 
       }
       if (incomingLightState==0)  {
          // Turn off socket 3
       Serial.println("Turn off Socket 3");
      mySwitch.send(CODE_3Off, 24);
      delay(50); 
       }
       }
       if (incomingOutlet==4) {
       if (incomingLightState==1) {
          // Turn on  socket 4
          Serial.println("Turn on Socket 4");
       mySwitch.send(CODE_4On, 24);
       delay(50); 
       }
       if (incomingLightState==0)  {
          // Turn off socket 4
       Serial.println("Turn off Socket 4");
      mySwitch.send(CODE_4Off, 24);
      delay(50); 
       }
       }
        }
       delay(50);
      }
      
      
      posted in My Project
      Matt
      Matt
    • RE: Your workshop :)

      OK here's mine.
      0_1462611008576_WS.jpg

      posted in General Discussion
      Matt
      Matt
    • RE: LM393 as pulse powermeter sensor, swap out 'photodiode'

      OK so rather than wait for shipping from China I went to my local Jaycar and got one of these LDRs. If the link gets broken its a cadmium sulphine LDR with a rise time of 50ms and decay of 40ms.
      Works like a charm. Because its flat I can tape it directly to the LED in my power meter, covering the whole thing with black tape to ensure no ambient light problems. Two pinholes in the tape and the LDR leads go right through no probs. I have some thin wires going to the LM393 unit (so minimal weight on the LDR/Tape itself) and I guess the comparator in there is good enough to pick up the change in resistance on the LED pulses.
      So if you wind up with one of these units I recommend swapping the photodiode with a high spec LDR and soldering some leads from the module to the LDR to facilitate accurate fixing to the meters LED. I used two bits off an old length of ribbon cable (IDE HDD type stuff).

      posted in Hardware
      Matt
      Matt
    • RE: Your workshop :)

      @Samuel235 yeah the Dolmar leaks, I think its a design feature. Problem is I live with three drunken monkeys who are entropy impersonated, as such I cant keep anything inside if I want to find it again.

      posted in General Discussion
      Matt
      Matt
    • NewbiePCB sensors dying of old age

      Been a while lol Im still here though, running sundbergs PCBs around the house.
      Seems the battery powered ones are dying. I used cheap chinese clones for everything. Interestingly, the ones I have running off wall sockets or USB power just keep going and going, no probs at all.
      One wont get ACK or reach the controller. One I cant even talk to through the Ardunio IDE, another two wont accept uploads of new code, just sits there 'uploading' forever. another one is just dead dead, I got 3V from new batteries but nothing, nada, zip. Even my two nano's that were just sitting in a drawer for years seem to have expired. If I had a reflow oven I might give that a go as nothing to lose. I wonder if its a lead free solder thing. I have tried redoing the joints on a couple with a new tip on my hakko but made no difference. I cant really pull off/replace the NRF or pro mini as it will bugger the traces.
      <shrug> lol just looked back in my emails and I ordered sundbergs PCBs in 2016 so seven years, cant expect miracles eh.
      What Im gonna do now is m26872's slim nodes. I have the 328Ps and heaps of NRFs just waiting on the PCBs. As you get 10 that will mean 30(!) boards. I only ned around six but great to have spares. Programming bootloaders will be a new experience, now that my nanos have died I have also ordered an UNO to use as ISP. I think Ill just go for an 8Mhz bootloader as Im worried about issues with timing over onewire, I will be using mostly DS18B20s. Its cool that these chips have internal oscillators as well as vref so minimal components.
      Sort of excited again, MySensors remains a hugely valuable app for me, thankyou Hek et al.

      posted in General Discussion
      Matt
      Matt
    • RE: Compile error for Pro Mini 5,5v 168

      @mfalkvidd woohoo! Time to resurrect some old nodes 😃
      Thanks for this...

      posted in Bug Reports
      Matt
      Matt
    • RE: NRF24L01+PA+LNA wiring question

      @parachutesj
      Couple of things - get yourself a cheap multimeter. Indispensable and pretty important piece of kit when you are doing this kind of stuff, will save you frying stuff and help with trouble shooting.
      The PA+LNA version needs around 120 milli amps at peak power (from memory) some of the duinos cant supply this.
      And use the caps as suggested in the wiring guide for the NRF modules on this site.
      Cheers,
      Matt

      posted in Hardware
      Matt
      Matt
    • RE: 💬 Easy/Newbie PCB for MySensors

      @sundberg84 Hiya yep found it, starts with your post 30th June 2016.
      To be honest its a bit over my head, inductors. ferrite beads etc. A picture of what to solder where would help.
      I did try to 0.1uf cap across OUT and GND but the things still only work for a minute then go silent.
      I will desolder existing booster then add a jumper from vin to vout to see how stable they are with a good solid battery supply.
      If they are reliable I will order some more boosters, but it seems a bit hit and miss as to reliability...
      Unless someone can post a pic or explain (for dummies) how to filter the booster effectively?
      I should pull out my scope, which involves tidying my workbench, not a task I undertake lightly....

      Thanks,
      Matt

      posted in OpenHardware.io
      Matt
      Matt
    • RE: NewbiePCB sensors dying of old age

      Hi sundberg84.
      Yeah you're probably right it's something to do with the boost converter eh. I'm still dead keen on battery power hence the slimnodes. Although I'll be putting 8 and 28 pun ic sockets on the pcb so I can swap out either the 328p or nrf if needed. Haven't gone down the rfm route.
      I do have a single 833mhz transmitter to talk to my wall sockets has run continuously for 7 years off USB.

      posted in General Discussion
      Matt
      Matt
    • RE: 433mhz transmitter

      Thanks Boots. One thing I noticed was that three out of five of the receivers I bought did not work. If fact one heated up real quick. So buy a few cos QC in China is pants.

      posted in My Project
      Matt
      Matt

    Latest posts made by Matt

    • RE: Send 2x relay states to Home Assistant to make them visible?

      Oh no I'm wrong cog rail it is!

      posted in Troubleshooting
      Matt
      Matt
    • RE: Send 2x relay states to Home Assistant to make them visible?

      @eiten haha yep we went up the vernacular I think it's called still clearly remember the beautiful views and ice caves

      posted in Troubleshooting
      Matt
      Matt
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Very generous of you matey.
      I have a solar charge controller so no worries with overcharging or draining at night.
      I learned eventually to bring the battery inside through winter it lasts a lot longer now!
      I've been to Switzerland Jungfrau and Bern on a contiki tour around 2004 long time ago now still have a wee knife I bought.
      Have kids wife and mortgage now so sadly my travelling days are behind me, at least for another eight years or so lol

      posted in Troubleshooting
      Matt
      Matt
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Ah no sorry should have said Im usuing pro-mini and FTDI breakout board to program over USB.
      Sitting on sundbergs board with vreg added etc. Just running your code now...
      All works, picks up on first presentation thankyou! Have you got a paypal I can buy you a beer or coffee?

      posted in Troubleshooting
      Matt
      Matt
    • RE: Send 2x relay states to Home Assistant to make them visible?

      @eiten Hi I figured that out, radio was sort of working when device powered by serial usb programmer, enough for me to think was okay. HOWEVER was only ~1.7v so now I have SLA plugged in hardly any NACKs
      Yes I have a SLA that normally charges via solar panel.
      Controlled is a PI3 running mysgw development, is now conntected to linuxbox via ethernet.
      So I tried your code again there is still weird stuff but I have registered both switches, one temp and one bat so perfect!
      However, and this is annoying as this site is not letting me upload pics anymore but some characters are now messed up, same as in the serial ouput round arduino IDEW as before, and also device name in HA is now "{�������~��S��b������Mn�� 54" haha
      Firmware also is "Firmware: ����{�������~��S��b������" within HA.
      So all child sensors are there,
      Bit odd eh!
      Im gonna give the PC to my son so he can get his gametime in now and wife is away with the laptop but will be back a bit later tonight 😃

      Matt

      posted in Troubleshooting
      Matt
      Matt
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Wow Edi you put a lot of work into that, appreciated man!
      So your code seems to do some weird things see below from the serial output.
      Heres a bit of it below this seems to be a repeating loop once I activated the two switches from Domoticz. These switches were registered from my own code yesterday I guess the sensor and child IDs are the same.
      6952f27c-f2f6-4bf5-9f95-bb06d0c4e6e5-image.png
      Prior to this loop there is a long run of these !MCO:PRO:RC=1 which the log parser identifies as "Recursive call detected in _process(), call level=1". These go on for many pages.
      So yeah something a bit broken there Im sorry.
      Nothing registered on HA =(
      Have also had a go with my original code with your three suggested additions.
      Is running good, domoticz has seen temp/bat/switches.
      But still nothing on HA.
      I have tried deleting MyS integration from HA, restarting HA, reloading MyS integration and still does not come up.
      Do you think it could be because I have Domoticz listneing to the same mygw on the PI as HA? Would they compete for info or share? Beyond my level of understanding.
      Perhaps I should implement a MyS serial gateway on a spare PI and connect to the HA linux box via ethernet rather than wifi and see how that goes....?

      Many thanks,
      Matt

      posted in Troubleshooting
      Matt
      Matt
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Eiten I am much obliged. Sorry for my code Ive been trying this and trying that and sort of lost track of what I done and changed.
      You make it look so simple haha I just couldnt work out how to write the MyMessage and send bits thankyou so much.
      Need to retire for the evening as up at 5am for work but will be back on to try it all out tomorrow, am looking forward to your next post.
      Matt

      posted in Troubleshooting
      Matt
      Matt
    • Send 2x relay states to Home Assistant to make them visible?

      Hi all
      Been fiddling around all day. Trying to migrate from domoticz to HA.
      I have an irrigation controller with two relays plus temp and bat children as well.
      I cant get the relays to come up in HA although can see/use them on domoticz.
      Have mys running on a pi ethernetted to a linux box with HA running as a VM. It can see my other sensors okay.
      Code is rough sorry see below and TBH Im not sure which revision Im up to Ive got several .inos around but I think this is the best one. A coder I aint.
      Apparently I need to "Send at least one initial value per V_TYPE. In version 2.x of MySensors, this has to be done in the loop function. See below for an example in 2.0 of how to make sure the initial value has been received by the controller" as per HA.
      Is this true, does it have to be done in the main loop?
      Could someone show me how to do this for BOTH relays please? They should always start in the off state...
      Many many thanks in advance.
      Matt

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * 
       * DESCRIPTION
       * Example sketch showing how to control physical relays. 
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */ 
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 2 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
      #define MY_RF24_PA_LEVEL RF24_PA_HIGH
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 1
      #define CHILD_ID_BAT 9
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_RELAY1 2
      #define CHILD_ID_RELAY2 3
      unsigned long SLEEP_TIME = 600000; // Sleep time between reads (in milliseconds)
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      boolean receivedConfig = false;
      boolean metric = true; 
      // Initialize temperature message
      MyMessage msg(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgBat(CHILD_ID_BAT, V_VOLTAGE);
      
      //#define VBAT_PER_BITS 0.013971  
      #define VMIN 11                                  //  Vmin (radio Min Volt)=1.9V (564v)
      #define VMAX 14.5                                  //  Vmax = (2xAA bat)=3.0V (892v)
      int batteryPcnt = 0;                              // Calc value for battery %
      int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
      
      void before() { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Turn off all pins
          digitalWrite(pin, LOW);
        }
      }
      
      void setup() {
        analogReference(INTERNAL);
        // Startup up the OneWire library
        sensors.begin();
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      }
      
      void presentation()  
      {   
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Relay+Temp", "1.0");
      
        //for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID_RELAY1, S_BINARY);
          present(CHILD_ID_RELAY2, S_BINARY);
          present(CHILD_ID_TEMP, S_TEMP);
          present(CHILD_ID_BAT, S_MULTIMETER);
        }
      
        // Fetch the number of attached temperature sensors  
        //numSensors = sensors.getDeviceCount();
      
        // Present all sensors to controller
        //for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++)    {
        // present(i, S_TEMP);}
           
        
      //}
      
      
      void loop() 
      {
       // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      
        // query conversion time and sleep until conversion completed
        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
        wait(conversionTime);
      
        // Read temperatures and send them to controller 
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
       
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
       
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
       
            // Send in the new temperature
            send(msg.setSensor(i).set(temperature,1));
            Serial.print("SensorValue");
            Serial.print(temperature);
            // Save new temperatures for next compare
            lastTemperature[i]=temperature;
          }
        }
        int sensorValue = analogRead(BATTERY_SENSE_PIN);
        float Vbat  = sensorValue * 0.0139644;
        int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
        sendBatteryLevel(batteryPcnt);
        send(msgBat.set(Vbat, 2));
        /*Serial.print("VBat");
        Serial.print(Vbat);
        Serial.print("SensorValue");
        Serial.print(sensorValue);*/
        wait(SLEEP_TIME); 
      }
      
      void receive(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           //saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }
      
      
      posted in Troubleshooting
      Matt
      Matt
    • RE: NewbiePCB sensors dying of old age

      Hi sundberg84.
      Yeah you're probably right it's something to do with the boost converter eh. I'm still dead keen on battery power hence the slimnodes. Although I'll be putting 8 and 28 pun ic sockets on the pcb so I can swap out either the 328p or nrf if needed. Haven't gone down the rfm route.
      I do have a single 833mhz transmitter to talk to my wall sockets has run continuously for 7 years off USB.

      posted in General Discussion
      Matt
      Matt
    • RE: Water level sensor (inches) to integrate into hardware

      Dunno, depends a bit on context. You could use a strain gauge underneath the cup to measure weight. Or an ultrasonic distance sensor pointing down bouncing off the water? Youd have to seal everying in silicone or epoxy due to moisture I suppose.

      posted in General Discussion
      Matt
      Matt