Skip to content

General Discussion

A place to talk about whateeeever you want
1.5k Topics 14.2k Posts
  • ISR Pulse Meter Question

    12
    0 Votes
    12 Posts
    1k Views
    B
    Hello Here is my last code for my gas meter. If it could help somebody /* * 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-2018 Sensnology AB * Full contributor list: https://github.com/mysensors/MySensors/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 * Version 1.1 - GizMoCuz * * DESCRIPTION * Use this sensor to measure volume and flow of your house water meter. * You need to set the correct pulsefactor of your meter (pulses per m3). * The sensor starts by fetching current volume reading from gateway (VAR 1). * Reports both volume and flow back to gateway. * * Unfortunately millis() won't increment when the Arduino is in * sleepmode. So we cannot make this sensor sleep if we also want * to calculate/report flow. * http://www.mysensors.org/build/pulse_water */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 #include <MySensors.h> #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child unsigned long loopNumber = 0; unsigned long lastLoopSend = 0; MyMessage volumeMsg(CHILD_ID, V_VOLUME); MyMessage lastCounterMsg(CHILD_ID, V_VAR1); volatile uint32_t pulseCount = 0; bool pcReceived = false; double volume = 0; //========================= // BATTERY MEASURER // VOLTAGE DIVIDER SETUP // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 #define VBAT_PER_BITS 0.003363075 #define VMIN 2.2 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.2 // Vmax = (2xAA bat)=3.0V (892v) int batteryPcnt = 0; // Calc value for battery % int batLoop = 0; // Loop to help calc average int batArray[4]; // Array to store value for average calc. int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //========================= void setup() { // initialize our digital pins internal pullup resistor so one pulse switches from high to low (less distortion) pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP); pulseCount = 0; // Fetch last known pulse count value from gw request(CHILD_ID, V_VAR1); //Battery analogReference(INTERNAL); Serial.print("With Battery VMax (100%) = "); Serial.print(VMAX); Serial.print("volts and Vmin (0%) = "); Serial.print(VMIN); Serial.println(" volts"); Serial.print("Battery Percent 25%/50%/75% calculates to: "); Serial.print(((VMAX - VMIN) / 4) + VMIN); Serial.print("/"); Serial.print(((VMAX - VMIN) / 2) + VMIN); Serial.print("/"); Serial.println(VMAX - ((VMAX - VMIN) / 4)); delay(1000); int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(50); float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat - VMIN) / (VMAX - VMIN)) * 100.); Serial.print("Current battery are measured to (please confirm!): "); Serial.print(batteryPcnt); Serial.print(" % - Or "); Serial.print(Vbat); Serial.println(" Volts"); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Gas Meter", "2.0"); // Register this device as Water flow sensor present(CHILD_ID, S_GAS); } //========================= // BATTERY MEASURER void MeasureBattery() //The battery calculations { delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat - VMIN) / (VMAX - VMIN)) * 100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.print(" %"); Serial.print("Battery Voltage: "); Serial.print(Vbat); Serial.println(" Volts"); // Add it to array so we get an average of 3 (3x20min) batArray[batLoop] = batteryPcnt; if (batLoop > 2) { batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]); batteryPcnt = batteryPcnt / 4; if (batteryPcnt > 100) { batteryPcnt = 100; } Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %"); sendBatteryLevel(batteryPcnt); batLoop = 0; } else { batLoop++; } } void loop() { if (!pcReceived) { //Last Pulsecount not yet received from controller, request it again request(CHILD_ID, V_VAR1); wait(1000); return; } Serial.print("loopNumer="); Serial.println(loopNumber); if (loopNumber % 60 == 0) { Serial.println("Measuring Battery"); //========================= // BATTERY MEASURER MeasureBattery(); //========================= } if (loopNumber % 10 == 0) { Serial.println("Sending pulse Count"); volume = ((double)pulseCount / ((double)1000)); send(volumeMsg.set(volume,4)); send(lastCounterMsg.set(pulseCount)); } Serial.println("I'm sleeping"); int8_t cause = sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), FALLING, 60000); Serial.print("WakeUp , cause:"); Serial.print(cause); Serial.print("(pin interrupt :"); Serial.print(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR)); Serial.println(";-1=timer)"); if (cause == digitalPinToInterrupt(DIGITAL_INPUT_SENSOR)) { pulseCount++; wait(100); } Serial.print("Pulsecount="); Serial.println(pulseCount); loopNumber++; } void receive(const MyMessage &message) { if (message.type==V_VAR1) { uint32_t gwPulseCount=message.getULong(); pulseCount += gwPulseCount; Serial.print("Received last pulse count from gw:"); Serial.println(pulseCount); pcReceived = true; } }```
  • Questions on Routing, Discovery, Protocol and Multiple Controllers

    5
    1 Votes
    5 Posts
    1k Views
    G
    @stevanov Hi, I'm no MySensors guru to be sure. You started by saying you were considering a second Controller. Then mentioned two Gateways. You didn't mention what particular Controller you are using now. I've been using Domoticz for my Controller for a couple of years. Domoticz is perfectly happy to talk to multiple Gateways. I have some sensors on a MySensors radio network exposed to Domoticz through a single Mysensors Gateway. I also expose multiple ESP8266 (wifi) sensor nodes, each of which Domoticz sees as a separate Mysensors Gateway. I also have several virtual gateways collecting online data from Netatmo sensors and other online sources. You can certainly have more than one MySensors (radio) gateway if they are on different radio types (and I believe different channels). The concern is that Mysensors radio nodes must communicate exclusively with a single Mysensors radio gateway. You can't have a gateway wander around into the area covered by another gateway unless its on a different frequency, or routing may get all mixed up. It doesn't work like Wifi or cellular where connections are handed off. Your sensors won't get exposed to Controllers at all. Just one gateway for any node and multiple Gateways should be OK...at least for Domoticz. Hope I got that all right. Cheers!
  • Why IOYT matters...

    13
    10 Votes
    13 Posts
    6k Views
    Nca78N
    Some more services disappearing, "Bonjour" alarm clock didn't even finish sending the kickstarter orders, and those who have received the product will soon get a brick (nice enclosure for a MySensors project, though :smile: ) https://www.gearbrain.com/bonjour-smart-alarm-clock-killed-2626720300.html Lima is also closing with only 2 weeks notice, their device was offering a "personnel cloud" service, if data is encrypted it's a short delay to save it :o https://www.zdnet.com/article/lima-closes-its-doors-personal-cloud-devices-will-cease-to-function/
  • Over current protection

    2
    0 Votes
    2 Posts
    583 Views
    B
    @sham-sharma I think that if you'd type these 3 words as you've used in the title of your post in any search machine you would get the info you're looking for.
  • Is Sale of personal hardware acceptable in this group?

    2
    1 Votes
    2 Posts
    651 Views
    hekH
    Yes, selling boards (none commercially) is ok.
  • Detection of Flying Tiny Objects

    4
    0 Votes
    4 Posts
    824 Views
    G
    @mooshamee Hardware Raspi software: https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/ Then as I use MQTT for everything, it is very easy to send states, people count, etc.
  • MYSController for RPi?

    10
    0 Votes
    10 Posts
    2k Views
    S
    @jimbolaya Or you can use https://github.com/tsathishkumar/MySController-rs A light weight controller which can be used for FOTA and act as a proxy for all other usages.
  • Touch screen with built in Arduino 328p

    1
    1 Votes
    1 Posts
    611 Views
    No one has replied
  • Set forum search to only look back 2 years?

    5
    2 Votes
    5 Posts
    880 Views
    mfalkviddM
    Neither could I. Tried to trace the html elements and javascript but there doesn't seem to be anything that is easily configurable.
  • Need Sensor to detect presence of water in pipe line

    2
    0 Votes
    2 Posts
    614 Views
    mfalkviddM
    Welcome to the MySensors forum @shahdad-marri Can you share some more information? What material is the pipe made of? How large is the pipe? Can you open and place a sensor inside the pipe? Is the water drinking water, sewage or something else? Is the pipe oriented vertically or horizontally? Will the pipe either be completely full or completely empty, or can there be varying degrees of water in it? Does the sensor need to be battery powered, or is there access to mains power? Do you have a price range in mind?
  • Does the simple security option work for a serial gateway?

    12
    0 Votes
    12 Posts
    2k Views
    alowhumA
    @scalz Thank you for the clarification. Is there a way to enable OTA that would be 'n00b friendly'? Perhaps by attaching a small device that can then itself be programmed via the Nano's USB port?
  • Ble presence/positioning nodes

    3
    0 Votes
    3 Posts
    3k Views
    J
    @mfalkvidd thanks for your reply. I had allready read these, but thanks for the links never the less. I have some bluetooth modules (hm-10 & at-09) in the mail. Allready have some i-tags laying around. I will see what i can make of this. My house is only one story so i would like to place one node in the middle of each room on the attic floor. If this works i will have some kick-ass presence detection 😁, if it doesnt i will have some spare ble modules to play with. There just is no down-side to this 😂
  • At home / away?

    away
    25
    0 Votes
    25 Posts
    4k Views
    nagelcN
    I have been using this BLE method (python script) with Domoticz and a couple of raspberry pi zero W. https://www.domoticz.com/wiki/Presence_detection_(Bluetooth_4.0_Low_energy_Beacon) One pi is near my driveway, and one on the other side of the house. I have an old Tile tag in one car and a Nut in the other. Both work fine for detecting when my cars leave and return. It also detects my Fitbit, an old one of the original type. I have that with me most of the time, so it acts like a tag for my presence. I haven't done much with it so far except to turn on the porch light when the cars pull into the driveway at night.
  • garage doors sensor not working good

    4
    0 Votes
    4 Posts
    906 Views
    dbemowskD
    @laoadam Your garage door safety sensors may not be aligned quite right. It could be off just enough that vibration from the door itself when opening and closing is knocking one of the sensor modules out of alignment. The same could be true if one of the wires to it is loose. Check both sensor modules to make sure they are aligned right and not loose. One should be a transmitter that shoots a beam to the other module which is the receiver. If the transmitter beam is not aligned exactly right with the receiver, it won't work. As I mentioned too, check that there are no loose or broken wires. If wires go to screw terminals, make sure those are secured properly and that none of the wire casing is getting pinched in with the wire as that may cause a partial connection that could be lost with vibration of the door. With all that being said, this is a forum for a DIY home automation hardware platform called MySensors. Were you planning at some point to implement this for your garage door?
  • Quantifying IAQ values of BME680

    4
    0 Votes
    4 Posts
    1k Views
    Nca78N
    @electrik said in Quantifying IAQ values of BME680: @nikhil-sukhdev As I read the datasheet, the sensor also provides raw measurements of the gas sensor (5.3.4.4). Perhaps you can use that instead of the compensated IAQ values? I think it's not a good idea. All the interest of the software suite that generates the IAQ is to process nearly meaningless raw values (dependant on temperature, humidity, time the sensor has been running, age of sensor,...) and provide a consistant and understandable value.
  • received message child id [SOLVED]

    5
    0 Votes
    5 Posts
    2k Views
    M
    Finally! Thanks @Boots33 ! I think mysensors is a great platform but simple tutorials are needed.
  • MQTT Protocol Question

    10
    0 Votes
    10 Posts
    2k Views
    G
    @wimd Thanks. Why would I want a non presented node? I am guessing a Mysensors MQTT gateway will let me send and receive MQTT messages direct to/from the Mysensors network without having to rely on Domoticz?
  • Code explanation

    4
    1 Votes
    4 Posts
    982 Views
    R
    @bjacobse Ok, now i understand, thank you for the link and for a quick reply. Case closed:grinning:
  • Looking for a specific pressure sensor

    1
    0 Votes
    1 Posts
    443 Views
    No one has replied
  • [SOLVED] Strange behavior on MQTT Gateway Reset

    13
    0 Votes
    13 Posts
    2k Views
    electrikE
    @xefil thank you, happy new year!

7

Online

11.9k

Users

11.2k

Topics

113.2k

Posts