Good afternoon! I have a question.
Can we register a number via SMS?
That is, the idea is as follows. 1. Turn on the device.
2. Insert the registered SIM card into the SIM800L.
3. Send the number (+7 747 XXXXXXX) by SMS
4. The device remembers this number in its memory.
5. When you press the button, the device will call this number
6. If you send another number by SMS. then the memory is cleared and a new number is recorded.
7. If you press the button, they will dial a new number.
8. When the device turns off, it should remember the last saved number
In both cases save the number to EEPROM if it does not match the currently saved number
#include <SoftwareSerial.h>
SoftwareSerial SIM800(0, 2); // 8 - RX Arduino (TX SIM800L), 9 - TX Arduino (RX SIM800L)
void setup() {
Serial.begin(9600); // Π‘ΠΊΠΎΡΠΎΡΡΡ ΠΎΠ±ΠΌΠ΅Π½Π° Π΄Π°Π½Π½ΡΠΌΠΈ Ρ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠΌ
Serial.println("Start!");
SIM800.begin(9600); // Π‘ΠΊΠΎΡΠΎΡΡΡ ΠΎΠ±ΠΌΠ΅Π½Π° Π΄Π°Π½Π½ΡΠΌΠΈ Ρ ΠΌΠΎΠ΄Π΅ΠΌΠΎΠΌ
}
void loop() {
//If you receive any SMS{
SIM800.println("AT+CMGDA="DEL READ""); //delete read
delay(200);
SIM800.println("AT+CMGR=1,0"); //read first sms
delay(200);
//take number from serial and store in variables = number;
delay(200);
if you press the button {
SIM800.println("ATD"+number);
}
}
How can we make working code out of this?
by first using code tags and then fixing the bugs and then adding the features you want...
why do you think it's a relevant code to start from?
I don't think this is the correct code. I try to explain how it works. I honestly tried very hard to solve this problem. But it doesn't work. Therefore, I ask you for hints for this solution.
This solution should answer your question.
when you receive the SMS you can read it and save the number in EEPROM
each time you receive an SMS check if it matches the previous one or stores the new one in EEPROM.
this is how even if the device is off it still there.
you don't even need to check if it's the same... just update() the EEPROM when you get a new phone number and if it's the same the update() function won't change anything
please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's barely readable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)
How to extract a number from this line and save it to EEPROM and call it when the button is pressed?
by adding code tags to all your posts....
I apologize for the inconvenience, fixed
Can you help me?
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project See About the Installation & Troubleshooting category.
nope
Please insert your code to the code tags.... again
I must admit I've limited interest in spending time on a topic with +7 international country code and comments in Russian.
I think I'll pass, other might see it differently.
I am not Russian and do not live in Russia. I copied the code from the Russian community.
If this prevents me from helping, I will delete the comments in Russian.
Fixed
Please post the fixed sketch so that others may benefit from seeing it