These are chat archives for esp8266/Arduino

17th
Jul 2016
Anirudh Varanasi
@anirudh838
Jul 17 2016 01:54
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
i just got esp8266 and ftdi friend
i am trying to replicate this
and during the process i get this error warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
can some please help me with this.
thanks.
Ivan Grokhotkov
@igrr
Jul 17 2016 03:12
@anisimovsergey yup, you are right, my suggestion doesn't work because of operator bool member in std::function. let me think a bit about other solutions.
@andig you were asking about extra argument for attachInterrupt, right?
here's a pull request to the official arduino core: arduino/Arduino#4519
if they merge it, we can implement the same void* approach (i prefer lambdas, but having a standard thing is better).
Holger Lembke
@holgerlembke
Jul 17 2016 11:48
@anirudh838 check your serial port speed. set it to a lower speed.
Clemens Kirchgatterer
@everslick
Jul 17 2016 11:58
which MQTT lib are you guys using? i have esp-mqtt-arduino, but it consumes ~5KB of my precious heap.
andig
@andig
Jul 17 2016 15:30
I like the async version, didn't look at heap though
Helio Machado
@crushedice2000
Jul 17 2016 15:34
Hi!
I'm trying to change the SoftAP MAC address of a ESP8266 without luck. I've done it a few months ago, but now it does not works now.
#include <Arduino.h>
#include <ESP8266WiFi.h>

#include "main.h"

extern "C" {
  #include "user_interface.h"
}

extern "C" void __run_user_rf_pre_init(void) {
  uint8_t mac[] = AP_BSSID;
  wifi_set_opmode(SOFTAP_MODE);
  wifi_set_macaddr(SOFTAP_IF, mac);
}


void setup() {
  pinMode(LED, OUTPUT);
  Serial.begin(115200);

  WiFi.softAP(AP_ESSID,
              AP_PASSWORD,
              AP_CHANNEL,
              AP_VISIBLE);

  //WiFi.mode(WIFI_AP);
}


