These are chat archives for esp8266/Arduino

28th
Nov 2015
brutzler
@brutzler
Nov 28 2015 09:17
thx for input. will check. But interesting prior would be, if I can really sniff foreign packages. otherwise its of no use.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:32
Hello
I just got a NodeMCU and flashed the Arduino firmware, and am trying to read a few sensors, but the damn thing keeps dumping core at random times. Has anyone had the same experience of instability?
d-anders
@d-anders
Nov 28 2015 10:34
a lot of ways to crash it
code?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:36
I'll post it when I'm at the pc, but it doesn't seem to me like it would be code-related, I'm just doing some digitalReads
Does it ever crash randomly for you?
d-anders
@d-anders
Nov 28 2015 10:36
no
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:36
Hmm, I'll post some code soon then, thanks
d-anders
@d-anders
Nov 28 2015 10:37
but for example if you use interrupts the wrong way (doing much work in a timer etc) it will crash
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:43
yes, I also hit that (I was adding a timer and it kept crashing), so I took it out
d-anders
@d-anders
Nov 28 2015 10:44
having timers should work fine, but the code needs to finish quickly
brutzler
@brutzler
Nov 28 2015 10:48
How do you ensure always to have a connection to a router?
When ESP is running with an established connection to the router, and I restart the router. Will the WiFi connection be automatic restored?
Or do I have to restart the ESP too in that case? Perhaps automatically with a watchdog or similiar?
d-anders
@d-anders
Nov 28 2015 10:49
good question, i always asumed it would reconnect :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:50
@brutzler, that code contains a function to reconnect as well, if you want to check it out
Me No Dev
@me-no-dev
Nov 28 2015 10:51
@brutzler it will reconnect automatically
Mario Mikočević
@mozgy
Nov 28 2015 10:52
I have several NodeMCU hw, all works fine with sensors (DHT11/22, DS18B20)
Me No Dev
@me-no-dev
Nov 28 2015 10:54
@skorokithakis code looks fine
d-anders
@d-anders
Nov 28 2015 10:54
@skorokithakis didnt really see anything strange in your code
Me No Dev
@me-no-dev
Nov 28 2015 10:54
maybe mqtt giving you headaches?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:54
@me-no-dev it is, but it's also crashing without mqtt (i removed it from the code)
d-anders
@d-anders
Nov 28 2015 10:54
when does it crash and can you remove code to avoid it?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:55
sometimes it crashes on startup, sometimes it works for minutes, sometimes it crashes after a few seconds
completely random
brutzler
@brutzler
Nov 28 2015 10:56
How do you ensure, that the ESP is still working proper?
I want to setup a little 24/7 controller for my warmwater-heating. And this "PLC" should not stop working.
Is there a need/possibility for a watchdog to reset the ESP in case of hanging? And how to recognize this?
d-anders
@d-anders
Nov 28 2015 10:56
it crashed even if you comment out everything in your loop?
Me No Dev
@me-no-dev
Nov 28 2015 10:56
@skorokithakis you said you use nodemcu. Any chance something is wrong with the power to it?
power spikes can reseti it easily
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:58
i'm powering it from the computer's USB, as i want to be able to read the serial. i don't know if the computer's power supply is that unstable, it's a macbook plugged in to the wall
Me No Dev
@me-no-dev
Nov 28 2015 10:58
it should be fine then
Mario Mikočević
@mozgy
Nov 28 2015 10:58
try this example DHT and OTA
Me No Dev
@me-no-dev
Nov 28 2015 10:58
given that the cable is OK
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:58
hmmm
i should try another cable
d-anders
@d-anders
Nov 28 2015 10:58
do you have any hardware connected to nodemcu board?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 10:59
@d-anders, some sensors
@mozgy what does that code do?
Mario Mikočević
@mozgy
Nov 28 2015 10:59
nodemcu boards are working on 3.0V
reading DHT sensor and posting data on web
d-anders
@d-anders
Nov 28 2015 10:59
seperate power supply for those or are you using the usb?
Mario Mikočević
@mozgy
Nov 28 2015 11:00
so those 3.0V might not be enough juice
d-anders
@d-anders
Nov 28 2015 11:00
maybe try disconnecting the wires and see if it will stop the crashes
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:01
@d-anders i had done that and it kept crashing, but i'll try again
the iot-OTA thing can't find ArduinoOTA.h, where can i find that?
Mario Mikočević
@mozgy
Nov 28 2015 11:03
staging release
tho I ment to check WiFi related code, I had problems when I had code very similar like yours
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:05
oh, what was the solution?
Mario Mikočević
@mozgy
Nov 28 2015 11:05
then igrr posted an example and I based my code on his
a bit different check loop
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:05
ah
okay, i've changed cables, unplugged all the sensors and used the different wifi code
let's see
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:11
hmm, gcc complains on the empty WiFi.begin();
says it needs to accept parameters
Me No Dev
@me-no-dev
Nov 28 2015 11:11
do not use empty...
I saw it in example sketches and leads to lots of connection problems
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:13
well, changing the nodemcu, cable and code seems to have worked
let me try the old nodemcu with the new code and cable
by the way, do i need to do anything special to flash the firmware? i'm using platformio which generates a firmware.elf and flashes it with esptool
i mean do i need to do an initial flash of the arduino firmware or something?
Me No Dev
@me-no-dev
Nov 28 2015 11:15
no
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:15
thanks
Me No Dev
@me-no-dev
Nov 28 2015 11:15
it replaces what's on the flash anyways
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:15
right, i thought so
brutzler
@brutzler
Nov 28 2015 11:18
@all: may I ask again:
How do you ensure, that the ESP is still working proper?
I want to setup a little 24/7 controller for my warmwater-heating. And this "PLC" should not stop working.
Is there a need/possibility for a watchdog to reset the ESP in case of hanging? And how to recognize this?
Me No Dev
@me-no-dev
Nov 28 2015 11:18
wdt will reset if it hangs
make sure GPIOs are properrly pulled so you do not get into wrong boot mode
brutzler
@brutzler
Nov 28 2015 11:19
that means, I do not have to care. all is implemented internal?
ok GPIO is a good hint
Me No Dev
@me-no-dev
Nov 28 2015 11:19
implemented is not exactly what it is
but rather it reboots if something is keeping it locked for more than 10-20ms
brutzler
@brutzler
Nov 28 2015 11:21
ok, sounds good.
Will try this with a "bad loop"
but delay() should overrule this? (I know nobody should use the delay function)
Me No Dev
@me-no-dev
Nov 28 2015 11:22
do not delay :) delay will let the network run and wdt will not trigger
brutzler
@brutzler
Nov 28 2015 11:22
was only theoretical :-)
Me No Dev
@me-no-dev
Nov 28 2015 11:22
if you do
while(1);
it will reset
brutzler
@brutzler
Nov 28 2015 11:23
exactly this i mean with a "bad loop"
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:23
how do we feed the watchdog without a delay?
Me No Dev
@me-no-dev
Nov 28 2015 11:24
there are methods to change WDT but keep in mind it's there for a reason
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:24
i need to do some delay() for precise timings, will that cause problems?
i wouldn'
i wouldn't want a delayMicroseconds(10) delaying for 30
Me No Dev
@me-no-dev
Nov 28 2015 11:24
you can use optimistic_yield(10000); to have it delay only when needed
delayMicroseconds() does not let the network run
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:25
ah, thanks
Me No Dev
@me-no-dev
Nov 28 2015 11:25
only delay() does
brutzler
@brutzler
Nov 28 2015 11:25
For timing stuff I use the Ticker.h
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:25
i tried that, it kept crashing :(
Me No Dev
@me-no-dev
Nov 28 2015 11:26
@skorokithakis in the Timer interrupt routine you should only set a flag or do something really really quick
holding that interrupt is a big no
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:26
ah, i see
so no checking the sensors?
Me No Dev
@me-no-dev
Nov 28 2015 11:26
no
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:26
thanks
brutzler
@brutzler
Nov 28 2015 11:28
If I use the Ticker.h: Is there the same rule; only set a flag in the ticker subroutine, or can I put my code in it?
Me No Dev
@me-no-dev
Nov 28 2015 11:28
static bool tickerHasRun = false;
void onTicker(){
  tickerHasRun = true;
}

void loop(){
  if(tickerHasRun){
    tickerHasRun = false;
    //do what you need to do
  }
}
brutzler
@brutzler
Nov 28 2015 11:29
my way: good so?
```
// Instance of ticker-objects
Ticker tick_5000ms;
Ticker tick_2000ms;
Ticker tick_500ms;

void SetupTicker() {
 tick_5000ms.attach_ms(5000, T_5000ms);
 tick_2000ms.attach_ms(2000, T_2000ms);
 tick_500ms.attach_ms(500, T_500ms);
}

void T_5000ms() {
 //DEBUG_PRINTLN (F("Ticker 5000ms")); 
  Serial.println(ESP.getFreeHeap());
  LCD_main();
}
Me No Dev
@me-no-dev
Nov 28 2015 11:30
dangerous :)
brutzler
@brutzler
Nov 28 2015 11:30
why?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:30
can you attach multiple functions to one ticker?
d-anders
@d-anders
Nov 28 2015 11:30
move your code to the loop as in me-no-dev example
Me No Dev
@me-no-dev
Nov 28 2015 11:30
what does LCD_main(); do?
brutzler
@brutzler
Nov 28 2015 11:30
prints stuff on a I2C display
Me No Dev
@me-no-dev
Nov 28 2015 11:31
Ticker interrupt is a hardware one, which means that while ytou are in it, no other hardware interrupt can run
brutzler
@brutzler
Nov 28 2015 11:33
OK, then I should change to set flag in Ticker, and do code depending on flag in loop() ?
Me No Dev
@me-no-dev
Nov 28 2015 11:33
yes, that is the best way
brutzler
@brutzler
Nov 28 2015 11:33
Ok, even my old way would make code more readable.....
d-anders
@d-anders
Nov 28 2015 11:36
true, but it wont be too bad. set flags in the handlers and if you want to add a function called from the main loop which checks flags and acts
that way your loop will not be cluttered if that troubles you
Mario Mikočević
@mozgy
Nov 28 2015 11:37
I'm using Ticker the same as @me-no-dev
Me No Dev
@me-no-dev
Nov 28 2015 11:38
@brutzler I will guess that the LCD is an OLED SSD1306
updting such thing in interrupt it big danger :)
because it sends a byte for every 8 pixels
and that takes time over I2C even if running at MAX speed (700KHz)
d-anders
@d-anders
Nov 28 2015 11:43
they really should add a logic level converter on the next gen nodemcu boards
Me No Dev
@me-no-dev
Nov 28 2015 11:44
why?
d-anders
@d-anders
Nov 28 2015 11:44
to use 5v sensors quickly with no need for a veroboard or similar
and yes, im lazy
or are you brave enough to use 5v inputs?
Me No Dev
@me-no-dev
Nov 28 2015 11:46
I actually find myself using level converter much less often on the ESP than on 5V arduino
but I guess that is up to the sensor used
d-anders
@d-anders
Nov 28 2015 11:46
i have done that for short periods of time
Me No Dev
@me-no-dev
Nov 28 2015 11:46
inputs are easy with 2 resistors
d-anders
@d-anders
Nov 28 2015 11:46
for example ultrasonic sensors are usually 5v
yeah
2 resistors and some wires, sure
and outputs are usually ok on 3.3v
Me No Dev
@me-no-dev
Nov 28 2015 11:47
yes
d-anders
@d-anders
Nov 28 2015 11:47
but still
Me No Dev
@me-no-dev
Nov 28 2015 11:47
3.3V is HIGH on 5V boards
d-anders
@d-anders
Nov 28 2015 11:48
so either resistors on board or a cd4050 or something
Me No Dev
@me-no-dev
Nov 28 2015 11:48
I believe things are steadily moving to 3.3V
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:48
hmm, looks like my thing crashes when i put it on the breadboard
Me No Dev
@me-no-dev
Nov 28 2015 11:49
and AVRs run just fine at 16MHz 3.3V
d-anders
@d-anders
Nov 28 2015 11:49
yeah, but still quite many old things left which were used on 5v arduinos etc
Me No Dev
@me-no-dev
Nov 28 2015 11:49
if you read the datasheets you might find that they work fine on 3.3V :)
d-anders
@d-anders
Nov 28 2015 11:50
also on the next gen boards they really should have a pins with vin/vusb
Me No Dev
@me-no-dev
Nov 28 2015 11:50
as I have found lots of hardware that is happy at 5V even though advertised as 3.3V
d-anders
@d-anders
Nov 28 2015 11:50
yeah
brutzler
@brutzler
Nov 28 2015 11:50
@me-no-dev: No, actually its only a 2004 display
d-anders
@d-anders
Nov 28 2015 11:50
hcr-s04 i never got to work on 3.3v
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:51
wait
i'm plugging in my 5v sensors to the vin
for a nodemcu
is that wrong?
d-anders
@d-anders
Nov 28 2015 11:51
no thats fine
Me No Dev
@me-no-dev
Nov 28 2015 11:51
depends on the output level of the sensor
d-anders
@d-anders
Nov 28 2015 11:51
you can use vin
Me No Dev
@me-no-dev
Nov 28 2015 11:51
but vin is 5V
d-anders
@d-anders
Nov 28 2015 11:51
just dont connect them directly to digital io
brutzler
@brutzler
Nov 28 2015 11:52
the idea from d-anders is good! a I2C levelconverter already on the nodemcu would be great. I always have to add one manually....
Me No Dev
@me-no-dev
Nov 28 2015 11:52
@brutzler you got the point of why it should be something quick though, right?
@brutzler @d-anders the problem is that you can not remove it :)
once on the board, it's there
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:53
@d-anders what do you mean about the digital io?
you mean the output, if it's 5v?
d-anders
@d-anders
Nov 28 2015 11:53
the inputs on esp8266 are for 3.3v
Stavros Korokithakis
@skorokithakis
Nov 28 2015 11:53
right
let me check what their outputs are
d-anders
@d-anders
Nov 28 2015 11:54
most 5v sensors will output 5v, dangerous
Me No Dev
@me-no-dev
Nov 28 2015 11:54
what I would like is next nodemcu to label the GPIOs correctly
d-anders
@d-anders
Nov 28 2015 11:54
yes!
oh the horror i had with that
Me No Dev
@me-no-dev
Nov 28 2015 11:54
and replace the LDO with more proper power
d-anders
@d-anders
Nov 28 2015 11:55
i connected my ds18b20 to a stupid pin
brutzler
@brutzler
Nov 28 2015 11:55
@me-no-dev why remove? define two GPIOS for I2C. using this for 3,3V. And then parallel a levelshifter. Using normal GPIOs for 3,3V I2C-components, and using the levelshifter for 5V. And if no 5V: don't use it.
Mario Mikočević
@mozgy
Nov 28 2015 11:55
to GPIO16 ? :D
d-anders
@d-anders
Nov 28 2015 11:56
yes, parallell pins but maybe not too many because it takes up space
Me No Dev
@me-no-dev
Nov 28 2015 11:56
@brutzler imagine the size of the board :)
d-anders
@d-anders
Nov 28 2015 11:56
maybe level shifting on a couple of pins only
Mario Mikočević
@mozgy
Nov 28 2015 11:56
@brutzler that defies GP in GPIO tho
brutzler
@brutzler
Nov 28 2015 11:56
come on... two pins more....
Harrison Mclean
@h4rm0n1c
Nov 28 2015 11:56

A lot of I2C devices will actually only pull down to ground for zero, as in, they need pullups to VCC, which means you can use 5v i2c devices.

I've used the DS1307 on the esp8266 naked, you just pull up to 3.3v instead of 5, since it's still above the 2.0v ttl high level, it works.

d-anders
@d-anders
Nov 28 2015 11:56
@h4rm0n1c yes
the cheap ultrasonic sensors will not work that way though
for example
brutzler
@brutzler
Nov 28 2015 11:57
@mozgy yes, then GPIOs for I2C are fix. Thats the bad site
Harrison Mclean
@h4rm0n1c
Nov 28 2015 11:58
ah. good to know.
Mario Mikočević
@mozgy
Nov 28 2015 11:58
crap, they release new eagle, still buggy libraries ..
Harrison Mclean
@h4rm0n1c
Nov 28 2015 11:58
7?
Mario Mikočević
@mozgy
Nov 28 2015 11:59
7.5.0 is out
d-anders
@d-anders
Nov 28 2015 11:59
also i would prefer if the pins were upside down on the nodemcu board
becuase i usually dont mount it on a prototypin board
brutzler
@brutzler
Nov 28 2015 12:01
@d-anders never saw this as a problem, because i plug the NodeMCU on a board (stripe-proto) with screw-terminals (RM2,54)
d-anders
@d-anders
Nov 28 2015 12:02
yeah
for quick things i usually just connect with duponts though
and then the pins would be better placed upside down
brutzler
@brutzler
Nov 28 2015 12:05
proto.jpg
Mario Mikočević
@mozgy
Nov 28 2015 12:06
cute
brutzler
@brutzler
Nov 28 2015 12:06
Look above:
NodeMCU with I2C levelshifter
If something dies.... easy to exchange...
d-anders
@d-anders
Nov 28 2015 12:09
:)
siedi
@siedi
Nov 28 2015 12:10
is there any library/example for remote debugging? Having a telnet server which prints the debug messages instead to Serial to the connected client (if one is connected)
Me No Dev
@me-no-dev
Nov 28 2015 12:13
not yet and not that easy to do :)
debug output works with single chars and sendin one byte per network packet is a killer
siedi
@siedi
Nov 28 2015 12:15
ok, so I write a "wrapper" function (using a define macro for my debug prints anyways) which sends the output to serial.print + client.write if connected. should work, shouldn't it?
Me No Dev
@me-no-dev
Nov 28 2015 12:15
yes
siedi
@siedi
Nov 28 2015 12:15
thx
Me No Dev
@me-no-dev
Nov 28 2015 12:16
client is the same as serial in terms of API
siedi
@siedi
Nov 28 2015 12:16
cool, I'll have a look
Me No Dev
@me-no-dev
Nov 28 2015 12:16
try not to use client.write(char)
because that will send a packet for each char
siedi
@siedi
Nov 28 2015 12:16
I see
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:22
ooh
gitter has IRC
this is nice
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:37
it's official
the nodemcu hates my breadboard
when i disconnect it, it works fine
what sorcery is this?
Me No Dev
@me-no-dev
Nov 28 2015 12:38
can you take a picture of it?
we ruled out software, let's see the hardware
:)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:38
sure
how do i post a photo here?
Me No Dev
@me-no-dev
Nov 28 2015 12:39
just drag it in the window
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:39
i'm using an irc client, let me install the mobile app
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:46
any insight? :smile:
Mario Mikočević
@mozgy
Nov 28 2015 12:49
thats first release of v1.0 nodemcu (by Amica), should work
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:49
what's the latest release?
Mario Mikočević
@mozgy
Nov 28 2015 12:49
this release is the best v1.0 IMNHO
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:49
ah
well, whenever i connect it to the breadboard, it crashes
Mario Mikočević
@mozgy
Nov 28 2015 12:50
pinned breadboard ?
I b0rked one :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:51
i connected it to the other side, same thing :/
Mario Mikočević
@mozgy
Nov 28 2015 12:51
ok, it works if you just plug USB in ?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:52
yep
Me No Dev
@me-no-dev
Nov 28 2015 12:52
@skorokithakis there is no logical explanation
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:53
i know :(
Me No Dev
@me-no-dev
Nov 28 2015 12:53
you show a blank breadnoard with just the nodemcu plugged
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:53
indeed
Me No Dev
@me-no-dev
Nov 28 2015 12:53
if it works unplugged there is no reason to not work plugged
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:53
yeah :(
Mario Mikočević
@mozgy
Nov 28 2015 12:53
it is, b0rked breadboard :(
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:54
all of it? i tried different positions and see the same thing
Me No Dev
@me-no-dev
Nov 28 2015 12:54
unless there is a short on the breadboard which is not something I have seen
can be checked if you remove the sticky tape underneath and expose all metal parts
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:57
ah, let me check that
Mario Mikočević
@mozgy
Nov 28 2015 12:57
20151128_135504.jpg
my current collection -
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:57
are the top and bottom ones different?
Mario Mikočević
@mozgy
Nov 28 2015 12:57
yep
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:57
what's the difference?
Mario Mikočević
@mozgy
Nov 28 2015 12:58
power supply
LDO
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:58
are they different versions?
i have the bottom one
Sven Eliasson
@comino
Nov 28 2015 12:58
Is there actually any version with valid fcc?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 12:58
don't they all have valid fcc?
Sven Eliasson
@comino
Nov 28 2015 12:59
afaik they just claim to have one - but since there is no fcc number on it its not legal to sell like this
(in a real product)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:00
looks like 0024160509
hm
afaik, all the esps are fcc certified
Sven Eliasson
@comino
Nov 28 2015 13:01
you cant certify a chip - just a module
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:02
yeah, that's the certification for the esp12
Sven Eliasson
@comino
Nov 28 2015 13:09
as far as I understood it the esp12 may have a cetification, but since you (or better AI Thinker) adds a antenna the module it self needs a seperate FCC. And this number must be visible on the module - on my NodemCU there is no number. But I think for just hacking around you dont need a fcc ;)
Me No Dev
@me-no-dev
Nov 28 2015 13:10
nodemcu's ESP modules have different board layout than all of the rest ESP-12s
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:11
oh hmm
Me No Dev
@me-no-dev
Nov 28 2015 13:11
it's not just the Flash that is different
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:11
as far as i know, as long as you don't alter the module, the certification stands, but i didn't know nodemcu altered theirs
Sven Eliasson
@comino
Nov 28 2015 13:12
FCC of ESP-12 is aproved!
actually I had a hour long discussion with the german twin of fcc
As long as you dont produce tousands its a "grey" zone
So there is a certificate - im all wrong ;) its certified
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:15
yep
ugh, now it won't connect to the wifi, with no code changes :( this is so frustrating
in comparison, the arduinos just work
Sven Eliasson
@comino
Nov 28 2015 13:17
(I also have issues with wifi :/ )
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:18
:(
it used to work fine until now, but i didn't change anything
Sven Eliasson
@comino
Nov 28 2015 13:22
Can you post the relevant code? Maybe just a hickup ;)
Mario Mikočević
@mozgy
Nov 28 2015 13:23
darn, installed new eagle and gnd pads are very wrong now ..
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:27
comino: the code is just this: http://dpaste.com/2H0CTD8
Sven Eliasson
@comino
Nov 28 2015 13:35
Do you ever call Wifi.begin() before that function ?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:38
comino: no
Sven Eliasson
@comino
Nov 28 2015 13:38
uint8_t ESP8266WiFiClass::waitForConnectResult(){ if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled return WL_DISCONNECTED; while (status() == WL_DISCONNECTED) delay(100); return status(); }
this loop waits for WL_CONNECTED - you never enter your while loop I think
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:39
i used this example that the guys here pointed me to:
Sven Eliasson
@comino
Nov 28 2015 13:39
oh my bad . let me test in on my board
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:40
it used to work a few minutes ago
then i removed the nodemcu from the breadboard and it doesn't
:(
Mario Mikočević
@mozgy
Nov 28 2015 13:40
there is one more wifi.begin in my example
Sven Eliasson
@comino
Nov 28 2015 13:41
but actually on my board it works oO
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:42
mozgy: the one without the parameters? someone suggested i don't use that because there are problems, and it wouldn't compile without parameters anyway
Mario Mikočević
@mozgy
Nov 28 2015 13:42
  WiFi.mode( WIFI_STA );
  WiFi.begin( );
  while ( WiFi.waitForConnectResult() != WL_CONNECTED ){
     WiFi.begin( ssid, pass );
     Serial.println( "Retrying connection..." );
  }
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:42
yeah, that wouldn't compile for me
Mario Mikočević
@mozgy
Nov 28 2015 13:43
#include <ESP8266WiFi.h>
it should compile
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:43
that's already in there, there's no begin() without parameres
s/parameres/parameters/
Mario Mikočević
@mozgy
Nov 28 2015 13:44
what is the compile error ?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:44
hmm, wait a minute, my chromecast can't connect to the wifi either
Sven Eliasson
@comino
Nov 28 2015 13:45
:,D
Mario Mikočević
@mozgy
Nov 28 2015 13:45
stable or staging release ?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:46
mozgy: i'm not sure, i use platformio
Mario Mikočević
@mozgy
Nov 28 2015 13:46
uh, never heard of it
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:46
it's just a cli application to compile and flash easily
wraps esptool and xtensa gcc
how do you compile? arduino ide?
Mario Mikočević
@mozgy
Nov 28 2015 13:47
yep, arduino ide
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:48
esp_iot_sdk_v1.2.0_15_07_03, it says
hmm
that's ancient
and 10605 for the arduino sdk
Chris Elsworth
@celsworth
Nov 28 2015 13:55
@skorokithakis, the 1.2 sdk in platformio is only used if you're using the native platform
look in ~/.platformio/packages/framework-arduinoespressif/sdk instead, its 1.3.0
since it uses this project for that framework setup, it will mirror whatever sdk this project currently uses
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:56
celsworth: right, i just replaced all that with the latest, let me recompile
i may have borked it, i put the 1.4.0 sdk there
yep, borked
Chris Elsworth
@celsworth
Nov 28 2015 13:57
I suspect there's a good reason this project didn't go to 1.4.0, I think it has issues :)
hopefully 1.5.0 is adopted soon though
Mario Mikočević
@mozgy
Nov 28 2015 13:57
1.4.0 has problems
even arduino ide is still at 1.3.0. igrr will know a lot more
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:58
15:58:07 $ cat ~/.platformio/packages/framework-arduinoespressif/sdk/version
1.2.0_15_07_03⏎ y
i'm not sure how to upgrade it :/
Sven Eliasson
@comino
Nov 28 2015 13:58
is 1.5 out yet? Its not on expressiv´s page
Chris Elsworth
@celsworth
Nov 28 2015 13:58
oh I am on platformio git HEAD
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:59
ah
Chris Elsworth
@celsworth
Nov 28 2015 13:59
you might try that :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 13:59
i'll install that
Sven Eliasson
@comino
Nov 28 2015 14:00
:D thanks
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:00
okay, there seems to be a problem with my router as well, as the chromecast isn't connecting
let me rejoin
Mario Mikočević
@mozgy
Nov 28 2015 14:01
ooh, 1.5 is out :) groowy
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:03
still 1.2 :/
Chris Elsworth
@celsworth
Nov 28 2015 14:04
in ~/.platformio/packages/framework-arduinoespressif/sdk ?
remember packages/sdk-esp8266 isn't used if you're using arduino framework
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:05
$ platformio --version
PlatformIO, version 2.3.6.dev3

$ cat ~/.platformio/packages/framework-arduinoespressif/sdk/version 
1.2.0_15_07_03
Chris Elsworth
@celsworth
Nov 28 2015 14:05
hm I wonder if I checked out git HEAD of esp8266/Arduino as well
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:05
hm
Mario Mikočević
@mozgy
Nov 28 2015 14:05
nice -> Add new function, WPA2-Enterprise is supported.
Chris Elsworth
@celsworth
Nov 28 2015 14:06
yeah I did.. if you clone the git HEAD of this repo and put it in framework-arduinoespressif, you can get 1.3 then
you just have to move tools/sdk into sdk
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:06
let me try that
Chris Elsworth
@celsworth
Nov 28 2015 14:06
(and make a version.txt or platformio complains)
that's what I'm currently using so I can use Wifi.persistent() in platformio compiles
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:08
how does WiFi.persistent() work?
Chris Elsworth
@celsworth
Nov 28 2015 14:08
it just doesn't write the ssid/password into flash
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:08
great, that seems to work
Chris Elsworth
@celsworth
Nov 28 2015 14:08
calls an alternate sdk function to set it for the current boot only
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:08
oh
ah, i don't mind it getting written into flash
Chris Elsworth
@celsworth
Nov 28 2015 14:08
the problem is it writes it on every boot, whether its changed or not = flash wear
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:09
oh hm
Chris Elsworth
@celsworth
Nov 28 2015 14:09
there's a ticket about it, let me find..
#1054
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:10
esp8266/Arduino#1054
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:16
celsworth: hmm, how do you use the persistent option?
@celsworth or is it enabled by default?
Chris Elsworth
@celsworth
Nov 28 2015 14:17
its just a new function - WiFi.persistent(false) before your WiFi.mode() etc
then anything you pass to WiFi.begin() isn't saved
I don't think its enabled by default atm
yep defaults to persistent(true), so saves it
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:18
but he's also checking if the config is the same and doesn't rewrite
so you don't really need to do anything different to avoid ear
ear = wear
Chris Elsworth
@celsworth
Nov 28 2015 14:18
I think that is also a recent commit
but yes its better than it used to be
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:18
yep
Chris Elsworth
@celsworth
Nov 28 2015 14:19
yeah I see it, sta_config_equal()
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:19
yep
so this is in the latest arduino core i just pulled, right?
Chris Elsworth
@celsworth
Nov 28 2015 14:19
yep
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:20
ugh, now i get "ets Jan 8 2013,rst cause:2, boot mode:(3,6)"
not to mention there's a bug that doesn't set the uart rate
Chris Elsworth
@celsworth
Nov 28 2015 14:20
I haven't seen that uart bug
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:21
I do Serial.begin(57600) and the rate is 115200
wow, you can do OTA update?
Mario Mikočević
@mozgy
Nov 28 2015 14:22
yep, OTA is nice
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:23
how do you send the firmware over? is there any documentation?
Mario Mikočević
@mozgy
Nov 28 2015 14:23
cause:2 is pulling RST to GND
Chris Elsworth
@celsworth
Nov 28 2015 14:23
I haven't got OTA to work so well yet :( I need to try and make reproduceable error ot debug it
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:23
ah
Chris Elsworth
@celsworth
Nov 28 2015 14:24
mostly the problem I get is it doesn't cleanly reboot after flash, so its hung until you poke it manually to reset it
Mario Mikočević
@mozgy
Nov 28 2015 14:24
several ways, tru IDE upload, httpget
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:25
that's great, where can i find the docs on it?
i see them in the repo, but i don't know where the web version is
Chris Elsworth
@celsworth
Nov 28 2015 14:25
espota.py seemed the simplest no-hassle way to me, especially if you don't use Arduino IDE
Mario Mikočević
@mozgy
Nov 28 2015 14:25
@celsworth that too :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:27
does anyone know where the docs for ota are?
oh,
Mario Mikočević
@mozgy
Nov 28 2015 14:30
@skorokithakis that my sketch I linked before does OTA
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:33
mozgy: i noticed the letters but i didn't know it was a thing, so i figured it was something else
is the typo actually like that? OTA_RECIEVE_ERROR
ah, it is
onkelfunny
@onkelfunny
Nov 28 2015 14:35

hi @all i have a question about the plan modes.

WiFi.mode(WIFI_AP);
WiFi.begin("abcd", "abcd");
Serial.println(WiFi.getMode());

after WiFi.begin the mode is WIFI_AP_STA

is this correct?
Markus
@Links2004
Nov 28 2015 14:46
yes
AP means opening an AP on the ESP
if you want to connect to you router you need STA mode.
onkelfunny
@onkelfunny
Nov 28 2015 14:47
the mode AP is ok. but if i call the begin function the mode is WIFI_AP_STA
why not WIFI_AP
Markus
@Links2004
Nov 28 2015 14:48
WiFi.begin is to connect to an router (STA mode) the begin change the mode so it can work.
if you want to open an AP you need to call WiFi.softAP
Stavros Korokithakis
@skorokithakis
Nov 28 2015 14:57
:(
how do i debug things :( now it's crashing on startup
Chris Elsworth
@celsworth
Nov 28 2015 15:00
you can use the pointer it crashes at and dump what is at taht location in your elf binary
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:01
oh, how?
Chris Elsworth
@celsworth
Nov 28 2015 15:02
erm, I'll have to look this up, I saw it mentioned a few days ago in a ticket or something :)
something like..
~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-objdump -x firmware.elf
then grep for the 40xxxx location in your crash
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:03
ah, thank you
it's not actually crashing :/ it just says: ets Jan 8 2013,rst cause:4, boot mode:(1,7); wdt reset
and then freezes
Chris Elsworth
@celsworth
Nov 28 2015 15:07
with a really simple sketch that can't cause issues? ie just a Serial print in setup() or something? :)
not sure what the numbers in rst cause and boot mode are, I need a cheat sheet on my monitor with them :D
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:08
let me check
Rohit Yermalkar
@romuye123
Nov 28 2015 15:08

@romuye123

include <Ticker.h>

Ticker tmr;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
tmr.attach(1.0,tim_check);
}
void tim_check(){
Serial.println("check");
}

void loop() {
// put your main code here, to run repeatedly:
Serial.println("loop");
}
this code crashes
keeps on printing loop
and after few second crash

Chris Elsworth
@celsworth
Nov 28 2015 15:08
hm they seem to be the states of some gpios
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:09
looks to me like the interrupt takes too long
Chris Elsworth
@celsworth
Nov 28 2015 15:10
@skorokithakis some info on the boot mode() in https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:10
@celsworth yeah, even just a Serial.println() in setup freezes it
Chris Elsworth
@celsworth
Nov 28 2015 15:10
rst cause 4 is wdt reset
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:10
hm :/
Chris Elsworth
@celsworth
Nov 28 2015 15:11
you're sure all your gpios are pulled correctly?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:11
i'm using a nodemcu, it should
this happened after the upgrade to the latest HEAD of the arduino repo
Chris Elsworth
@celsworth
Nov 28 2015 15:12
maybe there is more info on UART1
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:13
let me just clear everything first and flash something else
it says rst cause 2, rst cause 4, wdt reset
Chris Elsworth
@celsworth
Nov 28 2015 15:15
2 is reset pin, 4 is wdt
boot mode (1, x) indicates its in flash mode I think? you want 3 for normal boot
Chris Elsworth
@celsworth
Nov 28 2015 15:18
ah good link :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:23
hmm, i'm not sure how these are even set
i'm just connecting the nodemcu to usb
rst cause 2, but the reset pin is unconnected
where can i find the release commit of the arduino sdk?
i mean stable
it doesn't look like there's a tag on the repo
Mario Mikočević
@mozgy
Nov 28 2015 15:32
@skorokithakis try this sketch ->
/*
 ESP8266 CheckFlashConfig by Markus Sattler

 This sketch tests if the EEPROM settings of the IDE match to the Hardware

 */

void setup(void) {
    Serial.begin(115200);
}

void loop() {

    uint32_t realSize = ESP.getFlashChipRealSize();
    uint32_t ideSize = ESP.getFlashChipSize();
    FlashMode_t ideMode = ESP.getFlashChipMode();

    Serial.printf("Flash real id:   %08X\n", ESP.getFlashChipId());
    Serial.printf("Flash real size: %u\n\n", realSize);

    Serial.printf("Flash ide  size: %u\n", ideSize);
    Serial.printf("Flash ide speed: %u\n", ESP.getFlashChipSpeed());
    Serial.printf("Flash ide mode:  %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));

    if(ideSize != realSize) {
        Serial.println("Flash Chip configuration wrong!\n");
    } else {
        Serial.println("Flash Chip configuration ok.\n");
    }

    delay(60000);
}
thats my first debug sketch in case of module problems
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:36
ah, that's good, thanks. i'm bisecting right now, HEAD is bad
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:42
is there a way to make a sparse image? i don't want to upload 1 mb every time
Markus
@Links2004
Nov 28 2015 15:44
you can erase the flash python esptool.py --port COM3 --baud 76800 erase_flash
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:46
i mean i want to make my images be smaller, not erase the flash
the compiled images
this is why my NodeMCU build won't work: esp8266/Arduino#1101
Markus
@Links2004
Nov 28 2015 15:50
what build error do you get?
the commit is old, I have runing several ESP modules at latest git just fine.
but i dont one a NodeMCU to test but on there shut be a ESP12 which a have many working.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:50
a build error where? the errors i get are in the ticket
i know the commit is old, no commit after that one works
Markus
@Links2004
Nov 28 2015 15:51
k then i misunderstood some thing.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:51
it compiles and works fine, it just crashes the nodemcu
Markus
@Links2004
Nov 28 2015 15:52
ets Jan 8 2013,rst cause:2, boot mode:(1,7)
indicates that you are in boot loader mode, so your sketch will never run.
with what terminal do you open the serial connection?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:52
picocom
picocom /dev/ttyUSB0 --baud 115200
how can i debug a crash with objdump? where's the address i should look for?
Exception (0): epc1=0x40107070 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
Chris Elsworth
@celsworth
Nov 28 2015 15:54
the epc1 value
Markus
@Links2004
Nov 28 2015 15:54
0x40107070 and excvaddr indecates its a null prt problem.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:54
thanks
hm
ah, looks like digitalRead is where the crash happens
so many problems :(
Markus
@Links2004
Nov 28 2015 15:55
can picocom control the DTR / RTS manually?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:56
hmm, i don't know what those are
looks like it can
says it can pulse and toggle DTR
Markus
@Links2004
Nov 28 2015 15:57
they are used to reset the ESP and control the bootmode
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:57
ah
Markus
@Links2004
Nov 28 2015 15:58
for nodeMCU:
blob
blob
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:59
hmm, i'm not sure what to do with those :/
all i know is that, after that commit, it doesn't boot
Markus
@Links2004
Nov 28 2015 15:59
no RTS control?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 15:59
doesn't look like it
Markus
@Links2004
Nov 28 2015 15:59
ok then its hard to get out of the bootloader mode.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:00
hm
i'm just staying on a good commit for now
i've spent two days just trying to get this to connect to wifi
i'm about to just give up and use an arduino
Markus
@Links2004
Nov 28 2015 16:01
right now i not see how the commit can fact the booting, may @igrr can give you a hint.
or you nodeMCU board is simply damaged.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:02
i tried two different boards, same thing
@Links2004 yeah, it doesn't look like that commit has anything relevant, but i can reproduce this reliably
Markus
@Links2004
Nov 28 2015 16:04
have you tried to not use platformio and use the IDE direct?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:05
no, the ide has different versions of things
let me try it
yeah, the ide seems to work
i just need to figure out the version it runs
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:12
i just copied the arduino esp8266 dir to platformio
yeah, doing that seems to work
Chris Elsworth
@celsworth
Nov 28 2015 16:14
stable or staging or git?
stable is from June, staging is a couple of weeks old iirc
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:16
whatever is in arduino, but i downloaded the archive from the json url
it seems to work, even on the breadboard
Chris Elsworth
@celsworth
Nov 28 2015 16:16
yeah but there's two json urls :)
staging was updated Nov 24th, if that works and platformio doesn't there's something odd goign on
cos it certainly has the commit that broke things for you before
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:20
hm
i'm not sure which one it is that works, it's whatever the arduino ide downloaded
Chris Elsworth
@celsworth
Nov 28 2015 16:22
what url did you use for the json?
see in the middle of it, there's either stable or staging
Chris Elsworth
@celsworth
Nov 28 2015 16:23
right :) stable :)
hasn't got the commit that broke things, so this is no surprise
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:23
right
but it also works with the breadboard
so basically it just works
(finally, after two days)
works with wifi, mqtt
Chris Elsworth
@celsworth
Nov 28 2015 16:24
awesome :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:24
yes :(
thank you for the help!
Mario Mikočević
@mozgy
Nov 28 2015 16:30
nice, glad that it isnt broke :)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:31
me too!
hey, do you guys know how i can pass an IP to mqtt to connect?
it's something like {192, 168, 10, 1}
but i can't get the type right
Chris Elsworth
@celsworth
Nov 28 2015 16:37
byte ip[] = {1,2,3,4}; ?
some people write ip[4] but I think the compiler will make exactly the same code out of it
Harrison Mclean
@h4rm0n1c
Nov 28 2015 16:41
justcompilerthings, lol.
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:45
is there any way to have that in a define and not as a variable? I tried (byte[]) {1, 2, 3, 4} but it didn't work
i want to do #define MQTT_SERVER {1, 2, 3, 4}
Markus
@Links2004
Nov 28 2015 16:49
 #define MQTT_SERVER {1, 2, 3, 4}

byte ip[] =MQTT_SERVER;
shut do the jop
Stavros Korokithakis
@skorokithakis
Nov 28 2015 16:51
ah, that works, thanks
Rohit Yermalkar
@romuye123
Nov 28 2015 17:22
hello everyone trying to run triac based dimmer
using this program
the FADER program works fine, but the program crashes if I keep one stable value
for example 0 or 128
what could be the reason ?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:23
what's the output?
Rohit Yermalkar
@romuye123
Nov 28 2015 17:23
WDT SOFT RESET
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:23
looks like you aren't feeding the watchdog
Rohit Yermalkar
@romuye123
Nov 28 2015 17:24
what should i do ?
Sven Eliasson
@comino
Nov 28 2015 17:24
add ESP.wdtFeed()
Rohit Yermalkar
@romuye123
Nov 28 2015 17:24
in loop ?
Sven Eliasson
@comino
Nov 28 2015 17:24
or yield()
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:24
yes
can you paste the loop?
Rohit Yermalkar
@romuye123
Nov 28 2015 17:25
wait a sec

void setup()
{
Serial.begin(115200);
delay(10);
pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
digitalWrite(AC_LOAD,LOW);
// Serial.setDebugOutput(true);
//pinMode(inPin,INPUT_PULLUP);
attachInterrupt(inPin, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above

dimming = 100;
}

//the interrupt function must take no parameters and return nothing
void zero_crosss_int() //function to be fired at the zero crossing to dim the light
{
// Firing angle calculation : 1 full 50Hz wave =1/50=20ms
// Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle)
// For 60Hz => 8.33ms (10.000/120)
// 10ms=10000us
// (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65

Serial.println("Zero cross detected");
int dimtime = (75*dimming); // For 60Hz =>65
Serial.println(dimtime);
delayMicroseconds(dimtime); // Wait till firing the TRIAC
digitalWrite(AC_LOAD, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay (for 60Hz use 8.33)
digitalWrite(AC_LOAD, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
Serial.println("Done");
}

void loop() {

delay(10);
}

here is my program
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:26
jeez
use a pastebin man
Rohit Yermalkar
@romuye123
Nov 28 2015 17:26
oops
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:26
you can also format it for pasting here
with:
code
use ``` at the start and end
but a pastebin is better if it's this long
Rohit Yermalkar
@romuye123
Nov 28 2015 17:27
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:27
you shouldn't put a function that long in the interrupt
if i'm not mistaken
Sven Eliasson
@comino
Nov 28 2015 17:28
yep
Rohit Yermalkar
@romuye123
Nov 28 2015 17:28
this is the same function i copied from the URL
please suggest
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:28
although, @comino, is that the best way to detect a rising edge? i need to do that too, and right now i just do "if previousEdge == 0 && currentEdge == 1"
@romuye123, make the interrupt set a flag, and then check it in the loop
Rohit Yermalkar
@romuye123
Nov 28 2015 17:30
sorry did not get you
i am newbie
will you pls explain
like here
oh moment
forgot something ;)
Rohit Yermalkar
@romuye123
Nov 28 2015 17:30
ok
basicly - a interrupt should just set a flag and you check in the loop() if the flag is set
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:32
actually, i generally prefer just checking if the previous state is 0 and the current is 1, as it requires only one variable and no extra functions
interrupts are too much code (not really that much, just more than the alternative)
Rohit Yermalkar
@romuye123
Nov 28 2015 17:32
ok let me try this quickly
Sven Eliasson
@comino
Nov 28 2015 17:32
yeah that possible too
maybe esier if you are new
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:33
@comino do you find 115200 baud to be reliable? i've found one step down to be more reliable
Sven Eliasson
@comino
Nov 28 2015 17:33
I never had problems with it
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:34
ah thanks
Rohit Yermalkar
@romuye123
Nov 28 2015 17:34
even i never had problems with 115200
Sven Eliasson
@comino
Nov 28 2015 17:34
With some serial adapters I can go up to 512k
Rohit Yermalkar
@romuye123
Nov 28 2015 17:34
@comino : still facing crash
here is the serial monitor output
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:35
can you paste your code again?
Rohit Yermalkar
@romuye123
Nov 28 2015 17:35
ok hold on
here is my updated code
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:36
needs to be attachInterrupt(inPin, buttonPressend, RISING);
brutzler
@brutzler
Nov 28 2015 17:36
Does anybody know, if I can use a "PCF8574T I/O Module" (I2C Port extender) in mixed mode e.g. 6Input+2xOutput
Sven Eliasson
@comino
Nov 28 2015 17:36
attachInterrupt(inPin, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
zero_crosss_int -> buttonPressed
Rohit Yermalkar
@romuye123
Nov 28 2015 17:36
ok ok
Sven Eliasson
@comino
Nov 28 2015 17:38
what happen is - when u press the button, the "buttonPressed" function is executed and just sets the flag to true. In the loop() you check for this flag
Rohit Yermalkar
@romuye123
Nov 28 2015 17:39
just tried the code
the code does not crashed now
but facing flicker on LAMP
Sven Eliasson
@comino
Nov 28 2015 17:40
But as skorokithakis mentioned - it might be esier for you if you just put the zero_cross_int() into the loop and check manually if the pin value changed
Rohit Yermalkar
@romuye123
Nov 28 2015 17:41
good news is program is not crashing now
but there is flicker
on AC LOAD
how to check manually if pin value change ?
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:45
if (previousPin == LOW && digitalRead(pin) == HIGH) {
    previousPin = HIGH;
    your_code_here();
} else {
    previousPin == digitalRead(pin)
}
something like that
Harrison Mclean
@h4rm0n1c
Nov 28 2015 17:45
you've got a 10 millisecond delay in loop() that you're not accounting for. That's a lot of time for an AC waveform, 1/2 a cycle, that'd be the reason if any I think.
Rohit Yermalkar
@romuye123
Nov 28 2015 17:46
10ms delay should not be there ?
Markus
@Links2004
Nov 28 2015 17:47
10us are 0.01ms
delayMicroseconds
have you wifi aktive?
Sven Eliasson
@comino
Nov 28 2015 17:49
void loop()  {
if(buttonFlag){
  buttonFlag= false;
  zero_crosss_int();
}
  delay(10);
 // ESP.wdtFeed();
}
remove delay(10)
still it will add another delay
which is not intended
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:53
@comino why will it add a delay?
oh, you mean because of the interrupt and loop?
Sven Eliasson
@comino
Nov 28 2015 17:53
yeah
Mario Mikočević
@mozgy
Nov 28 2015 17:53
whoa, made a mishap in my PCB and OSHPark canceled order on my request without any problem, big thumb up !
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:54
i really need to learn how to make PCBs :9
:(
i'm making a home sensor board and a breadboard is very inconvenient
Sven Eliasson
@comino
Nov 28 2015 17:54
Its not that hard ;)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:54
i don't know man
i watched a video for eagle and the dude made it sound like you could make a thousand mistakes with the layers and vias and everything
Mario Mikočević
@mozgy
Nov 28 2015 17:54
Eagle ftw !
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:55
he was teaching eagle, but not how to make PCBs
and something tells me i'd spend $20 and wait for a month to get them back from china only to realize i crossed two wires or something
Sven Eliasson
@comino
Nov 28 2015 17:55
yeah you can do a lot of mistakes, but very few will cause everything to burn :P
Stavros Korokithakis
@skorokithakis
Nov 28 2015 17:55
haha
so i'll only be homeless a few times? :tongue:
Mario Mikočević
@mozgy
Nov 28 2015 17:56
giggle
Sven Eliasson
@comino
Nov 28 2015 17:56
yolo
Markus
@Links2004
Nov 28 2015 17:57
eagle will warn you for every short you make :)
the impotent part is to make the schematic valide.
the rest is like a puzzle
Mario Mikočević
@mozgy
Nov 28 2015 17:57
pondering .. to add or not - autoreset onto my next PCB
exactly @Links2004 , like LEGO :)
Markus
@Links2004
Nov 28 2015 17:59
if you want to use the IDE serial monitor then you need this if you use a better terminal you can use it like this:
Rohit Yermalkar
@romuye123
Nov 28 2015 17:59
Wifi is not active
The lamp is blinking,
It should be at a steady value
Mario Mikočević
@mozgy
Nov 28 2015 18:01
@Links2004 already have PCBs with that, does not work always
Markus
@Links2004
Nov 28 2015 18:02
for me its working fine have it at all my PCBs like that.
Mario Mikočević
@mozgy
Nov 28 2015 18:02
even with RESET to GPIO16 ?
Sven Eliasson
@comino
Nov 28 2015 18:02
you might add some more caps ;)
Markus
@Links2004
Nov 28 2015 18:05
@mozgy yes no problems, the FTDI runs in open drain mode by default.
blob
@comino there are more then one ;)
blob
Sven Eliasson
@comino
Nov 28 2015 18:06
What valuse do you have for C4/C5 ?
Markus
@Links2004
Nov 28 2015 18:07
C4 220uF and C5 330uF
Sven Eliasson
@comino
Nov 28 2015 18:07
ok :D thats more than enough
Markus
@Links2004
Nov 28 2015 18:07
that what i have around right now.
Sven Eliasson
@comino
Nov 28 2015 18:07
I get trouble if its below 40µF on WROOM-2
Mario Mikočević
@mozgy
Nov 28 2015 18:08
@Links2004 can't see DeepSleep connection on your schematics
Me No Dev
@me-no-dev
Nov 28 2015 18:09
@mozgy put a jumper between GPIO16 and CH_PD
Markus
@Links2004
Nov 28 2015 18:09
I use a jumper, its optional based on what i want to bild
some times I need GPIO16 for other thinks so its not on PCB
Mario Mikočević
@mozgy
Nov 28 2015 18:11
I see
Stavros Korokithakis
@skorokithakis
Nov 28 2015 18:24
what's that pcb for?
Sven Eliasson
@comino
Nov 28 2015 18:26
@skorokithakis you need special kind of sensors?
Markus
@Links2004
Nov 28 2015 18:26
its my basic PCB for the most projects it have a LDO and a easy to use SPI or I2C interface and a programming connector on the back.
you also can plug a nrf24 or something wit the same interface to it.
Sven Eliasson
@comino
Nov 28 2015 18:27
blob
Temperature, Humidity, Light, Air quality, Microphone ;)
Stavros Korokithakis
@skorokithakis
Nov 28 2015 18:27
oh, that's what i want to make too
although i have no idea what i'm seeing
Sven Eliasson
@comino
Nov 28 2015 18:28
A pcb :P
Stavros Korokithakis
@skorokithakis
Nov 28 2015 18:28
haha
i got that far :tongue:
Chris Elsworth
@celsworth
Nov 28 2015 18:30
pretty :) what are the 4 diagonal cyan lines?
they seem to go off the board
Sven Eliasson
@comino
Nov 28 2015 18:31
milling routes
you can break off the edges
Chris Elsworth
@celsworth
Nov 28 2015 18:31
oh I see
siedi
@siedi
Nov 28 2015 19:17
@comino great stuff your pcb, do you think it is easily possible to extend it with a PIR, lipo charger, LDR, and MQ2 gas sensor? I'm thinking of a smoke / motion detector, with alarm, emergency light (leds) in the night etc., for each room in my house. what do you think?
Sven Eliasson
@comino
Nov 28 2015 19:29
@siedi actually there is already a light sensor and a WS2812 LED and some kinde of gas sensor on it. I have a seperatie lipo charger circuit, but it might be a good idea to still put in on the board.. I never worked woth PIR - since I want to have it in a closed case a radar sensor is more suitable maybe
Sven Eliasson
@comino
Nov 28 2015 19:47
Is someone working with eclipse? Im still using sublime but the lack of code completion is annoying me more and more. I installed eclipse according to the github description. Its building fine- but there is no code completion??
Markus
@Links2004
Nov 28 2015 21:00
I use eclipse, code completion is working fine her.
blob
press ctrl + space
Sven Eliasson
@comino
Nov 28 2015 21:01
yeah I work with eclipse in java and used it with sming :/ I gues I will just reinstall everything
Markus
@Links2004
Nov 28 2015 21:02
have you include the #include <Arduino.h> ?
brutzler
@brutzler
Nov 28 2015 21:14
Does anybody have a working sketch for PCF8574-I2C Port expander? I tried the sketch and lib from Rob Tillaart, but only running into reboots :-(
Mario Mikočević
@mozgy
Nov 28 2015 21:23
hmm, I have one, haven't tried it yet ..
brutzler
@brutzler
Nov 28 2015 21:30
here is the link to the sketch/lib: http://playground.arduino.cc/Main/PCF8574Class
I want to use one for controlling a 8port relay-module.
Me No Dev
@me-no-dev
Nov 28 2015 21:32
it all looks fine to me
brutzler
@brutzler
Nov 28 2015 21:33
not to my NodeMCU:
 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x42
csum 0x42
~ld
Me No Dev
@me-no-dev
Nov 28 2015 21:34
what if you unplug the expander
brutzler
@brutzler
Nov 28 2015 21:35
same
checked the address of the module. was unsure, because of dip-switches. LOW or HIGH in actual position.
But in both cases there ar the reboots.
Me No Dev
@me-no-dev
Nov 28 2015 21:39
shorten up the tests and see what will happen
maybe make it so it switches just one port
but I see no reason for resets
brutzler
@brutzler
Nov 28 2015 21:41
empty loop -> still reboots
without all code depending to the lib, the reboots are gone
as soon, as I call an instance of the lib, reboots are back
PCF8574 PCF_01(0x20);
Maybe there is a problem, because of the "define Arduino" in the PCF8574.h? I have an ESP....
brutzler
@brutzler
Nov 28 2015 21:51
hmmmm... how does the ESP know, at which ports I want to use SDA/SCL ???
brutzler
@brutzler
Nov 28 2015 21:53
ok, thats a different library....
Markus
@Links2004
Nov 28 2015 21:53
its the ESP I2C libary
brutzler
@brutzler
Nov 28 2015 21:56
with my I2C-LCD, I coded this to define different pins:
#define SDA 13   // SDA <-> D7 (GPIO13 / HSPID)
#define SCL 14   // SCL <-> D5 (GPIO14 / HSPICLK)
...
  Wire.begin(SDA,SCL); //NodeMCU ESP-12
Markus
@Links2004
Nov 28 2015 21:57
you have defines that have the same name then the default variables, not sure if that work.
brutzler
@brutzler
Nov 28 2015 21:58
with the LCD, it worked, but will change...
Not better with different names (SDAx SCLx)
Markus
@Links2004
Nov 28 2015 22:00
the library has Wire.begin(); inside so you need to change it there.
Martin Ayotte
@martinayotte
Nov 28 2015 22:03
@brutzler, beware that PCF8574, is "A quasi-bidirectional I/O can be used as an input or output without the use of a control signal for data direction". This mean that when you are using some outputs, they can drive in sinking mode, but not in source, and when used as inputs your have to set corresponding outputs to HIGH so the input can be read. Personally, I prefer MCP23017, since they are real bidirectionnal thru data-direction register.
brutzler
@brutzler
Nov 28 2015 22:03

changed to

wire.begin(13,14);

still reboots

Markus
@Links2004
Nov 28 2015 22:04
try to remove the wire.begin from the constructor and move it in you setup above all PCF8574, functions.
brutzler
@brutzler
Nov 28 2015 22:06
ok, will try. hope I have enough time... gf is calling.... ;-)
brutzler
@brutzler
Nov 28 2015 23:50
@Links2004: good idea. Do not know, why the wire.begin() is in the lib. Decleration of PCF8574 is intended to be outside void setup(). But I know wire.begin() only inside void setup()
With this change, there is no reboot any more.
Now I will have to check, if IO-Exteder is working as expected.
@martinayotte: I didn't find any breakout-boards for the MCP23017. And I have 5 pieces of the PCF8574 in my box :-)