• Hello. I have a NodeMcu Lua wifi module(https://aliexpress.ru/item/32408097207.h­tml?spm=a2g0s.9042311.0.0.1ad333ed1mlnaz­) + ir diode(https://aliexpress.ru/item/32491780864.h­tml?spm=a2g0s.9042311.0.0.264d33edJE2Wsr­). I have successfully read the codes and the TV remote control(http://www.espruino.com/Pico+Infrared). How can I control the IR diode to send a signal to the TV?

  • It will be good to get a diagram for connecting an IR diode to a NodeMcu Lua wifi module, as well as an example code for sending a signal.

  • @user107037,

    I'm not sure if you are at the right spot here. But may be you are. Espruino is not LUA... The example you refer to is for an Espruino PICO: get yourself an https://shop.espruino.com/espruino-pico-­unpinned and - of course - an IR diode - and I can tell you it will run within less than 5 minutes following the instructions in the example.

    Trying to do it with your LUA modules is a bit more work: re-flash it with Espruino Firmware and then adapt the code in the example, and it will most likely work as well. For starters, take a look at http://forum.espruino.com/conversations/­311849/ . Other spots on the forum and even on the Espruoino site have more details: https://www.espruino.com/EspruinoESP8266­

  • My module is already flashed with espruino firmware. I also connected the ir receiver and read the codes from the TV remote control. The only thing I need is to understand how to connect the IR diode and send a signal to the TV.

  • I don’t understand how to adapt the code https://www.espruino.com/Pico+Infrared from the section "Software - Transmitting" to send an infrared signal to TV

  • screenshot of code


    1 Attachment

    • Screenshot_1.png
  • Mon 2019.12.23

    I am violating my own choice to only provide assistance with official authentic supported boards @user107037, but as the issue is with an existing code example, and with the spirit of X-Mas upon us, I'll have Santa send through a few observations.

    It would be cleaner to wrap the setWatch() within it's own function, and call that function within the E.on('init', ... that is structured correctly in place. Insert as the very first line before the intervals are set.

    L40 points to an invalid pin name, maybe a habit left over from Arduino development?

    L45 and L55 I believe it is setTimeout rather than setInterval that is required.

    https://www.espruino.com/Reference#l__gl­obal_setTimeout


    'The only thing I need is to understand how to connect the IR diode'

    From the image within the link provided in #5 post, the IR transmit diode is across Pins A5 and A6. See the third bulleted point that indicates to connect the shortest leg, the cathode to pin A5 It's current limiter resistor makes use of the internal pullup.

    ref: https://www.espruino.com/Pico


    'I don’t understand how to adapt the code'

    The separate second setWatch() function is missing. See the last function on that page and take a close look at how the 'times' array of pulses is sent out through the IR diode by investigating the 'Send the pulses' comment there.

    Good luck! Have fun and have a Happy Holiday Season!!

  • Guys, I am very grateful to you for your help and for the work you have done. I still have problems that I have not found answers from your posts ((.

    From the image within the link provided in #5 post, the IR transmit
    diode is across Pins A5 and A6. See the third bulleted point that
    indicates to connect the shortest leg, the cathode to pin A5 It's
    current limiter resistor makes use of the internal pullup.

    ref: https://www.espruino.com/Pico

    My module does not have contacts A5, A6. I attach the screenshot with the pinout of my module. Can you tell what pins in my module should I connect an IR diode?

    Maybe such a connection scheme is suitable?
    https://www.google.com/search?q=nodemcu+­ir+led&sxsrf=ACYBGNSqNbHslbCiq6V7xUnUov_­d_Ug2tQ:1577184026202&source=lnms&tbm=is­ch&sa=X&ved=2ahUKEwiu_IGtjM7mAhWoyqYKHWY­UBEsQ_AUoAXoECAwQAw&biw=1920&bih=937#img­rc=yqz6CjkbPSk1lM:


    1 Attachment

    • Screenshot_2.png
  • The separate second setWatch() function is missing. See the last
    function on that page and take a close look at how the 'times' array
    of pulses is sent out through the IR diode by investigating the 'Send
    the pulses' comment there.

    setWatch(function(e) {
      // stop recording
      stopWatching();
      // Light up LED1
      digitalWrite(LED1,1);
      // Start the 38kHz square wave
      analogWrite(A5,0.9,{freq:38000});
      // Send the pulses
      digitalPulse(A6, 1, times);
      // Wait until pulsing is finished
      digitalPulse(A6, 1, 0);
      // Turn LED1 off
      digitalWrite(LED1,0);
      // start recording again
      startWatching();
    }, BTN, {repeat:true, edge:"rising", debounce:50});
    

    My module also does not have LED1, BTN(please see the screenshot in post 8). Therefore, I asked the question how to adapt this piece of code to my NodeMcu Lua wifi module (https://aliexpress.ru/item/32408097207.h­tml?spm=a2g0s.9042311.0.0.1ad333ed1mlnaz­).

    Most likely, if possible, then using only this piece of code:

    // Start the 38kHz square wave
      analogWrite(A5,0.9,{freq:38000});
      // Send the pulses
      digitalPulse(A6, 1, times);
      // Wait until pulsing is finished
      digitalPulse(A6, 1, 0);
      // Turn LED1 off
    

    This can only be dealt with after it is clear how to connect the IR diode (post 8)

  • Tue 2019.12.24

    from post #4 'My module is already flashed with espruino firmware'

    Bravo, it appears success has be achieved with the flash process.

    Your post is in the correct thread under the correct heading. Maybe others are willing, but for me however;

    As I pointed out in #7 post @user107037, my choice is to provide assistance gratis to those that support the Espruino community with their purchse of official authentic supported boards.

    https://www.espruino.com/Other+Boards

    Still, in the spirit of the Holiday season . . .


    'I still have problems that I have not found answers from your posts (('

    That statement as indicated, from #5 post, the third bulleted item beneath heading 'Wiring Up' is clear and succinct.

    https://www.espruino.com/Pico+Infrared


    'My module does not have contacts A5, A6'

    It most likely wouldn't as;

    The examples and tutorials were written with the intent to further the Espruino community with fair compensation returned with the offical authentic board purchase. @allObjects had the best suggestion in his #3 post above to obtain rapid results.

    'Maybe such a connection scheme is suitable?'

    The link provided there with images has many useable suggestions. I'd pick one with the least amount of supporting components. Also, there is a hardware use case example clearly detailed in the the board purchase link #1 post, although the supporting code snippet appears to be Arduino 'C'.


    'This can only be dealt with after it is clear how to connect the IR diode'

    My suggestion would be to use a visible LED (color of your choice - and with a current limiter to protect the LED of around 220 ohms until the internal pullup concept is mastered) in place of the IR diode, and use a simple command to illuminate that LED. When satisfied with that task, replace with the IR one. If the circuit still doesn't work, then maybe the IR diode is in backwards, or at worst damamged.

    The easiest command to toggle a GPIO pin is:

    https://www.espruino.com/Reference#l__gl­obal_digitalWrite

    along with many in use examples.



    To assist the others;

    @user107037 is the struggle with the connectivity and placement of the parts, the understanding of the electrical characteristics of IR diodes and current flow, how to re-write code in 'C' for Arduino using Javascript with Espruino, mastering the commands of the Javascript language or deciphering the datasheet of the microcontroller?

  • It is very sad that I spent so much time studying the documentation and writing other espruino libraries for my personal project (smart home system), and now I have to abandon the use of espruino at all because I see no reason to continue without this part ((. Your modules are very expensive, that is, almost comparable in price to raspberry pi which has much wider possibilities.I understand that you do not want to support other modules for free, and I do not blame you, but it is advisable to immediately inform people about this fact so as not to waste not your time on me or other people. I thank you anyway for your help. Thank you.

  • 'now I have to abandon the use of espruino at all because I see no reason to continue without this part'

    and what is the justification for the above statement @user107037? You have successfully flashed a non-supported device, and there hasn't been an indication that Espruino is not running on that, so I'm bewildered by the #11 post.

    As none of the questions to assist others in helping out here were answered last pp in #10 post, I can only surmise there is a mis-understanding of how the device you have actually works. To confirm, Espruino is running on that device correct? . . . and all the suggestions from #10 post were exhaustively tested to view usage visibly? (doubt it)



    IMO it is also the Holiday season, and most are spending time with their families. I reached out as I was checking on a post of my own, when this thread showed up. I feel I've gone out of my way assisting with a non supported board, there just hasn't been a response from others that might chose to support an 8266. As the indication is that 'so much time has been spent' then I'm sure you realize the advantages of Espruino Javascript speed to development success and debug ease, in comparrison with other micros. Be a shame to abandon all that effort as the successful use of the current device hasn't been discovered yet.


    'and writing other espruino libraries for my personal project (smart home system)'

    Again, as code for libraries has been developed, this means full immersion into the workings of the speed and efficiency of Espruino development has been acquired. It seems the issue is with the understanding of how IR tansmissions using modulation is where the understanding effort should be made. Nothing to do with Espruino or the Javascript language as I see it.


    ' but it is advisable to immediately inform people about this fact'

    Done in detail on the web site in several places, here is the first I uncovered:

    https://www.espruino.com/Other+Boards

    First sentence

    'These are other boards that Espruino compiles for, but which aren't 'officially supported'. This means:'

    Bullet #7

    'We're not able to support you if you have problems using these boards. If you want support, get an official board'



    This is the opportunity cost of 'Open Source'.


    In this case the entire work of others was acquired for free, put in use for a project with unrelated hardware that benefits yourself, and now the expectation is that support should be provided when no contribution is made to the Espruino community? That is akin to test driving a car, not purchasing it, then demanding transportation of that owner somewhere because the vehicle you have invested time and money in, isn't working as needed. There ain't no free lunch!

  • In the spirit of the season, let's take a look at the issue at hand:

    • 1. Pin mapping from Espruino PICO to ESP8266 ESP-12E
    • 2. Figuring out if ESP8266 ESO-12E GPIO pins can provide enough sink and source current
    • 3. ESP8266 Wifi stack irq requirements not violated

    Re 1: Take a look at GPIO Pin BTN LED naming conventions specific to ESP8266. The code is done so smart that when you put the right pins in line 43 and 44 (in your screenshot), you are good to go.

    Re2: I/O pins of the ESP8266 ESP-12E are the pins of the ESP8266EX chip. According to data sheet - for example, from https://cdn-shop.adafruit.com/product-fi­les/2471/0A-ESP8266__Datasheet__EN_v4.3.­pdf under 2.2. Electrical Characteristics
    Table 3 ESP8266EX Electrical Characteristics on page 13, I max that can be drawn(sourced/sunk) is 12mA within specified levels of LOW and HIGH, did though not find the LOW and HIGH it is specified for. STM32 chips specify it... but it is for sure not 0V and 3.3V. For thoughts about this take a look at GPS powered by Espruino pin(s). There you also find the comment about the max power a chip can manage because of overall dissipation, which is a fraction of what the sum of what each individual pin can handle. The ESP8266EX chip has an additional challenge compared to the STM32 chips: it also does all the RF on / in the same chip which is usually worse in regard of heat creation. (It's though nice to have Wifi on the same chip). If power is pulled to low within the chip, it browns out and resets... worst case it burns up and goes lala land for ever.

    Re3: Described in many places, including the conversation referred to in my first link of this post, ESP8266 Wifi stack has hard requirements of getting control of the CPU every so much ms for number of ms. If someone else - the soft PWM / Espruino / JavaScript execution task is not done within the remaining time (window), ESP8266 panics and does a restart. For that reason, it is always good to have a processor for less time critical high/application level control and a separate processor for time low level - HW oriented things - that have their time critical requirements met in regard of available resources - interrupts, interrupt service times, etc.

    Try with various pins in that you have available on your ESP8266 ESP12E. This https://randomnerdtutorials.com/esp8266-­pinout-reference-gpios/ may help you. I searched for free pins... because many pins require to be at a certain state on power-on and some others are reserved for the operation mode / life cycle control.

    If you ran out of power, you may add FET transistors to increase transmission power of the IR LED. A quick look at the code runs the IR LED between two pins, one it emits a continuous PWM signal, and with the other it turns it on and off.

    PS:

    It is very sad that I spent so much time studying the documentation and writing other espruino libraries for my personal project (smart home system), and now I have to abandon the use of espruino at all because I see no reason to continue without this part

    ooops... Espruino consists of two parts: The targeted hardware - Espruino boards - and the firmware - Espruino binary... and Espruino (firmware) makes life so ease in the application realm - and that was exactly the motivation why it was created (the major point; others were more computing power - 32 vs 8 bit as Arduino - and with less current power - interrupt driven with sleep and deep sleep vs continuous run as Arduino's main loop. Going bare metal hardware and C - even with nice support, such as Arduino - life is quite different... It is your choice: usually a nut and a bolt have to match and go and together to do what is expected from the concept they implement. Choosing one part and avoiding the other one and then complaining seems to me unfair - or to say the least - unbalanced. It is the community - and the the smart choice of @Gordon regarding software/firmware architecture, implementation, and choice of processor - ARM3/4 - that brought it so far that Espruino is available on other than Espruino financing - lit.: @Gordon salary paying - hardware...

    ain't no free lunch? ...may be once in a while... after all - being within the season - it is Christmas!

    @user107037, you mentioned all the libraries and other things you developed and that you now have to abandon if ESP8266 does not make it: may be you pay forward in the spirit of open software and hardware as Espruino lives - in sharing in the Espruino forum - so others can enjoy as well as you can enjoy Espruino and the attention you get - for free.

  • Hi @user107037

    take a look at this ESP8266 analog write

  • @user197937 the chosen title is very confusing, it might be helpful if you change it :)

  • ...is there something like ESP8266 butter?-@MaBe : German Butter ...with some Espruino Jam on a 'Zopf' - that would be something new and for sure of great taste...!

    @Gordon, sorry, had my fun, like a while ago when I mistyped and it became a meaning of its own... (too bad that cannot remember).

    PS: Zopf = https://www.youtube.com/watch?v=AOMrlBe-­u3U

    - a perfect language mix... for sure not the origin one... https://www.goodfoodstories.com/swiss-br­ead/

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

NodeMcu Lua wifi(esp8266), how to send a signal through an ir diode?

Posted by Avatar for user107037 @user107037

Actions