using jeelib

i have used jeelib in the code i have been doing..i need some help whether i have successfully used jeelib or not...thanks

#include <VirtualWire.h>

#include <JeeLib.h>
#include <Ports.h>

ISR(WDT_vect) { Sleepy::watchdogEvent(); }

int dig= 8;
int val = 0;

int digib=4;
int bat= 0;
int j=0;

void setup() {
Serial.begin(9600);
pinMode(dig,OUTPUT);
pinMode(digib,OUTPUT);

Serial.println("setup");
Serial.println("RANDOM");
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2400); // Bits per sec
vw_set_tx_pin(7);

Serial.println("RANDOM");
delay(200);

}

void loop()
{
if (j%11==0){

{
digitalWrite(dig,LOW);
delay(500);
digitalWrite(dig,HIGH);
val= analogRead(A3);
if(val>1000)
{

const char *msg2 =("ok");
vw_send((uint8_t *)msg2, strlen(msg2));
vw_wait_tx();
for(byte i=0; i<30; ++i)
Sleepy::loseSomeTime(60000);

digitalWrite(dig,LOW);

}

else
{

Serial.print(" fail ");
const char *msg = "FL";
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
for(byte i=0; i<30; ++i)
Sleepy::loseSomeTime(60000);
digitalWrite(dig,LOW);

}

delay(200);
}

digitalWrite(digib,HIGH);
delay(200);
bat=analogRead(A2);
if(bat>1000)
{
const char *str = " ok,";

vw_send((uint8_t *)str, strlen(str));
//Serial.print(strlen(str)); // Debug check
Serial.print(" OK , ");
vw_wait_tx(); // Wait until the whole message is gone
for(byte i=0; i<30; ++i)
Sleepy::loseSomeTime(60000);
digitalWrite(digib,LOW);
}
else
{
const char *str = "cut,";

vw_send((uint8_t *)str, strlen(str));
//Serial.print(strlen(str)); // Debug check
Serial.print(" cut ");
vw_wait_tx(); // Wait until the whole message is gone
for(byte i=0; i<30; ++i)
Sleepy::loseSomeTime(60000);

digitalWrite(digib,LOW);
}

delay(200);
}
else

j++;

}

Hi, first read this link, and then edit how your sketch is posted.

Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Then explain step by step what you are trying to achieve.
What the problem is.
For example what is JeeLib?

Tom........ :slight_smile:
Then we can probably help you with your problem

Hi,

you should link your other posts when the information in it is needed for answering that question. Or maybe you should post it under your old thread instead of starting a new one...

regards

TomGeorge:
Hi, first read this link, and then edit how your sketch is posted.

Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Then explain step by step what you are trying to achieve.
What the problem is.
For example what is JeeLib?

Tom........ :slight_smile:
Then we can probably help you with your problem

Then explain step by step what you are trying to achieve.
What the problem is.

basically i have two loops..simply one wire connected from Pin 8 to A3..and another one from pin 4 to A2..basically when pin 8 and A3 are shorted and pin 4 and A2 are shorted...it will give a certain ADC reading to which i have printed OK..and when i open a wire..it will print CUT..or something along those lines..i have tested the code and the logic is fine..now i wanna use power saving modes so that my battery can last longer..so I went with jeelab library..its basically a power saving mode..
http://jeelabs.org/2011/12/13/developing-a-low-power-sketch/#comments

the power saving mode seems to work fine because during sleep mode...i hve measured current across the loop say Pin 8 and A3.. and the current is zero..and when it wakes up for transmittion there is a sudden burst of current reading on my multimetre..

but despite it working my 9V battery lasts only for 3days..am i missing something from jeelab...??thats basically my doubt...

and apologies for not posting it the right way..ill make sure next time..ill post it the right way..

Hi, how often do you wake up, have you measured your sleep and awake current?
Are you using the arduino in its minimum physical configuration or an arduino board?
Which arduino controller are you using?
Is the battery a 9V "transistor" battery? ie the type used in DMM and smoke detectors?

Tom...... :slight_smile:

TomGeorge:
Hi, how often do you wake up, have you measured your sleep and awake current?
Are you using the arduino in its minimum physical configuration or an arduino board?
Which arduino controller are you using?
Is the battery a 9V "transistor" battery? ie the type used in DMM and smoke detectors?

Tom...... :slight_smile:

i have put in in sleep mode as long as 4hours..as in wake up once every 4hour..transmit data from Transmitter RF module..then go back to sleep..i am using barebone arduino...with a LM7805....capictors..one 10k resistor..a 16Mhz crystal clock external one..i am using all the components as SMD components..except the atmega 328P which is the normal chip...i have the measured the current with multimeter across the battery and chip and it was around 0.5mA constanst..so thats the current going in the chip...

the batteries iam using arent that great...its a 9V battery..of current 220mhA..these are HW batteries chinese make lol....but i did switch too everyready batteries of around 420mAh..but didnt get huge amount of difference..just a few more days.. jeelab isnt being used properly here...otherwise its meant to run for months...any help regarding jeelab??

"am using barebone arduino...with a LM7805........"

I'd guess there is your problem right there, you might be using up all your power running that regulator. Can you run it off 3x AA and get rid of the regulator?

Jimmy

I'd guess there is your problem right there, you might be using up all your power running that regulator. Can you run it off 3x AA and get rid of the regulator?

Jimmy
[/quote]

3 x AA meaning 1.5 times 3 right i.e 4.5V right...the slot where ill will be inserting is actually not that huge...it can fit in 9V battery..i would have to check whether i would be able to fit in 3batteries...in the slot...

The point here is that if you use 4.5v you won't need a voltage regulator, and then you can get down to some good power saving modes.

mixographer:
The point here is that if you use 4.5v you won't need a voltage regulator, and then you can get down to some good power saving modes.

Hi there can i use 2x1.5 i.e 3volts to run my barebone arduino...that would get rid of my voltage regulator..the main issue iam facing is actually of size of battery slot that we are planning to insert the battery or batteries..it just about fits in a 9V battery..so 3 x 1.5V would not be able to fit in iam afraid..so if I use 3V power supply and replace my 16Mhz crystal oscillator into 8Mhz..would that be feasable for the barbone..thanks...