Simulation of arduino mega 2560 with GSM Module using proteus - arduino

have really been suffering with my simulation! Tried connecting my arduino mega 2560 to COMPIM (used as GSM Module) in my circuit and also loaded sample code but damn! In vain! I wanted to view the data sent in virtual terminal but am getting nothing! and its also complaining of excessive CPU usage.
And thereafter, the messages are displayed as shown below.
Someone please help me out. Am I making a mistake oh? Infact the arduino code for displaying in the simulation is also giving me hard time. The one am using is as shown below.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
mySerial.println("Hello, world?");
if (Serial.available())
mySerial.println("Hello, world?");
}
Will b every grateful for any help offered.

Related

Weird behavior when using monitor and analogWrite (ESP32)

I'm currently working on a project where I want to vary the PWM to a motor given an input from a potentiometer. However, I cant seem to use the serial monitor and an analogWrite statement in the same program.
When I run this code I get this output from the serial monitor:
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.print("WORKING");
//analogWrite(1, 255);
}
void loop()
{
}
12:09:48.314 ->
12:09:48.314 -> WORKING
However, when I run this code (the only difference is that the analogWrite() line is no longer commented out), the serial monitor outputs garbage.
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.print("WORKING");
analogWrite(1, 255);
}
void loop()
{
}
{l$ܞ⸮⸮$⸮|⸮⸮l⸮#|⸮⸮⸮⸮{⸮#⸮"⸮⸮on⸮lon⸮⸮⸮#p⸮⸮bl`{lp⸮o⸮⸮l⸮⸮bo⸮|⸮⸮⸮#⸮⸮nN⸮$⸮⸮$`⸮on⸮{lor⸮⸮⸮⸮{r⸮ p⸮o⸮s⸮ܜ⸮⸮⸮#o⸮|⸮B⸮⸮on⸮⸮l ⸮No⸮{lor⸮⸮⸮Nrd`{⸮⸮N{d`⸮⸮⸮⸮⸮⸮$`⸮⸮N⸮l
⸮
Does anyone know why this is happening and how to fix it?
Not sure if it helps but im using an ESP8266 NodeMCU purchased from this amazing link: https://www.amazon.com/gp/product/B081CSJV2V/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&th=1
analogWrite(1, 255) is writting to GPIO1. If you look at the pin-out for the ESP8266 NodeMCU, GPIO1 is the TXD line for serial port 0 (it's labeled TXD0). I don't have a NodeMCU schematic handy, but port 0 is typically used for the serial monitor and wired to the USB-UART converter for that purpose. So by writing to GPIO1, you are interfering with the monitor output.
Try doing an analogWrite to a different GPIO, for example, GPIO5.

AT works at half for HC05

I am currently trying to send my sensor data from my Arduino to an android app made on android studio using an HC05 module for Arduino.
I tried to configure the HC05 as every tutorial on the internet says, but i meet some problems.
I am using the arduino code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
int PotPin = A7;
int Vdata = 15;
void setup() {
Serial.begin(9600);
pinMode(9,OUTPUT); digitalWrite(9,HIGH);
Serial.println("Enter AT commands:");
mySerial.begin(38400);
}
void loop()
{
Vdata = analogRead(PotPin);
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
When I type "AT" in the Serial monitor, it returns me "OK" (that is normal).
But when I try to see the name/the address/the password of the module, it returns me "Error:(0)". The strangest thing is that the command " AT+NAME="NameWanted" " or even " "AT+PWD="4321" " works since it correctly changes the name of the module.
I looked on the internet but I didn't see someone with the same problem as mine, I hope someone will lead me to the solution!
Thanks
I found out what's the problem. My mcu's bauderate was bigger (115200), then my hc05's bauderate (38400). With this bauderate, my MCU sent the messages faster, then hc05 could read it. So, I decreased the bauderate of my MCU and now it's working

Using XBee with Arduino

I use Xbee in my project with arduino. I have set up Xbee configuration(i can send massge in xctu serial consol), but i have problems with arduino code. I try to use "SoftwareSerial" library, but it doesn't work properly. For example I send data using Xctu, but Xbee connected to arduino cannot receive data. Can you please help me with receiver and transmiter arduino code? Thank you, in advance.
The code:
#include <SoftwareSerial.h>
#define rxPin 1
#define txPin 0
SoftwareSerial xbee = SoftwareSerial(rxPin, txPin);
void setup(){
xbee.begin(9600);
Serial.begin(9600);
//Serial.println("Starting XBee Comunication");
xbee.listen();
}
void loop(){
if(Serial.available()){
xbee.write(Serial.read());
}
else{
Serial.println("not available");
}
if(xbee.available()){
byte x = xbee.peek();
Serial.println(x);
}
else{
Serial.println("none to read");
}
delay(2000);
//Serial.println(rec);
}
Some quick debugging tips:
Disconnect the XBee and short your TX and RX pins together. Make sure you read back what you send.
Are you sure you have the TX and RX pins connected to the XBee module correctly? TX out of the Arduino goes to RX of the XBee and vice versa.
Have you powered the XBee module correctly? XCTU should have support for finding nodes on the network and interacting with them. Make sure the module is powered up and responding on the network.

How to use SoftwareSerial with ESP8266

I'm trying to get an ESP8266 to work with Arduino by using PlatformIO. But, I get errors when importing SoftwareSerial.h
Tried: Arduino IDE, PlatformIO, Change baudrate, change port
How can I get SoftwareSerial to work with the ESP8266?
#include <SoftwareSerial.h>
SoftwareSerial BTserial(3, 1); // RX | TX
char Bluetooth_Name = ' ';
void setup()
{
// Arduino IDE serial monitor
Serial.begin(9600);
// HC-05 default serial speed for AT mode is 38400
BTserial.begin(38400);
// Wait for hardware to initialize
delay(1000);
// Print debug string
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTserial.available())
{
reading = BTserial.read();
Serial.println(reading);
}
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
{
reading = Serial.read();
BTserial.write(reading);
}
}
I want to use the SoftwareSerial without errors.
Error code:
Compiling .pio\build\huzzah\lib0be\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o
In file included from C:\Users\Bart\.platformio\lib\EspSoftwareSerial_ID168\src/SoftwareSerial.h:27:0,
from C:\Users\Bart\.platformio\lib\EspSoftwareSerial_ID168\src\SoftwareSerial.cpp:23:
C:\Users\Bart\.platformio\lib\EspSoftwareSerial_ID168\src/circular_queue/circular_queue.h:144:10: error: expected ';' at end of member declaration
bool IRAM_ATTR push(T&& val);
^
Actually the standard software serial library didn't work for me with my NodeMCU v1.0... And in the rare cases when it worked, it was very limited. Maybe check out this library:
ESP 8266/32 Software Serial Library
in platformio.ini you can add the following line to choose a specific version which compiles with the latest released 8266 platform
lib_deps_external =
plerup/espsoftwareserial#5.0.3 ; this version compiles with a standard 8266 platform
Using this way the code is directly fetched from github.

Serial communication does not work on Intel Galileo Gen 2

I cannot get serial communication working on Intel Galileo Gen 2. I'm using Serial1 on port /dev/ttyS0 assigned to pin 0 and 1. For testing purposes I created loopback on that serial port (connected RX and TX together). Unfortunately, it seems that nothing works. After few test it seems that my board can receive data, but cannot send any.
void setup() {
Serial.begin(9600);
Serial1.begin(19200);
Serial.println("Ready");
}
void loop() {
while(Serial1.available() > 0) {
Serial.print(Serial1.read());
Serial.print(' ');
}
uint8_t buf[3] = {0xC0, 0xFF, 0xEE};
Serial1.write(buf, 3);
delay(2000);
}
I run same sketch with same configuration on Arduino Yún and it worked well. Where the problem could be? Thanks.
For this particular Galileo board, the baud rate for Serial object is always 115200 baud no matter the argument you give it. Since you connected Serial1 to Serial it could be just a synchronisation error due to different baud rate. Did you try to change this Serial1.begin(19200); to this Serial1.begin(115200); ?

Resources