I have a Waveshare Sim7600X 4G Hat with the Sim7600A-H on it and I am trying to use it with an Arduino Mega 2560 (I think it's an off brand one, the one that Im using is pictured below) via UART. I have tried both this
and this
(Sorry I am a new user and it would not let me post with two images. config 2 is the same as the first however instead of connecting to the side header tx and rx I am connecting to the Pi header, the ground wire stays where it is, also imaged is the 4g hat with a Sim7600G-H, mine is the same board just with a Sim7600A-H)
wire setups, I have kept the small yellow jumpers on segment B (where they are in the images) as in the documentation this one seemed to simply forward the uart to the pi header pins. I have also tried simply removing these two jumpers in the first configuration.
Using an oscilloscope I have been able to see that the arduino is Txing what I assume is the correct message (at the very least it is txing) but I am unable to see anything coming back, I think something is coming back though as it is returning a backwards question mark sometimes, idk it is very odd, here is a picture of what Ive been getting back
(1 media thing again, here is the output in text)
15:37:58.676 -> Starting up...
15:37:58.777 -> AT Command:
15:37:58.777 -> AT
15:38:03.786 ->
15:38:03.886 -> AT Command:
15:38:03.886 -> AT
15:38:08.855 ->
15:38:09.972 -> AT Command:
15:38:09.972 -> AT
15:38:10.005 -> resp: ⸮
15:38:14.953 ->
15:38:16.077 -> AT Command:
15:38:16.077 -> AT
15:38:16.077 -> resp: ⸮
15:38:16.111 -> resp: ⸮
15:38:21.054 ->
15:38:22.164 -> AT Command:
15:38:22.198 -> AT
15:38:22.198 -> resp: ⸮
15:38:27.167 ->
15:38:28.284 -> AT Command:
15:38:28.284 -> AT
15:38:33.261 ->
for code I have been testing with 2 things the first is Ive been using a library Waveshare made and I have edited as shown below.
Header for Library
/**
* @filename : Waveshare_SIM7600.h
* @brief : Implements for sim7600 library
* @author : Kaloha from Waveshare
*
* Copyright (C) Waveshare April 27 2018
* http://www.waveshare.com / http://www.waveshare.net
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documnetation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef Waveshare_sim7x00_h
#define Waveshare_sim7x00_h
#include <stdlib.h>
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <wiring.h>
#endif
//#define unsigned int uint8_t
/* Sim7x00 Class */
class Sim7x00 {
public:
// Pin definition
const static int powerkey = 2;
int userkey;
Sim7x00();
~Sim7x00();
// SIM query
void PowerOn();
// Phone calls
//void PhoneCall(const char* PhoneNumber);
// SMS sending and receiving message
bool SendingShortMessage(const char* PhoneNumber,const char* Message);
bool ReceivingShortMessage();
// Other functions.
uint8_t sendATcommand(const char* ATcommand, const char* expected_answer, unsigned int timeout);
//char sendATcommand2(const char* ATcommand, const char* expected_answer1, const char* expected_answer2, unsigned int timeout);
};
extern Sim7x00 sim7600;
#endif
Library File
/**
* @filename : Waveshare_SIM7600.cpp
* @brief : Implements for sim7600 library
* @author : Kaloha from Waveshare
*
* Copyright (C) Waveshare April 27 2018
* http://www.waveshare.com http://www.waveshare.net
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documnetation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "Waveshare_SIM7600.h"
Sim7x00::Sim7x00(){
}
Sim7x00::~Sim7x00(){
}
/**************************Power on Sim7x00**************************/
void Sim7x00::PowerOn(){
uint8_t answer = 0;
Serial1.begin(9600);
Serial.begin(9600);
Serial.println("Starting up...");
// checks if the module is started
answer = sendATcommand("AT", "OK", 5000);
if (answer == 0)
{
//Serial.print("Starting up...\n");
//pinMode(PowerKey, OUTPUT);
// power on pulse
//digitalWrite(PowerKey, HIGH);
//delay(500);
//digitalWrite(PowerKey, LOW);
// waits for an answer from the module
while (answer == 0) { // Send AT every two seconds and wait for the answer
answer = sendATcommand("AT", "OK", 5000);
delay(1000);
}
}
delay(5000);
while ((sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0)
delay(500);
}
/**************************SMS sending and receiving message **************************/
//SMS sending short message
bool Sim7x00::SendingShortMessage(const char* PhoneNumber,const char* Message){
uint8_t answer = 0;
char aux_string[30];
//Serial.print("Setting SMS mode...\n");
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
//Serial.print("Sending Short Message\n");
sprintf(aux_string,"AT+CMGS=\"%s\"", PhoneNumber);
answer = sendATcommand(aux_string, ">", 3000); // send the SMS number
if (answer == 1)
{
Serial.println(Message);
Serial.write(0x1A);
answer = sendATcommand("", "OK", 20000);
if (answer == 1)
{
//Serial.print("Sent successfully \n");
return true;
}
else
{
//Serial.print("error \n");
return false;
}
}
else
{
// Serial.print(answer);
//Serial.print(" error.\n");
return false;
}
}
//SMS receiving short message
bool Sim7x00::ReceivingShortMessage(){
uint8_t answer = 0;
int i = 0;
char RecMessage[200];
Serial.print("Setting SMS mode...\n");
sendATcommand("AT+CMGF=1", "OK", 1000); // sets the SMS mode to text
sendATcommand("AT+CPMS=\"SM\",\"SM\",\"SM\"", "OK", 1000); // selects the memory
answer = sendATcommand("AT+CMGR=1", "+CMGR:", 2000); // reads the first SMS
if (answer == 1)
{
answer = 0;
while(Serial.available() == 0);
// this loop reads the data of the SMS
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(Serial.available() > 0){
RecMessage[i] = Serial.read();
i++;
// check if the desired answer (OK) is in the response of the module
if (strstr(RecMessage, "OK") != NULL)
{
answer = 1;
}
}
}while(answer == 0); // Waits for the asnwer with time out
// RecMessage[i] = '\0';
Serial.print(RecMessage);
Serial.print("\n");
}
else
{
Serial.print(answer);
Serial.print(" error.\n");
return false;
}
return true;
}
/**************************Other functions**************************/
uint8_t Sim7x00::sendATcommand(const char* ATcommand, const char* expected_answer, unsigned int timeout) {
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while( Serial1.available() > 0) Serial1.read(); // Clean the input buffer
Serial1.println(ATcommand); // Send the AT command
Serial.println("AT Command:");
Serial.println(ATcommand);
x = 0;
previous = millis();
// this loop waits for the answer
do{
if(Serial1.available() > 0){
// if there are data in the UART input buffer, reads it and checks for the asnwer
response[x] = Serial1.read();
Serial.print("resp: ");
Serial.println(response[x]);
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));
Serial.print("\n");
return answer;
}
Sim7x00 sim7600 = Sim7x00();
Arduino Code
/**
* @filename : SMS.cpp
* @brief : SIM7600CE 4G HAT demo
* @author : Kaloha from Waveshare
*
* Copyright (C) Waveshare April 27 2018
* http://www.waveshare.com / http://www.waveshare.net
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documnetation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "Waveshare_SIM7600.h"
char phone_number[] = "**********"; //********** change it to the phone number you want to call
char text_message[] = "test"; //
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
sim7600.PowerOn();
Serial.println("made it");
//printf("Sending Short Message Test:\n");
//sim7600.SendingShortMessage(phone_number, text_message);
//printf("Message sent, check phone");
}
I have also been testing with a more simple file that might not work I was just going for something that I thought would be the simplest possible setup, that code is below.
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
if (Serial.available()) {
Serial1.print(Serial.read());
Serial.print(Serial.read());
}
if(Serial1.available()) {
Serial.print(Serial.read());
}
}
again though like I said this may be dumb and not useful for testing I dont know.
Please if anyone has had any experience with this hardware or something like it I need help, I do not know what I am doing wrong. If you need anymore information about the hardware or software I am 100% willing and able to provide.
Thank you <3