Arduino - serial port interrupt - serial-port

Arduino question on interrupts:
For my Arduino RTC project I need to put my Arduino to sleep until interrupted by either a pin interrupt or by a single char present on the serial port (an arbitrary character) -- How may I achieve this?
I see that a pin interrupt is relatively straightforward, but I'm unable complete this by the serial port [I could poll the serial port, but this wastes energy].
Suggestions welcome

Related

Why Arduino reset when I check for serial port using serial.tools.list_ports in python?

Arduino will reset when DTR signal go Low usually happen when we connect to Serial port.
But when I write code in python using module serial.tools.list_ports. Arduino alway reset when I check for available port except I use Arduino port in other program.
Here my code.
def serial_ports():
return [p.device for p in serial.tools.list_ports.comports(include_links=True)]
Why I happen and how to stop it?
As you have correctly mentioned that
Arduino will reset when the DTR signal goes Low, usually happens when we connect to Serial port.
You might try connecting a 100 Ohm resistor between the 5V pin and the reset pin to stop reset signal going low with the DTR signal.

On Arduino Micro, is there a way to use the "Serial" port from pin connections?

Micro and Leonardo have two serial ports, denoted by "Serial" and "Serial1."
I can use Serial1 through the RX and TX pins for my sensor, a TF Mini, and still get output to the Arduino IDE through the Serial connection via USB.
I would like to, instead send that output via Bluetooth, which also requires a serial connection. I have attempted Software Serialization solutions for the sensor, without success.
Is it possible to access both Serial and Serial1 connections through the pins?
The Serial port in the Arduino Leonardo is virtual, so there is no physical way to interact with it, you'll need to do bit banging in other GPIO pins to simulate this connection. By doing this, it will slow down your sketch if you are doing more complicate stuff. And if you add an extra connection via Serial1 port, will be worse.

Use the Arduino Nano's serial interface to communicate with ESP8266 -- currently hangs

I have designed a ledstrip driver capable of receiving commands over UDP-IP. I initially worked with an Arduino MEGA, and currently I'm in the process of deploying the code in an Arduino NANO.
The Arduino NANO only has one hardware serial interface, unlike the MEGA, which has several. This forces me to disable the usual debugging through one of the Serial ports (by sending strings to the computer) and to reserve the one and only serial interface for the ESP8266. In short, I am connecting the ESP8266 to the TX and RX pins in the NANO.
I am aware that I could use the softwareserial.h library, but I'd like to avoid it if possible.
The following function sets up the Wifi object:
void wifi_setup(){
// Initialize serial for ESP module
Serial.begin(9600);
// Initialize ESP module
WiFi.init(&Serial); /* GETS STUCK HERE */
...
}
The problem is: the microcontroller gets stuck in the Wifi.init() function and never abandons it.
I am aware that the serial interface is connected to the USB port, and am suspicious this might be a problem. However, I have tried giving power to the NANO through the VIN pin instead of through the USB port, and it hasn't worked.
What am I doing wrong?
The best solution will be to write separate code for ESP8266 and Arduino Nano - or even only for ESP8266 (NodeMCU to make it easy). It will be much easier. But if you really want to do it in your way, i think ESP uses 115200 baud, and you've set it to 9600.

Cannot connect to ESP8266 after serial speed change

After some trial and error, tonight my Arduino Uno began talking to an ESP8266 module, with the most common wiring, 3.3V power to the module from a well-sized external supply, direct connection of the 3.3V TX line, and a voltage divider to read from the 5V RX.
SoftwareSerial esp8266(2,3);
void setup()
{
Serial.begin(9600);
esp8266.begin(115200);
char buffer[50];
esp8266.write("AT\r\n");
esp8266.readBytes(buffer, sizeof(buffer));
Serial.println(buffer);
}
After setting the 115200 speed for the ESP8266<->Arduino serial communication, some clear boot messages and command responses appeared on the serial monitor.
Since these messages were interleaved by some garbage characters, I tried reducing the communication speed.
For this purpose I issued the command AT+IPR=9600 to the module, which immediately showed some action on the blue LED, an OK response on the console and finally resulted in the same LED being fixed on.
I consequently adjusted the serial speed on the Arduino side, with esp8266.begin(9600);, but could never obtain any further communication with the module.
I can now see garbage only at any speed.
Could the module have escalated to a different speed? I tried many of them (4800, 57600, 19200, back to 115200 etc.) but no clear response appeared on the monitor.
May you suggest any attempt to reestablish the connection? Any way to reset the last command result?
I'd rather avoid setting up for firmware update, if any simpler solution can be tried.
Here is the solution!
The AT+IPR command was known to break the firmware and make the module unresponsive until a complete reflash.
I found the solution in this forum discussion.

Arduino undesirable incoming serial datas from SPI

I'm working with Arduino with a NFC Shield (this one). I'm trying to use interrupts on Rx: I want my Arduino to wake up, each it receives data on serial line. This works correctly without the NFC shield. However, with the NFC shield, it sends '0' on the serial port, triggering an interrupt, which I really don't want.
After some research, I discovered that each time the library writes on the SPI pins (like digitalWrite(_clk, LOW);, it returns '0'.
In the loop function, I have this line:
id = NFC.readPassiveTargetID(PN532_MIFARE_ISO14443A);
So, each time this line is executed, a '0' is sent through the serial bus, and the Arduino never goes into sleep mode... (even if there is no NFC card to read)
Does someone know why? And how can I avoid it?

Resources