sim800L and serial baud(?) problem

Hi, I am trying to get a medical data from body and sent to using gsm module as sms..

I'm using maxim sensor and sim800L gsm module with UNO.

Maxim sensor and oled screen connected A4 and A5 (scl, sda). gsm module also connected pin 10 and 11.

Sensor and screen working standalone and also sim800l send sms using standalone.

But when i combined the codes there is no meaningful output from circuit.

Sim800L using Serial.begin(9600) , maxim and oled using Serial.begin(115200). I think there is a problem
with this baudrate.

Can someone explain or answer this question?

And also oled screen and maxim connected sda scl pins. May I use Wire.begin() ??

fatihtamer:
Can someone explain or answer this question?

Probably not until you make up your mind about what you are holding in your hand, and be more forthcoming about it...
You first say OLED is on pins A4,A5 thereby strongly implying that it is an I2C device, which is quite common.
You then say OLED is on serial @115200, which is possible. So, is that two OLED devices?
Since you clearly state that SIM800 is on hardware serial, you imply the other devices are on software serial @ 115200, which is fatal but then again they might not be there at all. There is a faint chance that revealing your currently secret code might help.

Thanks for your interest. There is no secret code :slight_smile: you can see in the photo. oled screen and maxim sensor
connnected A4 an A5 yes there is an I2C operation.
20200626_220409.jpg - Google Drive
But in that code someone used serial.begin(115200) and it’s working it’s giving the results.

#include “MAX30100_PulseOximeter.h”
#include <U8g2lib.h>
#include <U8x8lib.h>
#include <Wire.h>
#define REPORTING_PERIOD_MS 100
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
PulseOximeter pox;
const int numReadings=10;
float filterweight=0.5;
uint32_t tsLastReport = 0;
uint32_t last_beat=0;
int readIndex=0;
int average_beat=0;
int average_SpO2=0;
bool calculation_complete=false;
bool calculating=false;
bool initialized=false;
byte beat=0;
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
show_beat();
last_beat=millis();
}
void show_beat()
{
u8g2.setFont(u8g2_font_cursor_tf);
u8g2.setCursor(8,10);
if (beat==0) {

  • u8g2.print("_");*
  • beat=1;*
    }
    else
    {
  • u8g2.print("^");*
  • beat=0;*
    }
    u8g2.sendBuffer();
    }
    void initial_display()
    {
    if (not initialized)
    {
  • u8g2.clearBuffer();*
  • show_beat();*
  • u8g2.setCursor(24,12);*
  • u8g2.setFont(u8g2_font_smart_patrol_nbp_tf);*
  • u8g2.print(“Parmaginizi”); *
  • u8g2.setCursor(0,30);*
  • u8g2.print(“yerlestiriniz”);*
  • u8g2.sendBuffer();*
  • initialized=true;*
    }
    }
    void display_calculating(int j)
    {
    if (not calculating) {
  • u8g2.clearBuffer();*
  • calculating=true;*
  • initialized=false;*
    }
    show_beat();
    u8g2.setCursor(24,12);
    u8g2.setFont(u8g2_font_smart_patrol_nbp_tf);
    u8g2.print(“Olculuyor”);
    u8g2.setCursor(0,30);
    for (int i=0;i<=j;i++) {
  • u8g2.print(". ");*
    }
    u8g2.sendBuffer();
    }
    void display_values()
    {
    u8g2.clearBuffer();
    u8g2.setFont(u8g2_font_smart_patrol_nbp_tf);
    *u8g2.setCursor(65,12); *
    u8g2.print(average_beat);
    u8g2.print(" Bpm");
    u8g2.setCursor(0,30);
    u8g2.print("SpO2 ");
    *u8g2.setCursor(65,30); *
    u8g2.print(average_SpO2);
    u8g2.print("%");
    u8g2.sendBuffer();
    }
    void calculate_average(int beat, int SpO2)
    {
    if (readIndex==numReadings) {
  • calculation_complete=true;*
  • calculating=false;*
  • initialized=false;*
  • readIndex=0;*
  • display_values();*
    }

if (not calculation_complete and beat>30 and beat<220 and SpO2>50) {
average_beat = filterweight * (beat) + (1 - filterweight ) * average_beat;
average_SpO2 = filterweight * (SpO2) + (1 - filterweight ) * average_SpO2;

  • readIndex++;*
  • display_calculating(readIndex);*
    }
    }
    void setup()
    {
  • Serial.begin(115200);*
  • u8g2.begin();*
  • pox.begin();*
  • pox.setOnBeatDetectedCallback(onBeatDetected);*
  • initial_display();*
    }
    void loop()
    {
  • // Make sure to call update as fast as possible*
  • pox.update();*
  • if ((millis() - tsLastReport > REPORTING_PERIOD_MS) and (not calculation_complete)) {*
  • calculate_average(pox.getHeartRate(),pox.getSpO2());*
  • tsLastReport = millis();*
  • }*
  • if ((millis()-last_beat>10000)) {*
  • calculation_complete=false;*
  • average_beat=0;*
  • average_SpO2=0;*
  • initial_display();*
  • }*
    }

