Skip to content

My Project

967 Topics 13.5k Posts

Show off and share your great projects here! We love pictures!

  • Office plan monitor (advice required)

    12
    4 Votes
    12 Posts
    4k Views
    C
    Hello, Last modification: [image: 1462288485642-2016-05-03-17.11.55.png] [image: 1462288493657-2016-05-03-17.14.09.png] I still have your make minor modification on marking and then go to production :) David.
  • Mailbox sensor (Arduino pro mini + NRF24L01+) Luup code?

    4
    0 Votes
    4 Posts
    2k Views
    H
    No I haven't moved to UI7 so I couldn't say.
  • 32 I2C Relay

    relay i2c pcf8574
    1
    1 Votes
    1 Posts
    4k Views
    No one has replied
  • My Small GateWay

    19
    1 Votes
    19 Posts
    13k Views
    M
    @C4Vette thanks! I can see more details is at http://www.mysensors.org/build/advanced_gateway
  • My PhD Project

    8
    2 Votes
    8 Posts
    5k Views
    mark_vennM
    @TheoL Hey Theo If you do get to come over some time, let me know and I will show you how my project is going in the test house. Assuming I get some where soon. I have been trying to get an Insteon hub working with openHAB and I have had so many problems, hence my looking for a different approach and looking at MySensors! Just waiting for my pro minis and radio boards to arrive then I can actually get somewhere. (I hope) Might have made a bad decision with my choice of 5v minis with step down regulators for the radio. Wasn't thinking of power for the boards themselves. What do you recommend I do to power 5v boards when there is no power locally?
  • Relay and light dimmer with light level in one node

    7
    0 Votes
    7 Posts
    3k Views
    J
    OK thanks everyone for help, this is code witch works very well: Only I must add the line where the light will be turn "off" when light level will be > 350 after 5 minutes. #include <SPI.h> #include <Encoder.h> #include <MySensor.h> #include <Bounce2.h> #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define ONE_WIRE_BUS 19 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 1 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. #define LED_PIN 3 // Arduino pin attached to MOSFET Gate pin #define KNOB_ENC_PIN_1 4 // Rotary encoder input pin 1 #define KNOB_ENC_PIN_2 5 // Rotary encoder input pin 2 #define KNOB_BUTTON_PIN 6 // Rotary encoder button pin #define photoPin A6 // Fotorezystor #define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim) #define SEND_THROTTLE_DELAY 400 // Number of milliseconds before sending after user stops turning knob #define SN "DimmableLED /w button" #define SV "1.2" #define CHILD_ID_LIGHT 16 #define ID 15 #define EEPROM_DIM_LEVEL_LAST 1 #define EEPROM_DIM_LEVEL_SAVE 2 #define LIGHT_OFF 0 #define LIGHT_ON 1 //WENT //#define WENT_RELAY_PIN 17 // Arduino Digital I/O pin number for relay //#define WENT_BUTTON_PIN 18 // Arduino Digital I/O pin number for button //#define CHILD_ID_WENT 17 // Id of the sensor child #define RELAY_ON 1 #define RELAY_OFF 0 #define noRelays 1 const int relayPin[] = {17}; // switch around pins to your desire const int buttonPin[] = {18}; // switch around pins to your desire class Relay // relay class, store all relevant data (equivalent to struct) { public: int buttonPin; // physical pin number of button int relayPin; // physical pin number of relay byte oldValue; // last Values for key (debounce) boolean relayState; // relay status (also stored in EEPROM) }; //END int dimValue; int fadeTo; int fadeDelta; int persons; byte oldButtonVal; bool changedByKnob=false; bool sendDimValue=false; unsigned long lastFadeStep; unsigned long sendDimTimeout; char convBuffer[10]; float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; unsigned long on = 0; unsigned long onT = 0; MySensor gw; // Initialize temperature message MyMessage msg(0,V_TEMP); MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER); MyMessage msgl(0, V_LIGHT_LEVEL); //WENT Relay Relays[noRelays]; Bounce debouncer1[noRelays]; MyMessage msg1[noRelays]; //END Encoder knob(KNOB_ENC_PIN_1, KNOB_ENC_PIN_2); Bounce debouncer = Bounce(); int lastLightLevel; void setup() { // The third argument enables repeater mode. // gw.begin(NULL, AUTO, true); //Send the sensor node sketch version information to the gateway // gw.sendSketchInfo("Repeater Node", "1.0"); // Set knob button pin as input (with debounce) pinMode(KNOB_BUTTON_PIN, INPUT); pinMode(photoPin, INPUT); digitalWrite(KNOB_BUTTON_PIN, HIGH); debouncer.attach(KNOB_BUTTON_PIN); debouncer.interval(5); oldButtonVal = debouncer.read(); // Set analog led pin to off analogWrite( LED_PIN, 0); // Init mysensors library gw.begin(incomingMessage, ID, true); // Send the Sketch Version Information to the Gateway gw.present(CHILD_ID_LIGHT, S_DIMMER); gw.sendSketchInfo(SN, SV); gw.sendSketchInfo("Repeater Node", "1.0"); // Retreive our last dim levels from the eprom fadeTo = dimValue = 0; byte oldLevel = 0; Serial.print("Sending in last known light level to controller: "); Serial.println(oldLevel); gw.send(dimmerMsg.set(oldLevel), true); Serial.println("Ready to receive messages..."); // Startup up the OneWire library sensors.begin(); // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); // 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++) { gw.present(i, S_TEMP); } gw.present(15, S_LIGHT_LEVEL); //WENT gw.sendSketchInfo("MultiRelayButton", "0.9b"); delay(250); // Initialize Relays with corresponding buttons for (int i = 0; i < noRelays; i++){ Relays[i].buttonPin = buttonPin[i]; // assign physical pins Relays[i].relayPin = relayPin[i]; msg1[i].sensor = i; // initialize messages msg1[i].type = V_LIGHT; debouncer1[i] = Bounce(); // initialize debouncer debouncer1[i].attach(buttonPin[i]); debouncer1[i].interval(5); pinMode(Relays[i].buttonPin, INPUT_PULLUP); pinMode(Relays[i].relayPin, OUTPUT); Relays[i].relayState = gw.loadState(i); // retrieve last values from EEPROM digitalWrite(Relays[i].relayPin, Relays[i].relayState? RELAY_ON:RELAY_OFF); // and set relays accordingly gw.send(msg1[i].set(Relays[i].relayState? true : false)); // make controller aware of last status gw.present(i, S_LIGHT); // present sensor to gateway delay(250); } //END } void loop() { // Process incoming messages (like config and light state from controller) gw.process(); //WENT for (byte i = 0; i < noRelays; i++){ debouncer1[i].update(); byte value = debouncer1[i].read(); if (value != Relays[i].oldValue && value == 0){ Relays[i].relayState = !Relays[i].relayState; digitalWrite(Relays[i].relayPin, Relays[i].relayState?RELAY_ON:RELAY_OFF); gw.send(msg1[i].set(Relays[i].relayState? true : false)); gw.saveState( i, Relays[i].relayState );} // save sensor state in EEPROM (location == sensor number) Relays[i].oldValue = value; } //END // Sprawdzenie temperatury CheckTemp(); onT = onT + 1; on = on + 1; if (on > 401 + 2*ID) { // Poziom swiata lightLevel(); on = 0; } if (analogRead(photoPin) > 350) { persons = 0;} else {persons = 1;} // Check if someone has pressed the knob button checkButtonClick(); // Fade light to new dim value fadeStep(); } void lightLevel() { int lightLevel = (analogRead(photoPin)); Serial.println(lightLevel); if (lightLevel != lastLightLevel) { gw.send(msgl.set(lightLevel)); lastLightLevel = lightLevel; } } void CheckTemp() { // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // 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>((gw.getConfig().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 if (onT > 400 + 2*ID) { // Send in the new temperature gw.send(msg.setSensor(i).set(temperature,1)); onT = 0; } // Save new temperatures for next compare lastTemperature[i]=temperature; } } } void incomingMessage(const MyMessage &message) {// if (message.sensor == 17){ //} else { if (analogRead(photoPin) > 350) { persons = 0;} else {persons = 1;} if (message.type == V_LIGHT && persons == 1 && message.sensor == 16) { // Incoming on/off command sent from controller ("1" or "0") int lightState = message.getString()[0] == '1'; int newLevel = 0; if (lightState==LIGHT_ON) { // Pick up last saved dimmer level from the eeprom newLevel = loadLevelState(EEPROM_DIM_LEVEL_SAVE); } // Send dimmer level back to controller with ack enabled gw.send(dimmerMsg.set(newLevel), true); // We do not change any levels here until ack comes back from gateway return; } else if (message.type == V_DIMMER && persons == 1 && message.sensor == 16) { // Incoming dim-level command sent from controller (or ack message) fadeTo = atoi(message.getString(convBuffer)); // Save received dim value to eeprom (unless turned off). Will be // retreived when a on command comes in if (fadeTo != 0) saveLevelState(EEPROM_DIM_LEVEL_SAVE, fadeTo); } if (persons == 1 && message.sensor == 16){ saveLevelState(EEPROM_DIM_LEVEL_LAST, fadeTo); Serial.print("New light level received: "); Serial.println(fadeTo); if (!changedByKnob) knob.write(fadeTo); // Cancel send if user turns knob while message comes in changedByKnob = false; sendDimValue = false; // Stard fading to new light level startFade(); } else if (persons == 0){ if (message.getString() != 0) {gw.send(dimmerMsg.set(0), true);} else {return;} } //WENT if (message.type == V_LIGHT){ if (message.sensor <noRelays){ // check if message is valid for relays..... previous line [[[ if (message.sensor <=noRelays){ ]]] Relays[message.sensor].relayState = message.getBool(); digitalWrite(Relays[message.sensor].relayPin, Relays[message.sensor].relayState? RELAY_ON:RELAY_OFF); // and set relays accordingly gw.saveState( message.sensor, Relays[message.sensor].relayState ); // save sensor state in EEPROM (location == sensor number) } } //END }//} void checkButtonClick() { if ( persons == 1 ) { debouncer.update(); byte buttonVal = debouncer.read(); byte newLevel = 0; if (buttonVal != oldButtonVal && buttonVal == LOW) { if (dimValue==0) { // Turn on light. Set the level to last saved dim value // int saved = loadLevelState(EEPROM_DIM_LEVEL_SAVE); int saved = 100; newLevel = saved > 0 ? saved : 100; } gw.send(dimmerMsg.set(newLevel),true); } oldButtonVal = buttonVal; } } void startFade() { fadeDelta = ( fadeTo - dimValue ) < 0 ? -1 : 1; lastFadeStep = millis(); } // This method provides a graceful none-blocking fade up/down effect void fadeStep() { unsigned long currentTime = millis(); if ( dimValue != fadeTo && currentTime > lastFadeStep + FADE_DELAY) { dimValue += fadeDelta; analogWrite( LED_PIN, (int)(dimValue / 100. * 255) ); lastFadeStep = currentTime; Serial.print("Fading level: "); Serial.println(dimValue); if (fadeTo == dimValue && changedByKnob) { sendDimValue = true; sendDimTimeout = currentTime; } } // Wait a few millisecs before sending in new value (if user still turns the knob) if (sendDimValue && currentTime > sendDimTimeout + SEND_THROTTLE_DELAY) { // We're done fading.. send in new dim-value to controller. // Send in new dim value with ack (will be picked up in incomingMessage) gw.send(dimmerMsg.set(dimValue), true); // Send new dimmer value and request ack back sendDimValue = false; } } // Make sure only to store/fetch values in the range 0-100 from eeprom int loadLevelState(byte pos) { return min(max(gw.loadState(pos),0),100); } void saveLevelState(byte pos, byte data) { gw.saveState(pos,min(max(data,0),100)); }
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    55 Views
    No one has replied
  • IR Sender for stereo receiver

    5
    1 Votes
    5 Posts
    3k Views
    Dan S.D
    I should add that I use a vera scene to turn the receiver on and select a particular preset for the Hd FM tuner. I just select device off for the receiver in vera to turn everything off.
  • Sonos plugin (Newbie)

    5
    0 Votes
    5 Posts
    2k Views
    miroM
    I have now got all my parts and should test this sensor. Now when I connect the serial gateway to my vera edge it says "Lua Startup Failure Can't Detect Device". What can the problem be? I tried to disconnect it and connect it again but nothing happends. Erlier when I haven`t all parts for the sensor all worked okay with the gateway, the only difference now is that I have connected the radio laso. Please help.
  • Burglary and tamper detector for door and window

    1
    2 Votes
    1 Posts
    1k Views
    No one has replied
  • PH and Temp controller

    1
    1 Votes
    1 Posts
    2k Views
    No one has replied
  • MySensors on ATTINY85

    attiny
    24
    2 Votes
    24 Posts
    20k Views
    T
    @Oitzu Thanks!!
  • RelayWithButtonActuator (6 channel)

    33
    0 Votes
    33 Posts
    15k Views
    V
    Connect the power supply to the relay which should be governed by the device stops working
  • 2 channel in wall dimmer

    54
    6 Votes
    54 Posts
    28k Views
    S
    @Oitzu Ahh, sorry I missunderstood you - the other way around. I read it like you had to have the nrf attached to make it work :)
  • Irrigation computer with MySensor. Noob needs some help.

    5
    0 Votes
    5 Posts
    3k Views
    D
    @SuperKris Have you read through the project thread on the irrigation controller? It is a long thread but there was some discussion on sending 'sprinkler on' times from Domoticz.
  • Car remote start with Amazon Echo, Homeseer, and My Sensors hardware

    6
    2 Votes
    6 Posts
    3k Views
    T
    @ajachierno I'm sorry to hear that. It's one of the reasons why I focus on security a lot. Smart of you not to hookup the unlock button.
  • 6 Votes
    9 Posts
    5k Views
    alexsh1A
    I hate to disappoint you @micah but @Mike-Musskopf has got a point: MQ* sensors are power hungry. You may want to connect everything up to 240V via a small PSU. There is a big thread on mysensors about air quality detection. DHT is not the best sensor for a battery application. Please check BME280 (pressure, temp and hum) or Si7021 (temp and hum) - these would be my favourite sensors for low power consumption. Small tip - your Arduino Pros must be 3.3V and not 5V for the battery usage.
  • Event Drops: Visualizing message frequencies with d3.js

    d3.js
    1
    3 Votes
    1 Posts
    3k Views
    No one has replied
  • Gesture controlled Floor Lamp

    14
    7 Votes
    14 Posts
    9k Views
    V
    @TheoL said: of course I will wait. Thank you for your ideas. they are very useful.
  • Hacking my home alarm

    4
    0 Votes
    4 Posts
    2k Views
    T
    @Sander-Stolk I'm guessing your Home Alarm must be protected against over power and thinks like that. It's worth the risk. Maybe you can connect a good old transistor? Just to separate the circuits. I'm by far no expert. But I just don't trust the 0.01V that's a low and strange value. At least to me it is ;-)

16

Online

12.0k

Users

11.2k

Topics

113.4k

Posts