Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Programming ➜ General ➜ sms weight scale

sms weight scale

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Fajsa   (1 post)  Bio
Date Mon 19 Jan 2015 07:56 PM (UTC)
Message
Hi,i am new in this forum,I am working on a project arduino beekeeping sms scales , I made a prototype but I have a problem great battery consumption , namely my battery is spent in two days , it is necessary to take at least one month without recharging .
I saw the text of Mr. Gammon on power save function , so I asked him because I see that he is the expert in this area to help with the upgrade code .
twice in 24 hours my balance takes the data from the sensors and through text messages sent my report on my cell phone , this time in the code are listed as one TIMER 1 , and TIMER 2.
whether it is possible to balance it off , and that wakes up only when the reading and sending messages .
if we can use an external RTC I have a DS1302 as a trigger, for awakening or some another way ?Sorry for my bad english,and thank you for any help!!
My code is:


#include <stdio.h>
#include <DS1302.h>
#define EEPROM_TARE 0
#define EEPROM_TIMER1 4
#define EEPROM_TIMER2 5
#define TEL_NUMBER "+385xxxxxxx"
#define OUTBUFSIZE 160
uint8_t CE_PIN = 11;
uint8_t IO_PIN = 12;
uint8_t SCLK_PIN = 13;
char m_outBuffer[OUTBUFSIZE];
void setup()
{
SerialInit();

Scale_init( EEPROMReadlong( EEPROM_TARE) );
TimersInit( EEPROMRead( EEPROM_TIMER1), EEPROMRead( EEPROM_TIMER2) );
Temp_humidity_sensor_init();
//SetGSMSerial(false);
//sprintf( m_outBuffer, "start" );
//SendData( m_outBuffer );
}

void loop()
{
SerialComunication();
if( IsNewHour() )
{
if( IsTimer1() )
{
SetGSMSerial(true);
MakeReport( m_outBuffer, 160);
SendData( m_outBuffer );
}
if( IsTimer2() )
{
SetGSMSerial(true);
MakeReport( m_outBuffer, 160);
SendData( m_outBuffer );
}
}
delay(1000);
}

void SerialComunication()
{
if( IsSerialMsg() )
{
GetSerialMsg();
int ordnerIndex = GerOrderIndex();
switch(ordnerIndex)
{
case 0://SetTimer1_hh
EEPROMWrite( EEPROM_TIMER1, ReadSerialInt(0, -1 ) );
SetTimer1( EEPROMRead( EEPROM_TIMER1) );
ClearOutBuffer();
sprintf( m_outBuffer, "Is%s%d", GetOrder(ordnerIndex), EEPROMRead( EEPROM_TIMER1) );
SendData( m_outBuffer );
break;
case 1://SetTimer2_hh
EEPROMWrite( EEPROM_TIMER2, ReadSerialInt( 0, -1 ) );
SetTimer2( EEPROMRead( EEPROM_TIMER2 ) );
ClearOutBuffer();
sprintf( m_outBuffer, "Is%s%d", GetOrder(ordnerIndex), EEPROMRead( EEPROM_TIMER2) );
SendData( m_outBuffer );
break;
case 2://Tare_
EEPROMWritelong( EEPROM_TARE, GetTare() );
Scale_init( EEPROMReadlong( EEPROM_TARE) );
break;
case 3://SetClock_hhmmss
SetClock( ReadSerialInt( 0, 2 ), ReadSerialInt( 2, 2 ), ReadSerialInt( 4, 2 ) );
ClearOutBuffer();
// GetTime( char* pcText )
break;
case 4://SendReport_
MakeReport( m_outBuffer, 160);
SendData( m_outBuffer );
break;
case 5://SetSendPC_ np #SetSendPC_#
SetGSMSerial(false);
break;
default:
ClearOutBuffer();
sprintf( m_outBuffer, "Not recognized order" );
SendData( m_outBuffer );
break;
}
Serial.print( "n" );
}
}
void ClearOutBuffer()
{
for (int i=0; i<OUTBUFSIZE;i++)
{ m_outBuffer=NULL;}
}
void MakeReport(char* pcReportText, int iSize )
{
for (int i=0; i<iSize;i++)
{ pcReportText=NULL;}
int h, m, s;
float hum = ReadHumidity();
float temp = ReadTemperature();
double mass = GetWeigth();
if( mass <0)
mass= mass*-1;
GetTime( &h, &m, &s );
sprintf( pcReportText, "%02d:%02d:%02d Hum: %d%% Temp: %d.%dC Weight: %d.%dkg",
h, m, s,(int)hum, (int)temp, (int)(( temp -(int)temp) *10 ), (int)mass, (int)(( mass -(int)mass) *10 ) );
}
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 19 Jan 2015 08:00 PM (UTC)
Message
Template:Arduino Please post Arduino-related questions to the Arduino Forum or to StackExchange: Arduino. This saves splitting questions and answers between this forum and the Arduino ones.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,683 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.