I'm making a quadcopter with SparkFun ESP32 Thing module and using MPU9255 Waveshare IMU.
It looks like when I'm reading PWM signals from RC receiver with interrupts (6 interrupts for 6 chanels) I2C fails after some time. I am using interrupt over MPU9250 either (but not the DMP module, just sync for accel and gyro data). I am not sure if the connection fails, MPU9250 or ESP32.
It looks like this:
After 10-50sec, MPU9250 fails, and MPUs interrupt works at 8kHz (instead of 1,6kHz), and values wont change.
No idea what is happening ;/ Anyone?
Without interrupts, I2C works fine...
Your ISRs must save and restore ALL registers and flags that are used. If you are calling any external functions from your ISRs, there could be reentrancy issues. Without a look at the code, that's the best I can offer.
Related
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.
I am using ESP8266 (NODEMCU 3.0 or something) to make a quadcopter. Ive connected ardu pro mini to RC receiver so I am reading PPM values from it. Pro mini sends data with tx to ESP8266. ESP reads it with software serial with 115200 baudrate. I am communicating with MPU9255 (Waveshire) via I2C either.
My problem is that I cant fully controll my brushless motors. When I was using arduino instead of ESP8266, servo library was the best and reliable. But ESP's servo library is different, since its not AVR, and problems occurs. First of the servo library didnt want to work on most frequencies. I mean default is 50Hz (20000uS) and in this state ESC of motors did armed but unfortunatelly when changes was fast and short (1250-> 1370 -> 1250) it did miss that change like nothing happnd... This makes my D value in PID controller useless...
Sometimes on 100Hz freq all was working fine, but sometimes not...
When Ive started to use analogWrite only 500Hz was working fine, rest of freq didnt want to arm ESCs.
PS. I am using 3.3V to 5V converter for PPM/PWM pins so I am sure that the signal is fine for ESCs.
PS2. I dont have any osciloscope unfortunately.
The ESP82266 present on your module is a RF transceiver integrated circuit that can handle WiFi communication, both configured as a slave to a microcontroller such as the ones present on various Arduino boards, or as a standalone chip by having it's on-board Tensilica L106 32-bit processor programmed via an external SPI flash memory. If used as a slave, the communication between, for example, an Arduino an the ESP82266 can be done using different protocols such as SPI / SDIO or I2C / UART interfaces. Googling a comprehensive Tensilica L106 user guide on the internet doesn't seem an easy task, and it looks as if some people have already failed to find it. If you're seeking to add Wi-Fi capabilities to your quadcopter the solution I suggest is having the Arduino take control over the servos, motors, etc. and hand off messages via SPI to your ESP82266 module. If this isn't the answer you are looking for, please try to be clearer about it, maybe find someone to do as an English translator for you.
However, if this is what you're concerned about, and you would like to use the ESP82266 module as as standalone solution, please link its built-in processor datasheet and the relevant parts of the quadcopters code that might need debugging.
I came across this website when trying to find a reliable way to use the watchdog for preventing failures (code lock ups) and saving battery using an Arduino.
I tried the code and it worked fine. However, i would also like to use the serial monitor. I tried adding Serial.begin(9600); in the setup, however, most of what is shown in the serial monitor (from the code within the main loop) are strange characters (the baud rate is set to 9600). Is this something to do with the function to configure the wdt and the placement of Serial.begin(9600) in the code?
I'd also like to use an external interrupt (via a button on Digital pin 3) to wake the board from sleep. How can be achieved based on the current code? I know how to implement using a different method of making the board go to sleep without using any watchdog at all, however, i have been unsuccessful in making it work with this code.
Many thanks for any help.
As said above, the serial communication should work fine. Are you sure you are able to make your serial communication work fine without the watchdog part of the code? I have used the watchdog tips given on the website along with serial communications without any problem on Arduino Uno, so I would guess the serial communication problem lies somewhere else in your code.
Can you write a bare bone example of your code with the watchdog management part, a serial communication or two somewhere in your loop(), and if you want some delays / infinite loops to test the watchdog firing, post it here, test it on your board and indicate if / where you have problems?
I have never used a pin interrupt, but it seems that google gives some nice results with example code. Have you tried the results given by google?
https://www.arduino.cc/en/Reference/AttachInterrupt
http://www.allaboutcircuits.com/technical-articles/using-interrupts-on-arduino/
You will have to be careful regarding the choice of the pin on which you put the interrupt, as explained in the Arduino Reference only pins 2 and 3 support interrupt on the Uno.
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.
I'm a beginner. I'm trying to understand about I2C Initialization of TMP102. It is a temperature sensor. It is connected via I2C. So, the initialization must be of I2C. But, my leader told we have to initialize GPIO also in this case, since interrupt pin is connected via GPIO. He also told it is not necessary in other cases. I couldn't understand the original purpose.
Why do we initialize GPIO?
In other cases, where does the slave's interrupt pin gets connected?(if not in GPIO)
Also, in case of large message, TX/RX FIFO may not fit. So, draining feature is used (XDR/RDR bit is set). What exactly is draining feature and what it does?
Why do we initialize GPIO?
Since interrupt pin is connected via GPIO.
In other cases, where does the slave's interrupt pin gets connected?
If slave has an interrupt pin, you SHOULD initialize corresponding GPIO/IOMUX.
Some slave devices may not contain interrupt. In that case, no need to initialize any GPIO.
Summary:
You should initialize ALL GPIO/IOMUX for all input/output from processor to slave device.