@m26872 Thanks for the input.
@Tom71 Have you looked at your controller software if you could manage the "no Motion state" after 20sec ? I'm using domoticz and I could set an "Off delay", avoiding the emission of a zero from the sensor.
@m26872 Thanks for the input.
@Tom71 Have you looked at your controller software if you could manage the "no Motion state" after 20sec ? I'm using domoticz and I could set an "Off delay", avoiding the emission of a zero from the sensor.
There are a some low voltage temp+hum alternatives, although not cheaper than the DHT.
There's at least the Si7021, which should work between 1.9v and 3.6v
@m26872 You wrote about the idea of letting the sensor ask my controller when to arm or to disarm : have you figured out what way the node could get that information from the controller ?
Hello !
@Tom71 Had you had the bigger PIR sensor, you could have adapted the delay manually, but it seems this smaller device doesn't offer that possibility. But I think you could wake up the node on a "CHANGE" interrupt instead of only "RISING" as in the example. For this PIR, it would happen approx 8s after last movement detection. Maybe you could add a 12s sleep phase before sending the zero ?
@m26872 I've read somewhere that a short distance between the nrf24l01 and the motion sensor could lead to perturbations, and I wonder if you've tested a bigger separation between them and also got those false trips ? They are very close to each other on your example, which makes me wonder.
Mikael
Hello,
For the temperature, the mcp9700 is cheap and works from 2.3v up to 3.1v. The accuracy is not good out of the box (+-2°c) but it can be improved via calibration.
Here's some reading about it : http://blog.kkessler.com/2012/06/20/mcp9700/
Mikael
Hi,
I'm working on a battery operated node doing motion + temp, and I use Yveaux's Arduino_Vcc library to measure battery voltage.
I've tested the voltage from the 2 AAs and it's 2.99v, but the internal measurement gives 2.22v. I have a 25% difference where we should expect max 10%, shouldn't we ?
I'll try to debug that tomorrow with a dedicated sketch, but maybe someone can easily spot the error in the following code ?
/**
* DESCRIPTION
* Motion Sensor (HC-SR501) + Temp sensor (MCP9700 analog sensor)
* inspired by :
* mysensors PIR example created by Henrik Ekblad : http://www.mysensors.org/build/motion
* Slim Node as a Mini 2AA Battery PIR Motion Sensor : http://forum.mysensors.org/topic/2715/slim-node-as-a-mini-2aa-battery-pir-motion-sensor
* Kevin Kessler's blog for reading MCP9700 temperature sensor : http://blog.kkessler.com/2012/06/20/mcp9700/
*/
#include <MySensor.h>
#include <SPI.h>
#include <Vcc.h>
#define NODE_ID 30
#define MOTION_INPUT_PIN 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define CHILD_ID_MOTION 1
#define CHILD_ID_TEMP 2
#define CHILD_ID_BATT 3
#define DOMOTICZ_OFF_DELAY 10000
#define MINIMUM_SEND_INTERVAL 86400000 // once a day
#define TEMP_SEND_FREQ 300000 // every 5min
#define TEMP_SEND_THRESHOLD 0.3 // do not send temp if variation is below delta
#define VCC_MIN 1.9
#define VCC_MAX 3.3
float lastTemperature = 0;;
float lastVoltage = 0;
int loopCounter = 0;
bool interruptReturn = false; // "false" will make the first loop disregard high output from HC-SR501 (from start-up) and make a battery+temp report instead.
Vcc vcc(1.34); // 2.98/2.22=1.3423 . Can this be ok ???
MySensor gw;
MyMessage msgMotion(CHILD_ID_MOTION, V_TRIPPED);
MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP);
MyMessage msgBattery(CHILD_ID_BATT, V_VOLTAGE);
void setup()
{
delay(100); // to settle power for radio
gw.begin(NULL, NODE_ID);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Motion & Temp Sensor", "1.0");
pinMode(MOTION_INPUT_PIN, 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_MOTION, S_MOTION);
gw.present(CHILD_ID_TEMP, S_TEMP);
gw.present(CHILD_ID_BATT, S_MULTIMETER);
gw.sleep(20000); // Wait until motion sensor warmed-up and output returned low.
}
void loop()
{
int sleeptime = 0;
if (interruptReturn) { // Woke up by rising pin
gw.send(msgMotion.set("1")); // Domoticz will take care of setting the node off after some delay
sleeptime = DOMOTICZ_OFF_DELAY; // sleep until domoticz sets the sensor off on its side
}
else
{
float voltage = vcc.Read_Volts();
float temperature = readMCP9700(4,0);
// send if variation is enough or if delay was reached
if (abs(temperature - lastTemperature) >= TEMP_SEND_THRESHOLD) {
lastTemperature = temperature;
sleeptime = 3000;
loopCounter = 0;
gw.send(msgTemp.set(temperature, 1));
}
// send on first iteration, then if variation is enough or if delay was reached
if (abs(voltage - lastVoltage) >= 0.1) {
sendBatteryReport(voltage);
sleeptime = 3000;
loopCounter = 0;
lastVoltage = voltage;
}
if (loopCounter++ * TEMP_SEND_FREQ >= MINIMUM_SEND_INTERVAL) {
loopCounter = 0;
sleeptime = 3000;
gw.send(msgTemp.set(temperature, 1));
sendBatteryReport(voltage);
}
}
if (sleeptime) {
gw.sleep(sleeptime); // Make sure everything is stable before start to sleep with interrupts. (don't use "gw.wait()" here). Tests shows false trip ~2s after battery report otherwise.
}
interruptReturn = gw.sleep(MOTION_INPUT_PIN-2, RISING, TEMP_SEND_FREQ);
}
void sendBatteryReport(float voltage) {
float perc = 100.0 * (voltage-VCC_MIN) / (VCC_MAX-VCC_MIN);
gw.send(msgBattery.set(voltage, 2));
gw.sendBatteryLevel(static_cast<int>(perc));
}
// this function comes from Kevin Kessler's blog : http://blog.kkessler.com/2012/06/20/mcp9700/
float readMCP9700(int pin,float offset)
{
analogReference(INTERNAL);
for (int n=0;n<5;n++)
analogRead(pin);
int adc=analogRead(pin);
float tSensor=((adc*(1.1/1024.0))-0.5+offset)*100;
float error=244e-6*(125-tSensor)*(tSensor - -40.0) + 2E-12*(tSensor - -40.0)-2.0;
float temp=tSensor-error;
return temp;
}
Regards
Mikael
@AWI it was not clear, but I was thinking of using a mosfet in combination with the water level sensor shown in my first post, which is in fact drawing about 1.4mA when dry, and around 15mA when put in water.
Add those 1.4mA to the those taken by the step up, and it feels like the mosfet would lower that a lot when the node is sleeping (if I read the datasheet correctly, it draws between 25 and 250µA, depending on its operating temperature).
Thanks. That seems indeed a good and simple alternative. And potentially cheap as I've found this one.
Besides, I've read a (very little) bit about mosfets and concluded that a N-Channel where one digital pin feeding 0 or 3.3v to the gate, and the load (3.3v step-up + sensor) could be a nice solution. I read about the IRL540N which could be a relevant mosfet. Well, I would not be surprised my conclusions are wrong. Any thought about that ?
Regards,
Mikael
Hello,
Do you mean I should use water as a conductor between 2 unjoined wires or some other technique ?
I'm affraid relying on water as a conductor would lead to many false positives as my basement is always quite wet (old house on granit with unsufficient drainage), and I've choosen this sensor because it should give a better understanding of how much water there is.
Actually, I've read some posts where people use mosfets and feel it could be an option but that's a unknown field to me, so I'm looking for alternatives or examples.
Regards
Mikael
Hello,
I've bought a water level sensor one year ago, and would now like to set it up on a battery powered sensor in order to detect a flood in my basement.
I'm not sure about the infos I've found about this sensor, but if I'm correct, it can work at 3.3v (not below) and it takes 20mA, which could be ok if I power it on only when needed, which would be about once or twice a day.
Would you have a suggestion / example about which way to handle power on/off for this thing (which would have to be wired to a 3.3v step up to cope with discharge) ?
Regards
Mikael
Thanks I guess adding a meter may be the only viable solution, but I'm still not there yet (still waiting for the hall sensor).
I've looked at various examples on the net, and from what I've seen, it boils down to 2 possibilities where none of them corresponds to my situation :
Someone toyed with the idea to put a color sensor but prefered the hall sensor. That could maybe be worth a try, but I've not still not found anything simple to get inspiration from, so wait and see...
Regards
Mikael
Thanks, and sorry, my question was not clear enough : I would like to retrieve this information from the sensor node, in order to only activate the motion detection and message transmission when domoticz's security is "armed away".
Regards
Mikael
Hello,
Is there a way to retrieve domoticz's security panel's status ? It would be nice for example to activate motion sensors only when it's "armed away".
edit for clarification : I'd like to retrieve domoticz"s security status from the sensor node by polling the gateway every now and then.
Regards,
Mikael
@fleinze Yes, I tried. I could get to the point where the led was either on or off, but at no time would the led blink as the wheel rotated. I guess the distance between the rotating part and the bottom is just too small.
I've contacted the firm that provides water and they could change the meter by one giving impulses, but that would cost around 100€ so I'll wait and hope for a better issue.
Regards
Mikael
I've tried to place a small cheap compass near the watermeter during a flow, but I couldn't notice any influence on it. I moved it on the sides of it (around the black and the blue sides) : http://snag.gy/ewSSa.jpg
Well, I've read that the effect is quite low, so I still have a bit hope left and maybe I will succeed with the hall effect module I've bought on aliexpress.
Apart from those two approaches, is there some other method that could be tested to track the flow ?
Unfortunately, the digits won't track small consumntions so even if the last one has a reflector, it would not serve my goal to track for leakages, showers etc...
Regards
Mikael
Hello
Thanks for the answer. I went to the cellar today for a test, and as we feared, the line tracker did not detect any of the movements on the meter.
So next step will be to check if there's a varying magnetic field.
Regards
Mikael
Hello,
I hope to be soon able to build some battery powered sensors, and for one of them, I thought I reuse the enclosure of a cheap battery powered siren (something like this : http://snag.gy/M0jJe.jpg). I would use it as a motion sensor
This item is powered by 4 aaa batteries, and I thought it could be a good idea to put two pairs in parallel as it seems to be a common practice to run with two 1,5v batteries. That way, there would be no need to reduce voltage to 3.3v for the nrf24L01+.
Am I correct or is there something I've overlooked ?
Regards
Mikael
Hello,
I've going to try to setup a watermeter sensor using a line track sensor put on top of my meter.
You can see a picture of the meter here : http://snag.gy/YF03V.jpg
(it's an abb kent messtechnik kmt 30238670)
I've finished by circuit and put it in a little box, and I should be ready to go, provided I succeed in detecting the flow.
I thought I'd ask for any advice, because I'm not feeling very confident about the method.
I could put my tracker on top of the counter at the bottom left, and each rotation should be equivalent to one liter. I hope it will work because the "meter hand" (is that expression correct ?) is quite small and large.
Then, there is the leakage detector (smaller black wheel with 6 pins), but I don't know what one 6th of a rotation amounts to and have not found any clue about it.
If someone has experience about that or just a thought about it, I'd be glad to hear. Anyway, I hope to make some tests soon.
Regards,
Mikael
Thanks for the anwser.
Sorry for the noise, it was some weak soldering issue on the gateway. Worked the whole night, but broke around noon today. It's now fixed and works.
Mikael
Hello,
I've setup my gateway yesterday using the development branch so I could put a humidity sensor on it (works great !).
I now have a small network with the gateway using development branch, and one arduino nano on the master branch also having a humidity sensor.
Now, I've begun working on a future watermeter with a tcrt-5000 IR Barrier Line Track sensor.
First step has been to put components (arduino nano + nrf24l01+ + tcrt-5000) on a breadboard and upload sketch. Unfortunately, I can't join the node to the network.
With the sketch taken from dev branch, I get this on the serial monitor
Radio init successful.
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=fail:
send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=fail:2.0.0-beta
send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,st=fail:Water Meter
send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:1.1
find parent
send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
send: 2-2-0-0 s=1,c=0,t=21,pt=0,l=0,sg=0,st=fail:
Init complete, id=2, parent=0, distance=255
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
find parent
send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
find parent
send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
When using the sketch from master branch, I get this :
send: 2-2-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=fail:0
send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=fail:1.5.4
send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
sensor started, id=2, parent=0, distance=1
send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,st=fail:Water Meter
send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:1.1
send: 2-2-0-0 s=1,c=0,t=21,pt=0,l=0,sg=0,st=fail:
find parent
send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
I just remembered having read about some inclusion time and I tried to unplug/plug the gateway to the rpi controller and it worked a bit better :
sensor started, id=2, parent=0, distance=1
send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,st=ok:Water Meter
send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
send: 2-2-0-0 s=1,c=0,t=21,pt=0,l=0,sg=0,st=ok:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
send: 2-2-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=fail:
Doing this, Domoticz could detect the hardware : http://snag.gy/kuVGr.jpg
But I could not find anything in the device tab, which I think is due to the following failed sendings.
I guess it could be related to the development version but if someone has a suggestion, it would be welcome.
Regards
Mikael
Hello,
Two things :
first, the atmega chip was due to bad low fuse setting.
secondly, I had some luck when reverting to 1.5.1 and got a value on domoticz because the problem came back quickly. I tested my setup with 2 others ds18b20 temp sensors and it worked with only one of them. I checked again the DHT22 on my other sensor node (an arduino nano) and it works.
It seems to me that my board has some issue, and one of those temp sensor is tolerant to it (I believe the other one works but I should check that). I Checked the voltage with my multimeter and it is 3.3v as it should. But I'm not experimented on electronics and I could have done some basic mistake.
Would someone have any idea ?
Regards
Mikael
Ok, sorry for previous reply : the revert was the right solution. Thanks again !
If someone has a clue about diagnosing the first atmega328p chip, I'd be glad to hear about that.
Regards
Mikael
Thanks for the tip.
I reverted to 1.5.1 with a new atmega328p chip but it did not help, apart from the fact that the debug led now blinks and domoticz receives updated sendings with zeros.
By the way, would anyone have a clue why my first atmega328p chip does not work even if it behaves well with avrdude and my isp ?
Here is the output of avrdude : http://ur1.ca/ohh42
When I burn a bootloader or upload a new sketch, I get no warning saying something goes wrong but my circuit does not work as with the new replacement chip.
Regards
Mikael
edit : might have spoken too fast. I think I messed the revert to 1.5.1. I'll update soon.
Hello,
I've recently begun building my first sensors. So far, I have an usb serial gateway talking with a humidity sensor (nano+dht22).
My next step would be to build a sensor with the minimum components, and the first experimental step I've made almost works, but I get no value from the DHT22.
My setup is :
The code is taken from HumiditySensor, slightly changed for debugging.
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT");
temperature = 0.0;
gw.send(msgTemp.set(temperature, 1));
}
else {
lastTemp = temperature;
gw.send(msgTemp.set(temperature, 1));
Serial.print("T: ");
Serial.println(temperature);
}
// same thing for humidity
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500);
What happens is that the sensor is detected by the gateway and domoticz, but the readings are not numbers (see code above) and I get only zero on domoticz.
I've swapped the DHT22 with the other working sensor : it works
I've also tried with a DallasDS18B20 temp sensor and had a similar issue (I've not debbuged as much on that setup).
I wonder if the programming should be done differently. I have tried adding a board definition taken from here : https://maniacbug.wordpress.com/2011/10/19/sensor-node/, but I may have bricked the chip as it does not anything anymore (no blinking led, no new value on domoticz), although the upload process works well.
Would someone have an idea about what could be wrong with the setup ?
Thanks in advance
Mikael
Hello,
I'm a total newbie on arduino, but I am planning to build different types of sensors based on mysensors (raspberry pi + serial gateway etc),. Besides, I have another project and wondered if I could reuse mysensors for that or if other solutions would be more adapted : As I'm planning to buy a 2 din android autoradio in order to improve my car in different ways (reverse camera, osb2 display, etc), I thought I could try to add some arduino operated temperature sensors with display on widgets of the android unit.
I would like to keep it simple : one arduino with 2 wired temp sensors, powered and linked to android via an usb port. Unfortunately, it seems like mysensors doesn't support sensors on the gateway so I'd like to know if you would have some suggestions about that idea.
Best regards,
Mikael