And also i have sim800 L gsm module for arduino.
And also i have run the sim800 L standalone with arduino for sending sms using this code.

#include <SoftwareSerial.h>
SoftwareSerial sim(10, 11);
//int _timeout;
String _buffer;
String number = “…”; // gsm number
void setup() {
delay(7000); //delay for 7 seconds to make sure the modules get the signal
Serial.begin(9600);
_buffer.reserve(50);
Serial.println(“sms aktif”);
sim.begin(9600);
delay(1000);
}
void loop() {
if (digitalRead(buton)==LOW)
{

  • Serial.println(“sensor datasi okundu”);*
  • SendMessage();*
  • delay(1000);*
  • }*
  • else*
  • Serial.println(“sensor datasi yok”); *
    }
    void SendMessage()
    {
    //Serial.println (“Sending Message”);
    sim.println(“AT+CMGF=1”); //Sets the GSM Module in Text Mode
    delay(1000);
    //Serial.println (“Set SMS Number”);
    sim.println(“AT+CMGS=”" + number + “”\r"); //Mobile phone number to send message
    delay(1000);
    String SMS = “hello world this is an sms”;
    sim.println(SMS);
    delay(100);
    sim.println((char)26);// ASCII code of CTRL+Z
    delay(1000);

}

When i want to combine each other how can i use the serial.begin code? Because combined code is not working?
this one is combined code… :slight_smile:

----xxxx------

