Ok, related to MySensors 1.6 tehen, that explain why I never seen this !
Posts made by petoulachi
-
RE: Sensebender Micro
-
RE: Sensebender Micro
Thanks !
I took a look at the sketch, I didn't know there was a presentation() method to implement to present the different sensor's ID; is this new ? when is it called? I guess after setup() ?
-
RE: Sensebender Micro
I am adventurous !
Were can I find the beta version of the sketch ?
-
RE: Sensebender Micro
Oh and BTW, which boxes are you using with your Sensebender ? I guess it's maybe the most difficult part of the entire project, finding the perfect box
-
RE: Sensebender Micro
Started to solder my 6 sensebender. I've noticed that if I set it to 1Mhz directly, the sensor cannot register itself on the gateway (but unfortunately I dont know why because there's no serial). Putting it at 8Mhz, being detected by the GW with an ID, and I can set it back to 1mhz. Weird.
-
RE: Sensebender Micro
Oooh so I guess that also explain why I have strange output on the serial using the default sketch ?
Well, I'll start without touching frequency and see how it behave in the next month. This is the sketch I use (not tested yet !). Sleeping all the time, awake but interrupt. When awake, send the Battery % if different from last mesure.
/** * 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 * Default sensor sketch for Sensebender Micro module * Act as a temperature / humidity sensor by default. * * If A0 is held low while powering on, it will enter testmode, which verifies all on-board peripherals * * Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below) * */ #include <MySensor.h> #include <Wire.h> #include <SPI.h> #include "utility/SPIFlash.h" #include <EEPROM.h> #include <avr/power.h> #define RELEASE "1.0" // Child sensor ID's #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID_DOOR 1 // Id of the sensor child MySensor gw; // Sensor messages MyMessage msgDoor(CHILD_ID_DOOR, V_TRIPPED); // Global settings int measureCount = 0; int sendBattery = 0; boolean highfreq = true; // Storage of old measurements long lastBattery = -100; boolean oldDoorValue; /**************************************************** * * Setup code * ****************************************************/ void setup() { Serial.begin(115200); Serial.print(F("Sensebender Micro FW ")); Serial.print(RELEASE); Serial.flush(); gw.begin(); Serial.flush(); Serial.println(F(" - Online!")); gw.sendSketchInfo("Battery Door", RELEASE); // sets the motion sensor digital pin as input pinMode(DIGITAL_INPUT_SENSOR, INPUT); // Activate internal pull-ups digitalWrite(DIGITAL_INPUT_SENSOR, HIGH); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_DOOR, S_DOOR); } /*********************************************** * * Main loop function * ***********************************************/ void loop() { gw.process(); sendBattLevel(false); door(false); gw.sleep(INTERRUPT, CHANGE, 0); } // Check if digital input has changed and send in new value void door(bool force) { // Short delay to allow buttons to properly settle sensor_node.sleep(5); bool tx = force; boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; if (tripped != oldDoorValue) { tx = true; oldDoorValue = tripped; } if (tx) { // Send in the new value gw.send(msgDoor.set(tripped ? 1 : 0)); // Send tripped value to gw } } /******************************************** * * Sends battery information (battery percentage) * * Parameters * - force : Forces transmission of a value * *******************************************/ void sendBattLevel(bool force) { if (force) lastBattery = -1; long vcc = readVcc(); if (vcc != lastBattery) { lastBattery = vcc; // Calculate percentage vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 14.0; gw.sendBatteryLevel(percent); } } /******************************************* * * Internal battery ADC measuring * *******************************************/ long readVcc() { // 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__) ADcdMUX = _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 }
BTW, what is the F() function ? instead of Serial.print("Sensebender Micro FW "); why using Serial.print(F("Sensebender Micro FW ")); ?
Thanks !
-
RE: Sensebender Micro
Hello,
I've just received my sensebender boards and start playing with it.My first goal is to make a door sensor running on battery. I will not use the integrated temp/hum sensor for battery purpose, and use interrupt to have the sensor on sleep the majority of time.
Looking at the sketch given with temp/hum, I have one question;
on the loop function, we have
if ((measureCount == 5) && highfreq) { clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power. highfreq = false; }
But I don't really understand this ; highfreq is initialized to true in the declaration, and never again. So, does this clock_prescale_set is call only once, meangin that the sensor will run at 1Mhz all the time ?
It is the 5 first mesure that are running at normal speed, and then the sensor goes into a "battery efficient" mode ?
Why waiting for 5 mesure to do so, and not doing it at startup ?Thanks for your explanation !
-
RE: Sensebender Micro
Ordered 6 board too ! I'm glad to support MySensors project !
-
RE: Sensebender Micro
That's why I think i'm going to go with this senseboard.
But I want to be sure that some connectors (D3 ?) support interrupts ? The goal is to have the sensor always in sleep mode, and wake up on interrupts only.Regards,
-
RE: Sensebender Micro
Well I do, but I think that using a Arduino Pro 3.3V will be less effecient, but maybe I'm wrong ?
I'm currently using temp/hum/motion sensors with Arduino Pro 5V, but they are not battery powered. Now I need to make very small sensor with battery, and I thought that maybe this sensebender board is my solution ?
-
RE: Sensebender Micro
@tbowmo
Well can't I use this board without using the temp/hum sensor ?This board is quite small and allows to stack the radio module with minimum place. Also it works at 1Mhz, I guess it's a bit better than an Arduino Pro @ 3.3V ?
-
RE: Sensebender Micro
Hello,
one simple quick question, does this board can be used to create door sensors ? I do not need the temp/hum sensors, but I'm interested with the small footprint and the battery optimized board to make smallest door sensors (and some buttons).
regards,
-
RE: Humidity, temperature, motion and bunch of relays...
I found where was the problem, I'm really a newbee... The motion sensor was plugged to the 3.3VCC, not 5V, doing this strange behaviour !
-
RE: Humidity, temperature, motion and bunch of relays...
If you were meaning that I have to do
pinMode(MOTION_SENSOR_DIGITAL_PIN, INPUT_PULLUP);
instead of
pinMode(MOTION_SENSOR_DIGITAL_PIN, INPUT);
It changes nothing !
-
RE: Humidity, temperature, motion and bunch of relays...
I'm sorry I'm a newbie with arduino so I don't understand what you want me to test ?
-
RE: Humidity, temperature, motion and bunch of relays...
Hey !
I'm trying to use your code to do a Motion/temp/humidity sensor, but I dont know why the motion sensor is sending 0/1/0/1... if there is nothing moving ?!
Here is my code :
#include <SPI.h> #include <MySensor.h> #include <DHT.h> #include <SimpleTimer.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_MOT 2 #define MOTION_SENSOR_DIGITAL_PIN 3 #define HUMIDITY_SENSOR_DIGITAL_PIN 4 //#define INTERRUPT MOTION_SENSOR_DIGITAL_PIN-2 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) MySensor gw; DHT dht; SimpleTimer timer; float lastTemp; float lastHum; boolean lastTripped; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED); void setup() { gw.begin(); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity/Motion", "1.0"); pinMode(MOTION_SENSOR_DIGITAL_PIN, INPUT); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); gw.present(CHILD_ID_MOT, S_MOTION); timer.setInterval(30000, getMeasure); } void loop() { timer.run(); boolean tripped = digitalRead(MOTION_SENSOR_DIGITAL_PIN) == HIGH; if (tripped != lastTripped) { lastTripped = tripped; Serial.print("M: "); Serial.println(tripped); gw.send(msgMot.set(tripped?"1":"0")); // Send tripped value to gw } } void getMeasure() { 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)); Serial.print("T: "); Serial.println(temperature); } 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)); Serial.print("H: "); Serial.println(humidity); } }
Do you have any idea what could be causing that ?
Regards !
-
RE: Door, Motion and Temperature Sensor
Hello,
I've read this thread with interest because I want to make my Motion/Temp sensor using Dallas.
Adapting the given code was quite easy (well I guess as I have not tested it for now ), I only have changed gw.wait with gw.sleep, because if I understand it correctly, gw.sleep put the sensor in sleep mode which is a bit better for battery :
#include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID_S1 1 // Id of the sensor child #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected #define CHILD_ID_T1 2 //CHILD ID for temp OneWire oneWire(ONE_WIRE_BUS); DallasTemperature DallasSensors(&oneWire); float lastTemperature ; unsigned long SLEEP_TIME = 30000; // Sleep time between reports (in milliseconds) unsigned long lastRefreshTime = 0; boolean lastTripped = 0; MySensor gw; // Initialize motion message MyMessage motionMsg(CHILD_ID_S1, V_TRIPPED); MyMessage tempMsg(CHILD_ID_T1,V_TEMP); void setup() { // Startup OneWire Temp Sensors DallasSensors.begin(); DallasSensors.setWaitForConversion(false); gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Motion and Temperature Sensor", "1.0"); pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_S1, S_MOTION); gw.present(CHILD_ID_T1, S_TEMP); } void loop() { // Process incoming messages (like config from server) gw.process(); // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; if (lastTripped != tripped ) { Serial.println("Tripped"); gw.send(motionMsg.set(tripped?"1":"0")); // Send tripped value to gw lastTripped=tripped; } boolean bNeedRefresh = (millis() - lastRefreshTime) > SLEEP_TIME; if (bNeedRefresh) { lastRefreshTime = millis(); DallasSensors.requestTemperatures(); gw.sleep(750); float tempC = DallasSensors.getTempCByIndex(1); float difference = lastTemperature - tempC; if (tempC != -127.00 && abs(difference) > 0.1) { // Send in the new temperature gw.send(tempMsg.set(tempC, 1)); lastTemperature = tempC; } } else { gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME); } }
But I'm concerned about thoses particular lines :
lastRefreshTime = millis(); DallasSensors.requestTemperatures(); gw.sleep(750); float tempC = DallasSensors.getTempCByIndex(1);
Why do we need gw.sleep(750) ? My concern is, when the sensor tries to pull temperature, it could not trigger new motion state for at least 750ms ? This is a problem for me, as I want to use these sensor to trigger light when I come in the room, so I need it to be fast.
Thanks !
-
RE: Nice box for your Sensors/Serial GW
They are nice ! Where do you bought them ?
Regards,
-
Nice box for your Sensors/Serial GW
Hello,
I'm curious to know how you all box your sensors and the serial gateway ?
Regards,
-
RE: Motion/Humidity on Pro Mini ?
I know about the step-down yes, that's why I'm guessing that the VCC for the radio cannot be used for the sensors as they use 5V (using thoses )
I'm not sure I've understood the part about capacitors. Are you suggesting me to add capacitors for every sensors ? I have thoses, do they fit my needs ?
The pro-mini will be powered using this . I hope everything's fine !
regards,
-
Motion/Humidity on Pro Mini ?
Hello,
I'm new to MySensors and very excited discovering all the possibility !
I have one simple question at start : is it possible, using the PRO Mini (5V), to connect both Motion AND Humidity on the same VCC ?
The PRO Mini only has two VCC, and one is already used by the NRF in 3.3V. So, could I connect two more sensors, or I have to switch to the Nano ?Thanks !