MyGLCD.print("Runtime: (msecs)", CENTER, 210) MyGLCD.print("few seconds.", CENTER, 132) MyGLCD.print("Restarting in a", CENTER, 119) MyGLCD.print("* Universal Color TFT Display Library *", CENTER, 1) MyGLCD.print("pqrstuvwxyz~ ", CENTER, 144) MyGLCD.print("`abcdefghijklmno", CENTER, 64) MyGLCD.print("PQRSTUVWXYZ^_", CENTER, 48) Remember to change the model parameter to suit your display module! CTE TFT LCD/SD Shield for Arduino Mega : ,38,39,40,41 Standard Arduino Mega/Due shield : ,38,39,40,41 DisplayModule Arduino Uno TFT shield : ,A5,A4,A3,A2 Standard Arduino Uno/2009 shield : ,A5,A4,A3,A2 Also, if you read any character other than \ n and \ r, it means that the line is not blank.// Set the pins to the correct ones for your development shield If we get here, it is because the request has been read in full. And, after the previous line, it is: \ r \ nso. We see that the last line of the request is: \ r \ n alone, \ r \ n. Apenas a primeira linha da requisição nos interessa Faz a leitura da primeira linha da requisição char* readRequest(WiFiEspClient client) Here, we have the reading of the first line of the request. User-Agent: Mozilla/5.0 (Linux Android 8.0.0 SM-G955F Build/R16N ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/.91 Mobile Safari/537.36\r\nĪccept: text/html,application/xhtml+xml,application/xml q=0.9,image/webp,image/apng,*/* q=0.8\r\n ![]() ![]() I emphasize that even after reading the first line, it is important to read it until the end, otherwise the WiFiESP lib gives a timeout. What does it do? When we press a button on the smartphone, the function sends the command in HTTP to ESP8266, using only the first line, as you see in the example below. Tempo para o navegador receber os dados Executamos a ação com o valor passado na requisiçãoĮxecute(getAction(request), getValue(request)) WiFiEspClient client = server.available() We determine a time for the browser to receive the data and close the connection with the client. We then read the sensors and send the response to the customer. We read the request and, if the request is not for the favicon, we execute the action with the value passed in the request. Serial.println("Sensor não encontrado!") Inicializa o sensor DS18B20 void setupDS18B20() Serial onde está o ESP-01 com o firmware AT já instalado We wait to connect to the WiFi network, configure the IP, and verify the same IP. Here, we perform a function that initializes the serial where the ESP-01 is with the AT firmware already installed. Coloca os pinos que estão ligados os relês como saída ![]() In this step, we put the pins that are connected to the relays as outputs. Para o sensor de luminosidade apenas precisamos ler o pino analógico Serial onde está o ESP-01 com firmware AT We also initialize the WiFi and connect to the network. For the brightness sensor, we just need to read the analog pin. We initialize the serial and serial monitor where the ESP-01 is with AT firmware, in addition to pins, and DS18B20 and DHT22 sensors. Mantém o estado atual dos pinos (HIGH ou LOW) Variáveis para armazenar os valores dos sensores Servidor que receberá as requisições na porta 80 (porta padrão http) SSID e senha da rede wifi para o ESP se conectar Sensor de Temperatura DS18B20 OneWire oneWire(PIN_DS18B20) We point to the server that will receive the requests on port 80 (standard port http), as well as the variables to store the values of the sensors. We then set out for definitions involving the WiFi network, such as the SSID and password for the ESP to connect. We continue with the DS18B20 temperature sensor, and the DHT22 temperature and humidity sensor. #define PINS_COUNT 16 //Quantos pinos a partir do primeiro serão utilizados #define FIRST_PIN 36 //Pino onde está o primeiro relê ![]() We also point out the pin where the first relay will be and how many pins (starting from this first one) will be used. We start off by including the libraries and defining the pins attached to the sensors.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |