Problem uploading sketch to arduino uno/esp8266 - arduino

Getting this error while uploading:
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Executable segment sizes:
IROM : 236720 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 26892 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1252 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 780 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 24976 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 265644 bytes (27%) of program storage space. Maximum is 958448 bytes.
Global variables use 27008 bytes (32%) of dynamic memory, leaving 54912 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM3
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
File "C:\Users\Arsh\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.4/tools/upload.py", line 65, in <module>
esptool.main(cmdline)
File "C:/Users/Arsh/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.7.4/tools/esptool\esptool.py", line 2890, in main
esp.connect(args.before)
File "C:/Users/Arsh/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.7.4/tools/esptool\esptool.py", line 483, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
or it says Invalid Head of Packet(0xF0)
_
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
This is the pin configuration:
Insted of the 3.3v im using a voltage regulator.
Also RX connected to RX & TX to TX.
Code:
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
Serial.println();
WiFi.begin("username", "password");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {}
Someone suggested to ground the GPIO0, didn't work.
Tried installing different version of the Board:"Generic ESP8266 Module" still getting the same error.
The module works fine when working without the library using the Board:"arduino uno"

GPIO-00 needs to be held at ground while RESET goes to ground, then back to high. This reboots the ESP-01 into the FLASH mode.
For a good overview of a circuit to accomplish this, read:
https://www.allaboutcircuits.com/projects/flashing-the-ESP-01-firmware-to-SDK-v2.0.0-is-easier-now/
Read about the ESP8266 boot modes here:
https://tttapa.github.io/ESP8266/Chap04%20-%20Microcontroller.html

Could you give more details about the 3.3V regulator that you using?
Do you have it connected between the serial signals?
If that is the case, I suggest this connection instead:
3.3V signal voltage divisor
ESP TX and Arduino RX can be connected directly without any issue

Related

What is default baudrate of serial communication of Octave Arduino Toolkit and how can i configure?

I tried Octave Arduino Toolkit and tried following command.
>> pkg load arduino
>> arduinosetup
Running "C:\Program Files (x86)\Arduino\arduino.exe" "C:\Users\XXXXXX\AppData\Local\Temp\oct-aiBvJS\octave\octave.in
o"
ans = 1
>> dev = arduino
dev =
arduino object with fields of:
port = \\.\COM4
board = uno
libraries = {
i2c
spi
servo
shiftregister
}
availablepins = {
d0 - d13
a0 - a5
}
>> val = readVoltage(dev,"A0")
val = 1.9746
So i think it is working correctly. But i do not know
Q1. What is default buadrate of COM4
Q2. How can i change the baudrate
Does any body know the answer for Q1 and Q2?
=========
I found OCTAVE_COMMS_PORT.begin (9600) in LiberaryBase.cpp that seems to configure baudrate. So i changed 9600 to other value.
Compile and write successed but arduino octave does not work correctly.
The error message on Octave is
>> dev = arduino("COM4")
error: __initArduino__: failed valid response err=2 - Malformed packet header
error: called from
__initArduino__ at line 34 column 8
arduino at line 94 column 16
You set the baudrate for the Arduino uno to use in your code, generally the setup block.
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
There's many supported rates and other options (https://www.arduino.cc/en/Serial.Begin), but unlikely you'll need more than the above line.

WeMos D1 Mini esptool.FatalError: Timed out waiting for packet header

I have a WeMos D1 Mini. Here is the board information:
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
I am trying to upload the blink program but getting the following error:
Executable segment sizes:
IROM : 228360 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 26564 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1236 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 1520 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 24896 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 257680 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 27652 bytes (33%) of dynamic memory, leaving 54268 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM5
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 38:2b:78:04:7a:c0
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Traceback (most recent call last):
File "C:\Users\adiba\OneDrive\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.1/tools/upload.py", line 69, in <module>
esptool.main(cmdline)
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 2933, in main
detect_flash_size(esp, args)
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 2241, in detect_flash_size
flash_id = esp.flash_id()
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 607, in flash_id
return self.run_spiflash_command(SPIFLASH_RDID, b"", 24)
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 853, in run_spiflash_command
old_spi_usr = self.read_reg(SPI_USR_REG)
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 490, in read_reg
val, data = self.command(self.ESP_READ_REG, struct.pack('<I', addr))
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 347, in command
p = self.read()
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 292, in read
return next(self._slip_reader)
File "C:/Users/adiba/OneDrive/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.6.1/tools/esptool\esptool.py", line 2045, in slip_reader
raise FatalError("Timed out waiting for packet %s" % waiting_for)
esptool.FatalError: Timed out waiting for packet header
esptool.FatalError: Timed out waiting for packet header
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Is there any solution for this? My friend has tried this board on his computer and it seems to work just fine. Thanks for any support.
I receive the same error, my solution was:
remove usb from wemos D1 mini
solder wire D3 to GND
plug usb
upload your Sketch
disconnect D3 from GND

ESP8266 and Arduino UNO

