i meet a issue. when i send a text message to my arduino board with a shield sim900 its show my message in number mode. who know what is the problem? here is my code. at the bottom i use serial monitor to see my message and it is read the message in number.
`
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
char incoming_char=0;
void setup()
{
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
SIM900power(); // turn on shield
delay(25000); // give time to log on to network.
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(1000);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(1000);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop()
{
// Now we simply display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0)
{
incoming_char=SIM900.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
if (incoming_char=='a')
{
digitalWrite(4,HIGH);
Serial.println(incoming_char);
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
if (incoming_char=='b')
{
digitalWrite(4,LOW);
Serial.println(incoming_char);
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
}
}
Related
i'm actually trying to make a connected doorbell. Like when you press the button, the wifi-arduino ( ESP32 DEVKITV1 ) sends to my laptop (on Processing) the signal to make a song over wifi. The laptop is connected to a wireless to make the song stronger.
I don't suceed in the wifi connexion :
#include <WiFi.h> // Include the Wi-Fi library
const char* ssid = "Wifi Guest"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = ""; // The password of the Wi-Fi network
const int bouton = 14;
const int ledtemoin = 12;
int compteur = 0;
int etatbouton = 0;
int etatboutonprecedent = 0;
void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println('\n');
pinMode(bouton, INPUT);
pinMode(ledtemoin, OUTPUT);
Serial.begin(115200);
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid);
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(500);
Serial.print('.');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
pinMode(13, OUTPUT);
}
void loop() {
etatbouton = digitalRead(bouton);
if (etatbouton != etatboutonprecedent) {
if (etatbouton == HIGH) {
compteur++;
digitalWrite (ledtemoin, HIGH);
Serial.println("APPUI");
Serial.print("nombre d'appuis: ");
Serial.println(compteur, DEC);
}
else {
Serial.println("PAS D'APPUI");
digitalWrite (ledtemoin, LOW);
}
etatboutonprecedent = etatbouton;
}
}
You have to connect the ESP32 (it is not an Arduino) to your WiFi router.
On
const char* ssid = "Wifi Guest"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = ""; // The password of the Wi-Fi network
You have to give the SSID and password of your router. This is the only way to connect your ESP32 to your network.
Using some library line WiFiManager, you can set your ESP32 as AccessPoint and so, if it can't connect to your router, it will create a new Network. So you can set the SSID and password over your phone or your PC, without coding it in your code.
But to keep it short: put your router ssid and router password in your code, if you want see your esp32 inside your network.
I just bought a Bluetooth HM-10 module with CC2541 chip. I am powering it with Arduino Uno. I scanned for bluetooth devices with my phone (samsung j3, 2016) and found the module named as BT05. I paired the devices but I could not connect the bluetooth module with any app. I tried to connect it with AMR Voice/BT Voice Control app and LED controller.
The code I used for controlling LED through app came from here: create.arduino.cc/projecthub/user206876468/arduino-bluetooth-basic-tutorial-d8b737
I put the code here aswell:
char data = 0; //Variable for storing received data
void setup()
{
Serial.begin(9600); //Sets the baud for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data & store into data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n");
if(data == '1') // Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') // Checks whether value of data is equal to
0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
}
These are the errors I get:
Maybe you can try if it's work and change the code by urself
#include <SoftwareSerial.h>
SoftwareSerial BT(2, 3); //RX, TX
char val;
void setup() {
Serial.begin(9600);
BT.begin(9600);
Serial.println("BT is ready!");
}
void loop() {
if (BT.available()>0) {
val = BT.read();
Serial.print(val);
}
}
I am trying to send the number "25" from arduino to android application created by using MIT AppInventor2. At the same time, I want to make "on" or "off" a LED by clicking "lock" and "unlock" buttons on the android app. There is no problem making LED status "on" and "off" but I can not read the 25 on the application. I only read 2 or 5. I read 25 very very rarely.
What is the problem about my arduino code or AppInventor blocks?
Arduino code:
int ledPin = 13;
String readString;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
Serial.println(25);// Here I want to send 25
delay(20);
while (Serial.available()) {
delay(3);
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
// Serial.println(readString);
if (readString == "on")
{
digitalWrite(ledPin, HIGH);
}
if (readString == "off")
{
digitalWrite(ledPin, LOW);
}
readString="";
}
}
Edit: Time interval for AppInventor clock is 1000.
I'm trying to use arduino with Bluetooth module (HC-06).
And also im trying to send/receive data from android with the app (ArduDroid which is in playstore).
But i have the problem while sending program to Arduino uno after successful compilation.
The error Code is when vcc connected to 3.3V
avrdude: stk500_getsync(): not in sync: resp=0x00
When i connected to 5V sometimes error code changes to but usually same as 3.3v
avrdude: stk500_getsync(): not in sync: resp=0x45.
When i unplug the bt device sending program is successful but i cant receive or send anything.
I checked com port and board. Everything is OK.
Please help me to continue my licence project.
Best regards..
The code is as below:
int ledPin = 13;
int state = 0;
int flag = 0;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600); // Default connection rate for my BT module
}
void loop() {
if(Serial.available() > 0){
state = Serial.read();
flag=0;
}
if (state == '0') {
digitalWrite(ledPin, LOW);
if(flag == 0){
Serial.println("LED: off");
flag = 1;
}
}
else if (state == '1') {
digitalWrite(ledPin, HIGH);
if(flag == 0){
Serial.println("LED: on");
flag = 1;
}
}
}
You need to unplug the module before uploading the code via USB.
the module uses the same serial pins than the ones used for USB serial, that's where your issue comes from.
uploading code via bt is tricky. it can be done but I've never succeeded myself... :(
I've solved the problem as the same way. Just unplug the bt device and upload. After this step, plug again and connect to dc. Thats OK. working.
The source of the problem is serial ports as i understand. BT module using 9600 port and disconnecting the connection between computer and arduino.
I am working with Aurdino and Amarino task. I am able to connect with Aurdino and I can send data to Aurdino from Android app. In the same way how I can access the data from Aurdino which I supposed to send to Android app(accessing data from aurdino means not the same data which I have sent from android app to aurdino). Aurdino can contain different data and I want to access that. Please help me
Regards,
Krishna
If you connect the Bluetooth RX to your Arduino TX (after uploading your sketch), you should be able to the data that is coming from Android with normal Serial operations. Here is an example sketch, that will turn LED on port 13 on if '1' is received otherwise it will be turned off
see this for a tutorial
You can also use a SoftSerial port
char val;
int ledpin = 13;
void setup() {
pinMode(ledpin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if( Serial.available() )
{
val = Serial.read();
Serial.println(val);
}
if( val == '1' )
{
digitalWrite(ledpin, HIGH);
} else {
digitalWrite(ledpin, LOW);
}
delay(100);
}