Noobix IoT - Code
22/10/2022 | Views: 1430 | Arduino | by: ELECTRONOOBS      

Now download the Arduino Code from below. Read the instructions in the code line by line. First, you have to change your wifi name and password. Then scroll down and in the http.begin function change the website from "" to the name of your website. See in the previous video how to install the ESP32 boards. Once you do that, go to tools, board and select the ESP DEV MODULE board. Connect wires from an FTDI module like this one to the PCB. RX to TX, TX top RX and DTR to DTR together with RTS to RTS. Share ground and 5V. Then in Arduino, select the COM and upload the code. That's it.

Arduinop Noobix Code V1.3 22/10/2022

//Include libraries
#include <HTTPClient.h>                       //Download:
#include <WiFi.h>                             //Download:

//Add WIFI data
const char* ssid = "ElectroNoobs-Taller";     //Add your WIFI network name 
const char* password =  "12345678";           //Add WIFI password

//Variables used in the code
String LED_id = "1";                          //Just in case you control more than 1 LED    
String data_to_send = "";                     //Text data to send to the server
unsigned int Actual_Millis, Previous_Millis;
int refresh_time = 200;                       //Refresh rate of connection to website (recommended more than 1s)

int LED = 2;                                  //LED connected on IO2
int Relay = 12;                               //Pin for SSR control is IO12

void setup() {
  Serial.begin(115200);                       //Start monitor
  pinMode(LED, OUTPUT);                       //Set pin 2 as OUTPUT
  pinMode(Relay, OUTPUT);                     //Set pin 12 as OUTPUT  
  digitalWrite(LED, LOW);                     //Start with LED turned OFF
  digitalWrite(Relay, LOW);                   //Start with SSR turned OFF
  WiFi.begin(ssid, password);                 //Start wifi connection
  while (WiFi.status() != WL_CONNECTED) {     //Check for the connection

  Serial.print("Connected, my IP: ");
  Actual_Millis = millis();                   //Save time for refresh loop
  Previous_Millis = Actual_Millis; 

void loop() {  
  //We make the refresh loop using millis() so we don't have to use delay();
  Actual_Millis = millis();
  if(Actual_Millis - Previous_Millis > refresh_time){
    Previous_Millis = Actual_Millis;  
    if(WiFi.status()== WL_CONNECTED){                         //Check WiFi connection status  
      HTTPClient http;                                        //Create new client
      data_to_send = "check_LED_status=" + LED_id;            //Create the data to send
      /*Begin new connection to website. Make sure you change "" to
       *the name of your website. So the next line should be:
      http.begin("");          //Indicate the destination webpage 
      http.addHeader("Content-Type", "application/x-www-form-urlencoded");        //Prepare the header
      int response_code = http.POST(data_to_send);                                //Send the POST. This will giveg us a response code
      //If the code is higher than 0, it means we received a response
      if(response_code > 0){
        Serial.println("HTTP code " + String(response_code));                     //Print return code
        if(response_code == 200){                                                 //If code is 200, we received a good response and we can read the echo data
          String response_body = http.getString();                                //Save the data comming from the website
          Serial.print("Server reply: ");                                         //Print data to the monitor for debug

          //If the received data is LED_is_off, we turn OFF the SSR and LED
          if(response_body == "LED_is_off"){
            digitalWrite(LED, LOW);
            digitalWrite(Relay, LOW);
          //If the received data is LED_is_on, we turn ON the SSR and LED
          else if(response_body == "LED_is_on"){
            digitalWrite(LED, HIGH);
            digitalWrite(Relay, HIGH);
        }//End of response_code = 200
      }//END of response_code > 0
       Serial.print("Error sending POST, code: ");
      http.end();                                                                 //End the connection
    }//END of WIFI connected
      Serial.println("WIFI connection error");

Last tutorials

Arduino Mirror Steering Control
Washing Machine Universal Motor - Control speed with AC and DC
Arduino + MCP4725 DAC module
ESP32 IOT and Arduino Database + POST method
Raspberry Pi Voice Recognition + Arduino UART




PCBWAY PCB service

Curso Arduino Online nivel bajo