I am trying to upload a sketch and getting below error:
Except the usual connection my GPIO 0 is grounded.
Arduino: 1.8.1 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, 40MHz,
DOUT, 115200, 512K (64K SPIFFS), ck, Serial1, All"
Sketch uses 232813 bytes (53%) of program storage space. Maximum is 434160 bytes
Global variables use 34092 bytes (41%) of dynamic memory, leaving 47828 bytes for local variables. Maximum is 81920 bytes.
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
You must have a bad connection. I recommend that you follow this scheme that I leave here.
ESP01 connection with Arduino UNO
You can also consult this complete guide on the ESP01 (https://programarfacil.com/podcast/como-configurar-esp01-wifi-esp8266/) that although it is in Spanish, is very simple to follow.
Make sure GPIO 0 is grounded, and then reset the ESP8266. Also make sure you have 3.3v coming in to CH_PD and RST. Set baud rate to 115200 unless you changed it already.

How to get the ESP8266 to work in update mode?

I have been trying to get my WiFi module, ESP8266 to work in the "update mode" where you connect GPIO_0 to ground.
The board is functional when GPIO_0 is disconnected from ground and I am able to use AT commands to talk to it via the Arduino serial monitor.
Following is what it prints upon connecting:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x40100000, len 1396, room 16
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4
tail 8
chksum 0xc0
csum 0xc0
2nd boot version : 1.4(b1)
SPI Speed : 40MHz
SPI Mode : DIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 # 1000
rrlÌÿ
Ai-Thinker Technology Co.,Ltd.
ready
However, I cannot do most things as the firmware is out of date.
As a result, I am trying to update it (with no success)
When I set it to update mode and use the python tool "esptool.py", the script fails to connect to the ESP board.
Following is the command:
python esptool.py -p /dev/ttyUSB0 write_flash 0x00000 "/home/aditya/Desktop/v0.9.2.2 AT Firmware.bin"
Following is the output:
Connecting...
Traceback (most recent call last):
File "esptool.py", line 532, in <module>
esp.connect()
File "esptool.py", line 159, in connect
raise Exception('Failed to connect')
Exception: Failed to connect
I have even run the Windows counterpart of this tool "ESP Flasher" with no luck
The one who helps will be given a cookie (unless you value privacy)
This tool (esptool.py) works with a ROM bootloader, which is only started if GPIO_0 is tied to the GND during hardware reset. Bootloader also times out pretty fast, so just connecting GPIO_0 to the ground is not enough.
For me, following works:
Connect TXD/RXD/GND/VCC to the PC and CH_PD to VCC;
Make sure I can talk to the firmware via terminal (picocom/minicom/etc);
Connect GPIO_0 to the GND;
Connect RST to GND;
Release RST;
Run esptool.py
If still no dice, swap 5 and 6 above, i.e. first run esptool.py, then (as quickly as possible) release/disconnect RST. You will only have a second or two before esptool.py times out.
Try making the ground of all devices connected: if you have a level shifter inbetween, make sure the GND is tied to the GND of Arduino and also to the RS232 GND.

Can't send data to Xively through Arduino Wi-Fi Shield, sending just one stream

I'm doing a project involving uploading data wirelessly, from an analog sensor. In this case it is a light sensor.
I am using an Arduino Uno R2, and an official Arduino Wi-Fi Shield. Below is my code:
#include <SPI.h>
#include <WiFi.h>
#include <HttpClient.h>
#include <Xively.h>
char ssid[] = "Bradley's MacBook Pro"; // your network SSID (name)
int status = WL_IDLE_STATUS;
// Your Xively key to let you upload data
char xivelyKey[] = "SOP7lASYJVcRecV98zlHosDc9nLIAXqnDnIxRnXAmNeKorIk";
// Analog pin which we monitor (0 and 1 are used by the Ethernet shield)
int sensorPin = 2;
// Define the strings for our datastream IDs
char sensorId[] = "light";
XivelyDatastream datastreams[] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
XivelyFeed feed(1125419529, datastreams, 1 /* number of datastreams */);
WiFiClient client;
XivelyClient xivelyclient(client);
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Starting single datastream upload to Xively...");
Serial.println();
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
printWifiStatus();
}
void loop() {
int sensorValue = analogRead(sensorPin);
datastreams[0].setFloat(sensorValue);
Serial.print("Read sensor value ");
Serial.println(datastreams[0].getFloat());
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
Serial.print("xivelyclient.put returned ");
Serial.println(ret);
Serial.println();
delay(15000);
}
However unfortunately every time I get this back in serial:
Attempting to connect to SSID: Bradley's MacBook Pro
Connected to wifi
SSID: Bradley's MacBook Pro
IP Address: 10.0.2.3
signal strength (RSSI):-20 dBm
Read sensor value 1023.00
Uploading it to Xively
xivelyclient.put returned -1
Read sensor value 1023.00
Uploading it to Xively
xivelyclient.put returned -1
Read sensor value 684.00
Uploading it to Xively
xivelyclient.put returned -1
Read sensor value 684.00
Uploading it to Xively
xivelyclient.put returned -1
Read sensor value 684.00
Uploading it to Xively
No Socket available
xivelyclient.put returned -1
Read sensor value 684.00
Uploading it to Xively
No Socket available
xivelyclient.put returned -1
I noticed that after a few attempted it started to say No Socket available.
Does anyone have any clues as to where I've gone wrong?
I have resolved this problem. The issue is that I was using Arduino IDE 1.0.5 and there is a bug in that which prevents Wi-Fi communication. I have now changed to using an earlier IDE 1.0.2 and everything is running perfectly.
Even if you change IDE version to 1.0.2 , for few months it worked fine. If this problem occurs again, consider upgrading Wifi Shield Firmware . Latest package availble in Arduino site.It solved the error
Steps to follow for ugrading:
1. Download and install Flip from here. http://www.atmel.com/tools/FLIP.aspx You don't need to use or run the Flip program. There is a sub-program in the download you will need to use later. You will get to this sub-program (batchslip.exe) using a DOS command prompt. There is also a driver for the chip on the WiFi Shield (AT32UC3A or AT32UC3A DFU) that you will need.
If you recently installed a version of Arduino onto your computer, the software you need to update the WiFi Shield is in the Arduino directory structure. I know this to be true for me when I recently installed Arduino Version 1.0.5. (You might need to install a current version).
Connect your WiFI Shield to the Uno board. Put the jumper across both pins on 'DFU Programming Jumper'. Shown on 4th picture of the WiFi Shield on this page: ? http://arduino.cc/en/Main/ArduinoWiFiShield
To find the picture of the jumper, look for the words and arrow pointing to the board " DFU programming jumper (only used for updating shield firmware, leave unconnected for typical use)".
Connect power to your Arduino. Then connect a mini USB to the WiFi shield (not a micro-USB) and your computer.
Hopefully your Windows Device manager will show AT32UC3A DFU under "Other Devices". You may have to play with plugging/ unplugging power to Arduino and also the WiFI Shield's USB port connected to your computer. One time I had luck by not powering the Arduino and only plugging in the USB mini between computer and the WiFi Shield.
Right-Click on the device in 'Device Manager' and select "Update Driver" . I chose to install from my computer and directed the Device Installer application to Install from... C:\Program Files (x86)\Atmel\Flip 3.4.7 . I had an option to click "Include Subdirectories'. Sorry, I am not certain what sub-folder the driver might actually be in. When this step is complete, The AT32UC3A DFUshould be properly listed in Device Manager under "Atmel USB Devices".
Open a command prompt and navigate to the directory where "batchslip.exe" was installed by Flip. For me it was C:\Program Files (x86)\Atmel\Flip 3.4.7\bin ...but it depends where the Atmel software is installed and what version you download.
Once you are in the directory ( C:\Program Files (x86)\Atmel\Flip 3.4.7\bin) , you will need to run two commands. You will need to determine where you initially installed your Arduino software. I installed mine in C:\Arduino instead of the recommended lengthy folder suggested ( * something like C:\Arduino 1.0.5.) .. Therefore you might need to adjust the directory structure in the two commands I have listed below.
I suggest Cut and paste the first command from below, then make it match your * Arduino folder name. You may have to dump the following command in to a notepad or something to make sure there are no line breaks. Make the path as small as possible. Don't paste Arduino folder in program files while upgrading,because if path has Program Files (x86) ,spaces in between words will create un necessary error like : missing arguments
"
c:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer c:\Arduino\hardware\arduino\firmwares\wifishield\binary\wifi_dnld.elf program verify start reset 0
"
Here is what you should see on the command line..........
Running batchisp 1.2.5 on Sat May 10 21:16:01 2014
AT32UC3A1256 - USB - USB/DFU
Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS 1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS 0x00000 0x3ffff
Parsing ELF file....................... PASS c:\Arduino\hardware\arduino\firmwares\wifishield\binary\wifi_dnld.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS 0x00000 0x2902b
Verifying memory....................... PASS 0x00000 0x2902b
Starting Application................... PASS RESET 0
Summary: Total 11 Passed 11 Failed 0
c:\Program Files (x86)\Atmel\Flip 3.4.7\bin>
Now to update the second piece
Cut and paste the command from below. You may have to dump it in to a notepad or something to make sure there are no line breaks.
"
c:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer c:\Arduino\hardware\arduino\firmwares\wifishield\binary\wifiHD.elf program verify start reset 0
"
Press Enter
Here is what will happen on your screen..
Running batchisp 1.2.5 on Sat May 10 21:34:04 2014
AT32UC3A1256 - USB - USB/DFU
Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS 1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS 0x00000 0x3ffff
Parsing ELF file....................... PASS c:\Arduino\hardware\arduino\firmwares\wifishield\binary\wifiHD.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS 0x00000 0x3fe2b
Verifying memory....................... PASS 0x00000 0x3fe2b
Starting Application................... PASS RESET 0
Summary: Total 11 Passed 11 Failed 0
c:\Program Files (x86)\Atmel\Flip 3.4.7\bin>
Remove the Jumper from the WiFi Card. Remove the Min USB.
Verify Wifi shield with any sketch.
This method really solved the No Socket available issue.

Resources