Skip to content

General Discussion

A place to talk about whateeeever you want
1.5k Topics 14.2k Posts
  • Triple Axis Compass Sensor for mailbox?

    12
    0 Votes
    12 Posts
    3k Views
    Cliff KarlssonC
    I used the BinarySwitchSleepSensor sketch and tried adding the battery measuring info. Does this look ok If I only want the sensor to sleep until the magnetswitch attached to PIN 2 is opened and every 6h it reports battery? // Enable debug prints to serial monitor #define MY_DEBUG #define SLEEP_TIME 21600000 // Sleep time between reads (in milliseconds) // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensor.h> #define SKETCH_NAME "Mailbox +Battery" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define PRIMARY_CHILD_ID 3 #define CHILD_ID_BATTERY 1 #define BATTERY_FULL 3143 // 2xAA usually give 3.143V when full #define BATTERY_ZERO 2340 #define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED); MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE); long oldvoltage = 0; void setup() { // Setup the buttons pinMode(PRIMARY_BUTTON_PIN, INPUT); // Activate internal pull-ups digitalWrite(PRIMARY_BUTTON_PIN, HIGH); } void presentation() { // Send the sketch version information to the gateway and Controller 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. present(PRIMARY_CHILD_ID, S_DOOR); delay(250); present(CHILD_ID_BATTERY, S_CUSTOM); } // Loop will iterate on changes on the BUTTON_PINs void loop() { uint8_t value; static uint8_t sentValue=2; // Short delay to allow buttons to properly settle sleep(5); value = digitalRead(PRIMARY_BUTTON_PIN); if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg.set(value==HIGH ? 1 : 0)); sentValue = value; } long voltage = readVcc(); if (oldvoltage != voltage) { // Only send battery information if voltage has changed, to conserve battery. send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts. Set wants volts and how many decimals (3 in our case) sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO))); oldvoltage = voltage; } // Sleep until something happens with the sensor sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SLEEP_TIME); } long readVcc() { // From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/ // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ADMUX = _BV(MUX5) | _BV(MUX0); #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) ADMUX = _BV(MUX3) | _BV(MUX2); #else ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #endif delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA, ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high << 8) | low; result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts }
  • WISP computer has no battery, gets power wirelessly from radio waves

    3
    0 Votes
    3 Posts
    1k Views
    ahmedadelhosniA
    Yeah that's a weak point. This technolgy seems to grow fast and will save a lot of effort in industry and IOT applications.
  • Several dimmers

    11
    0 Votes
    11 Posts
    3k Views
    M
    The answer was simple Change digitalWrite( LED_PIN_1, 0); to analogWrite( LED_PIN_1, 0);
  • Code problem

    6
    0 Votes
    6 Posts
    1k Views
    M
    Well everything almost fixed. The code if somebody will be building something similar... 4 push buttons attached and 3 dimmers + MQ and DHT22 All the logic is supposed to be handled by the controller. Problems remaining... If you set the button state in the controller - it doesn't get updated on the node... Any hints appreciated on this And the major problem - if the node resets the LIGHTS are ON! As has been hinted in another topic the code has to be rewritten so in the beginning it sets the values to zero and informs the controller isntead of pulling values. But my lack of knowledge stops me on this one. So help will be much appreciated #define SN "Kitchen Hood" #define SV "1.0" #include <MySensor.h> #include <SPI.h> #include <DHT.h> #include <math.h> #include <Wire.h> #include <Bounce2.h> //DEFINE CHILD_IDS #define DIMMER_NODE_1 0 #define DIMMER_NODE_2 1 #define DIMMER_NODE_3 2 #define CHILD_ID_HUM 4 #define CHILD_ID_TEMP 5 #define CHILD_ID_MQ 6 #define CHILD_BUT1 7 #define CHILD_BUT2 8 #define CHILD_BUT3 9 #define CHILD_BUT4 10 //BUTTONS #define BUTTON_PIN1 A0 #define BUTTON_PIN2 A1 #define BUTTON_PIN3 A2 #define BUTTON_PIN4 A3 //MQ+DHT #define MY_LEDS_BLINKING_FEATURE #define HUMIDITY_SENSOR_DIGITAL_PIN 8 const int MQ_Pin = A4; //DIMMER #define LED_PIN_1 3 #define LED_PIN_2 5 #define LED_PIN_3 6 #define FADE_DELAY 10 MySensor gw; DHT dht; //BUTTONS Bounce debouncer_1 = Bounce(); Bounce debouncer_2 = Bounce(); Bounce debouncer_3 = Bounce(); Bounce debouncer_4 = Bounce(); int oldValue_1=-1; int oldValue_2=-1; int oldValue_3=-1; int oldValue_4=-1; bool state1; bool state2; bool state3; bool state4; MyMessage msgbut1(CHILD_BUT1,V_TRIPPED); MyMessage msgbut2(CHILD_BUT2,V_TRIPPED); MyMessage msgbut3(CHILD_BUT3,V_TRIPPED); MyMessage msgbut4(CHILD_BUT4,V_TRIPPED); //MQ+DHT float lastTemp; float lastHum; float hum_floa; float last_mq_reading; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgMQ(CHILD_ID_MQ, V_LEVEL); //DIMMER byte currentLevel[3] = {0,0,0}; MyMessage dimmerMsg0(0, V_DIMMER); MyMessage lightMsg0(0, V_LIGHT); MyMessage dimmerMsg1(1, V_DIMMER); MyMessage lightMsg1(1, V_LIGHT); MyMessage dimmerMsg2(2, V_DIMMER); MyMessage lightMsg2(2, V_LIGHT); unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) void setup() { Serial.begin(9600); Serial.println( SN ); gw.begin( incomingMessage ); gw.sendSketchInfo(SN, SV); //MQ+DHT dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); gw.present(CHILD_ID_MQ, S_AIR_QUALITY); gw.wait( 50 ); //DIMMER gw.present( DIMMER_NODE_1, S_DIMMER ); gw.wait( 50 ); gw.present( DIMMER_NODE_2, S_DIMMER ); gw.wait( 50 ); gw.present( DIMMER_NODE_3, S_DIMMER ); gw.wait( 50 ); gw.request( DIMMER_NODE_1, V_DIMMER ); gw.wait( 50 ); gw.request( DIMMER_NODE_2, V_DIMMER ); gw.wait( 50 ); gw.request( DIMMER_NODE_3, V_DIMMER ); //BUTTONS pinMode(BUTTON_PIN1,INPUT); digitalWrite(BUTTON_PIN1, HIGH); pinMode(BUTTON_PIN2,INPUT); digitalWrite(BUTTON_PIN2, HIGH); pinMode(BUTTON_PIN3,INPUT); digitalWrite(BUTTON_PIN3, HIGH); pinMode(BUTTON_PIN4,INPUT); digitalWrite(BUTTON_PIN4, HIGH); debouncer_1.attach(BUTTON_PIN1); debouncer_1.interval(5); debouncer_2.attach(BUTTON_PIN2); debouncer_2.interval(5); debouncer_3.attach(BUTTON_PIN3); debouncer_3.interval(5); debouncer_4.attach(BUTTON_PIN4); debouncer_4.interval(5); gw.present(CHILD_BUT1, S_DOOR); gw.wait( 50 ); gw.present(CHILD_BUT2, S_DOOR); gw.wait( 50 ); gw.present(CHILD_BUT3, S_DOOR); gw.wait( 50 ); gw.present(CHILD_BUT4, S_DOOR); gw.wait( 50 ); } void loop() { gw.process(); int value_but_1 = debouncer_1.read(); int value_but_2 = debouncer_2.read(); int value_but_3 = debouncer_3.read(); int value_but_4 = debouncer_4.read(); //BUTTONS debouncer_1.update(); if (value_but_1 != oldValue_1) { if ( value_but_1==0) { state1 = !state1; gw.send(msgbut1.set(state1)); } oldValue_1 = value_but_1; } debouncer_2.update(); if (value_but_2 != oldValue_2) { if ( value_but_2==0) { state2 = !state2; gw.send(msgbut2.set(state2)); } oldValue_2 = value_but_2; } debouncer_3.update(); if (value_but_3 != oldValue_3) { if ( value_but_3==0) { state3 = !state3; gw.send(msgbut3.set(state3)); } oldValue_3 = value_but_3; } debouncer_4.update(); if (value_but_4 != oldValue_4) { if ( value_but_4==0) { state4 = !state4; gw.send(msgbut4.set(state4)); } oldValue_4 = value_but_4; } } //DHT+MQ delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; gw.send(msgTemp.set(temperature, 1)); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); } float mq_reading = analogRead(MQ_Pin); if (isnan(mq_reading)) { Serial.println("Failed mq_reading"); } else if (mq_reading != last_mq_reading) { last_mq_reading = mq_reading; gw.send(msgMQ.set(mq_reading, 1)); } //DIMMER void incomingMessage(const MyMessage &message) { if (message.type == V_LIGHT || message.type == V_DIMMER) { int requestedLevel = atoi( message.data ); requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 ); requestedLevel = requestedLevel > 100 ? 100 : requestedLevel; requestedLevel = requestedLevel < 0 ? 0 : requestedLevel; Serial.print( "Changing level to " ); Serial.print( requestedLevel ); Serial.print( ", from " ); Serial.println( currentLevel[message.sensor] ); fadeToLevel( requestedLevel, message.sensor); switch(message.sensor) { case 0: gw.send(lightMsg0.set(currentLevel[0] > 0 ? 1 : 0)); gw.send( dimmerMsg0.set(currentLevel[0]) ); break; case 1: gw.send(lightMsg1.set(currentLevel[1] > 0 ? 1 : 0)); gw.send( dimmerMsg1.set(currentLevel[1]) ); break; case 2: gw.send(lightMsg2.set(currentLevel[2] > 0 ? 1 : 0)); gw.send( dimmerMsg2.set(currentLevel[2]) ); break; } } } void fadeToLevel( int toLevel, byte sensorId ) { int delta = ( toLevel - currentLevel[sensorId] ) < 0 ? -1 : 1; while ( currentLevel[sensorId] != toLevel ) { currentLevel[sensorId] += delta; switch(sensorId) { case 0: analogWrite( LED_PIN_1, (int)(currentLevel[sensorId] / 100. * 255) ); break; case 1: analogWrite( LED_PIN_2, (int)(currentLevel[sensorId] / 100. * 255) ); break; case 2: analogWrite( LED_PIN_3, (int)(currentLevel[sensorId] / 100. * 255) ); break; } delay( FADE_DELAY ); } }```
  • Easily configure settings

    2
    0 Votes
    2 Posts
    655 Views
    hekH
    @miclane said: Has anyone worked on it? Nope, not that I know of.
  • Monitor if an outlet has power - send email

    10
    0 Votes
    10 Posts
    4k Views
    ThomasDrT
    Hello, Measure A socket directly is always a risk. just take a power adapter, power the Mysensors Note and send a Life Bit to your Application. Is the Outlet power down the Note send no Life Bit and your Application can send a E-Mail. regards Thomas
  • NRF24L01+PA+LNA

    32
    0 Votes
    32 Posts
    10k Views
    OitzuO
    @Mark-Swift let us know how they perform. The supplier looks very professional. Would be interesting if they really reach the promised 2.1km :D (I wonder with which antenna) even better to use 3.3v (hence on my next one to play it safe I'll use a spare 5v -> 3.3v level shift converter too). Or use a 3.3V pro mini.
  • Z-wave sensor

    5
    1 Votes
    5 Posts
    3k Views
    hekH
    The MySensors project was created to bypass the rigorous rules of z-wave and closeness of their protocol and source code. MySensors is capable of everything on your list every node is a repeater low power encryption I addition we provide message authentication and "standardized" OTA updates capability. The latest version of z-wave addresses some of their previous security problems.. but considering their closeness it's hard to know how good they are.
  • MQTT dimmer message

    9
    0 Votes
    9 Posts
    3k Views
    martinhjelmareM
    gw.process is called in the loop, so messages should be processed even with repeater mode turned off. I suggest upgrading the library to 1.5.4 for the nodes, as the bug regarding payloads was solved with that version.
  • Looking for a GPS tracker

    gps
    1
    0 Votes
    1 Posts
    744 Views
    No one has replied
  • Telephone line switch

    4
    0 Votes
    4 Posts
    1k Views
    mfalkviddM
    The relay example should work fine I think.
  • Power source and worklight on sale (in Sweden)

    4
    2 Votes
    4 Posts
    999 Views
    S
    Damn you sweedish guys! I need one of those lighted magnifying workstations. I might move there just to get this sale haha.
  • Combined sketch PH meter and Temp Sensor

    3
    0 Votes
    3 Posts
    1k Views
    S
    These are the reading i got. send: 2-2-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0 send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.3 send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0 read: 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:M sensor started, id=2, parent=0, distance=1 send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=7,sg=0,st=ok:pHmeter send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0 send: 2-2-0-0 s=0,c=0,t=21,pt=0,l=0,sg=0,st=ok: send: 2-2-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=ok: pH:3.36 send: 2-2-0-0 s=0,c=1,t=24,pt=7,l=5,sg=0,st=ok:3.36 send: 2-2-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:21.3 send: 2-2-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:21.1 send: 2-2-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:21.0 send: 2-2-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:20.8 pH:3.86 send: 2-2-0-0 s=0,c=1,t=24,pt=7,l=5,sg=0,st=ok:3.86 The 14.79 is from the PH the rest the temp sensor. as you can see both values are on parent 0. is it possible to get the ph on parent 0 and the temp on 1?
  • Login openhardwareio with mysensors data

    7
    0 Votes
    7 Posts
    1k Views
    L
    @hek Thank you, it's working again. Glad I could help (finding a bug ;) )
  • Doubt of components to my project

    6
    0 Votes
    6 Posts
    1k Views
    mfalkviddM
    Great! Thanks for reporting back.
  • Arduino UNO + serial gateway

    12
    0 Votes
    12 Posts
    5k Views
    hekH
    It is a development branch define.
  • Good-looking way to control dimmer?

    11
    1 Votes
    11 Posts
    3k Views
    mfalkviddM
    @BulldogLowell that's a great idea. It will require some learning (a guest will probably not be able to figure out how to handle the lights) but once learned, it should be really easy to operate.
  • [SOLVED] Mysensors Lux

    10
    0 Votes
    10 Posts
    2k Views
    the cosmic gateT
    @TheoL said: @the-cosmic-gate Great! And you're also good with a soldering iron. I don't think I could replace an SMD resistor ;-) i didn't solder the SMD :) just replaced the whole radio :) much more easy btw: congratz :P
  • GC-0016 connection and sketch for arduino

    1
    0 Votes
    1 Posts
    634 Views
    No one has replied
  • Cloud storage for home automation?

    11
    0 Votes
    11 Posts
    4k Views
    V
    @TRS-80 said: Your concerns are absolutely valid! And, BTW congratulations for being one of the few nowadays that question these sort of things (privacy, security) in general, instead of just blindly accepting them! Why would you not consider rolling your own? There are a number of inexpensive hardware available, and a number of software choices (and/or combinations of softwares that integrate well together) that will let you do almost whatever you want. Going the commercial "out of the box" route may be the easiest to get started, but you may eventually run in to proprietary lock in, incompatibility, and/or missing one or more certain features that you really need (some of which, may not even be apparent at the current time). It is for these reasons that I tend personally to lean more in the direction of rolling my own, and using open source software, hardware, etc. You can do whatever you want to, and it's almost always costs less money. :) If things end up not working out with one system, you can change software later and go in another direction, you still own your hardware. But, you will need to spend a little time learning some things. Is that so bad? :) There are many guides, much useful information, and many helpful communities (like this one!) on the internet nowadays; it's really not that difficult. Plus, it is very rewarding learning and figuring things out and accomplishing them. :) How much/what kind of data do you need to store? Just the HA setup? Sounds like maybe security system video as well? Video can take up a lot of HDD space (or bandwidth, so much in fact that it is probably not practical to upload). Do you also need a backup solution also for perhaps photos and/or other data? Give us a little more information about what you want your ultimate, complete dream system to eventually look like and include, and that will allow us to recommend some hardware and software which will (eventually) meet that goal. Begin with the end in mind, I say. It will save you a lot of time, headaches, and $ down the road. Thanks for effort! :) However, I just feel that it's way more complex, which is a bit unfortunate. It's not motivating for me to change software/hardware over time, it feels a bit unnecessary and it may increase the odds of adding devices in an non-optimal way. The things is that I don't have so many devices to start with and I see this as a project. Therefore, getting a solution, that will eventually solve all my problems, is more suitable for me. I don't need to think so much about the hardware/software, instead, I can focus on the devices and what they can do together :) I don't mind learning new stuff, it's just that I already have a pile of those things already haha, or at least time consuming hobbies/duties. In the future, I would like to have the following: lamps, sensors, kitchen appliances, blinds, speakers, TV, smoke detectors, alarm system, assistance/surveillance for pets and kids. I want multiple integration and communication to set up scenarios; Moreover, dinner time, movie time, gaming time, morning routines, alarm package, party or social gatherings and so forth.

11

Online

11.7k

Users

11.2k

Topics

113.0k

Posts