Hi guys.
I'm working on a weather station project based on a bare arduino chip and i want to send data with Sim800L module. My weather station will work in a remote place on solar power and battery so i need to reduce the current draw of the Sim800 module.
I use the AT sleep command which technically should allow me to reduce its current draw to 1 ma. However, after some testing the current draw of my station is way higher than it should be (average value between 20 and 30 ma -determined with battery voltage- instead of ~5 ma theoritically when sending temperature every 3 mins). I think there is a problem somewhere. I tested the current draw of my bare arduino chip with my multimeter and it shows low values (20/30 micro amps on sleep mode). The problem should then come from the GPRS module.
In order to find what is wrong the module i wanted to test its current draw but i couldn't manage to do it with my multimeter in series. The module keeps restarting and can't connect to the network and enter sleep mode. I also tested with a schottky diode in series and used ohm law to determine the current but the module sends me back symbols and it's also not working.
Here is my code.
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <String.h>
#include <Wire.h>
#include "ClosedCube_Si7051.h"
#include <elapsedMillis.h>
#include <Sleep_n0m1.h>
#include <Vcc.h>
#include "Adafruit_SHT31.h"
ClosedCube_Si7051 si7051;
Adafruit_SHT31 sht31 = Adafruit_SHT31();
elapsedMillis waitTime;
SoftwareSerial mySerial(7, 8);
Sleep sleep;
char incomingByte;
unsigned long sleepTime;
const float VccCorrection = 1/1; // Measured Vcc by multimeter divided by reported Vcc
Vcc vcc(VccCorrection);
void setup()
{
mySerial.begin(9600); // the GPRS baud rate
Serial.begin(9600); // the GPRS baud rate
si7051.begin(0x40);
sht31.begin(0x44);
sleepTime = 30000;
}
void loop()
{
sleep.pwrDownMode();
float tempsi=gettempsi();
float tempsht=gettempsht();
float humsht=gethum();
float volts=getvcc();
sendinfo(tempsi,tempsht,humsht,volts);
sleep.sleepDelay(sleepTime);
return;
}
float gettempsi(){
float averagesi=0;
for(int i = 0; i < 60; i++) {
averagesi=averagesi + si7051.readTemperature();
sleep.sleepDelay(2000);
}
float tsi=averagesi/60;
float asi = round(tsi*10);
float tempsi=asi/10;
return tempsi;
}
float gettempsht(){
float average=0;
for(int i = 0; i < 10; i++) {
average = average + sht31.readTemperature();
sleep.sleepDelay(1000);
}
float t= average/10;
float a = round(t*10);
float tempsht=a/10;
return tempsht;
}
float gethum(){
float average=0;
for(int i = 0; i < 4; i++) {
average = average + sht31.readHumidity();
sleep.sleepDelay(250);
}
float t= average/4;
float a = round(t*10);
float humsht=a/10;
return humsht;
}
float getvcc(){
float average=0;
for(int i = 0; i < 10; i++) {
average = average + vcc.Read_Volts();
sleep.sleepDelay(300);
}
float volts= average/10;
return volts;
}
float sendinfo(float tempsht,float tempsi,float humsht,float volts)
{
mySerial.println("AT");
delay(200);
mySerial.println("AT");
delay(200);
mySerial.println("AT+CIPSHUT");
waitforshutok();
mySerial.println("AT+CSTT=\"Free\"");
waitforok();
mySerial.println("AT+CIICR");//bring up wireless connection
waitforok();
mySerial.println("AT+CIPSPRT=0");
waitforok();
mySerial.println("AT+CIFSR");
delay(500);
mySerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");
waitforconnectok();
mySerial.println("AT+CIPSEND");//begin send data to remote server
delay(100);
String str="GET http://api.thingspeak.com/update?api_key=B7TCZ12P3W1A26ZG&field1=" + String(tempsi)+"&field2=" + String(tempsht)+"&field3="+String(humsht)+"&field4="+String(volts);
mySerial.println(str);//begin send data to remote server
mySerial.println((char)26);//sending
mySerial.println();
delay(1000);
mySerial.println("AT+CIPSHUT");
waitforshutok();
mySerial.println("AT+CSCLK=2");
}
bool waitFor(String searchString, int waitTimeMS) {
Serial.println("Waiting for string");
waitTime = 0;
String foundText;
while (waitTime < waitTimeMS) {
if (!mySerial.available()) {
// Nothing in the buffer, wait a bit
delay(5);
continue;
}
// Get the next character in the buffer
incomingByte = mySerial.read();
if (incomingByte == 0) {
//Ignore NULL character
continue;
}
Serial.print(incomingByte);
foundText += incomingByte;
if (foundText.lastIndexOf(searchString) != -1) {
Serial.print("Found string after ");
Serial.print(waitTime);
Serial.println("ms.");
return true;
}
}
// Timed out before finding it
Serial.println("string not found, timed out");
return false;
}
bool waitforok() {
return waitFor("\nOK\r\n", 3000);
}
bool waitforshutok() {
return waitFor("\nSHUT OK\r\n", 4000);
}
bool waitforconnectok(){
return waitFor("\nCONNECT OK\r\n",5000);
}
I have two questions :
-
What can i do in order to measure the current draw of the Sim800 module with a reasonable accuracy ( +- 1 ma accuracy is enough for me) ? That could help me finding the reason why it doesn't work as planned.
-
Can you see something wrong in my code that could cause my high current issue ?