Toon posts:

Seriele communicatie SIM800 wil niet op Arduino Leonardo

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Mijn vraag
Ik ben aan het experimenteren met een SIM800 module aan een Arduino. Ik heb twee varianten, een losse module met een losse Leonardo, en een geïntegreerde combinatie met een 32U4 die als Leonardo werkt.
https://www.tinytronics.n...m-gprs-module-met-antenne

Als ik deze code draai, dan kan ik prima met de module communiceren:
#include <SoftwareSerial.h>

//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8

//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7

//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);

void setup() {
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
while(!Serial);

//Being serial communication witj Arduino and SIM800
serialSIM800.begin(9600);
delay(1000);

Serial.println("Setup Complete!");
}

void loop() {
//Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
if(serialSIM800.available()){
Serial.write(serialSIM800.read());
}
//Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
if(Serial.available()){
serialSIM800.write(Serial.read());
}
}
Maar het probleem is, dat deze code een virtuele UART poort opzet op pin 7 en 8.
Op de geïntegreerde module hangt de SIM module echter aan de ingebouwde 2e seriële poort, op pin 0 en 1.
Dus pas ik de code aan naar:
// GSM test SIM 800 with Leonardo

void setup() {
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
while(!Serial);

//Being serial communication witj Arduino and SIM800
Serial1.begin(9600);
delay(1000);

Serial.println("Setup Complete!");
}

void loop() {
//Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
if(Serial1.available()){
Serial.write(Serial1.read());
}
//Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
if(Serial.available()){
Serial1.write(Serial.read());
}
}
Uiteraard verplaats ik ook de draden naar 0 en 1. Nu kan ik echter geen commando's meer sturen in de seriële monitor. Wat gaat hier fout en hoe krijg ik het toch werkend op de hardware seriële poort 0 en 1?

Alle reacties


Acties:
  • 0 Henk 'm!

  • farlane
  • Registratie: Maart 2000
  • Laatst online: 27-09 13:03
Werkt het wel 1 kant op ( bijv van HW Serial1 naar USB Serial, of andersom)?
Als je vanuit je code naar Serial danwel Serial1 stuurt zie je dan iets verschijnen in de monitor danwel op de pinnen (protip:scope/logic analyzer)?

Je initialisatie zou volgens de docs moeten wachten op Serial1 me eenzelfde loop als Serial ipv een harde delay van een seconde trouwens...

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.