void loop() {
  digitalWrite(LED, HIGH);
  delay(30);
  digitalWrite(LED, LOW);
  delay(30);
}
Martin Ayotte
@martinayotte
Jul 17 2016 15:56
@crushedice2000 , did you tried to do that directly in setup() ?
Helio Machado
@crushedice2000
Jul 17 2016 15:57
@martinayotte: No, however it should be done on preinit. That must be set before the rf init (I think).
Martin Ayotte
@martinayotte
Jul 17 2016 16:00
However, you should maybe give it a try. the whole run_user_rf_pre_init is not well documented, it may have changed.
Helio Machado
@crushedice2000
Jul 17 2016 16:02
@martinayotte: So, how do I run C code on setup? Should I use extern "C" also?
Martin Ayotte
@martinayotte
Jul 17 2016 16:06
You still included the user_interface.h the same way, and then in setup() simply call wifi_set_macaddr(SOFTAP_IF, mac); without extern "C"
Helio Machado
@crushedice2000
Jul 17 2016 16:07
Trying
@martinayotte: Doesn't work
Mehrdad K
@mkeyno
Jul 17 2016 16:13
hi @martinayotte , I intend to digitalread() the week signal by cheep mosfet, do you have any suggestion or schematic? I have no problem reading the week pin status by Arduino AVR by it wont work with ESP, I've tried it by transistor but as the transistor need current input , it wont work , that's why I'm look for cheep mosfet to read that
Martin Ayotte
@martinayotte
Jul 17 2016 16:13
@crushedice2000 , then, I don't have much other idea :-(
@mkeyno , I'm not sure to understand your issue. why do you need mosfet for digitalRead() ? Is it as level-shifter ? Do you have the pullups ?
Mehrdad K
@mkeyno
Jul 17 2016 16:19
just simple reading of week signal (less than 2mA), ESP by itself can't handle it (whereas Arduino did well) so I've tried use transistor to read signal but it also didn't work due to very low input current to base , so I have to move to Mosfet option
Helio Machado
@crushedice2000
Jul 17 2016 16:19
@martinayotte: Don't worry. Thank you anyway!
I'll ping @me-no-dev and @igrr. They should know what is happening here.
@one or @both: please read my question above.
Martin Ayotte
@martinayotte
Jul 17 2016 16:24
@mkeyno , I still don't understand : reading a pin has nothing with current, it is the voltage level that is important. As long as voltage don't exceed 3.3V, ESP can read that without issues.
(BTW, about current, Input Leakage on ESP is 50uA, but again, it has no relation about reading voltage)
Maybe you can provide a schematic about what you are trying to do ?
Mehrdad K
@mkeyno
Jul 17 2016 16:31
I don't know why , but it didn't work , I've tried to hack simple PIR sensor in market and read its status by ESP-01(pin 3) , whereas I easily read sensor status by Arduino but in no way can read it by ESP , after couple of weeks I've noticed the PIR sensor signal is so week , no voltage divider , no transistor , no optocoupler didn't work, the sensor signal voltage status change from around 3 volt to zero ,
it seems ESP pin sink the sensor signal to GND and sensor is too week to pull it back
Helio Machado
@crushedice2000
Jul 17 2016 16:40
Another question: Why digitalRead(PIN) on a PIN set as OUTPUT ever returns 1? Should not return the pin status?
andig
@andig
Jul 17 2016 16:53
Hi, any idea why passing a string pointer through va_args gives garbled output?
String* pwr = new String(_power[pin], 2);
DEBUG_MSG("s0", "pwr %s\n", pwr);
this is the function behind the macro:
void debug_message(const char *module, const char *format, ...) {
  #define BUFFER_SIZE 150
  char buf[BUFFER_SIZE];
  ets_printf("%08d [%-6s] ", millis(), module);
  // snprintf(buf, BUFFER_SIZE, "%6.3f [%-6s] ", millis()/1000.0, module);

  va_list args;
  va_start(args, format);
  vsnprintf(buf, BUFFER_SIZE, format, args);
  ets_printf(buf);
  browser_event(module, format, args);
  va_end(args);
Michael Miller
@Makuna
Jul 17 2016 17:08
@andig the string type is unknown, pass the internal ptr not the actual class. The compiler isn't selecting the converter when var arg is used.
Helio Machado
@crushedice2000
Jul 17 2016 17:53
Another question more to @iggr or @me-no-dev: Can I see the STAs that are in the nearby of the ESP?
Martin Ayotte
@martinayotte
Jul 17 2016 17:53
@mkeyno , did you initialized the GPIO as Input using pinMode(3, INPUT) ? How a Input pin can sink a signal to GND, unless it is actually an output with LOW level ? Is the PIR signal really swing from LOW to HIGH, where HIGH is lower than 3.3V ? Maybe your ESP is broken and GPIO is shorted.
@crushedice2000 , the digitalRead() on GPIO set as output depends of hardware implementation, depending of the MCU, some are actually reading the GPIO pins, some other are returning irrelevant values. (I didn't check what ESP is actually doing here, because I simply didn't need too)
Helio Machado
@crushedice2000
Jul 17 2016 18:06
@martinayotte: Some time ago, it worked (or I think so). Now it returns 1. Really weird
andig
@andig
Jul 17 2016 18:09
@Makuna c_str()? Will try that.
Mehrdad K
@mkeyno
Jul 17 2016 18:10
@martinayotte the pin setting and sketch is totally work well when use the another arbitrary high or low signal , this issue just related to this sensor and I think with mosfet can read the signal status
Me No Dev
@me-no-dev
Jul 17 2016 18:10
@crushedice2000 on your first Q, I am not 100%, but I believe that __run_user_rf_pre_init is used to setup the RF part of the radio and not the network layer stuff
Martin Ayotte
@martinayotte
Jul 17 2016 18:10
@crushedice2000 , are you sure ? I've just look at core_esp8266_wiring_digital.c history and I don't see anything about that
Me No Dev
@me-no-dev
Jul 17 2016 18:10
changing the mac in setup is the right way to go
on your second question, look at the SDK for promiscuos callback to get raw packets from the radio
on the third, nothing has changed and the code still reads the same register
I am not aware of any hardware change that can cause that behaviour
maybe you have pullup?
Martin Ayotte
@martinayotte
Jul 17 2016 18:12
@mkeyno , you can try that out with a mosfet, as long as you don't forget to have pullup on ESP side.
Me No Dev
@me-no-dev
Jul 17 2016 18:12
@mkeyno pinMode(pin, INPUT_PULLUP); can also help
PIRs pull the line low on movement
Martin Ayotte
@martinayotte
Jul 17 2016 18:13
of course, but I don't trust the weak internal pullup, especially if there are long wires. :-)
Me No Dev
@me-no-dev
Jul 17 2016 18:13
true
Mehrdad K
@mkeyno
Jul 17 2016 18:14
I did it , actually this my routine configuration to reading digital pin
Me No Dev
@me-no-dev
Jul 17 2016 18:14
what model is the PIR sensor?
Mehrdad K
@mkeyno
Jul 17 2016 18:15
normal PIR sensor in market (not arduino kit type) , I've tried to put my ESP-01 inside it and add it to my IOT home network
Me No Dev
@me-no-dev
Jul 17 2016 18:16
there are generally two types for the arduino market, so please answer with image or something so I get an idea
there is a chip on the back. One comon used is BIS S0001 and the other might be BA10324
Mehrdad K
@mkeyno
Jul 17 2016 18:21
17072016094.jpg
dear @martinayotte & @me-no-dev please check the image
the green wire is the signal that hacked form somewhere in module which is voltage varied from 3 to zero
Me No Dev
@me-no-dev
Jul 17 2016 18:22
any chance you take a picture that the board is actually on focus?
Mehrdad K
@mkeyno
Jul 17 2016 18:22
I've found most PIR sensor in market has week signal
Me No Dev
@me-no-dev
Jul 17 2016 18:23
currently really blurry and it looks like you try to get the signal directly from the sensor
which is not the way to go
one of the other chips is probably the opamps that amplify the signal
but can not tell from the picture you posted
Martin Ayotte
@martinayotte
Jul 17 2016 18:24
Usually, those PIR are for connecting to Alarm system, so the output is not 0-3V but a dry contact relay. In such case, you need a PullUp.
Holger Lembke
@holgerlembke
Jul 17 2016 18:25
doesnt the esp have internal pullups? yes, it does.
so relais close to ground is enough.
Martin Ayotte
@martinayotte
Jul 17 2016 18:25
Yes, but has I said above, personally, I don't trust weak internal ones :-)
Mehrdad K
@mkeyno
Jul 17 2016 18:26
because I run the module with 5v and in actual , look for the point that change in case of motion detection
Martin Ayotte
@martinayotte
Jul 17 2016 18:27
@mkeyno , did you actually verified with voltmeter or scope the output of that weak signal ?
Mehrdad K
@mkeyno
Jul 17 2016 18:28
yes , the signal change in motion detection and I took the point that pass the opamp and other filtering chip
Martin Ayotte
@martinayotte
Jul 17 2016 18:29
I mean the output signal available on the terminal screw .
Holger Lembke
@holgerlembke
Jul 17 2016 18:30
this KX15ED seems to be a little bit more advanced....
Mehrdad K
@mkeyno
Jul 17 2016 18:30
17072016096.jpg
no terminal screw because these device run with 12 volt and as you can see I power up device from other point beside the input terminal
Martin Ayotte
@martinayotte
Jul 17 2016 18:31
But if you bypass all the electronics, of course, you get into trouble of having only the sensor, you will need to change the strategy.
Mehrdad K
@mkeyno
Jul 17 2016 18:32
I know this is ugly hack but I've tried with couple of different types in market , all has same problem , very week signal that my poor ESP can read it correctly
Me No Dev
@me-no-dev
Jul 17 2016 18:34
that is probably because most are made to work with 5V arduinos
there is this really cheap PIR sensor on ali and everywhere with two pots on the back and electrolitic caps in the corners
prolly the most common one
Mehrdad K
@mkeyno
Jul 17 2016 18:35
multi meter shows the sensor signal clearly change from high to low or reveres but ESP cant catch it whereas my Arduino board read it very fast and clearly
Me No Dev
@me-no-dev
Jul 17 2016 18:35
and that one has 3.3 LDO on it to drop to 3.3V
so that one is what you need
just bypass the LDO
Mehrdad K
@mkeyno
Jul 17 2016 18:36
LDO?
Low-dropout regulator
Me No Dev
@me-no-dev
Jul 17 2016 18:36
yes
:D
but linear
Mehrdad K
@mkeyno
Jul 17 2016 18:38
but I have no experience with LDO, or any electrical solution , I've just thinking with simple mosfet can detect this voltage change regardless any current issue
Me No Dev
@me-no-dev
Jul 17 2016 18:40
so you talk about simple mosfets, though you have no clue of LDOs? like 1117 or 98XX?
Mehrdad K
@mkeyno
Jul 17 2016 18:41
AMS117 3.3 regulator?
Holger Lembke
@holgerlembke
Jul 17 2016 18:41
ok, the cpc1008n is a solid state relais. so look at the ends and hook up there
Me No Dev
@me-no-dev
Jul 17 2016 18:41
sure, there are many 1117 LDOs
Mehrdad K
@mkeyno
Jul 17 2016 18:42
you say I should connect sensor signal pin to the 3.3 regulator and then read it by ESP
Me No Dev
@me-no-dev
Jul 17 2016 18:42
I did not say such a thing
Mehrdad K
@mkeyno
Jul 17 2016 18:43
dear @me-no-dev can you be more specific
Me No Dev
@me-no-dev
Jul 17 2016 18:43
I said that you can power the most common PIR for hobby use out there from the ESP and that it runs on 3.3V actually
to make it 5V compatible, they add a 3.3V LDO (like that AMS you quoted)
Mehrdad K
@mkeyno
Jul 17 2016 18:45
not work , because sensor need 5 volt to warm up correctly and run and both module and ESP feed for same power
holgerlembke @holgerlembke thinks the discussion is a lost case.
Me No Dev
@me-no-dev
Jul 17 2016 18:46
you said you tried different sensors
if any of them are for hobby use, chances are it's like the one I talk about
Mehrdad K
@mkeyno
Jul 17 2016 18:46
actually in normal PIR sensor in market , there is regulator on board which is change the 12 volt to 5 volt
Me No Dev
@me-no-dev
Jul 17 2016 18:47
define "normal"
Mehrdad K
@mkeyno
Jul 17 2016 18:47
you can find it in any PIR sensor in market ,
every one has same way , converting the 12 volt to 5 volt
this is a hobby pir sensor
it's for hobby use and not what your security alarm guys install
though it does the same exact thing that you need
this one is powered by 5V and has a small 3.3V LDO that drops it to 3.3V
Mehrdad K
@mkeyno
Jul 17 2016 18:50
I know and I've play it long ago when I come to Arduino world , but my purpose is to turn the home devices in market to the smart node
this is my actual project to make network of home devices with ESP
Me No Dev
@me-no-dev
Jul 17 2016 18:50
so it has to be in that box :D?
Mehrdad K
@mkeyno
Jul 17 2016 18:51
yes , this is not hobby project , I should install my ESP in every device which is find in market
Me No Dev
@me-no-dev
Jul 17 2016 18:51
ok, go ahead then
the device you showed has a 3.3V ST MCU
find better spot to attach the test probe
Mehrdad K
@mkeyno
Jul 17 2016 18:52
03052016081.jpg
I did and test it with all possible spot , and find it , the best spot in the jumper which is common in every PIR sensor
03052016080 - Copy.jpg
those are couple of successful embedded project
Ivan Grokhotkov
@igrr
Jul 17 2016 19:11
@crushedice2000 hehe, yes, this method will not work any more
you got it right that mac address has to be changed from rf init hook, but the function you are overriding is no longer named that way.
the way which will not break in the future is like this
RF_PRE_INIT() {
  // do stuff
}
now to the reason why __run_user_rf_pre_init doesn't work anymore...
Arduino 1.6.9 fixed a bunch of things, but unfortunately it doesn't generate forward declarations for extern "C" functions correctly — it drops extern "C" part
so we had to make a workaround by removing extern "C" in __run_user_rf_pre_init declaration.
Ivan Grokhotkov
@igrr
Jul 17 2016 19:16
extern "C" issue is fixed now in arduino-builder, so hopefully in the next version we can roll this change back
if you use RF_PRE_INIT() thing, then you should be good