• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP8266 NodeMCU Async Web Server, extra output-routine function required.

Q&A Forum › Category: ESP8266 › ESP8266 NodeMCU Async Web Server, extra output-routine function required.
0 Vote Up Vote Down
Alex asked 3 years ago

Dear All
Who can advise me or link me to an application to have an extra output- routine- function applied to :

“ESP8266 NodeMCU Async Web Server – Control Outputs with Arduino IDE”

I need  to expand One buttonfunction by sending an IR- code via an other preset GPIO- output- pin.

So my suggestion was to add extra functionallity in the space below , marked by “*********”

 // Send a GET request to <ESP_IP>/update?output=<inputMessage1>&state=<inputMessage2>
  server.on("/update", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage1;
    String inputMessage2;
    // GET input1 value on <ESP_IP>/update?output=<inputMessage1>&state=<inputMessage2>
    if (request->hasParam(PARAM_INPUT_1) && request->hasParam(PARAM_INPUT_2)) {
      inputMessage1 = request->getParam(PARAM_INPUT_1)->value();
      inputMessage2 = request->getParam(PARAM_INPUT_2)->value();
      digitalWrite(inputMessage1.toInt(), inputMessage2.toInt());

***************************************************************************

}

Thank you in advance for your advise,

Alex

11 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Alex.
I’m sorry, but I’m afraid I didn’t understand your request. Can you reformulate or provide more details?
Thanks.
Regards,
Sara

0 Vote Up Vote Down
Alex answered 3 years ago

Dear Sara,
Thank you so much for helping me, let me try to explain simply:
I need to combine 2 Sketches integrated in each other. Let’s call it A and B
A  =  ESP8266 NodeMCU Async Web Server – Control Outputs with Arduino IDE (ESPAsyncWebServer library)

ESP8266 NodeMCU Async Web Server – Control Outputs with Arduino IDE (ESPAsyncWebServer library)


 
B=Complete Guide for RF 433MHz Transmitter/Receiver Module With Arduino (transmitter part)

Complete Guide for RF 433MHz Transmitter/Receiver Module With Arduino


D=  A + B:
 
What I want to happen Extra is that every slidebutton generates it’s own message like “Hello from Button One” and “Hello from Button Two”
These messages need to be sent by one extra common output GPIO (x) which will be connected to the RX- transmitter pin.
(the existing output GPIO -Ledpins need to remain active)
 
That’s simply I want to do.
My question: Can you suggest me how I can realize it….?
I hope I succeed in making my request clear to you this way,
Thank you very much for your supprt,
Alex

0 Vote Up Vote Down
Steve Mercer answered 3 years ago

My suggestion would be to try as best you can. When you come across an error, you can post a new question here on the forum and some of us can try to help you.
 
We cannot write the code for you. This forum is for people to learn how to code Arduino’s of all shapes and sizes primarily the ESP32 and ESP8266.

0 Vote Up Vote Down
Alex answered 3 years ago

Did I ask you to write code for me?
My question was to give me a suggestion to find a solution of how to do…..
Not more not less……
Thank you very much for your understanding an support
Alex

0 Vote Up Vote Down
Steve Mercer answered 3 years ago

I’m sorry. I didn’t want to offend you. Your question came across as asking for code to be written for you.
 
There is really no other suggestion that anyone can give other than “Give it a try and see what happens”.

0 Vote Up Vote Down
Alex answered 3 years ago

‘Give it a try and see what happens…..?
What’s your task …. just asnwereing as much emails as you can in one hour or what….?
Let Sara  be an examplefor answering  people in a respectful way. For you…
Thanks
Alex
 

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Alex.

First, were you able to get the transmitter sketch working by itself on the ESP8266 board?
The library we use seems to be compatible with the ESP8266 board, but I haven’t tested it.

If you are successful with an example transmitter sketch, then you can proceed to merge the two examples.

Make sure you include the required libraries in your sketch:

#include <RH_ASK.h>
#include <SPI.h> 

Then, add the required lines to initialize the transmitter in the setup():

 if (!driver.init())
         Serial.println("init failed");

You can see in the example, that it sends a message as follows:

    const char *msg = "Hello World!";
    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();

So, you can add those lines in the ***** in your code, but replacing with the message you want to send. Try it and see if works.

I’m not sure if this will work, because the waitPacketSent() method might crash the AsyncWebServer routine because of the wait.

If that’s the case, you need to create auxiliary global variables that will change accordingly to the parameters received by the server in the AyncWebServer routine. Then, in the loop() check for the values of those variables, and add the commands to send the messages accordingly.

I hope this helps.

Regards,
Sara

0 Vote Up Vote Down
Alex answered 3 years ago

Thank you very much for your answer Sara,
For me it is just to test myself if I understood your Excellent course material.
I’ll let you know if I succeeded 
By the way YOU gave me the right suggestions to go on thank you so much for it…!
 
 

0 Vote Up Vote Down
Steve Mercer answered 3 years ago

I wasn’t going to bother responding but seeing as you have made it personal, I will. This is a forum with multiple people who like to help others.
 
Sara’s response specifically said “Try it and see if works” which is exactly what I said. Please don’t single me out just because you didn’t like my answer.
 
I will make it a point not to try to answer anything you post from now on.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

I’ll mark this issue as resolved for now.
Meanwhile, if you need further help, you just need to open a new question in our forum.
Regards,
Sara

0 Vote Up Vote Down
Alex answered 3 years ago

It’s oke, Sara
Thank you for your support
Alex

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.