Arduino Mega Pro & Modul BK-7000 SerialAT Issue

hi all, nice to meet you. I'm new to Arduino and I want to learn more about Arduino.

i have a project about Water Flow Measurement. and I'm currently having trouble communicating with the bk-7000 v2 module (SIM7000E). when i upload the sketch to the arduino mega 2560 pro board, i get the error message "failed to set the baud rate". i use example sketch dfrobot/tinygsm library. can anyone here help me with the problem i'm having? thank you very much for your kind feedback.

wiring illustration

here the sketch:

#define _PINRST 3
#define _PINCE 4
#define _PINDC 5
#define _PINDIN 6
#define _PINBL 7
#define _PINCLK 12
#define _PINMODRX 14
#define _PINMODTX 15
#define _PINLED 20
#define _PINBTN1 21
#define _PINBTN2 22
#define _PINBTN3 23
#define console Serial
#define RATE_CSL 115200
#define RATE_MDL 115200
#define TINY_GSM_MODEM_SIM7000
#define TINY_GSM_DEBUG console
#define DUMP_AT_COMMANDS

#include <LCD5110_Basic.h>
extern uint8_t SmallFont[];
LCD5110 n5110(_PINCLK, _PINDIN, _PINDC, _PINRST, _PINCE);

boolean oldSwitchState = LOW;
boolean newSwitchState = LOW; 
boolean LEDstatus = LOW;

#include <SoftwareSerial.h>
SoftwareSerial serialAT(_PINMODRX, _PINMODTX);

#include <TinyGsmClient.h>
uint32_t rateBAUD = 0;
#ifdef DUMP_AT_COMMANDS
  #include <StreamDebugger.h>
  StreamDebugger debugger(serialAT, console);
  TinyGsm modem(debugger);
#else
  TinyGsm modem(serialAT);
#endif

TinyGsmClient client(modem);

#include <PubSubClient.h>
PubSubClient mqtt(client);

int initLoop = 0;
void setup() 
{
  console.begin(RATE_CSL);
  serialAT.begin(RATE_MDL);

  pinMode(_PINLED, OUTPUT);
  digitalWrite(_PINLED, LOW);
  
  pinMode(_PINBL, OUTPUT);
  digitalWrite(_PINBL, HIGH);

  n5110.InitLCD();
  n5110.setFont(SmallFont);
  n5110.clrScr();
}

void loop()
{
  testLED();
  backlightLCD();

//  initModem();
}

void initModem()
{
  digitalWrite(_PINBL, LOW);
  
  if (!rateBAUD) {
    n5110.clrScr();
    n5110.print("Initializing", CENTER, 16);
    n5110.print("modem...", CENTER, 24);
    rateBAUD = TinyGsmAutoBaud(serialAT);
  }
  
  if (!rateBAUD) {
    initLoop++;
    console.println(F("***********************************************************"));
    console.println(F(" Module does not respond!"));
    console.println(F(" - Check your Serial wiring"));
    console.println(F(" - Check the module is correctly powered and turned on"));
    console.println(F("***********************************************************"));
    
    n5110.clrScr();
    n5110.print("Module does", CENTER, 16);
    n5110.print("not respond!", CENTER, 24);
    delay(5000);
    
    n5110.clrScr();
    n5110.print("Initializing", CENTER, 16);
    n5110.print("Modem x"+String(initLoop), CENTER, 24);
    delay(5000);
    
    delay(20000L);
    return;
  }
  
  n5110.clrScr();
  n5110.print("Connected to", CENTER, 16);
  n5110.print("Modem", CENTER, 24);
  modem.setNetworkMode(38); //38-LTE, 13-GSM
  modem.setPreferredMode(2); //2-NB-IoT, 1-CAT, 3-GPRS
  delay(10000L);

  serialAT.begin(rateBAUD);

  console.println(F("***********************************************************"));
  console.println(F(" You can now send AT commands"));
  console.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
  console.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
  console.println(F("***********************************************************"));

  while(true) {
    if (serialAT.available()) {
      console.write(serialAT.read());
    }
    if (console.available()) {
      serialAT.write(console.read());
    }
    delay(0);
  }
  
  digitalWrite(_PINBL, HIGH);
}

void backlightLCD()
{
  if (digitalRead(_PINBTN1) == HIGH) {
    digitalWrite(_PINBL, LOW);
    delay(6000);
    digitalWrite(_PINBL, HIGH);
  }
  
  /*newSwitchState = digitalRead(_PINBTN1);

  if ( newSwitchState != oldSwitchState ) 
  {
     if ( newSwitchState == HIGH )
     {
//         if ( LEDstatus == LOW ) { digitalWrite(_PINLED, HIGH);  LEDstatus = HIGH; }
//         else                    { digitalWrite(_PINLED, LOW);   LEDstatus = LOW;  }
         if ( LEDstatus == LOW ) { digitalWrite(_PINBL, HIGH);  LEDstatus = HIGH; }
         else                    { digitalWrite(_PINBL, LOW);   LEDstatus = LOW;  }
     }
     oldSwitchState = newSwitchState;
  }*/
}

void testLED()
{
  if (digitalRead(_PINBTN2) == HIGH) {
    for (int i = 0; i < 1 && digitalRead(_PINBTN2) == HIGH; i++) {
      digitalWrite(_PINLED, HIGH);delay(200);
      digitalWrite(_PINLED, LOW);delay(200);
    }
  }

  if (digitalRead(_PINBTN3) == HIGH) {
    for (int i = 0; i < 1 && digitalRead(_PINBTN3) == HIGH; i++) {
      digitalWrite(_PINLED, HIGH);delay(500);
      digitalWrite(_PINLED, LOW);delay(500);
    }
  }
}

You get that error message while uploading or after the upload while running your sketch?

hello @pylon thanks for your reply. I really appreciate it

this is what happens on the console when I finished uploading the script

rather than uploading a image of your code which only shows part of the program upload the complete code itself
you appear to be using pins D15 and D14 which are Serial3
can you measure the voltage in these pins - both should be 5V
If you have an oscilloscope you can check that the signals look OK
do you need to do something with the BK-7000 S (Sleep) pin? have you found any documentation on the device?

1 Like

Hello @horace,, thanks for your reply.

after I looked for references about Serial - Arduino Reference. and I tried with HardwareSerial, my sim7000 module was able to respond at baudrate 9600.

//#include <SoftwareSerial.h>
//SoftwareSerial serialAT(_PINMODRX, _PINMODTX);
#define serialAT Serial3

this the result

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.