Hello, everybody!
Hardware: SIM900 Keyestusio + Arduino Mega, Android
Recently I faced with a strange problem connected with sim900 and mega. This simple code works fine in Uno, but when i load similar one at, Mega in smatrphone I see only Blynk.connented! ant it’s all. I can not interact with mega using the V3.
I assume, that is program issue, not hardware.
Please, help!
This is for MEGA (on serial2 hardware)
//20 - sda, 21 - scl - используется для подключения дисплея
//V0,V1,V2,V3,V4
//Добавить датчик тока,30A реле включения ТЭН в зависимости от температуры носителя и температуры комнаты(добавить датчик температуры dallas)
#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_SIM900
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#define SerialAT Serial2
TinyGsm modem(SerialAT); // RX, TX (17,16) (соединить с TX, RX на модеме)
char auth[] = "-Ou5Tu8suT";
char apn[] = "internet";
char user[] = "";
char pass[] = "";
#define TINY_GSM_DEBUG SerialMon
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS 4 // DS18B20 - 4 pin
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
LiquidCrystal_I2C lcd(0x27,16,2); //проверить сначала адрес сканером. (0x27)
BlynkTimer timer;
#define SerialMon Serial
WidgetLED ledTest(V3);
BLYNK_WRITE(V4){ /////////TEST
if (param.asInt())
{
ledTest.on();
}
else
{
ledTest.off();
}
}
void setup() {
SerialMon.begin(9600);
SerialMon.println("FROM SETUP!");
delay(3000);
Serial.begin(9600);
delay(10);
SerialAT.begin(115200);
delay(3000);
Serial.println("Initializing modem...");
modem.restart();
SerialMon.println("BEFORE BEGIN!");
Blynk.begin(auth, modem, apn, user, pass);
Blynk.syncAll();
Blynk.notify("FROM SETUP");
SerialMon.println("FROM SETUP!");
}
void loop() {
Blynk.run();
// timer.run();
}
This works like “Blynk.Connected!” ant it’s all.
And for UNO I tested this code using softwareSerial pins. That worked fine.
Thanks for your answer. I used 9600 with softwareSerial in Uno. And 115200 with Mega. I reconfigured Sim900 to these boud rates in bouth cases. I know, that 115200 works fine with mega because i tried AT DEBUG program in this baud rate and ti worked (I send smth like AT -> OK, AT+CCLK? etc. and modem answered )
Thank you for advice, I tried to set this code like yours (
TinyGsm modem(&Serial2);
), but now I have this error : no matching function for call to ‘TinyGsmSim800::TinyGsmSim800(HardwareSerial*)’
What about baud rates, I tried 9600 with Mega and reult was all the same.
A simple AT command just shows the concept works, whereas Blynk requires constant communication… and that is where things can start acting up (dropped bits, etc.)
I probably missed some other change you need to make… I did NOT go through all your code.
Nothing wrong with Hardware Serial and Software Serial is just limited to the consistency at higher speeds (and a bit more processing power required in the device)
Thus if it is now working with SoftSerial and 9600, I believe my original hypothesis that the overall speed limit you were trying was simply “Too much too fast”. A properly setup SIM900 and Serial2 (or Serial1, Serial3) at 9600 for both should have exactly the same results, just with less processing (of which is lacking in the these older Arduino devices we love so much)