Please Help Me Fix This -arduino henhouse

Discussion in 'The Projects Forum' started by shutterb, May 7, 2015.

  1. shutterb

    Thread Starter New Member

    May 2, 2013
    10
    0
    I have designed a arduino based project to automate my hen house. I designed and printed the PCB, populated it and wrote the code. Everything works except I screwed up the simplest part of the board.

    One of my sensors detects the voltage in the battery / solar panels. What I attempted (see attached) was for the arduino to send a signal to a transistor to turn on and allow the voltage in the battery to flow into a voltage divider where the ardunio would then read the voltage present there. The problem is the transistor's base is 5v and the collector is 6v so I am only getting around 4.3 volts from the emitter. Obviously I forgot about this simple fact before I made the PCB.

    (Also it is not shown in the schematic but the arduino and battery share a ground.)

    I know I can bypass the transistor and just connect 6v to R1 but I don't want to waste the power when I am not sensing anything.

    What do you feel is the easiest way to fix this?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    You don't need the transistor.
    The input resistance of the Arduino analog input is very high and hence it draws very little current. Simply use a voltage divider of sufficiently high resistance.
    Very little power will be wasted.
     
  3. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,515
    1,246
    Atmel thinks the input resistance of the A/D converter is 100 megohms (good luck proving that in a commercial plastic package IC). That's so high that it would introduce an error of less than 1% to a voltage divider made of two 1 meg resistors. Lower impedance dividers increase both accuracy and power. Life is choice.

    If you want to work harder, change the transistor to a PNP, reverse it with the emitter tied to the battery, and add a small zener diode to the base. But unless you are careful with the transistor biasing, the transistor method will consume more power than the high-impedance voltage divider long-term.

    ak
     
  4. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    There is one other caution about using high-Z voltage divider to sample battery voltage. Most MCU A/Ds have a very high DC input resistance, but they require that the AC source resistance of the voltage being measured is <=10KΩ (I haven't looked specifically at Atmel). This can be accomplished with a high-Z resistive divider provided that the AD input pin is bypassed to the Vss pin with a low-leakage capacitor of at least 100nF.
     
  5. shutterb

    Thread Starter New Member

    May 2, 2013
    10
    0
    Thank you for the responses. Does anyone know a formula to calculate what the current would be if I hooked R1 directly to the battery and bypassed the transistor?
     
  6. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    a 6V SLA battery will be ~7.4V as it approaches full-charge. It should be floated at 6.80V, and should never be discharged below 5.5V. Here is a resistor network that keeps the AD input within range V(ad), while presenting a low AC impedance to the ADinput. The battery current drain I(R1) is shown. Plotted vs Battery voltage.

    59.gif
     
  7. Søren

    Senior Member

    Sep 2, 2006
    472
    28
    Atmel wants less than 10k of source impedance. The impedance of the A/D-C buried within is fairly academic, as you won't access it directly.
    The e-c drop of a transistor would give an error, even if this wasn't the case.

    The right solution is to use a reed relay to switch in the battery and keep the total impedance of R1//R2 < 10k

    Edit: If needs be, you can wind a coil directly on a reed switch with a low AT (Ampere/turn) rating, glue the assembly to the board and connect the dots, without taking up too much space.
     
    Last edited: May 8, 2015
  8. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Only for the AC part of the signal. If you put the capacitor I showed on the schematic of post #6 , then you can choose the resistors based purely on the DC pin leakage. The external capacitor I show stores the charge that is transfered to the AD's internal sample-and-hold capacitor, therby meeting the 10K source impedance requirement. The battery voltage changes so slowly that the time constant matters not.

    This ground was already ploughed above.
     
  9. Søren

    Senior Member

    Sep 2, 2006
    472
    28
    Hi Mike,

    Too washed out to consider it right now, nothing makes sense and I just hope I'll be able to find my bed in a minute - will look at it tomorrow :)
     
Loading...