I'm with some friends from my school and we have started to do a project where we send an SMS text message to our Arduino UNO (with GSM module), which then print the text message on a thermal printer(tx, rx). we've got huge problems, and now we can not figure it out anymore.
We started making a machine that will print out a message that is sent from any mobile.So I send an SMS message with my mobile to Arduino connected to a GSM shield (SIM800L). Then sends the Arduino the message to the thermal printer via TX RX, and then the message should be printed out.
We have spent two examples, GSM shield from Arduino itself, and thermal printer example from SparkFun.
These two files work fine separately, but when we try to merge them together, there is a compilation error.
The printer model from Sparkfun.
code:
#include <GSM.h>
#include <SoftwareSerial.h>
#define PINNUMBER ""
//Printer
SoftwareSerial Thermal(6, 7);
//GSM modul
//SoftwareSerial GSM(4, 5);
int heatTime = 10;
int heatInterval = 2;
char printDensity = 15;
char printBreakTime = 15;
// initialize the library instances
GSM_SMS sms;
// Array to hold the number a SMS is retreived from
char senderNumber[20];
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
Thermal.println("GSM initialized");
Thermal.println("Waiting for messages");
}
/*{
Thermal.begin(19200); // to write to our new printer
initPrinter();
}
*/
void initPrinter()
{
//Modify the print speed and heat
Thermal.write(27);
Thermal.write(55);
Thermal.write(7); //Default 64 dots = 8*('7'+1)
Thermal.write(heatTime); //Default 80 or 800us
Thermal.write(heatInterval); //Default 2 or 20us
//Modify the print density and timeout
Thermal.write(18);
Thermal.write(35);
int printSetting = (printDensity<<4) | printBreakTime;
Thermal.write(printSetting); //Combination of printDensity and printBreakTime
}
void loop() {
char c;
// If there are any SMSs available()
if (sms.available()) {
Thermal.println("Message received from:");
// Get remote number
sms.remoteNumber(senderNumber, 20);
Thermal.println(senderNumber);
// An example of message disposal
// Any messages starting with # should be discarded
if (sms.peek() == '#') {
Thermal.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
while (c = sms.read()) {
Thermal.print(c);
}
}
delay(1000);
}