Pulse counting for Gas meter using hall effect sensor

Evening,

I'm trying to set up an EmonTX for pulse metering (from a gas meter, with a magnet on the disk).

I have a hall effect sensor (TLE 4913);

http://uk.rs-online.com/web/p/hall-effect-sensor-ics/7533260/

I have soldered the jumper on the emonTX to give 5V.

I have NOT installed a 10k pull down resistor (I believe this is optional, on what basis should it be used?).

I have connected the sensor the the emonTX, and I'm using the sketch by Jerome (below). When I pass a magnet over the sensor, the serial monitor responds, but instead of showing a count number, it shows some random characters- see attached screenshot.

This doesn't seem right- any thoughts why it is doing this?

Chris

volatile unsigned int count;

void setup()
{
  Serial.begin(57600);
  Serial.println ("Start");     // signal initalization done

  pinMode(3, INPUT);   //set the interrupt0  pin3 to input
  digitalWrite(3, HIGH);   // and enable it's internal pull-up resistor

  attachInterrupt(1, countP, FALLING);  // device signals a low when active
  delay(100);
}

void loop()
{
 
}

void countP()
{
   count++;
   Serial.println (count);
}

MartinR's picture

Re: Pulse counting for Gas meter using hall effect sensor

Have you set the baud of your terminal window to match the 57600 in your sketch?

The default is 9600 if you haven't changed it.

edited to say: I just looked at your photo and noticed you do still have the baud set to 9600 so that's your problem

charliemic's picture

Re: Pulse counting for Gas meter using hall effect sensor

Martin,

Thanks for that! Sorted now.

Chris

Jérôme's picture

Re: Pulse counting for Gas meter using hall effect sensor

I have NOT installed a 10k pull down resistor (I believe this is optional, on what basis should it be used?).

Not my area so I won't try to explain. Search the web for "open drain".

The ATMega input is open drain. You use the (internal, because there is one) pull-up resistor to keep its input at Vcc and when 0 V is applied by the sensor, a falling edge is detected. You could use a (external, since there's no internal) pull-down resistor to keep it at 0 V and plug the sensors so as to send Vcc on the input when the magnet passes.

Actually what I wrote on my profile might be inaccurate:

Either connect it between GND and output and activate the pull-up resistor (tested), or just connect it between Vcc and output and don't activate the pull-up resistor (I suppose).

I don't know what happens if the internal pull-up is not active and if there is no external pull-down either.

I'm sorry, I think it used to be clear in my head, by the time I wrote it...

Anyway, I can't explain you clearly why, but you were right.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.