Connection Atmega8 with MPU6050 - atmega

I have question, because I have problem with connection Atmega8 with mpu6050 by means of I2C.
This is my connection:
Is this a good connetion?

Connections look good.
MPU6050 module has on board 3.3v regulator.
The module has also on board pull up resistors for I2C communication. So simply we can connect it directly without any extra components.
You can find this document useful: http://www.electronicwings.com/avr-atmega/mpu6050-gyroscope-accelerometer-temperature-interface-with-atmega16

answer will depend of the board used. MPU6050 is basically a 3.3V chip (not 5V). But if the daughter board is well designed (and boards designed to work for Arduino are) the connection seems to be OK.
Some more information may be accessible here : enter link description here

Related

Error in Arduino with Espressif ESP32-CAM [duplicate]

I've just recieved my very first esp32cam (AI THINKER) today and I was excited to test it, but I'm unable to upload any code to it. I'm always getting the following error:
Failed to connect to ESP32: Timed out waiting for packet header
So, the FTDI I'm using is the FT232r with the following wiring scheme
FTDI Wiring
How I reproduce this error:
Plug everything
Order IDE to upload the sketch
Wait for the "connecting" text
Press the RST button
Also:
Plug everything
Press the RST button
Order IDE to upload the sketch
I've already tried:
Switching to 3.3v (plugged on 3.3v pin)
Using external 5v power supply (plugged on 5v pin)
Using another computer
Swapping RX TX
Trying in different upload speeds
Holding RST button
Switching board between ESP32 Wrover Module and AI Thinker ESP32
I'm I doing something wrong or there's just something faulty?
I have delved for a solution in this regard for weeks and it seems I have a solution.
Findings-
FTDI module is probably faulty or not supported for each instance.
Aithinker Board is not compatible with esspressif (use ESP32Wrover, more details below )
I have an esp32cam from Esspressif, not Aithinker.
I was trying with FT232rl , No matter what Voltage/jumpers/USB cable I used, it didn't work. Always stuck with fatal timed out error.
After many futile attempts with FTDI breakout, I gave my Arduino UNO a try (please note my UNO has mega16u2 chip as USB serial chip (top right corner just beside the oscillator) and fortunately it worked.
I have read that CP2102 is also working.
**Here are the steps to follow-**
Arduino ESP32Cam connections
3.3 Arduino --------- 3v Esp32CAM
GND Arduino ------------ GND Esp32CAM
RESET Arduino to Ardunio GND
RX Arduino -------------- VOR Esp32CAM (this is not a mistake RX to rx & TX to tx)
TX Arduino -------------- VOT Esp32CAM
GPIO 0(zero)(written as IO0) Esp32CAM to GND Esp32CAM
I didn't have any need to press the reset button in any part of the operation before & during uploading.
I am assuming You have pre-installed the esp32 board manager.
Now select the correct COM port where your Uno (in this case) is
plugged in.
Select the correct board as mentioned
Tools>Board>ESP32 Arduino > select ESP32 Wrover Module
Some uploading setups are to be Done (Under Tools, these will only appear when the Wrover module is selected )
Upload speed -- 115200
Flash Frequency -- 40Mhz
Flash Mode -- QIO
Partition Scheme --- Huge App
Port ---- select the right com port for your breakout or UNO
JUST press upload and relax
After a while, you will be able to see this message
Leaving...
Hard resetting via RTS pin...
Disconnect the Esp32Cam GPIO 0 and GND
Power the ESP32Cam with 5/3v with external power supply (Arduino or other breakouts may not be able unless you are connected with a Powered USB Hub)
keep TX, RX, & GND of the 2 boards connected, don't disconnect Arduino Reset and GND.
Press Reset on ESPCAM and open Serial monitor and you will be able to see the IP address of the cam if it was configured with your wifi correctly.OR get any network scanner App on android or windows.
I hope it helped.
Pre-requisites for flashing:
ArduinoIDE 1.8.12
Core ESP32 1.04 (at time of writing)
Select board AI Thinker Cam
uplooad speed 921600
freq 240Mhz
flashfreq 80Mhz
mode QIO if not working try DIO
partition scheme default
Serial monitor is closed
NO hardware connected to the pins of the ESPcam
Make sure the USB cable is a data cable and NO loading cable only
check Windows device manager if programmer is shown and has max speed / 8n1 hardware
Connections
FTDI - ESP32
GND GND
5V 5V
TXD UOR
RXD UOT
If you use an AIThinker Cam clone you have to ground GIPO 0:
connect GPIO 0 with a dupont wire connected to GND
press reset
compile and upload (use AI THINKER CAM)
optional:
press reset
upload filesystem data (SPIFFS)
disconnect GPIO 0 and GND
press reset
code should execute
And yes you have to do it every upload, on my dev board I soldered a little switch with proper isolationSome more solutions from experience:
If there is still a problem use a 10K (or so) pull-down resistor between RX0 and GND (test on breadboard before soldering)
Pressing and holding (!) the boot-button while uploading on some "bad" boards
Happened with a "normal" ESP32 board to me - just to be sure - I got an ESP8266 in an ESP32 packaging. Configuring for the ESP8266 solved the issue of uploading.
In my case I forgot to remove the SD card. Other users recommended removing unnecessary connections to the pins-- and the SD card technically uses some of those :)
This was solved by using other jumpers. It seems one of the jumpers used in the wiring was faulty.
If you're having the same issue and tried everything in this post, try checking your cables!
Another solution here. Just to add, I tried everything on this QA, as well as many other things suggested online. e.g. tested by powering from 3.3V then 5V, various permutations of holding the reset button down and disconnecting IO00 from GND at the point of flashing. Changing various settings in Arduino IDE/
I was unable to flash a single one of the 5 ESP32-CAM boards I bought. Spent a good two hours on it. I even continuity tested every pin on the board to its ESP32 chip pad, and all the hookup wires were tested too. The board seemed fine.
Then I soldered a 100uF capacitor between 5V and GND, and used my USB-UART 5V power... tested and worked straight away. No need to pull out the IO00->GND connection and no need to press RST button on the board during flashing. (Of course, pull out IO00->GND after flashing complete.
So - it was a power problem.
I can only guess that the cheapo regulator they used on the copy of board that I got was not quite efficient enough, but basically that capacitor resolved the issue.
p.s. the ESP on board was marked "ESP32-S". I selected "AI Thinker ESP32-CAM" in Arduino IDE as suggested by most people online, and this worked.
There are 3 pins marked GND on the ESP32-CAM board. Buuuuut (!) the one marked GND/R just by the U0T is NOT connected to other grounds or anywhere else I could had find. Check with a multimeter and use a REAL GND. It just worked for me after days of puzzling.
If you try it with arduino it works but its needed to press reset button on esp32 before you upload your code
Basically I was facing the exact same problem fro quite some time. What worked for me was that as the chip was flashing, shifting the power wire from 5V to 3V3 pin. I do not know why but it workes. When esptool starts flashing at 2%, switching the cable just then, despite having 5V from supply into the 3V3 point made the flashing successful. I do realize this is probably a bad answer to your problem since it involves oversupplying voltage to the chip on the wrong point as it is flashing and could damage the chip. However, if anyone is tired of debugging and are at the point where you are considering throwing the chip away, might as well try my method. For other's who value their chip, don't try this method and if you still do, kniw it is at your own risk. But it worked for me after 3 days of just messing around with connections.

Is it possible to factory reset an arduino from hardware to remove bad user code?

I was troubleshooting why Serial1 was always throwing undefined errors in sketches I was trying to run when I found a solution posted online for a slightly different board that suggested this line:
HardwareSerial Serial1(2);
I uploaded it and now the Arduino doesn't show up in the IDE, did I remap it's serial communications? Why is this possible!
Is there any hardware factory reset option available on these boards? Did I just brick my device?
edit: It seems the STM32Cube programmer app can be used to communicate with the device but I'm not sure where to get the original firmware to flash. https://imgur.com/a/LbiHenf
Assuming from the tag in your question, I guess you have an STM32 – (BluePill) Development Board (STM32F103C8).
If you think that your board is not handling serial communication properly then you might consider burning bootloader to your board. This will reset the complete configuration of your board.
There are many ways in which you can burn bootloader to your board.
Using another Arduino board like Uno / Nano / Mega
Using an FTDI USB to TTL Serial Adapter.
You might want to go through tutorials list below:
Getting Started with STM32 using Arduino IDE: Blinking LED
Programming STM32F103C8 Board using USB Port

Esp32cam Failed to connect to ESP32: Timed out waiting for packet header

I've just recieved my very first esp32cam (AI THINKER) today and I was excited to test it, but I'm unable to upload any code to it. I'm always getting the following error:
Failed to connect to ESP32: Timed out waiting for packet header
So, the FTDI I'm using is the FT232r with the following wiring scheme
FTDI Wiring
How I reproduce this error:
Plug everything
Order IDE to upload the sketch
Wait for the "connecting" text
Press the RST button
Also:
Plug everything
Press the RST button
Order IDE to upload the sketch
I've already tried:
Switching to 3.3v (plugged on 3.3v pin)
Using external 5v power supply (plugged on 5v pin)
Using another computer
Swapping RX TX
Trying in different upload speeds
Holding RST button
Switching board between ESP32 Wrover Module and AI Thinker ESP32
I'm I doing something wrong or there's just something faulty?
I have delved for a solution in this regard for weeks and it seems I have a solution.
Findings-
FTDI module is probably faulty or not supported for each instance.
Aithinker Board is not compatible with esspressif (use ESP32Wrover, more details below )
I have an esp32cam from Esspressif, not Aithinker.
I was trying with FT232rl , No matter what Voltage/jumpers/USB cable I used, it didn't work. Always stuck with fatal timed out error.
After many futile attempts with FTDI breakout, I gave my Arduino UNO a try (please note my UNO has mega16u2 chip as USB serial chip (top right corner just beside the oscillator) and fortunately it worked.
I have read that CP2102 is also working.
**Here are the steps to follow-**
Arduino ESP32Cam connections
3.3 Arduino --------- 3v Esp32CAM
GND Arduino ------------ GND Esp32CAM
RESET Arduino to Ardunio GND
RX Arduino -------------- VOR Esp32CAM (this is not a mistake RX to rx & TX to tx)
TX Arduino -------------- VOT Esp32CAM
GPIO 0(zero)(written as IO0) Esp32CAM to GND Esp32CAM
I didn't have any need to press the reset button in any part of the operation before & during uploading.
I am assuming You have pre-installed the esp32 board manager.
Now select the correct COM port where your Uno (in this case) is
plugged in.
Select the correct board as mentioned
Tools>Board>ESP32 Arduino > select ESP32 Wrover Module
Some uploading setups are to be Done (Under Tools, these will only appear when the Wrover module is selected )
Upload speed -- 115200
Flash Frequency -- 40Mhz
Flash Mode -- QIO
Partition Scheme --- Huge App
Port ---- select the right com port for your breakout or UNO
JUST press upload and relax
After a while, you will be able to see this message
Leaving...
Hard resetting via RTS pin...
Disconnect the Esp32Cam GPIO 0 and GND
Power the ESP32Cam with 5/3v with external power supply (Arduino or other breakouts may not be able unless you are connected with a Powered USB Hub)
keep TX, RX, & GND of the 2 boards connected, don't disconnect Arduino Reset and GND.
Press Reset on ESPCAM and open Serial monitor and you will be able to see the IP address of the cam if it was configured with your wifi correctly.OR get any network scanner App on android or windows.
I hope it helped.
Pre-requisites for flashing:
ArduinoIDE 1.8.12
Core ESP32 1.04 (at time of writing)
Select board AI Thinker Cam
uplooad speed 921600
freq 240Mhz
flashfreq 80Mhz
mode QIO if not working try DIO
partition scheme default
Serial monitor is closed
NO hardware connected to the pins of the ESPcam
Make sure the USB cable is a data cable and NO loading cable only
check Windows device manager if programmer is shown and has max speed / 8n1 hardware
Connections
FTDI - ESP32
GND GND
5V 5V
TXD UOR
RXD UOT
If you use an AIThinker Cam clone you have to ground GIPO 0:
connect GPIO 0 with a dupont wire connected to GND
press reset
compile and upload (use AI THINKER CAM)
optional:
press reset
upload filesystem data (SPIFFS)
disconnect GPIO 0 and GND
press reset
code should execute
And yes you have to do it every upload, on my dev board I soldered a little switch with proper isolationSome more solutions from experience:
If there is still a problem use a 10K (or so) pull-down resistor between RX0 and GND (test on breadboard before soldering)
Pressing and holding (!) the boot-button while uploading on some "bad" boards
Happened with a "normal" ESP32 board to me - just to be sure - I got an ESP8266 in an ESP32 packaging. Configuring for the ESP8266 solved the issue of uploading.
In my case I forgot to remove the SD card. Other users recommended removing unnecessary connections to the pins-- and the SD card technically uses some of those :)
This was solved by using other jumpers. It seems one of the jumpers used in the wiring was faulty.
If you're having the same issue and tried everything in this post, try checking your cables!
Another solution here. Just to add, I tried everything on this QA, as well as many other things suggested online. e.g. tested by powering from 3.3V then 5V, various permutations of holding the reset button down and disconnecting IO00 from GND at the point of flashing. Changing various settings in Arduino IDE/
I was unable to flash a single one of the 5 ESP32-CAM boards I bought. Spent a good two hours on it. I even continuity tested every pin on the board to its ESP32 chip pad, and all the hookup wires were tested too. The board seemed fine.
Then I soldered a 100uF capacitor between 5V and GND, and used my USB-UART 5V power... tested and worked straight away. No need to pull out the IO00->GND connection and no need to press RST button on the board during flashing. (Of course, pull out IO00->GND after flashing complete.
So - it was a power problem.
I can only guess that the cheapo regulator they used on the copy of board that I got was not quite efficient enough, but basically that capacitor resolved the issue.
p.s. the ESP on board was marked "ESP32-S". I selected "AI Thinker ESP32-CAM" in Arduino IDE as suggested by most people online, and this worked.
There are 3 pins marked GND on the ESP32-CAM board. Buuuuut (!) the one marked GND/R just by the U0T is NOT connected to other grounds or anywhere else I could had find. Check with a multimeter and use a REAL GND. It just worked for me after days of puzzling.
If you try it with arduino it works but its needed to press reset button on esp32 before you upload your code
Basically I was facing the exact same problem fro quite some time. What worked for me was that as the chip was flashing, shifting the power wire from 5V to 3V3 pin. I do not know why but it workes. When esptool starts flashing at 2%, switching the cable just then, despite having 5V from supply into the 3V3 point made the flashing successful. I do realize this is probably a bad answer to your problem since it involves oversupplying voltage to the chip on the wrong point as it is flashing and could damage the chip. However, if anyone is tired of debugging and are at the point where you are considering throwing the chip away, might as well try my method. For other's who value their chip, don't try this method and if you still do, kniw it is at your own risk. But it worked for me after 3 days of just messing around with connections.

PWM/PPM Output misses some edges

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.

Is it possible to use both external power jack and USB port with Arduino?

I have the Arduino UNO board and I want to know if it is possible to use both the USB connection (for exchanging data) and the external jack to power supply it.
I will use the following cable: http://ecx.images-amazon.com/images/I/41OMXaj5cPL.SY355.jpg with a AC-DC 5V adaptor in order to power supply the Arduino. However, I want to use also the USB connection in order to send some data from the computer.
Both will be connected at the same time.
In short, I want the Arduino to be able to run even if the computer is OFF and whenever I open the computer to send data to Arduino from USB connection.
Is this possible? Will the Arduino Uno board support it?
Yes. From the official Arduino website:
Power
The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.
External DC power will override USB power if the Arduino detects it. [Source]
as other said, it is absolutely possible to have both usb and power jack plugged in.
but be aware that if you shut down your computer and turn it on after, when reading the usb port you'll restart the Arduino and might loose important data.
yeah both of them can be used. If you want to upload the code in arduino then simply use the usb cable otherwise keep it on adapter. it wont harm the device.
What I personally do is, I keep on plugging the adapter and remove the usb once I am done with uploading and then test it as normally the usb cable is quite small and I normally work on robots so I need long wires.
if you want just plugs it in, it's ok but Arduino board will chose one and usb has priority to other power source.
********* Very important :*****
if you are controlling other circuits, that are connected to an external power supply, with your Arduino and connecting it to your PC's usb, Arduino will have potential difference and it will cause current flow that will damage your PC and Arduino board. if you want to do such thing, you have to shield your Arduino board from your other circuits that you want to control and they have external power source. this could happen with optocouplers for digital ports, non signal analog ports with shield relays, and complex analog circuits for analog signals

Resources