Anyone know of a breakout board for a SPM0404UD5 or any other similar ultrasonic MEMS sensor? I want to build a ultrasonic detector so I'm looking for something that can detect the presents of ultrasonic sound (if you could call it that ).
Thanks
I did more investigation played around with sleep outside of mysensors and found a bit of code in a proximity sensor example:
// Reset flag and clear APDS-9960 interrupt (IMPORTANT!)
isr_flag = 0;
if ( !apds.clearProximityInt() ) {
Serial.println("Error clearing interrupt");
}
I then needed to play around with delays to allow the sensor to catchup..
void loop() {
delay(1000);
Recoding back to MySensors
if ( !apds.clearProximityInt() ) {
Serial.println("Error clearing interrupt");
}
wakeupReason = sleep(digitalPinToInterrupt(INT_PIN), FALLING, sleepTime);
setting up the interrupt pin with a pullup forced the FALLING when pin dragged down by the sensor.
void setup() {
pinMode(INT_PIN, INPUT_PULLUP);
All this is on caveat it makes it through some more testing.
@popsyann said in Battery life for Motion Sensor:
When I load the motion sensor sketch, it start properly, finding the right "parent" and immediately after this, there is a flow of info going out of the Arduino+sensor, sending 0s or 1s, constantly (like if there was an issue with the interrupt process).
And what I do not understand is that this (these) sensor(s) has(have) been working well for a while.
Please search for sleep() function - it has changed the way it works at some stage in MySensors 2.*
https://forum.mysensors.org/topic/1088/battery-powered-pir
https://forum.mysensors.org/topic/5807/interrupt-and-sleep/26
https://forum.mysensors.org/topic/5552/pin-change-interrupt-not-firing-with-mysensors/28
Another reason could you that your PIR is not settling properly - this is why it sends out 1s and 0s to the GW. Try to insert sleep(20000); into void setup() at the end to settle the PIR
@BulldogLowell I fried my breadbord power supply by connecting broken power adaptor(it have me about 13-14V instead of up to 12V), this fried AMS1117 5V. I replaced it, and it's working proper again.
@secantscope I understand - It is a few years since I looked into this and then the only conclusion I could make was to take a meter and interface with usb. It would be more work and my needs case didn't warrant that at the time.
I am sorry I could not be of more help in this, but it just seems to be the way things have been for a while. Maybe in the future things will change.
As @nagelc suggested a lesser sensor could be used and you could calibrate it yourself. Seems little other options really. (Now I said that you just wait for a killer posting with just the thing you want linked) !!!
@Yveaux
Have you read datasheet here...
At the o\p side they mention unity gain amplifier with OpAmp
but the thing is that unity gain amplifier always produced same output volts!
@AWI i've since done some more work on this and discovered the switched 3.95v didn't share a common ground with the rest of the circuit. So i ended up hooking up a DIL reed relay PRMA 0105 (5v) onto it, and used the relay contacts to connect to pin D3 on my nano.
So i've got it operating that whenever the motion sensor is tripped it toggles my 1 channel relay board, but what isn't working is being able to manually switch it from in domoticz.
Would someone be able to take a look at my code which i've taken from this thread
My code is:
/*
DESCRIPTION
Sketch for 1x relay with buttons bistable. After back power all relays set OFF and send correct status OFF to controller.
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>
// Define Relays
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
// Define Sensor ID's
#define SSR_A_ID 1 // Id of the sensor child
// Define buttons and relays
const int buttonPinA = 3;
const int relayPinA = 4;
// Define Variables
int oldValueA = 0;
bool stateA = false;
int trigger = 0;
Bounce debouncerA = Bounce();
MyMessage msgA(SSR_A_ID, V_STATUS);
void setup()
{
pinMode(buttonPinA, INPUT_PULLUP); // Setup the button Activate internal pull-up
// After setting up the buttons, setup debouncer
debouncerA.attach(buttonPinA);
debouncerA.interval(5);
// Make sure relays are off when starting up
digitalWrite(relayPinA, RELAY_OFF);
// Then set relay pins in output mode
pinMode(relayPinA, OUTPUT);
/*--------------------- Added these lines for toggle switch-------------------------*/
oldValueA = digitalRead(buttonPinA); // set oldValueA to the current status of the toggle switch
// send(msgA.set(false)); // Send off state for relayA to ensure controller knows the switch is off
// send(msgB.set(false)); // Send off state for relayB to ensure controller knows the switch is off
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Relay with Bistable", "1.1");
// Register all sensors to gw (they will be created as child devices)
present(SSR_A_ID, S_LIGHT);
}
/*
Example on how to asynchronously check for new messages from gw
*/
void loop()
{
if (trigger == 0){
send(msgA.set(false)); // Send off state for relayA to ensure controller knows the switch is off
trigger = 1;
}
debouncerA.update();
// Get the update value
int valueA = debouncerA.read();
if (valueA != oldValueA) {
// send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
send(msgA.set(stateA ? false : true), false); // Send new state with no request for ack
stateA = stateA ? false : true; // invert the state
digitalWrite(relayPinA, stateA ? RELAY_ON : RELAY_OFF); // toggle the relay
oldValueA = valueA;
}
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type == V_STATUS) {
switch (message.sensor) {
case 1:
stateA = message.getBool();
digitalWrite(message.sensor + 4, stateA ? RELAY_ON : RELAY_OFF);
break;
case 2:
break;
}
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.println(message.sensor);
Serial.print("from node:");
Serial.println(message.sender);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}