These are chat archives for esp8266/Arduino

3rd
Aug 2016
Me No Dev
@me-no-dev
Aug 03 2016 04:37
@Makuna ccompare and ccount are not the same thing :)
Michael Miller
@Makuna
Aug 03 2016 05:56
Sorry, my hands typed one thing and my mind was thinking something else, I meant they both use the same type, cycle counts.
Hagai Shatz
@hagai-shatz
Aug 03 2016 09:44
Is there a similar interrupt I can setup on a specific pin? That is, instead of using timer, my ADC can set an external pin to high when data is ready to read (every 500us). How can I attach interrupt handler that will have good priority to ensure execution?
Me No Dev
@me-no-dev
Aug 03 2016 10:02
use attachInterrupt(pin, fn, type);
Hagai Shatz
@hagai-shatz
Aug 03 2016 10:04
Do I need to use attachInterrupt(digitalPinToInterrupt(pin), fn, type)?
Me No Dev
@me-no-dev
Aug 03 2016 10:04
digitalPinToInterrupt no
pin and interrupt match here
Hagai Shatz
@hagai-shatz
Aug 03 2016 10:05
Okay, thanks.
Ivan Grokhotkov
@igrr
Aug 03 2016 10:30
regarding priority: the core inside esp8266 only has three interrupt levels. all "normal" interrupts are at level 1. Debug interrupt is level 2, and NMI is level 3.
so GPIO interrupt will not preempt other level 1 interrupts (e.g. timer interrupts)
Hagai Shatz
@hagai-shatz
Aug 03 2016 10:32
@igrr , thanks for the clarifications.
Holger Lembke
@holgerlembke
Aug 03 2016 11:58
so finally found some time to finish my flash check program for changing the flash chip.
Me No Dev
@me-no-dev
Aug 03 2016 11:58
@holgerlembke I spent some time myself and can confirm that space above 4M does not work
Holger Lembke
@holgerlembke
Aug 03 2016 11:59
and the results of the German jury are: if I write to it, I can read it back without errors....
@me-no-dev Hmmm. I write a integer into it and read that same value back
Me No Dev
@me-no-dev
Aug 03 2016 12:01
@holgerlembke even though you might be able to access it from within the firmware
the ESP thinks that the FLASH size is 512K and puts the conf there
also SPIFFS does not work
Holger Lembke
@holgerlembke
Aug 03 2016 12:03
hmmm.
Me No Dev
@me-no-dev
Aug 03 2016 12:03
overall your option is to set 4M config and use the space above from the sketch
Holger Lembke
@holgerlembke
Aug 03 2016 12:04
let me sum it up: use as program space: no. use as storage from my sketch: yes. right?
Me No Dev
@me-no-dev
Aug 03 2016 12:04
right
Holger Lembke
@holgerlembke
Aug 03 2016 12:04
so SPIFFS does not work why?
Me No Dev
@me-no-dev
Aug 03 2016 12:06
ESP understands flash up to 4MB and assumes 512K is magic does not match to 4M
the ESP will put at the end of whatever it thinks the size is the config secttors
it's kinda hard for me to formulate and explain it all
Holger Lembke
@holgerlembke
Aug 03 2016 12:07
me not understand that
SPIFFS is entirely sketch driven. right?
Me No Dev
@me-no-dev
Aug 03 2016 12:08
|--sketch--|--ota--|--spiffs--|--eeprom--|--config--|
not entirely ;) address and size are defined in linker
Holger Lembke
@holgerlembke
Aug 03 2016 12:09
so as the current flash sizes are... I had to change flashchip->chip_size
so why not create a config with 2mb |--sketch--|--ota--|--eeprom--|--config--| and put SPIFFS at the end?
Me No Dev
@me-no-dev
Aug 03 2016 12:12
config is written by the SDK, eeprom is defined as 4K after SPIFFS
you can maybe make a config for 1M and have EEPROM and SPIFFS after
though OTA will not work because it takes spiffs start as it's possible end
Holger Lembke
@holgerlembke
Aug 03 2016 12:13
i dont get it. why does the SDK care about SPIFFS?
Me No Dev
@me-no-dev
Aug 03 2016 12:13
SDK does not care about spiffs
SDK cares about WIFI config
and always puts that config in the last 4 sectors (or maybe it was 3) before what it thinkls is the end of the flash
which is determined by the magic byte of the image
Holger Lembke
@holgerlembke
Aug 03 2016 12:16
so if flashchip->chip_size is changed, it wont find its config any more, because it cant access beyond the 4mb?
Me No Dev
@me-no-dev
Aug 03 2016 12:17
flashchip->chip_size has not come into play when flash size is determined
flashchip->chip_size is set based on that (and we overwrite it if needed)
Holger Lembke
@holgerlembke
Aug 03 2016 12:18
it is all I need to get write/read access...
Me No Dev
@me-no-dev
Aug 03 2016 12:18
from within the firmware yes
but not from the bootloader
Holger Lembke
@holgerlembke
Aug 03 2016 12:19
sooooooo. where is the problem? boot 2mb |--sketch--|--ota--|--eeprom--|--config--| , change chip_size, init SPIFFS.
Me No Dev
@me-no-dev
Aug 03 2016 12:19
even if you manage some crazy config, it will break OTA, SPIFFS upload tool and maybe more
Holger Lembke
@holgerlembke
Aug 03 2016 12:20
oh. i see
so every time a spiffs-call is made, chipsize must be changed and restored....
Me No Dev
@me-no-dev
Aug 03 2016 12:21
what you can do also is set chip_size and attach second SPIFFS partition above 4M
|--sketch--|--ota--|--spiffs--|--eeprom--|--config--|--spiffs2--|
Holger Lembke
@holgerlembke
Aug 03 2016 12:27
ok, to sum that up: all tools assume sketch/ota/spiffs/eeprom/config for calculations. if it is changed, it is unclear, what happens.
Me No Dev
@me-no-dev
Aug 03 2016 12:27
yes
Holger Lembke
@holgerlembke
Aug 03 2016 12:29
so two spiffs would be the workable solution. just add the first for compatibility sake and ignore it and use the second instead.
Me No Dev
@me-no-dev
Aug 03 2016 12:29
or use both...
Holger Lembke
@holgerlembke
Aug 03 2016 12:30
squezze every drop out of it...
as I dont know much about the "internal thoughts of core developers", is SPIFFS really that good? Any other solutions? I mean, a file system with no folders...
Me No Dev
@me-no-dev
Aug 03 2016 12:35
our flash chips are small in size and most (modern) file systems are made for much larger memory
SPIFFS is optimized for what it does: save space, save the flash from wear and provide file system for MCUs
adding even a simple thing as folders will require more space to be used for storing a catalog of the folders and contents
maybe some old FAT can be made to work, but then there will be complains about file name length ;)
Holger Lembke
@holgerlembke
Aug 03 2016 12:48
this is something I totally know. :-) my question was more about the internal views, whether there is something in the development pipeline and some other flash file solutions... but as far as google goes, I didnt find any replacement candidate, too.
Me No Dev
@me-no-dev
Aug 03 2016 12:51
I doubt something better can be made ;) at least with the constrains that we have
Holger Lembke
@holgerlembke
Aug 03 2016 12:58
emfile is fat32 with about 15k/2k.. but closed source.
Holger Lembke
@holgerlembke
Aug 03 2016 13:06
and "Petit FAT File System Module" works on a ATtiny85 but has no flash support. on the other hand a very clear interface, so a wear leveling...
Ivan Grokhotkov
@igrr
Aug 03 2016 13:51
Hmm, there are lots of options for embedded FS out there
Even with free and permissive license.
Take the one from Apache Mynewt, for example.
Me No Dev
@me-no-dev
Aug 03 2016 13:53
what is OpenWRT's file system?
most routers run on flash like ours
Ivan Grokhotkov
@igrr
Aug 03 2016 13:55
Openwrt usually ends up with squashfs which is RO and some bit of jffs2
As for the 8 meg flash and above, I would solve the issue like this
Tell sdk that we are using 1 mb flash
And when we do flash ops on our own, change that to 8mb
Ivan Grokhotkov
@igrr
Aug 03 2016 14:03
Not that this is all important though. There isn't a single module with 8 or 16 mb flash on the market
Holger Lembke
@holgerlembke
Aug 03 2016 14:36
at least 131553173252 has been solder above 750 times. so "a single" is a bit strict
Holger Lembke
@holgerlembke
Aug 03 2016 16:30
Hmmmm. Porting petit fat file system seems not to difficult.
Only thing I fail: where do I get the starting point of "free flash" from? I thought of putting it at the place where SPIFFS lived before...
gonsays
@gonsays
Aug 03 2016 17:19
Hey Guys, do you know any .ino that can provide me INFO about the esp8266? Like the REAL flash size, memory, etc..
I have a esp-01, esp-07 and esp-12-f
Ivan Grokhotkov
@igrr
Aug 03 2016 17:20
Examples > ESP8266 > CheckFlashConfig
gonsays
@gonsays
Aug 03 2016 17:20
I use both arduino and nodemcu and when I do the node.heap() @ esp-01 I get 34.600 ; when I do the node.heap() @ esp-12-f I get 35.100
esp-12-f is supposed to have 4 Mbyte memory
@igrr thnks
Michael Miller
@Makuna
Aug 03 2016 17:34
@gonsays heap is ram, not flash size.
gonsays
@gonsays
Aug 03 2016 17:35
@Makuna but both esp-01 and esp-12-f have the same ram?
Michael Miller
@Makuna
Aug 03 2016 17:37
Did you search? I am unsure the ram values for different modules, but I thought they only varied by flash size.
gonsays
@gonsays
Aug 03 2016 17:38
I've been searching for some time and I haven't found anything certain about the ram
only about the flash size
but how can the flash size help me? I'm having memory issues.. The variables "eat" the ram and not the flash size
Michael Miller
@Makuna
Aug 03 2016 17:40
Correct, global variables, allocated memory, and call stack depth all use ram. What is eating so much ram? Large global array or buffer?
gonsays
@gonsays
Aug 03 2016 17:41
yup, large global array and a buffer to use arduinojson lib
Michael Miller
@Makuna
Aug 03 2016 17:42
Is the array read only?
gonsays
@gonsays
Aug 03 2016 17:42
I'm using a 24x4 int array to define action, red, green, blue values to a 24 NeoPixel ring
nop, it is refreshed at each http get to a json
Michael Miller
@Makuna
Aug 03 2016 17:44
what neopixel library are you using? That array is not that large.
I've followed this tutorial and used this lib
Michael Miller
@Makuna
Aug 03 2016 17:45
Int for red? Or int for rgb?
gonsays
@gonsays
Aug 03 2016 17:46
int for each r, g and b
Me No Dev
@me-no-dev
Aug 03 2016 17:47
want to share some code so we can rule out any obvious reason?
Michael Miller
@Makuna
Aug 03 2016 17:47
Note, the adafruit library is not stable on esp8266 when using wifi. It's based on my first version of my library, check out makuna/neopixelbus for a stable version for esp.
gonsays
@gonsays
Aug 03 2016 17:47
tnks makuna
@me-no-dev sure, it's a bit messy @ arduino, but i'll copy it to pastebin
Me No Dev
@me-no-dev
Aug 03 2016 17:48
@Makuna that does not sound like lib issue though :)
it is really messy
and I'm not using the neopixel lib yet
at that code
I've also tried nodemcu with different coding approaches
and there is always lack of memory
it does the first LOOP OK
but at the second loop it crashes
Michael Miller
@Makuna
Aug 03 2016 17:49
Nope, but I stated NOTE, you will run into displa and reset issues with it.
gonsays
@gonsays
Aug 03 2016 17:50
the problem is at LINE 141 @ http://pastebin.com/2dJEth4Z
that for loop @ parseJSON function at the 1st TIME it works OK
at the second time it crashes
HTTP GET -> Parse JSON -> Fill array
I know it is messy as hell
Me No Dev
@me-no-dev
Aug 03 2016 17:53
in the code you posted you are using WiFiClient to get the content of the remote page
and in the response first you will get headers
and then actuall content
what are all those delays for?
Michael Miller
@Makuna
Aug 03 2016 17:56
At line 131, does the static json buffer allocate a new buffer? Not familiar with that library enough.
gonsays
@gonsays
Aug 03 2016 17:58
@me-no-dev I've used them to be able to check some Serial.println that were removed
@Makuna, I'm not sure.. Are u suggesting that it creates a new buffer each time that runs parseJson?
maybe I should define it outside the function, I'll test it
Martin Ayotte
@martinayotte
Aug 03 2016 18:00
@gonsays , why b_cell array has 24x4 elements while t_cell has only 2x4 ?
gonsays
@gonsays
Aug 03 2016 18:00
@martinayotte t_cell are other two individual neoPixel LEDs
Me No Dev
@me-no-dev
Aug 03 2016 18:01
at line 109 you connect to the server and send the request but wait a whole second to start reading the data which have already arrived and is sitting in memory
generally not a good idea
gonsays
@gonsays
Aug 03 2016 18:01
I have a 24 LED NeoPixel Ring and a 2 Individual NeoPixel LEDs
@me-no-dev , thnks i'll certainly change it
every suggestion is appreciated
Me No Dev
@me-no-dev
Aug 03 2016 18:02
delay only when you do not have aconnection open
if response is large, it might eat up your heap
gonsays
@gonsays
Aug 03 2016 18:02
thnks! I know delays are not good, but without them I "feel" like I'm stressing the esp
Me No Dev
@me-no-dev
Aug 03 2016 18:03
if you delay too much it might stress you :D
gonsays
@gonsays
Aug 03 2016 18:03
looool 4 sure
with the delays I "feel", maybe wrongly, that I'm giving esp some "rest"
Me No Dev
@me-no-dev
Aug 03 2016 18:05
it depends on the case :) we use small delays sometimes to let the network stack run it's thing
but I'm talking delay(1) or 2
another note, make sure you read the whole response and then close the connection
gonsays
@gonsays
Aug 03 2016 18:06
oh, ok.. I haven't understand yet the best case scenario to use delays.. because sometimes, without delays, it started to execute functions very quickly and crashed
Me No Dev
@me-no-dev
Aug 03 2016 18:07
it's not quickly, but rather too much without givint the network a chance to run
and that chance is given by yield or delay
gonsays
@gonsays
Aug 03 2016 18:07
oh, ok
Me No Dev
@me-no-dev
Aug 03 2016 18:07
if you block for too long, watchdog will bite you
gonsays
@gonsays
Aug 03 2016 18:07
about the close connection, I have it this way: while(client.available()){ lineX = client.readStringUntil('\n'); } client.stop();
isn't it reading the response and then closing the client?
isn't this correct?
Me No Dev
@me-no-dev
Aug 03 2016 18:08
client might not end with new line
in which case you will hang
gonsays
@gonsays
Aug 03 2016 18:08
oh..
hum.. how can I make sure?
should i use ('\r')?
Me No Dev
@me-no-dev
Aug 03 2016 18:10
you read the headers, catch content length and read that many bytes after the headers
headers end with two new lines
or use http client
gonsays
@gonsays
Aug 03 2016 18:10
it is making and http get request to a json
first, it gets the headers
but the last line saved @ lineX String
is the json info, like: {.....}
Me No Dev
@me-no-dev
Aug 03 2016 18:12
are you sure your json ends with new line? and that you can hold it all into a single string?
gonsays
@gonsays
Aug 03 2016 18:13
I've used println to get the lineX string ( {....} ) and it returns what I need
(the json, without the headers)
I believe that I may have some issue at the 2nd HTTP-GET request
Me No Dev
@me-no-dev
Aug 03 2016 18:14
try client.flush() and client.close() after reading the line (or maybe it was client.stop())
gonsays
@gonsays
Aug 03 2016 18:14
ok, i'll try it
I'm configuring arduino and esp8266 on a new SSD HD
and previously, I had to do #include <esp8266....h>
now, I have installed the esp using boards manager (Without libraries/esp8266)
if i copy the esp8266 folder to libraries and try to include it
it does not work
is this normal?
the code I've presented was developed in another PC
Me No Dev
@me-no-dev
Aug 03 2016 18:16
esp8266 folder needs to go into hardware not libraries :)
gonsays
@gonsays
Aug 03 2016 18:16
ohh
but I've been using it on libs, on the other PC
like: Docs\Arduino\libraries\esp8266
then, I could use #include <ESP8266WiFi.h>
now, it gives me an error if upload the esp8266 folder (@ Documents) to libraries and try to compile it
gonsays
@gonsays
Aug 03 2016 18:42
i've managed to solve this lib issue :)
thnks a lot guys!!