0

So I want to create an application where I can send data with a SIM-Module, and when it's not needed it should fall into a "standby-mode" because it's battery powered. But I always get this exact output, and I have no clue why:

wakeup condition fulfilled
Tes

When it wants to print out "Testing ..." it always stops after three letters.

Here's my code:

/* 
 * PINOUT: 
 * 
 * UNO >> SIM800L
 * RX (8) >> TX
 * TX (9) >> RX
 *
*/
#include <BareBoneSim800.h>
BareBoneSim800 sim800("hologram"); //APN of the carrier
void sendData(char *url)
{
 sim800.enterSleepMode(false);
 Serial.println("Testing GSM module For GPRS Connectivity");
 delay(8000); // this delay is necessary, it helps the device to be ready and connect to a network
 Serial.println("Should be ready by now");
 bool deviceAttached = sim800.isAttached();
 if (deviceAttached)
 Serial.println("Device is Attached");
 else
 Serial.println("Not Attached");
 // Connecting the the GPRS APN Network
 Serial.println(" Connecting to APN");
 bool netConnect = sim800.gprsConnect();
 if (netConnect)
 Serial.println("Connected to Network");
 else
 Serial.println("An Error Occured");
 if (netConnect)
 {
 Serial.println("Making HTTP Get Request");
 String result = sim800.sendHTTPData(url);
 Serial.println("Received Info: ");
 Serial.println(result);
 Serial.println("Current time utc+0: ");
 Serial.println(sim800.getTime());
 }
 sim800.closeHTTP(); // disconnect from server
 sim800.gprsDisconnect();
 sim800.enterSleepMode(true);
}
void wakingUp()
{
 //hardware interrupt measurement goes here
}
void setup()
{
 Serial.begin(9600);
 sim800.begin();
 while (!Serial)
 ;
 //Save Power by writing all Digital IO LOW - note that pins just need to be tied one way or another, do not damage devices!
 for (int i = 0; i < 20; i++)
 {
 if (i != 8 && i != 9 && i != 2)
 {
 // pin 2 is for waking the arduino up from deep sleep
 //pin 8 and 9 are used to connect with the sim module,
 //these pins must be exluded from power saving
 pinMode(i, OUTPUT);
 }
 }
 attachInterrupt(0, wakingUp, FALLING); //interrupt for waking up
 /*
 various flags for turning stuff down when not needed
based on this very good tutorial https://www.youtube.com/watch?v=urLSDi7SD8M
 */
 //SETUP WATCHDOG TIMER
 WDTCSR = (24); //change enable and WDE - also resets
 WDTCSR = (33); //prescalers only - get rid of the WDE and WDCE bit
 WDTCSR |= (1 << 6); //enable interrupt mode
 //Disable ADC - don't forget to flip back after waking up if using ADC in your application ADCSRA |= (1 << 7);
 //ADCSRA &= ~(1 << 7);
 //ENABLE SLEEP - this enables the sleep mode
 SMCR |= (1 << 2); //power down mode
 SMCR |= 1; //enable sleep
 //BOD DISABLE - this must be called right before the __asm__ sleep instruction
 //MCUCR |= (3 << 5); //set both BODS and BODSE at the same time
 //MCUCR = (MCUCR & ~(1 << 5)) | (1 << 6); //then set the BODS bit and clear the BODSE bit at the same time
 __asm__ __volatile__("sleep"); //in line assembler to go to sleep
}
void loop()
{
 //do nothing, use ISR instead
}
char targetURL[] = "http://www.example.com/restAPI/";
ISR(WDT_vect)
{
 //DON'T FORGET THIS! Needed for the watch dog timer. This is called after a watch dog timer timeout - this is the interrupt function called after waking up
 //todo, turn on adc conversion again
 int halfHourCounter = 0; //30 minutes => 225 8sec intervals
 bool wakeUpCondition = (halfHourCounter % 225 == 0);
 if (wakeUpCondition)
 {
 Serial.println("wakeup condition fulfilled");
 //reset counter
 halfHourCounter = 0;
 //ADCSRA |= (1 << 7); // turn analog digital conversion back on
 //... measure data and send it away :)
 sendData(targetURL);
 //ADCSRA &= ~(1 << 7); // disable ADC again
 }
 else
 {
 Serial.println("wakeup condition not fulfilled");
 }
 halfHourCounter += 1;
} // watchdog interrupt

I'm using an Arduino Uno in combination with a SIM800L evaluation board. If I call the sendData()-function without any standby-flags enabled everything works fine. Vice versa if I call just a print function for debugging with all the standby flags enabled

asked Dec 25, 2019 at 20:14
2
  • Can your battery provide enough current? You didn't specify, what battery you are using and how it is connected Commented Dec 26, 2019 at 14:56
  • Right! Sorry I forgot about that. At the moment I'm just using a normal USB-Connection for power and reading the serial port. Commented Dec 27, 2019 at 6:32

1 Answer 1

1

It seems, that the Sim800 module is drawing too much current, when you start it again. The voltage drops and the Arduino/Sim800 stops working.

This datasheet of the Sim800 states, that it can draw up to 2A when doing a sending burst. An USB port on a computer can provide up to 500mA and you can draw between 200mA to 1A from the Arduino's 5V pin (depending on the version, that you use: Older Unos can provide 200mA, Uno r3 should be able to provide 1A). If you draw too much current through the Arduino from USB, you will fry the diode for voltage source seletion. Also you can fry the electronics of the USB port, if you draw too much current from it (though normally the port should go into shutdown, if you do that, and work again, if you restart the computer).

You have to provide the Sim800 module with enough power and not through the Arduino. You should choose a fitting battery for this. If you don't want to involve a battery at this point, since you are still testing, you can use an USB phone charger to provide enough current.

answered Dec 27, 2019 at 12:42
1
  • Thanks! I'll try it out :) Commented Dec 28, 2019 at 17:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.