r-map / rmap

rete monitoraggio ambientale partecipativo documentation at https://doc.rmap.cc
https://rmap.cc
53 stars 42 forks source link

Using Serial instead of Serial1 [SIM800 mqtt_basic example] #202

Closed karanmakharia closed 7 years ago

karanmakharia commented 7 years ago

This is the code I was trying : https://github.com/r-map/rmap/blob/master/arduino/sketchbook/libraries/sim800/examples/mqtt_basic/mqtt_basic.ino

Hardware using: Arduino Mega + SIM808. Works when SIM808 is connected to Serial1. But when I change the code and write if (s800.init(&Serial , 7, 6)) break;

It fails to work and is stuck at try to init SIM800. I did change Serial1 to Serial in header file.

My requirement is to make SIM808 work with Serial or SoftwareSerial but not Serial1, Serial2 etc.

pat1 commented 7 years ago

in sim800.h you have: // if define HARDWARESERIAL is set then it will be static (required by Time library)

define HARDWARESERIAL Serial1

You have to set it ti to a right value or unset it for software serial. Do not set it to software serial as the name explain. Software serial do not work well as a hardware serial, I suggest you to do not use it for this library. The use of "Serial" on arduino use the serial connected to the serial ftd, you can try but you have to disable every debug messages on it al last with // activate debug on serial port //#define DEBUGONSERIAL and remove all Serial.print* in example Disable wdt if you do not use atmega watchdog: //#define ENABLEWDT 1