OK. Now I understand. I had not recognised the pro mini in the image you shared. I thought it was another “something”
-
How to Mysensors.
-
Shields arrived. Now waiting for the nrfs.
-
@sweebee
thx for the info! i ordered some of the shields and nrf. now let’s see if i can finally make the step into the mysensor worldpimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
@sweebee Nice!
What is the type of the PIR on the photo? And where can these be ordered? -
that’s a standard HC-SR501 as it seems.
If using this on 3V you will have to do some adaptions.
you can have a look here http://forum.mysensors.org/topic/225/hc-sr501-motion-sensor/25
or maybe @sweebee gives a short description on how he built it?pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Its a normal HC-SR501. I just modified it so it could fit in my case and it works on <3V
I removed all the headers and rewired the left capacitor (removed the capacitor and put wires between it) so it fits tightly in my case.
-
In my bookmarks I have this connection. I have not tested this.
PIR Motion Sensor on 3.3vPimatic = Smart Home
-
Radio’s have arrived:
-
looks really nice and compact, good work soldering soldier
did you use the same code as here on your arduino?? could you say something about your battery lifetime?
I’m using the same code like motionsensor to get the soil 0/1 of my plant every hour.
#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define CHILD_ID 4 #define BUTTON_PIN 8 // Arduino Digital I/O pin for button/reed switch MySensor gw; Bounce debouncer = Bounce(); int oldValue=-1; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(CHILD_ID,V_TRIPPED); void setup() { gw.begin(); // Setup the button pinMode(BUTTON_PIN,INPUT); pinMode(6, OUTPUT); // Power Pin for A/D Module // Activate internal pull-up digitalWrite(BUTTON_PIN,LOW); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); // Register binary input sensor to gw (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. gw.present(CHILD_ID, S_DOOR); } // Check if digital input has changed and send in new value void loop() { digitalWrite(6, HIGH); // Power on YL-38 A/D Module delay(2000); debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue) { // Send in the new value gw.send(msg.set(value==LOW ? 1 : 0)); oldValue = value; } delay(2000); digitalWrite(6, LOW); // Power off YL-38 A/D Module delay(3600000); // wait a hour, then reloop }
If i dont care about the power of the soil-sensor-module the contacts corrode in a few days.
Maybe someone have a battery-friendlier solution… with delay(3600000) maybe its not the best solution for powering with batteries. -
@xCite86 theoretically they should run for around 450 days. I’m using my own sketch.
It measures the battery life (uses readVcc).
Resends if a message fails, thanks to @n3ro.
Does also send a false signal.#include <MySensor.h> #include <SPI.h> #include <readVcc.h> // ********** CONFIG ********************************** #define NODE_ID AUTO // ID of node #define CHILD_ID 1 // ID of sensor #define PIR_PIN 3 // Pin connected to the PIR #define MIN_V 2000 // empty voltage (0%) #define MAX_V 3200 // full voltage (100%) // **************************************************** MyMessage msg(CHILD_ID, V_TRIPPED); MySensor node; int oldBatteryPcnt; int sentValue; int forceSend = 0; void setup() { node.begin(NULL, NODE_ID, false); node.sendSketchInfo("PIR Sensor", "1.2"); node.present(CHILD_ID, S_MOTION); pinMode(PIR_PIN, INPUT); digitalWrite(PIR_PIN, HIGH); } void loop() { // Get PIR int value = digitalRead(PIR_PIN); // Get value of PIR if (value != sentValue) { // If status of PIR has changed resend(msg.set(value), 5); // Send PIR status to gateway sentValue = value; } // Send batterylevel sendBattery(); // Sleep until something happens with the sensor node.sleep(PIR_PIN-2, CHANGE); } // FUNCTIONS void sendBattery() // Send battery percentage to GW { forceSend++; int batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100); // Get VCC and convert to percentage if (batteryPcnt != oldBatteryPcnt || forceSend >= 20) { // If battery percentage has changed node.sendBatteryLevel(batteryPcnt); // Send battery percentage to gateway oldBatteryPcnt = batteryPcnt; forceSend = 0; } } void resend(MyMessage &msg, int repeats) // Resend messages if not received by GW { int repeat = 0; int repeatDelay = 0; boolean ack = false; while ((ack == false) and (repeat < repeats)) { if (node.send(msg)) { ack = true; } else { ack = false; repeatDelay += 100; } repeat++; delay(repeatDelay); } }
For your sketch, replace delay(3600000)) with sleep(3600000)
-
great sketch and the battery-lifetime was great
if i woult add readVcc in my sketch, did i need resistors too?? i’m in a voltage-range between 4 and 6 Volt.
replace delay with sleep(3600000); gets an error on compiling
sketch_mar16a.ino: In function 'void loop()': sketch_mar16a:81: error: 'sleep' was not declared in this scope 'sleep' was not declared in this scope
-
@xCite86 readVcc only works if the batteries are directly connected to the vcc of the arduino/uC. So no regulator. If you want it your way you need resistors yes, and readVcc is not needed for that.
for good battery life you need to remove the powerled, don’t use the regulator and modify the fuses so it can run till around 1.8V.
You’re using an arduino nano, not great for battery life. Arduino Pro Mini 3.3v are the best.
Ah yea you need
gw.sleep(3600000);
-
Hey folks,
i have modified the battery function some weeks ago to prevent sending to often:
void sendBattery() // Measure battery { bool force = false; int batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100); float diffbatteryPcnt = abs(oldBatteryPcnt - batteryPcnt); if (batteryReportCounter >= BATTERY_REPORT_CYCLE) { force = true; batteryReportCounter = 0; } if (diffbatteryPcnt > BAT_TRANSMIT_THRESHOLD or force == true) { DEBUG_PRINT(force ? "F " : "S "); gw.sendBatteryLevel(batteryPcnt); // Send battery percentage oldBatteryPcnt = batteryPcnt; } DEBUG_PRINT("---------- Battery: "); DEBUG_PRINTLN(batteryPcnt); }
pimatic + MySensors + Homeduino + z-way
https://github.com/n3roGit/MySensors_n3ro -
@n3ro i modified mine so it sends more often it can take weeks before it sends again.
Why did you sketch send to often?
-
@sweebee
The battery voltage differ a little bit on every mensure. If the PIR toggles and the voltage is low, my node sends the battery state everytime it wakes up.pimatic + MySensors + Homeduino + z-way
https://github.com/n3roGit/MySensors_n3ro -
found a very good thread for powerconsuming and Arduino Pro Mini modification here
-
Some people were interested how the auto discovery works in pimatic 0.9: https://youtu.be/5XN2iHnwouo
-
I also made some changes for the battery sensor. It uses icons now which i think looks much better. The look of the icon depends on the value of the battery.
-
@sweebee I built the same PIR sensor as you did with the Arduino mini pro, mini NRF with shield and battery.
Is the above sketch of 21 days ago still the latest version?
I’m very interested in the battery control you implemented.
When I have my DHT available I will probably extend this sensor with that and adjust my sketch. -
@Petjepet This is my latest:
#include <MySensor.h> #include <SPI.h> #include <readVcc.h> // ********** CONFIG ********************************** #define NODE_ID AUTO // ID of node #define CHILD_ID 1 // ID of sensor #define PIR_PIN 3 // Pin connected to the PIR #define MIN_V 2000 // empty voltage (0%) #define MAX_V 3200 // full voltage (100%) // **************************************************** MyMessage msg(CHILD_ID, V_TRIPPED); MySensor node; int oldBatteryPcnt = -1; int sentValue = -1; int forceSend = 0; void setup() { node.begin(NULL, NODE_ID, false); node.sendSketchInfo("PIR Sensor", "1.3"); node.present(CHILD_ID, S_MOTION); pinMode(PIR_PIN, INPUT); } void loop() { // Get PIR sendPir(); // Send batterylevel sendBattery(); // Sleep until something happens with the sensor node.sleep(PIR_PIN-2, CHANGE); } // FUNCTIONS void sendPir() { int value = digitalRead(PIR_PIN); // Get value of PIR if (value != sentValue) { // If status of PIR has changed resend(msg.set(value), 5); // Send PIR status to gateway sentValue = value; } } void sendBattery() // Send battery percentage to GW { forceSend++; int batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100); // Get VCC and convert to percentage if (batteryPcnt != oldBatteryPcnt || forceSend >= 20) { // If battery percentage has changed node.sendBatteryLevel(batteryPcnt); // Send battery percentage to gateway oldBatteryPcnt = batteryPcnt; forceSend = 0; } } void resend(MyMessage &msg, int repeats) // Resend messages if not received by GW { int repeat = 0; int repeatDelay = 0; boolean ack = false; while ((ack == false) and (repeat < repeats)) { if (node.send(msg)) { ack = true; } else { ack = false; repeatDelay += 100; } repeat++; delay(repeatDelay); } }