#include “MAX30100_PulseOximeter.h”
#include <U8g2lib.h>
#include <U8x8lib.h>
#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial sim(10, 11);
#define REPORTING_PERIOD_MS 100
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
PulseOximeter pox;
const int numReadings=10;
float filterweight=0.5;
uint32_t tsLastReport = 0;
uint32_t last_beat=0;
int readIndex=0;
int average_beat=0;
int average_SpO2=0;
bool calculation_complete=false;
bool calculating=false;
bool initialized=false;
byte beat=0;
char deger[100];
// Gsm için
String _buffer;
String number = “…”;
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
show_beat();
last_beat=millis();
}
void show_beat()
{
u8g2.setFont(u8g2_font_cursor_tf);
u8g2.setCursor(8,10);
if (beat==0) {

  • u8g2.print("_");*
  • beat=1;*
    }
    else
    {
  • u8g2.print("^");*
  • beat=0;*
    }
    u8g2.sendBuffer();
    }
    void initial_display()
    {
    if (not initialized)
    {
  • u8g2.clearBuffer();*
  • show_beat();*
  • u8g2.setCursor(24,12);*
  • u8g2.setFont(u8g2_font_smart_patrol_nbp_tf);*
  • u8g2.print(“Parmaginizi”); *
  • u8g2.setCursor(0,30);*
  • u8g2.print(“yerlestiriniz”);*
  • u8g2.sendBuffer();*
  • initialized=true;*
    }
    }
    void display_calculating(int j)
    {
    if (not calculating) {
  • u8g2.clearBuffer();*
  • calculating=true;*
  • initialized=false;*
    }
    show_beat();
    u8g2.setCursor(24,12);
    u8g2.setFont(u8g2_font_smart_patrol_nbp_tf);
    u8g2.print(“Olculuyor”);
    u8g2.setCursor(0,30);
    for (int i=0;i<=j;i++) {
  • u8g2.print(". ");*
    }
    u8g2.sendBuffer();
    }
    void display_values()
    {
    u8g2.clearBuffer();
    u8g2.setFont(u8g2_font_smart_patrol_nbp_tf);
    *u8g2.setCursor(65,12); *
    u8g2.print(average_beat);
    u8g2.print(" Bpm");
    u8g2.setCursor(0,30);
    u8g2.print("SpO2 ");
    *u8g2.setCursor(65,30); *
    u8g2.print(average_SpO2);
    u8g2.print("%");
    u8g2.sendBuffer();
    }
    void calculate_average(int beat, int SpO2)
    {
    if (readIndex==numReadings) {
  • calculation_complete=true;*
  • calculating=false;*
  • initialized=false;*
  • readIndex=0;*
  • display_values();*
    }

if (not calculation_complete and beat>30 and beat<220 and SpO2>50) {
average_beat = filterweight * (beat) + (1 - filterweight ) * average_beat;
average_SpO2 = filterweight * (SpO2) + (1 - filterweight ) * average_SpO2;

  • readIndex++;*
  • display_calculating(readIndex);*
    }
    }
    void setup()
    {
  • Serial.begin(115200);*
  • u8g2.begin();*
  • pox.begin();*
  • sim.begin(115200);*
  • delay(1000);*
  • pox.setOnBeatDetectedCallback(onBeatDetected);*
  • initial_display();*
  • //SendMessage();*
    }
    void loop()
    {
  • // Make sure to call update as fast as possible*
  • pox.update();*
  • if ((millis() - tsLastReport > REPORTING_PERIOD_MS) and (not calculation_complete)) {*
  • calculate_average(pox.getHeartRate(),pox.getSpO2());*
  • tsLastReport = millis();*
  • }*
  • if ((millis()-last_beat>10000)) {*
  • calculation_complete=false;*
  • average_beat=0;*
  • average_SpO2=0;*
  • initial_display();*
  • }*
    Serial.println(average_SpO2);
    if ((average_SpO2<90)){
    SendMessage();}
    }
    void SendMessage()
    {
    sim.println(“AT+CMGF=1”); //Sets the GSM Module in Text Mode
    delay(1000);
    //Serial.println (“Set SMS Number”);
    sim.println(“AT+CMGS=”" + number + “”\r"); //Mobile phone number to send message
    delay(1000);
    //String SMS = “SpO2 %”;
    sprintf(deger, “SpO2 degeri,%d”,average_SpO2);

//sim.println(SMS);
sim.println(deger);
Serial.println(“sms gonderildi”);
delay(1000);
sim.println((char)26);// ASCII code of CTRL+Z
delay(1000);

}

----xxxx------

I think if oled and maxim is connecting to I2C port then Wire.begin etc can be used or not? I didn’t solved it and I am asking again ?

 sim.begin(115200);

Software serial will not work at this baud rate. In the SMS code which worked properly to send the message you has the software serial at 9600 baud. Why did you change it?

In the combined code use

 sim.begin(9600);

because if you look at first code serial.begin(115200).
Yes I've changed to 9600 but it couldn't work.

because if you look at first code serial.begin(115200).
Yes I've changed to 9600 but it couldn't work.

Serial is connected to the serial monitor through the usb interface.

The 800l is connected to the arduino with software serial on pins 10 and 11. That connection is called "sim"

You need to change sim.begin() to 9600 in the combined code.

cattledog:
Serial is connected to the serial monitor through the usb interface.

The 800l is connected to the arduino with software serial on pins 10 and 11. That connection is called "sim"

You need to change sim.begin() to 9600 in the combined code.

Ok I've changed it. there is no measurement and no result.
serial port screen

sms gonderildi
0
sms gonderildi
0
sms gonderildi
0

average_spo2= 0 and sms gonderildi (this means sms sents. But no ! )

First order of business is for you to learn how to post your code using the code tags Please read How to Use this Forum and pay atttention to point #7.

Second, I would recommend that you debug the sensor reading and sms sending without the oled screen. Just use the serial monitor.

there is no measurement and no result.

Can you please post code, using the code tags, which gives heartbeat measurements to Serial without the oled and reports a value by sms when the average beat count is <90?

Ok I will try and send.

This post is my first forum post. so I did some wrong things when I wrote

I controlled the circuit and the code. I didn’t used the oled screen and system worked. (but not fine)
I will try to get requested results using this code. Sim800 and sms working fine.

maxim_sms_lcdless.ino (2.55 KB)