Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. lafleur
    3. Best
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by lafleur

    • Multi-sensor soil moisture node

      This is a work in progress! , but most everything works.

      0_1487524799943_Screen Shot 2017-02-19 at 9.17.43 AM.png

      Heavy rain lately, so soil is at 100% saturation...

      This was developed with MySensor 2.1.1  https://www.mysensors.org/
      IDE 1.81
      SAMD 1.6.11
      RocketScream M0 with RFM95 radio
      

      Data from the sensor to MQTT-gateway to MQTT to (Telegraf to InFluxdb to Grafana)
      Controller function via NODE.RED connected via MQTT.

      It measures soil moisture from 1 to 4 sensors, has options for soil and air temperature.
      Support MCP9800 or Si7021 (humidity also) or temp sensor in DS3231 for air temp
      DS18B20 for soil temp
      Support of a water pressure sensor via an analog port
      Has a DS3231 Real Time clock to wake up processor at designated hour
      Has support on the board for a flow meter and pressure sensor (but no software in this code base)
      Solar, battery Powered or via 8 to 28v AC or DC
      Sleep's most of the time and just wakes up to see if its time to send a report.
      Support for requesting and receiving time of day for setting RTC
      Support for updating sensor tx schedule via V_VAR1
      (Board is designed to fit in a Hammond 1554 case)

      https://github.com/trlafleur/Soil_Moisture_Sensor_MS_R1.1-RFM95

      http://www.rocketscream.com/blog/product/mini-ultra-pro-with-radio/

      Sensor are made from plaster of paris (gypsum)

      http://vanderleevineyard.com/1/post/2012/07/the-vinduino-project-2-making-and-installing-gypsum-soil-moisture-sensors.html
      http://www.irrometer.com/sensors.html#wm
      https://www.amazon.com/Delmhorst-GB-1-Gypsum-Sensor-Moisture/dp/B0002IKRUS (pkg of 10 each)

      Based on the work of: Reinier van der Lee, www.vanderleevineyard.com

      0_1487526137636_IMG_5178.JPG 0_1487526144517_IMG_5177.JPG 0_1487526150950_IMG_5308.JPG

      posted in My Project
      lafleur
      lafleur
    • RFM95 Soil Moisture Sensor

      This is a work in progress! , but most everything works.

      It measures soil moisture from 1 to 4 sensors, has options for soil and air temperature.
      Support MCP9800 or Si7021 (humidity also) or Temp sensor in DS3231 for air temp
      DS18B20 for soil temp
      Support of a water pressure sensor via an analog port
      Has a DS3231 Real Time clock to wake up processor at designated hour
      Has support on the board for a flow meter (but no software in this code base)
      Uses a RocketScream Mini-Pro M0 CPU with an RFM95 radio
      Solar, battery Powered or via 8 to 28v AC or DC
      Sleep's most of the time and just wakes up to see if its time to send a report.
      (Board is designed to fit in a Hammond 1554 case)

      https://github.com/trlafleur/Soil_Moisture_Sensor_MS_R1.1-RFM95
      

      Sensor are made from plaster of paris (gypsum)

      http://vanderleevineyard.com/1/post/2012/07/the-vinduino-project-2-making-and-installing-gypsum-soil-moisture-sensors.html
      
      http://www.irrometer.com/sensors.html#wm
      
      https://www.amazon.com/Delmhorst-GB-1-Gypsum-Sensor-Moisture/dp/B0002IKRUS
      

      Based on the work of: Reinier van der Lee, www.vanderleevineyard.com

      posted in Development
      lafleur
      lafleur
    • RE: Sensor IDs, best practices?

      I solved the issue by using extra I/O pins and assign a static node address from a base address + ID bits... In my case below, I used 3 ID pin's.

      /* **************************************************************************** */
      /*                                Before                                        */
      /* **************************************************************************** */
      
       // Before is part of MySensor core 
      void before() 
      { 
      
       
       // need to set up pins prior to reading them...
           pinMode(ID0, INPUT_PULLUP);
           pinMode(ID1, INPUT_PULLUP);
           pinMode(ID2, INPUT_PULLUP);
           
           myNodeID  = !digitalRead (ID0);                     // ID bit are 0 = on, so we invert them
           myNodeID |= (!digitalRead(ID1) << 1);           
           myNodeID |= (!digitalRead(ID2) << 2);
      
           myNodeID += NodeID_Base;                            // set our node ID
      
           // We no longer need these pins, so remove pullups to save power
           pinMode(ID0, INPUT);
           pinMode(ID1, INPUT);
           pinMode(ID2, INPUT);
      }
      
      
      posted in Development
      lafleur
      lafleur
    • RE: [Solved] MQTT ESP8266 Gateway 1.6

      This has been fixed.... It was an error on my part, I had a unlisted device with the same IP address as the GW... it was a pain to find this as GW would work for 3 to 4 hours.

      I have tested removing access point and GW re covers
      I remove MWTT broker and GW recovers

      posted in General Discussion
      lafleur
      lafleur
    • Apex-Ademco-Honeywell D6100 Alarm interface

      This is a MySensor program to control, interface with an APEX Destiny 6100(AN) Alarm panel. This is an older alarm panel, but its capability exceed what can be found on current Honeywell-Ademco panels.

      Apex was bought by Ademco who was bought by Honeywell. Its is NOT compatible with current Honeywell-Ademco panels, but has the framework to be adapted.

      My system has 63 active zones, most are using wireless Ademco-5800 series sensors

      It read's and parses serial data from the alarm and format them into MySensor messages.

      This is running on a MoteinoMEGA, and connect to the D6100 via a TTL serial interface
      Radio is 915MHz RFM69HW
      Tested with MySensor 2.0.0 beta
      Tested with D6100 firmware 8.07

      https://github.com/trlafleur/Sensor_D6100
      
      posted in My Project
      lafleur
      lafleur
    • Sensor PWB, with analog digital I/O, relays, MCP9800, Si7021

      Sensor 1
      This device was designed to be a remote sensor in a MySensor or LowPower network, but can be adapted to any network that uses RFM69W(H) radios and a Moteino ATmega328 processor.
      Basic functions:

      1. Carrier for a Moteino processor with a RFM69W(H) radio
      2. Power supply 8 to 24V AC or DC
      3. Condition pulse counter with 1st order pulse filtering
      4. 2 Relay outputs, that can be converted to FET output with a jumper
      5. 3 Analog input with scaling and filtering, can be converted to digital I/O
      6. 4 LED’s for device status
      7. An MCP9800 temperature sensor, and or
      8. An Si7021 temperature and humidity sensor
      9. Designed to fit in a Hammond 1554C water resistant case

      The power supply is designed to be run from a standard irrigation 24V AC power source, but can be run from 8 to 24V AC or DC. Input power is fused with a PTC and then connected to a bridge rectifier, filtered with a large capacitor and then connected to a Pololu D24V6F5 ($6), 5V 600ma switching power supply or a 300ma version, D24V3F5 ($4), or there is also space to use a TI TL720M05 three terminal regulator in a TO252 package.

      The pulse input provides a 1st order filtering of pulses from mechanical (reed) switch as found in many water meters. Switch de-bouncing-filtering is done by R7, D3, R9, C7 and U1. The 74AHC14 inverter has a Schmitt trigger input to help with noise immunity and will provide high voltage isolation on the input. (See the reference below on how it works.)

      The output of the 74ACH14 is connected to the T1, 16bit counter on the ATmega328 processor. This can be used with simple code to count pulses without the need for interrupts. This method also continues to operator during processor sleep.

      This input can be converted to a conventional, input circuitry by selection components. IE: to use a hall effect sensor, you could remove R7, D3, C7 and replace R9 with a zero ohm resistor as needed.

      http://www.ganssle.com/debouncing.htm

      Relays are driven by a N-FET from the Moteino I/O pins. Diodes across the relay coils are for back EMF. An optional jumper connected across pins 6 and 7 of the relay bring the FET outputs to the “C” pin on J3 for direct FET connection.

      
      On the analog inputs, two input resistors and the capacitor do analog input, filtering and scaling. Again, these components can be replaced as needed to provide a direct connection to the Moteino as analog or digital I/O pin.

      If you don’t need all of the input pins on J2, you can stuff smaller connectors on the board.
      Options for an MCP9800 temperature and/or a Si7021 temperature-humidity sensor. The I2C module of the processor controls these devices.

      PCB files, schematics are on Github... I use Seeed Fusion for board.
      (also located here is my Raspberry PI2 to Moteino gateway board)

      https://github.com/trlafleur

      posted in Hardware
      lafleur
      lafleur
    • Water flow and pressure Sensor

      WaterMeter-MS-3.0i-RFM95

      Data from the MySensor node to MQTT-gateway to MQTT to Telegraf to InFluxdb to Grafana.
      Controller function via NODE.RED connected via MQTT.

      0_1488549650584_Screen Shot 2017-02-21 at 6.29.37 AM.png

      It measures water flow from a Dwyer WMT2 water meter in pulse per gallon.

      Used a 0 to 100PSI pressure sensor (from ebay), via an analog port.

      Support MCP9800 or Si7021 (humidity also) for air temp.

      Two relay outputs

      3 Analog inputs

      MAX6816 or analog filter for contact de-bouncing for water meter

      Powered via an 8 to 28v AC or DC external power source

      (Board is designed to fit in a Hammond 1554 case)

      Processor is a Moteino R4 LoRa with a RFM95

      Sends:

      • Gal per minutes
      • Gal per hour
      • Gal per day
      • Gal of current flow
      • Total gallons
      • Air Temperature
      • Humidity
      • Water pressure
      • Excessive Flow Message

      https://www.dwyer-inst.com/Product/Flow/WaterMeters/SeriesWMT2

      https://lowpowerlab.com/shop/product/99

      design file are located at:

      https://github.com/trlafleur/WaterMeter-MS-3.0i-RFM95
      

      1_1488551446939_IMG_5072a.jpg 0_1488551446939_IMG_5073a.jpg

      posted in My Project
      lafleur
      lafleur
    • 8Bit or 32Bit processors

      A number of people have ask me about why I'm using 32bit processors when an 8bit will do. Well its simple, for small development projects of less that a few hundreds unit, the larger flash, larger ram, faster CPU, lower power devices, and cheaper raw devices, allow for faster code development... no time wasted on how to save flash or ram space.. seldom having to concern myself about CPU speed.

      If I'm doing a project that requires very large volume, or special needs, I will again consider an 8 or 16bit processor, but again, these days often the 32bit devices are cheaper and more functional.

      Below are a number of CPU boards with RFM69 or RFM95 Radios attach that can be used with MySensor.

      In MySensor space, for my projects, my favorite 32bit processor board is:
      RocketScream M0 ultra pro Ver2, RFM69 or RFM95 radio, battery connector/charger, USB port, EUI64 chip, large external flash, very low power, u.FL or SMA connector, great support...
      http://www.rocketscream.com/blog/product/mini-ultra-pro-v2-with-radio/

      Other 32 Bit:
      Adafruit Feather LoRa M0, NO EUI64, No External flash, battery connector
      https://www.adafruit.com/product/3178 RFM95
      https://www.adafruit.com/product/3176 RFM69

      Non 32 bit processors:
      MoteinoMega LoRa, ATmega1284P, RFM69 or RFM95, EUI64 chip, large external flash, u.FL or SMA connector
      https://lowpowerlab.com/shop/product/119

      Moteino LoRa, ATmega328P, RFM69 or RFM95, large external flash, NO EUI64 chip
      https://lowpowerlab.com/shop/product/99

      Adafruit Feather LoRa, ATmega32U4 CPU, NO EUI64, No External flash, battery connector, RFM69 or RFM95
      https://www.adafruit.com/product/3078

      posted in Hardware
      lafleur
      lafleur
    • API and core documents in .pdf format

      It would be great if the core documents for this project were available in .pdf format on the web site....
      This would make it easy to have a local copy on a tablet or equivalent device for reference...

      Thanks

      posted in Feature Requests
      lafleur
      lafleur
    • RE: 8Bit or 32Bit processors

      @Nca78

      1.27mm headers 5x2 (.05in) Mouser 855-M50-3500542 made by Harwin

      posted in Hardware
      lafleur
      lafleur
    • RE: 💬 Sensebender Micro mk2

      Is this board using the RFM69HCW footprint so that one could also use an RFM95??
      If not, please consider this change and you might want to consider as an option for DIO-1 connected to an I/O pin on the CPU.. (this would also make it compatible with LoRaWan network)

      Thanks

      posted in OpenHardware.io
      lafleur
      lafleur
    • RE: Default debug serial port

      Thanks... Unclear on why I did not see that when I looks for something like that...

      Made these changes... added issue 707 to development branch

      from:

      #define MY_SERIALDEVICE SerialUSB
      

      to:

      #ifndef MY_SERIALDEVICE
      #define MY_SERIALDEVICE SerialUSB
      #endif
      
      posted in Feature Requests
      lafleur
      lafleur
    • RE: Trace to antenna?

      These are a good starting point...

      http://pdfserv.maximintegrated.com/en/an/AN2093.pdf
      http://www.analog.com/media/en/training-seminars/tutorials/MT-094.pdf

      Yes, it all maters, having 50 ohms from the radio to the antenna will lower the VSWR and make transfer of more power to the antenna.

      posted in Hardware
      lafleur
      lafleur
    • RE: MQTT Client using MySensors Serial Gateway

      @arendst

      I have this gateway running on my Raspberry PI2, but I noticed that it not giving out node ID's... Is this something your going to add??

      Thanks

      posted in Development
      lafleur
      lafleur
    • Dragnio LG01 LoRa gateway

      Anyone had a chance to test or port MySensor code to this device? $56

      https://www.tindie.com/products/edwin/lg01-lora-openwrt-iot-gateway/

      posted in General Discussion
      lafleur
      lafleur
    • RE: 8Bit or 32Bit processors

      @Nca78

      As manufacturing of chips goes to smaller and smaller die size, chip cost go down and preformance goes up..... older processors cost more to build that newer parts!

      It all means better performance, less power and more features for less money...

      The intel 8080 when it was introduced was $360, power hungry, no ram, no storage, no I/O, needed a lot of support chips.... we have come a long way!!!!

      posted in Hardware
      lafleur
      lafleur
    • RE: Why is my ESP8266 MQTT Client Gateway an Access Point?

      @Mike-Cayouette

      You can add it in the setup of the gateway code, works fine for me...

      WiFi.mode (WIFI_STA); // turn off AP mode

      Also, a note: In my testing of a ESP8266 and a RFM69HW radio at 915MHZ, I noticed that i no longer had any range, 100 ft max. Using the same radio on a serial gateway, my range was over 1000ft.. I suspect that the WiFi radio was desensitizing the RFM69 radio receiver... So be cautious! and do some testing.

      posted in Troubleshooting
      lafleur
      lafleur
    • RE: Assigning NODE ID in VER 1.6b

      Found this issue, looks like it NEED TO BE PRIOR to the #include <MySensor.h>

      #define MY_NODE_ID 7                         // id of the node
      //#define MY_PARENT_NODE_ID 1    
      #define CHILD_ID 3                              // Id of the sensor child
      
      #include <SPI.h>
      #include <MySensor.h>  
      
      posted in Development
      lafleur
      lafleur
    • RE: 8Bit or 32Bit processors

      @gohan Pro-mini, is a great part, but sometime you need a lot more! 32 bit is the future for me, less power, less cost, more resources....less hassles...

      posted in Hardware
      lafleur
      lafleur
    • RE: VL53L0X with water tanks

      @Papari-Das

      See my documentation here for what I did for fuel oil, all will be applicable to water..

      https://github.com/trlafleur/Tasmota-Tank-Sensor

      posted in Troubleshooting
      lafleur
      lafleur
    • RE: LED name wrong in 2.0.0 beta

      My pull from the development hub is a few weeks old, I'll check my pull from current master when I get home tonight ....

      posted in Development
      lafleur
      lafleur
    • RE: 8Bit or 32Bit processors

      I use the standard Arduino IDE for most things but moving to PlatformIO as it's editor is so much better that the brain dead one in the Arduino IDE

      posted in Hardware
      lafleur
      lafleur
    • RE: Water well pressure moniter developing

      Here is my program that monitors pressure and flow... Its a work in progress, its still has a few minor issue to work out, but it works....
      It was build using the 2.0.0 development version of MySensor.

      It uses a 0 to 5V output sensor that I found on ebay. I fed its output into an ATD converter pin via a resistor divider.. 10.2k to sensor, 19.6k to gnd... This converts the 5v from the sensor to ~3.3v for the ATD. You can use 5% resistors of 10k and 20k, calibrate the ATD by setting input to divider at 2.5v and adjusting PSIcal to give you 50PSI. Also sending a V_VAR4 message to this sender, you can adjust the PSIcal value in real time...

      It should be easy to remove all of the flow stuff from my program to give you just pressure...

      in from sensor ---10.2k-------- to ATD-pin
      to ATD-pin----19.6k----- gnd

      sensor:
      http://www.ebay.com/itm/Pressure-transducer-or-sender-100-psi-stainless-steel-for-oil-fuel-air-water-/271576977896?hash=item3f3b3fd1e8:g:oQsAAOSwxN5WU8Cs&vxp=mtr

      This sensor has three pins, +5V, gnd and output.

      /*  
       *  Ver 1.2b TRL 1-Mar-2016
       *  
       *  Water flow from a Dwyer 1gal/pulse meter
       *  We measure the period of the pulse to determine the short term flow rate
       *    We also count the pulses to obtain the total gallons used
       *    We filter the input to debounce the reed switch in the meter the best we can, with a cutoff of ~80 gal/min
       *   
       *  Water from a pressure transducer, 0 to 5v
       *    Input fron sensor is scaled by .6577, 5.0v * .6577 = 3.288v
       *    (10.2k and a 19.6k resistor, flitered with a .1uf cap)
       *   
       *  Output: 0.5V – 4.5V linear voltage output. 0 psi outputs 0.5V, 50 psi outputs 2.5V, 100 psi outputs 4.5V 
       *    0   psi = 0.33v after scalling 5.0v to 3.3v
       *    50  psi = 1.65v
       *    100 psi = 2.97v
       *    3.3v/1024 = .0032266 volt per bit
       *    
       *    TX Led was on D3, now use for pulse-in
       *
       */
      
      
      /**
       * 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
       * Version 1.1 - GizMoCuz
       * 
       * DESCRIPTION
       * Use this sensor to measure volume and flow of your house watermeter.
       * You need to set the correct pulsefactor of your meter (pulses per gal).
       * 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
       */
      
      
      
      /* ************************************************************************************** */
      // These items need to be prior to #include <MySensor.h>  below
      
      /*  Enable debug prints to serial monitor on port 0 */
      #define MY_DEBUG            // used by MySensor
      #define MY_DEBUG1           // used in this program, level 1 debug
      #define MY_DEBUG2           // used in this program, level 2 debug
      
      #define SKETCHNAME "Water and Pressure Meter"
      #define SKETCHVERSION "1.2b"
      
      // Enable and select radio type attached
      #define MY_RADIO_RFM69
      #define MY_IS_RFM69HW          true
      #define MY_RFM69_FREQUENCY     RF69_915MHZ      // this set frequency band, not the real operating frequency
      
      #define MY_LEDS_BLINKING_FEATURE
      #define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Moteino 
      #define MY_RF69_SPI_CS 10
      #define MY_RF69_IRQ_PIN 2
      #define MY_RF69_IRQ_NUM 0
      #define MY_DEFAULT_TX_LED_PIN     9   // 4 on sensor 2a PCB as LED3 (9 == on Moteino)
      #define MY_DEFAULT_ERR_LED_PIN    6   // 6 on sensor 2a PCB as Err
      #define MY_DEFAULT_RX_LED_PIN     7   // 7 on sensor 2a PCB as Rx
      
      
      // MoteinoMEGA
      //#define MY_RF69_SPI_CS      4
      //#define MY_RF69_IRQ_PIN     2
      //#define MY_RF69_IRQ_NUM     2
      //#define MY_DEFAULT_TX_LED_PIN     15   // the PCB, on board LED
      //#define MY_DEFAULT_ERR_LED_PIN    7
      //#define MY_DEFAULT_RX_LED_PIN     6
      
      // Enabled repeater feature for this node
      #define MY_REPEATER_FEATURE
      
      #define MY_NODE_ID 6                            // My Sensor Node ID
      //#define MY_PARENT_NODE_ID 0                   // GW ID
      #define CHILD_ID    1                           // Id of my Water sensor child
      #define CHILD_ID2   2                           // Id of my 2nd sensor child
      
      /* ************************************************************************************** */
      /* These are use for local debug of code, hwDebugPrint is defined in MyHwATMega328.cpp */
      #ifdef MY_DEBUG1
      #define debug1(x,...) hwDebugPrint(x, ##__VA_ARGS__)
      #else
      #define debug1(x,...)
      #endif
      
      #ifdef MY_DEBUG2
      #define debug2(x,...) hwDebugPrint(x, ##__VA_ARGS__)
      #else
      #define debug2(x,...)
      #endif
      
      /* ************************************************************************************** */
      
      #include <SPI.h>
      #include <MySensor.h>  
      
      #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
      #define SENSOR_INTERRUPT DIGITAL_INPUT_SENSOR-2     // Usually the interrupt = pin -2 (on uno/nano anyway)
      
      #define PressPin      A0                       // Pressure sensor is on analog input A0
      #define PULSE_FACTOR 1                         // Nummber of pulse per gal of your meter (One rotation/gal)
      #define SLEEP_MODE false                       // flow value can only be reported when sleep mode is false.
      #define MAX_FLOW 60                            // Max flow (gal/min) value to report. This filters outliers.
      
      
      /* ******************************************************************* */
      
      unsigned long SEND_FREQUENCY = 4000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
      unsigned long FLOW_FREQUENCY = 180000;         // time to refresh flow to gateway
      
      MyMessage flowMsg         (CHILD_ID,V_FLOW);      // 34
      MyMessage volumeMsg       (CHILD_ID,V_VOLUME);    // 35
      MyMessage lastCounterMsg  (CHILD_ID,V_VAR1);      // 24
      MyMessage VAR2Msg         (CHILD_ID,V_VAR2);      // 25
      MyMessage VAR3Msg         (CHILD_ID,V_VAR3);      // 26
      MyMessage VAR4Msg         (CHILD_ID,V_VAR4);      // 27
      MyMessage pressureMsg     (CHILD_ID,V_PRESSURE);  // 4
      
      double ppg = ((double) PULSE_FACTOR) ;            // Pulses per gal 
      
      volatile unsigned long pulseCount = 0;   
      volatile unsigned long lastBlink = 0;
      volatile unsigned long newBlink = 0;   
      volatile unsigned long interval = 0;
      volatile double flow = 0; 
      
      boolean pcReceived = false;
      
      unsigned long oldPulseCount = 0;
      
      double oldflow = 0;
      double volume = 0;                     
      double oldvolume = 0;
      
      unsigned long currentTime = 0;
      unsigned long lastSend = 0;
      unsigned long lastPulse = 0;
      
      int t1 = 0 ;
      
      int pressure = 0;
      float PSI = 0;
      float PSI_CAL = 2.0;            // Calibration of sensor
      int PSImsb = 0;
      int PSIr = 0;
      
      /* **************************************************************************** */
      /* **************************************************************************** */
      /* **************************************************************************** */
      void setup()  
      {  
        // initialize serial communication at 115200bits per second:
        Serial.begin(115200);
      
        debug1(PSTR("** Hello from the Water Meter **\n") );
        const char compile_date[] = __FILE__ ", " __DATE__ ", " __TIME__;
        debug2(PSTR("%s %s\n"), SKETCHNAME, SKETCHVERSION);
        debug2(PSTR("%s \n\n"), compile_date);
      
        // initialize our digital pins internal pullup resistor so one pulse switches from high to low (less distortion) 
        pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);
        
        // reference to use (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, or EXTERNAL). 
        analogReference(DEFAULT);
      
        pulseCount = oldPulseCount = 0;
      
        // Fetch last known pulse count value from gw
        //request(CHILD_ID, V_VAR1);
      
        lastSend = lastPulse = millis();      // set current time
      
        attachInterrupt(SENSOR_INTERRUPT, onPulse, FALLING);
      }
      
      /* ******************************************************************* */
      void presentation()  
      {
       // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCHNAME, SKETCHVERSION);
        wait(250);
      
        // Register this device as Waterflow sensor
        present(CHILD_ID, S_WATER);       // S_WATER = 21 
        wait(250);
      
      }
      
      /* **************************************************************************** */
      /* **************************************************************************** */
      /* **************************************************************************** */
      void loop()     
      { 
      
          _process();
          
          currentTime = millis();                 // get the current time
        
          // Only send values at a maximum frequency or woken up from sleep
        if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY))
        {
          lastSend = currentTime;
          
      //    if (!pcReceived) 
      //    {
      //      //Last Pulsecount not yet received from controller, request it again
      //      request(CHILD_ID, V_VAR1);
      //      Serial.println("Last Pulsecount not yet received from controller");
      //      return;
      //    }
      
      
        //  if (!SLEEP_MODE && (flow != oldflow) )
          {
            oldflow = flow;
      
            flow = ((60000000.0 / (double) interval) ) / ppg;
      
            if (flow < 0) flow = 0;
      
            // Check that we dont get unresonable large flow value. 
            // could happen when long wraps or false interrupt triggered
            if (flow < ((unsigned long) MAX_FLOW)) 
            {
      
              PSImsb = flow * 100;
              PSIr = PSImsb % 100;
              debug1(PSTR("gal/min: %0d.%02d\n"), PSImsb/100, PSIr);
              
              send(flowMsg.set(flow, 2));                   // Send flow value to gateway
              wait(200);
            }  
          }
      
      
          // If no Pulse count received in 2min, update gateway flow to zero
          if(currentTime - lastPulse > FLOW_FREQUENCY)
          {
            flow = 0;
            debug1(PSTR("***Sending zero flow rate\n"));
      
            send(flowMsg.set(flow, 2));                   // Send flow value to gateway
            wait(200);
          } 
      
      
          // Pulse count has changed
          if ((pulseCount != oldPulseCount)||(!SLEEP_MODE)) 
          {
            oldPulseCount = pulseCount;
      
            debug1(PSTR("Pulse Count:  %u\n"), (unsigned int) pulseCount );
            
      
            send(lastCounterMsg.set(pulseCount));         // Send  pulse count value to gw in VAR1
            wait(200);
      
            double volume = ((double) pulseCount / ((double) PULSE_FACTOR));     
            if ((volume != oldvolume) || (!SLEEP_MODE)) 
            {
              oldvolume = volume;
      
              debug1(PSTR("Volume (gal): %u\n"), (unsigned int) volume );
      
              send(volumeMsg.set (volume,0));            // Send total volume to gateway
              wait(200);
            } 
          }
      
      /* ************************************************ */
          pressure  = analogRead    (PressPin) ;        // junk read
          wait(25);
          
      /* • Output: 0.5V – 4.5V linear voltage output. 0 psi outputs 0.5V, 50 psi outputs 2.5V, 100 psi outputs 4.5V 
          0   psi = .33v after scalling 5.0v to 3.3v
          50  psi = 1.65v
          100 psi = 2.97v
      
          3.3v/1024 = .0032266 volt per bit
       */
          pressure  = analogRead    (PressPin) ;
      
          if (pressure < 106) pressure = 106;         // this is minimum of .5v
          PSI = (pressure - 106 ) * .1246;            // where did we get this?? was .119904
          PSI = PSI + PSI_CAL;                        // adjustment
          
          PSImsb = PSI * 100;
          PSIr = PSImsb % 100;
          debug1(PSTR("PSI:  %0u.%02u\n"), PSImsb/100, PSIr);
      
          send(pressureMsg.set(PSI, 2));            // Send water pressure to gateway
          wait(200);
          
        }   // end of if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY))
      
        if (SLEEP_MODE) 
        {
          sleep(SEND_FREQUENCY);
        }
        
      }   // end of loop
      
      
      /* ******************************************************************* */
      void receive(const MyMessage &message) 
      {
         //debug1(PSTR("Received message from gw\n"));
       
        if (message.sensor == CHILD_ID )
        {
          if  (message.type==V_VAR1) 
            {
              unsigned long gwPulseCount=message.getULong();
              pulseCount += gwPulseCount;
              flow=oldflow=0;
              debug1(PSTR("Received last pulse count from gw: %u\n"), pulseCount);
              pcReceived = true;
            }
          
           if ( message.type==V_VAR2) 
            {
              pulseCount = message.getULong();
              flow=oldflow=0;
              debug1(PSTR("Received V_VAR2 message from gw: %u\n"), pulseCount );
            }
          
           if ( message.type==V_VAR3) 
            {
              FLOW_FREQUENCY = message.getULong();
              debug1(PSTR("Received V_VAR3 message from gw: %u\n"), FLOW_FREQUENCY);
      
           if ( message.type==V_VAR4) 
            {
        
              PSI_CAL = message.getULong();
              debug1(PSTR("Received V_VAR4 message from gw: %u\n"), PSI_CAL);
            }
            }
          }  // end if (message.sensor == CHILD_ID )
        
        if (message.sensor == CHILD_ID2 )
          {
            
          }
      }
      
      /* ******************************************************************* */
      /* As this is an interrupt service, we need to keep the code here as short as possable */
      void onPulse()     
      {
        if (!SLEEP_MODE)
        {
          newBlink = micros();              // get the current time in us
          interval = newBlink-lastBlink;    // get the delta time in us from last interrupt
          lastBlink = newBlink;             // setup for next pulse
        }
        
        pulseCount++;       // count the pulses from meter
        lastPulse = millis();
        
      }
      
      /* ************** The End ****************** */
      
      
      posted in Development
      lafleur
      lafleur
    • Sensor ID Code display

      I use this code header on my project to ID the code in a given device... you might find it useful in your projects...
      I use primarily, Moteino and MoteinoMega or equiv with RFM69 radios on my projects...

      It outputs an hello message to the serial port, with file name, compile date, time, sensor version number and node information

      /*  Enable debug prints to serial monitor on port 0 */
      #define MY_DEBUG            // used by MySensor
      
      #define SKETCHNAME "Water and Pressure Meter"
      #define SKETCHVERSION "1.2c"
      
      #define MY_RFM69_NETWORKID 200   // Network ID, unique to each network, production = 100, test = 200 
      #define MY_NODE_ID 7                            // My Sensor Node ID real = 6, 7 = test  
      
      
      void setup()  
      {  
        // initialize serial communication at 115200bits per second:
        Serial.begin(115200);
      
      #ifdef __AVR_ATmega1284P__      // use for Moteino Mega Note: LED on Mega are 1 = on, 0 = off
        debug(PSTR("** Hello from the Water Meter on a MoteinoMega **\n") );
        #else                         // we must have a Moteino
        debug(PSTR("** Hello from the Water Meter on a Moteino **\n") );
      #endif
      
        const char compile_file[]  = __FILE__ ;
        debug(PSTR(" %s %s\n"), SKETCHNAME, SKETCHVERSION);
        debug(PSTR(" %s \n"), compile_file);
        const char compile_date[]  = __DATE__ ", " __TIME__;
        debug(PSTR(" %s \n\n"), compile_date);
        debug(PSTR(" Network ID: %u  Node ID: %u\n\n"), MY_RFM69_NETWORKID, MY_NODE_ID);
      
      // your code as needed......
      
      }
      
      posted in Development
      lafleur
      lafleur
    • RE: rfm69 and atc

      I have all this working now and have 7 devices on it to a serial gateway...
      Using new RFM69 driver and RFM69_ATC...

      Its interesting to see the power levels change as packets flow...

      If I can figure out how to do a PULL request, I will make it happen to 2.0b development branch...

      tom

      posted in Development
      lafleur
      lafleur
    • RE: Changing Node ID at run time

      @lafleur

      See issue #675 in Github...

      https://github.com/mysensors/MySensors/issues/675

      posted in Development
      lafleur
      lafleur
    • RE: Changing Node ID at run time

      I have this working now, it was a setup issue on my part...

      #define MY_NODE_ID myNodeId
      
      
      int8_t myNodeId;
      
      #define MY_NODE_ID myNodeId
      
      void before () { 
          // read I/O pins and set myNodeId
          myNodeId = 32;
          Serial.println( myNodeId );
      }
      
      
      posted in Development
      lafleur
      lafleur