Hydreon connection with teensy board 2++

Status
Not open for further replies.
Hi all,(am a new user here,so if there is any mistake pls do tell)
im currently connected my teensy board(2++) to my rain gauge (hydreon) and there's no output(serial monitor) for my arduino 1.8.5 whenever the hydreon (tipping bucket mode) activated. (i've tested with another standard coding(serial print example) and saw serial print in it )
im unsure whether this is correct cause im following this website (http://cactus.io/hookups/weather/rain/hydreon/hookup-arduino-to-hydreon-rg-11-rain-sensor) and i need help in term of the pin/coding whether it's correct ornt.
my pin is connect to f7 on the teensy board 2++ Which i have also wrote to LED to test and its fine.

this is my coding

Code:
#define BOARD "Teensy++ 2.0"


#define RG11_Pin 45
#define Bucket_Size 0.01

volatile unsigned long tipCount; // bucket tip counter used in interrupt routine
volatile unsigned long ContactTime; // Timer to manage any contact bounce in interrupt routine


long lastCount;
float totalRainfall;
float AverageperTime;

void setup() {

lastCount = 0;
tipCount = 0;
totalRainfall = 0;
AverageperTime = 0;

Serial.begin(1200);
Serial.println("Hydreon RG-11 Rain Sensor");
Serial.print("Bucket Size: "); Serial.print(Bucket_Size); Serial.println(" mm");

pinMode(RG11_Pin, INPUT); // set the digital input pin to input for the RG-11 Sensor
// attach interrupt handler to input pin.
// we trigger the interrupt on the voltage falling from 5V to GND

sei(); //Enables interrupts
}

void loop() {
// we only display the tip count when it has been incremented by the sensor
cli(); //Disable interrupts

if(tipCount != lastCount) {
lastCount = tipCount;
totalRainfall = tipCount * Bucket_Size;
AverageperTime = totalRainfall / tipCount; 
Serial.print("Tip Count: ");
Serial.print(tipCount);
Serial.print("\tTotal Rainfall: ");
Serial.println(totalRainfall);Serial.println("mm/hr"); Serial.println(AverageperTime); 

}

sei(); //Enables interrupts
}

// Interrrupt handler routine that is triggered when the rg-11 detects rain
void rgisr () {

if ((millis() - ContactTime) > 15 ) { // debounce of sensor signal
tipCount++;
ContactTime = millis();
}
}
// end of rg-11 rain detection interrupt handler


if anyone could please kindly assist me ?? appreciate it alot & thanks a million!
 
Last edited:
Hey can you fix the link it doesn't work at least for me?
404 Page Not Found
Crikey! the page you wanted has disappeared, maybe never existed or is a bit shy.
EDIT:
Never mind, this is the sensor right:
http://cactus.io/sensors/weather/rain/hydreon/hydreon-optical-rain-sensor-RG-11
hydreon-rg-11-hookup-circuit.jpg
Data Sheets Hydreon RG-11 Instructions
http://static.cactus.io/docs/sensors/weather/Hydreon/rg-11_instructions.pdf
 
where is the attach interrupt handler ?
Code:
attachInterrupt(digitalPinToInterrupt(RG11_pin), rgisr, FALLING);

HERE:
Code:
#define BOARD "Teensy++ 2.0"


#define RG11_Pin 45
#define Bucket_Size 0.01

volatile unsigned long tipCount; // bucket tip counter used in interrupt routine
volatile unsigned long ContactTime; // Timer to manage any contact bounce in interrupt routine


long lastCount;
float totalRainfall;
float AverageperTime;

void setup() {

  lastCount = 0;
  tipCount = 0;
  totalRainfall = 0;
  AverageperTime = 0;

  Serial.begin(1200);
  Serial.println("Hydreon RG-11 Rain Sensor");
  Serial.print("Bucket Size: "); Serial.print(Bucket_Size); Serial.println(" mm");

  pinMode(RG11_Pin, INPUT); // set the digital input pin to input for the RG-11 Sensor
  // attach interrupt handler to input pin.
  attachInterrupt(digitalPinToInterrupt(RG11_pin), rgisr, FALLING);  // <------------ THE FIX?
  // we trigger the interrupt on the voltage falling from 5V to GND

  sei(); //Enables interrupts
}

void loop() {
  // we only display the tip count when it has been incremented by the sensor
  cli(); //Disable interrupts

  if (tipCount != lastCount) {
    lastCount = tipCount;
    totalRainfall = tipCount * Bucket_Size;
    AverageperTime = totalRainfall / tipCount;
    Serial.print("Tip Count: ");
    Serial.print(tipCount);
    Serial.print("\tTotal Rainfall: ");
    Serial.println(totalRainfall); Serial.println("mm/hr"); Serial.println(AverageperTime);

  }

  sei(); //Enables interrupts
}

// Interrrupt handler routine that is triggered when the rg-11 detects rain
void rgisr () {

  if ((millis() - ContactTime) > 15 ) { // debounce of sensor signal
    tipCount++;
    ContactTime = millis();
  }
}
// end of rg-11 rain detection interrupt handler
 
Okay i don't have Teensy++ 2.0 but they are based on AVR MCU which i believe you have limited number of interrupt pins, unlike Teensy 3.x series, all pins have interrupt capability.
You should use only PD0, PD1, PD2 or PD3
pinout4a.png

Connect the sensor to pin PD0
Edit this:
#define RG11_Pin 45
to
#define RG11_Pin 0
 
Hi @Chris O.!
Thanks for the help!
i have copy & paste into my coding and this is the error i have recieved
Code:
Arduino: 1.8.5 (Linux), TD: 1.41, Board: "Teensy++ 2.0, Serial, 8 MHz, US English"

In file included from /home/ivan/Desktop/arduino-1.8.5/hardware/teensy/avr/cores/teensy/Arduino.h:2:0,
                 from /home/ivan/Desktop/arduino-1.8.5/hardware/teensy/avr/cores/teensy/elapsedMillis.h:29,
                 from /home/ivan/Desktop/arduino-1.8.5/hardware/teensy/avr/cores/teensy/WProgram.h:26,
                 from /home/ivan/Desktop/arduino-1.8.5/hardware/teensy/avr/cores/teensy/Arduino.h:1,
                 from /tmp/arduino_build_548723/sketch/RG-11_Sketch.ino.cpp:1:
/home/ivan/Desktop/open this file to test/RG-11_Sketch/RG-11_Sketch.ino: In function 'void setup()':
/home/ivan/Desktop/open this file to test/RG-11_Sketch/RG-11_Sketch.ino:29:42: error: 'RG11_pin' was not declared in this scope
    attachInterrupt(digitalPinToInterrupt(RG11_pin), rgisr, FALLING);// attach interrupt handler to input pin.
                                          ^
/home/ivan/Desktop/arduino-1.8.5/hardware/teensy/avr/cores/teensy/pins_arduino.h:64:36: note: in definition of macro 'digitalPinToInterrupt'
 #define digitalPinToInterrupt(p) ((p) <= 3 ? (p) : (((p) == 36 || (p) == 37) ? (p) - 32 : (((p) == 18 || (p) == 19) ? (p) - 12 : -1)))
                                    ^
/home/ivan/Desktop/open this file to test/RG-11_Sketch/RG-11_Sketch.ino: In function 'void loop()':
/home/ivan/Desktop/open this file to test/RG-11_Sketch/RG-11_Sketch.ino:39:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(tipCount!= lastCount) {
               ^
Error compiling for board Teensy++ 2.0.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

which i dont really understand TT
 
if i were to pin my connection to PDO
do i change it to
Code:
#define RG11_Pin PD0

OR

Code:
#define RG11_Pin 0

OR Some different coding which is not #define ?

Thanks alot!
 
Your defining the pin as 45, I'm not sure if Teensy 2++ has that many pins?

Edit this 1st ok
Connect the sensor to pin PD0
Edit this:
#define RG11_Pin 45
to
#define RG11_Pin 0

this is correct
Code:
#define RG11_Pin 0
 
lol ;)
Code:
                               #define RG11_Pin 0
 attachInterrupt(digitalPinToInterrupt(RG11_pin), rgisr, FALLING);  // <------------ THE FIX?

pin or Pin :eek:

Code:
#define BOARD "Teensy++ 2.0"

#define RG11_Pin 0
#define Bucket_Size 0.01

volatile unsigned long tipCount; // bucket tip counter used in interrupt routine
volatile unsigned long ContactTime; // Timer to manage any contact bounce in interrupt routine

long lastCount;
float totalRainfall;
float AverageperTime;

void setup() {

  lastCount = 0;
  tipCount = 0;
  totalRainfall = 0;
  AverageperTime = 0;

  Serial.begin(1200);
  Serial.println("Hydreon RG-11 Rain Sensor");
  Serial.print("Bucket Size: "); Serial.print(Bucket_Size); Serial.println(" mm");

  pinMode(RG11_Pin, INPUT); // set the digital input pin to input for the RG-11 Sensor
  // attach interrupt handler to input pin.
  attachInterrupt(digitalPinToInterrupt(RG11_Pin), rgisr, FALLING);  //
  // we trigger the interrupt on the voltage falling from 5V to GND

  sei(); //Enables interrupts
}

void loop() {
  // we only display the tip count when it has been incremented by the sensor
  cli(); //Disable interrupts

  if (tipCount != lastCount) {
    lastCount = tipCount;
    totalRainfall = tipCount * Bucket_Size;
    AverageperTime = totalRainfall / tipCount;
    Serial.print("Tip Count: ");
    Serial.print(tipCount);
    Serial.print("\tTotal Rainfall: ");
    Serial.println(totalRainfall); Serial.println("mm/hr"); Serial.println(AverageperTime);

  }

  sei(); //Enables interrupts
}

// Interrrupt handler routine that is triggered when the rg-11 detects rain
void rgisr () {

  if ((millis() - ContactTime) > 15 ) { // debounce of sensor signal
    tipCount++;
    ContactTime = millis();
  }
}
// end of rg-11 rain detection interrupt handler
 
No problem
As far as the division I'm not sure without the hardware it's hard for me to give you advice on this.
In the post that you show the error the Teensy 2++ appears to be running on 8 MHz
Arduino: 1.8.5 (Linux), TD: 1.41, Board: "Teensy++ 2.0, Serial, 8 MHz, US English"
Perhaps you should change that to 16Mhz not sure if the setting will have any timing issues.
You can change the setting in Arduino Tools menu.
 
Status
Not open for further replies.
Back
Top