tag:blogger.com,1999:blog-5513833072608837410.post6618399019336577257..comments2023-03-25T09:59:27.972-04:00Comments on Fabiano Arndt: Arduino - Ethernet Shield + SDCard + ArquivosFabiano Arndthttp://www.blogger.com/profile/15268923442674744187noreply@blogger.comBlogger49125tag:blogger.com,1999:blog-5513833072608837410.post-92191286865082953952020-10-21T22:07:19.595-04:002020-10-21T22:07:19.595-04:00Boa noite Fabiano, gostaria de solicitar a sua aju...Boa noite Fabiano, gostaria de solicitar a sua ajuda. Sou novo na programação html. Estou tentando passar os dados de uma leitura analógica para o web server e depois coletar com o Node-red, para montar um gráfico. O meu problema está no código html no Arduino. Ao fazer a programação e testar, eu não estou conseguindo passar os valores da leitura como números, e sim como string. Daí não consigo tratar esses dados no Node-red. Você saberia como ajudar? <br /><br />Obrigado desde já. RodrigoApSilvahttps://www.blogger.com/profile/18003936709912335616noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-56821768426914255562019-11-27T19:47:22.171-04:002019-11-27T19:47:22.171-04:00Boa noite, você poderia disponibilizar esse artigo...Boa noite, você poderia disponibilizar esse artigo?Washington Tabosahttps://www.blogger.com/profile/15308562581072499986noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-90303758828384645462018-10-19T21:47:29.346-04:002018-10-19T21:47:29.346-04:00fabiano estou tentando colocar mais esta linha nes...fabiano estou tentando colocar mais esta linha neste sketch, mas so da este erro exit status 1<br />redefinition of 'void jpg_file(EthernetClient&, char*)' como posso fazer para resolver isto?<br /><br />Linha De Programação<br />void jpg_file(EthernetClient &client, char * trip){<br /> client.println(F("HTTP/1.1 200 OK\n"<br /> "Content-Type: file/jpg\n"<br /> "Connection: close\n"));<br /> <br /> write_from_file(client, trip);<br />}<br />Anonymoushttps://www.blogger.com/profile/03601732351385789379noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-50070526814538446452018-09-12T08:44:11.144-04:002018-09-12T08:44:11.144-04:00Fiz conforme o Caio Queiroz orientou no comentário...Fiz conforme o Caio Queiroz orientou no comentário, e funcionou perfeitamente.<br />Obrigado a todos!!!!Fabriciohttps://www.blogger.com/profile/18024020786163720411noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-10435156846210361192018-07-14T09:56:06.332-04:002018-07-14T09:56:06.332-04:00mesma coisa comigo. pede 3 parametros mas so tem 2...mesma coisa comigo. pede 3 parametros mas so tem 2.Anonymoushttps://www.blogger.com/profile/16214939619300779729noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-69462112424846687022017-11-16T09:54:09.211-03:002017-11-16T09:54:09.211-03:00Comigo também dá erro, char *out = base64_encode(u...Comigo também dá erro, char *out = base64_encode(usuario_senha, t);.<br />A função base64_encode pede 3 parâmetros e no caso aqui manda só 2. O piorhttps://www.blogger.com/profile/17065727397359499323noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-50807095741703924712017-10-30T21:34:46.464-03:002017-10-30T21:34:46.464-03:00Olá bom dia a todos. Estou com um problema em meu ...Olá bom dia a todos. Estou com um problema em meu codigo, ele funciona perfeitamente, porem ele demora cerca de 10 segundos para responder (passar valores do site para o arduino). Eu simplesmente não sei como resolver isso, alguem poderia me ajudar? Muito obrigado!<br />email: jonashenrique989@gmail.comjonashttps://www.blogger.com/profile/11984844590424645591noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-49718095048735944852017-10-25T21:28:32.790-03:002017-10-25T21:28:32.790-03:00Pra mim funcionou! Muito obrigado a todos que cola...Pra mim funcionou! Muito obrigado a todos que colaboraram!Anonymoushttps://www.blogger.com/profile/03401492135810413702noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-53501571694656496722017-09-18T19:04:36.356-04:002017-09-18T19:04:36.356-04:00void ButtonDebounce(void)
{
static byte button...void ButtonDebounce(void)<br />{<br /> static byte buttonState[2] = {LOW, LOW}; // the current reading from the input pin<br /> static byte lastButtonState[2] = {LOW, LOW}; // the previous reading from the input pin<br /> <br /> // the following variables are long's because the time, measured in miliseconds,<br /> // will quickly become a bigger number than can be stored in an int.<br /> static long lastDebounceTime[2] = {0}; // the last time the output pin was toggled<br /> long debounceDelay = 50; // the debounce time; increase if the output flickers<br /> <br /> byte reading[2];<br /> <br /> reading[0] = digitalRead(2);<br /> reading[1] = digitalRead(3);<br /> <br /> for (int i = 0; i < 2; i++) {<br /> if (reading[i] != lastButtonState[i]) {<br /> // reset the debouncing timer<br /> lastDebounceTime[i] = millis();<br /> }<br /> <br /> if ((millis() - lastDebounceTime[i]) > debounceDelay) {<br /> // whatever the reading is at, it's been there for longer<br /> // than the debounce delay, so take it as the actual current state:<br /> <br /> // if the button state has changed:<br /> if (reading[i] != buttonState[i]) {<br /> buttonState[i] = reading[i];<br /> <br /> // only toggle the LED if the new button state is HIGH<br /> if (buttonState[i] == HIGH) {<br /> LED_state[i] = !LED_state[i];<br /> }<br /> }<br /> }<br /> } // end for() loop<br /> <br /> // set the LEDs<br /> digitalWrite(30, LED_state[0]);<br /> digitalWrite(31, LED_state[1]);<br /> <br /> // save the reading. Next time through the loop,<br /> // it'll be the lastButtonState:<br /> lastButtonState[0] = reading[0];<br /> lastButtonState[1] = reading[1];<br />}<br /><br />// checks if received HTTP request is switching on/off LEDs<br />// also saves the state of the LEDs<br />void SetLEDs(void)<br />{<br /> // LED 1 (pin 6)<br /> if (StrContains(HTTP_req, "LED1=1")) {<br /> LED_state[0] = 1; // save LED state<br /> digitalWrite(30, HIGH);<br /> }<br /> else if (StrContains(HTTP_req, "LED1=0")) {<br /> LED_state[0] = 0; // save LED state<br /> digitalWrite(30, LOW);<br /> }<br /> // LED 2 (pin 7)<br /> if (StrContains(HTTP_req, "LED2=1")) {<br /> LED_state[1] = 1; // save LED state<br /> digitalWrite(31, HIGH);<br /> }<br /> else if (StrContains(HTTP_req, "LED2=0")) {<br /> LED_state[1] = 0; // save LED state<br /> digitalWrite(31, LOW);<br /> }<br />}<br /><br />// send the XML file with analog values, switch status<br />// and LED status<br />void XML_response(EthernetClient cl)<br />{<br /> int analog_val; // stores value read from analog inputs<br /> int count; // used by 'for' loops<br /> int sw_arr[] = {2, 3}; // pins interfaced to switches<br /> <br /> cl.print("");<br /> cl.print("");<br /> // LED1<br /> cl.print("");<br /> if (LED_state[0]) {<br /> cl.print("on");<br /> }<br /> else {<br /> cl.print("of");<br /> }<br /> cl.println("");<br /> // LED2<br /> cl.print("");<br /> if (LED_state[1]) {<br /> cl.print("on");<br /> }<br /> else {<br /> cl.print("of");<br /> }<br /> cl.println("");<br /> cl.print("");<br />}<br /><br />// sets every element of str to 0 (clears array)<br />void StrClear(char *str, char length)<br />{<br /> for (int i = 0; i < length; i++) {<br /> str[i] = 0;<br /> }<br />}<br /><br />// searches for the string sfind in the string str<br />// returns 1 if string found<br />// returns 0 if string not found<br />char StrContains(char *str, char *sfind)<br />{<br /> char found = 0;<br /> char index = 0;<br /> char len;<br /><br /> len = strlen(str);<br /> <br /> if (strlen(sfind) > len) {<br /> return 0;<br /> }<br /> while (index < len) {<br /> if (str[index] == sfind[found]) {<br /> found++;<br /> if (strlen(sfind) == found) {<br /> return 1;<br /> }<br /> }<br /> else {<br /> found = 0;<br /> }<br /> index++;<br /> }<br /><br /> return 0;<br />}<br />Anonymoushttps://www.blogger.com/profile/03768220893999867411noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-53081566638114853322017-09-18T19:02:51.344-04:002017-09-18T19:02:51.344-04:00Fabiano este Código fonte que mandei em partes tem...Fabiano este Código fonte que mandei em partes tem com você unir com este seu código fonte.<br />Ficaria uma ótima automação, por hora eu agradeço.<br />o site que eu achei foi este (http://startingelectronics.org/articles/arduino/switch-and-web-page-button-LED-control/) Anonymoushttps://www.blogger.com/profile/03768220893999867411noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-23953737280518027112017-09-18T18:54:28.529-04:002017-09-18T18:54:28.529-04:00void loop()
{
EthernetClient client = server.a...void loop()<br />{<br /> EthernetClient client = server.available(); // try to get client<br /><br /> if (client) { // got client?<br /> boolean currentLineIsBlank = true;<br /> while (client.connected()) {<br /> if (client.available()) { // client data available to read<br /> char c = client.read(); // read 1 byte (character) from client<br /> // limit the size of the stored received HTTP request<br /> // buffer first part of HTTP request in HTTP_req array (string)<br /> // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)<br /> if (req_index < (REQ_BUF_SZ - 1)) {<br /> HTTP_req[req_index] = c; // save HTTP request character<br /> req_index++;<br /> }<br /> // last line of client request is blank and ends with \n<br /> // respond to client only after last line received<br /> if (c == '\n' && currentLineIsBlank) {<br /> // send a standard http response header<br /> client.println("HTTP/1.1 200 OK");<br /> // remainder of header follows below, depending on if<br /> // web page or XML page is requested<br /> // Ajax request - send XML file<br /> if (StrContains(HTTP_req, "ajax_inputs")) {<br /> // send rest of HTTP header<br /> client.println("Content-Type: text/xml");<br /> client.println("Connection: keep-alive");<br /> client.println();<br /> SetLEDs();<br /> // send XML file containing input states<br /> XML_response(client);<br /> }<br /> else { // web page request<br /> // send rest of HTTP header<br /> client.println("Content-Type: text/html");<br /> client.println("Connection: keep-alive");<br /> client.println();<br /> // send web page<br /> webFile = SD.open("index.htm"); // open web page file<br /> if (webFile) {<br /> while(webFile.available()) {<br /> client.write(webFile.read()); // send web page to client<br /> }<br /> webFile.close();<br /> }<br /> }<br /> // display received HTTP request on serial port<br /> Serial.print(HTTP_req);<br /> // reset buffer index and all buffer elements to 0<br /> req_index = 0;<br /> StrClear(HTTP_req, REQ_BUF_SZ);<br /> break;<br /> }<br /> // every line of text received from the client ends with \r\n<br /> if (c == '\n') {<br /> // last character on line of received text<br /> // starting new line with next character read<br /> currentLineIsBlank = true;<br /> } <br /> else if (c != '\r') {<br /> // a text character was received from client<br /> currentLineIsBlank = false;<br /> }<br /> } // end if (client.available())<br /> } // end while (client.connected())<br /> delay(1); // give the web browser time to receive the data<br /> client.stop(); // close the connection<br /> } // end if (client)<br /> <br /> // read buttons and debounce<br /> ButtonDebounce();<br />}Anonymoushttps://www.blogger.com/profile/03768220893999867411noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-77836749309465855792017-09-18T18:54:01.618-04:002017-09-18T18:54:01.618-04:00#include
#include
#include
// size of buffer us...#include <br />#include <br />#include <br />// size of buffer used to capture HTTP requests<br />#define REQ_BUF_SZ 60<br /><br />// MAC address from Ethernet shield sticker under board<br />byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };<br />IPAddress ip(192, 168, 1, 102); // IP address, may need to change depending on network<br />EthernetServer server(8081); // create a server at port 80<br />File webFile; // the web page file on the SD card<br />char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string<br />char req_index = 0; // index into HTTP_req buffer<br />boolean LED_state[2] = {0}; // stores the states of the LEDs<br /><br />void setup()<br />{<br /> // disable Ethernet chip<br /> pinMode(10, OUTPUT);<br /> digitalWrite(10, HIGH);<br /> <br /> Serial.begin(9600); // for debugging<br /> <br /> // initialize SD card<br /> Serial.println("Initializing SD card...");<br /> if (!SD.begin(4)) {<br /> Serial.println("ERROR - SD card initialization failed!");<br /> return; // init failed<br /> }<br /> Serial.println("SUCCESS - SD card initialized.");<br /> // check for index.htm file<br /> if (!SD.exists("index.htm")) {<br /> Serial.println("ERROR - Can't find index.htm file!");<br /> return; // can't find index file<br /> }<br /> Serial.println("SUCCESS - Found index.htm file.");<br /> // switches<br /> pinMode(2, INPUT);<br /> pinMode(3, INPUT);<br /> // LEDs<br /> <br /> pinMode(30, OUTPUT);<br /> pinMode(31, OUTPUT);<br /> <br /> Ethernet.begin(mac, ip); // initialize Ethernet device<br /> server.begin(); // start to listen for clients<br />}Anonymoushttps://www.blogger.com/profile/03768220893999867411noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-48866948316682128852017-09-18T18:51:39.893-04:002017-09-18T18:51:39.893-04:00Este comentário foi removido pelo autor.Anonymoushttps://www.blogger.com/profile/03768220893999867411noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-29095608615256228562017-08-01T11:23:01.050-04:002017-08-01T11:23:01.050-04:00thx for fabiano :Dthx for fabiano :Dshare ilmuhttps://www.blogger.com/profile/01637840895472062903noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-26320417772867264342017-07-30T11:30:06.769-04:002017-07-30T11:30:06.769-04:00why i cant use admin admin for enter ?why i cant use admin admin for enter ?share ilmuhttps://www.blogger.com/profile/01637840895472062903noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-19399307808081158432017-05-03T19:18:48.028-04:002017-05-03T19:18:48.028-04:00aqui pra mim mesmo seguindo isso ainda da erradoaqui pra mim mesmo seguindo isso ainda da erradoAnonymoushttps://www.blogger.com/profile/01951248247175998332noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-19771722030995115802017-03-20T22:01:45.166-04:002017-03-20T22:01:45.166-04:00Galera, consegui achar a função que transforma o l...Galera, consegui achar a função que transforma o login_senha para base64.<br />Primeiro: Substituam a função validar_usuario exatamente como o Rodrigo postou.<br />Segundo: Tirem toda aquela parte entre /**** BASE 64 ****/ e /**** FIM DA BASE64 ****/<br />Terceiro: Coloquem o codigo abaixo nesse lugar. PS: obrigado ao Fabiano por postar esse código para nós!!!<br /><br />static const char b64all[] =<br /> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"<br /> "ghijklmnopqrstuvwxyz0123456789+/";<br /><br />const char *base64_encode(const char *original, int length) {<br /> // Se o tamanho não for informado, consideramos uma string bem<br /> // formada<br /> if (length == 0)<br /> length = strlen(original);<br /><br /> // Inteiro com o tamanho do código a ser gerado<br /> int b64length = ((length + 2) / 3) * 4 + 1;<br /><br /> // Contadores para percorrer as strings<br /> int i=0, j=0;<br /><br /> // Alocando memória para o código<br /> char *b64 = (char *) malloc(sizeof(char) * b64length);<br /> memset(b64, 0, b64length);<br /><br /> while (i < length) {<br /> // Codifica um grupo de três bytes...<br /> _encode(<br /> (uint8_t *) b64 + j,<br /> (const uint8_t *) original + i,<br /> (length - i)<br /> );<br /><br /> // E segue para o próximo grupo<br /> i += 3;<br /> j += 4;<br /> }<br /><br /> // Retorna o código<br /> return (const char *) b64;<br />}<br /><br />void _encode(uint8_t *dest, const uint8_t *src, int len) {<br /> // Menor que 1, nada a fazer<br /> if (len < 1)<br /> return;<br /><br /> // Dados a serem retornados<br /> int aux[] = { 0, 0, 0, 0 };<br /><br /> // Primeiro elemento: os 6 bits mais significativos do primeiro<br /> // byte<br /> aux[0] = src[0] >> 2;<br /><br /> // Segundo elemento: os 2 bits menos significativos do primeiro e<br /> // os quatro bits mais significativos do segundo byte<br /> aux[1] = (src[0] & 0x03) << 4;<br /><br /> if (len > 1) {<br /> // SE houver um segundo...<br /> aux [1] |= (src[1] & 0xf0) >> 4;<br /><br /> // Terceiro elemento: os quatro bits menos significativos do<br /> // segundo e os dois mais significativos do terceiro byte<br /> aux [2] = (src[1] & 0x0f) << 2;<br /><br /> if (len > 2) {<br /> // Se houver um terceiro...<br /> aux[2] |= src[2] >> 6;<br /><br /> // Quarto elemento: os seis bits menos significatos do<br /> // terceiro byte<br /> aux[3] = src[2] & 0x3f;<br /> }<br /> }<br /><br /> // Codifica agora os valores numéricos para string<br /> dest[0] = b64all[aux[0]];<br /> dest[1] = b64all[aux[1]];<br /> dest[2] = '=';<br /> dest[3] = '=';<br /> if (len > 1) {<br /> dest[2] = b64all[aux[2]];<br /> if (len > 2)<br /> dest[3] = b64all[aux[3]];<br /> }<br />}Elizabeth Queirozhttps://www.blogger.com/profile/07060850874553633472noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-31931075374256699192017-03-10T12:46:50.640-04:002017-03-10T12:46:50.640-04:00Ola boa tarde!
Fabiano eu estou usando a placa Meg...Ola boa tarde!<br />Fabiano eu estou usando a placa Mega 2560 com Eth Shield e não estou tendo sucesso em rodar este seu escript. Vi que no codigo você usa os pinos 4 e 10 do arduino UNO para habilitar/desabiltar o cartão SD e a ETH. Me pareceu que no Mega 2560 o pino 53 tem a mesma função do pino 4 do UNO, mas o pino 10, não consigo encontrar equivalente. Tambem não sei se só seria este dois os pontos. Gravei os arquivos no SD e no PC estão funcionando como esperado, porem no Arduino não passam do Login, rejeitando o usuario e senha admin:admin.. Vc pode me ajudar?? ObrigadoAmaurihttps://www.blogger.com/profile/16082111552054392242noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-48272685930843011242016-12-31T14:22:03.470-03:002016-12-31T14:22:03.470-03:00Boa tarde! O meu problema é : entro com senha e lo...Boa tarde! O meu problema é : entro com senha e login, mas ele entra em uma tela branca, poderia me ajudar ? Anonymoushttps://www.blogger.com/profile/00201800655129568658noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-61242631197773016592016-12-10T13:00:55.092-03:002016-12-10T13:00:55.092-03:00Rodrigo, tentei esse cod que vc deixou acima, mas ...Rodrigo, tentei esse cod que vc deixou acima, mas da um erro, -> invalid convertion fron 'byte {aka unsigned char}' to 'char*'[-fpermissive] <- esse erro da na linha : char out = base64_encode(usuario_senha, t); , se puder me ajudar eu agradeçoElitechttps://www.blogger.com/profile/01486151162774046349noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-55088049658982247792016-11-25T09:21:56.149-03:002016-11-25T09:21:56.149-03:00Bom dia Fabiano/Rodrigo,
Ainda estou com o proble...Bom dia Fabiano/Rodrigo,<br /><br />Ainda estou com o probleminha do login, ja fiz a alteração da função validar o usuario, quanto a alteração da função base64_encode não sei como editá-la, poderia me ajudar com o código?Anonymoushttps://www.blogger.com/profile/01267305268545276780noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-76661377759321233002016-11-09T21:09:24.887-03:002016-11-09T21:09:24.887-03:00Olá Fabiano. Sei que não é exatamente sobre o assu...Olá Fabiano. Sei que não é exatamente sobre o assunto desse post, mas estou a bastante tempo pesquisando e até agora não achei nenhuma resposta descente. Como faço para jogar valores de variáveis de sensores, para uma pagina HTML que esta sendo lida de dentro do cartão SD(index.htm)? obs: estou usando o shield ethernet.Arthurhttps://www.blogger.com/profile/12250413533944005059noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-58089903109490892092016-11-05T17:11:35.162-03:002016-11-05T17:11:35.162-03:00Boa tarde Fabiano, ainda não consegui fazer com qu...Boa tarde Fabiano, ainda não consegui fazer com que meu html acione minha saída, teria como você mandar um exemplo para meu email..<br />eduardoewertoncruzdelima@gmail.com<br />Muito show o post, porém ainda tenho dificuldades com a programação.<br />VlwAnonymoushttps://www.blogger.com/profile/01943170334884741097noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-60669169691828066162016-10-31T07:30:40.772-03:002016-10-31T07:30:40.772-03:00obrigado Rodrigo, várias pessoas tem relatado esse...obrigado Rodrigo, várias pessoas tem relatado esse problema, mas ainda não tinha conseguido um tempo pra verificar o que poderia ser. Vou editar no artigo pra quem estiver com problema seguir sua solução.<br />Fabiano Arndthttps://www.blogger.com/profile/15268923442674744187noreply@blogger.comtag:blogger.com,1999:blog-5513833072608837410.post-31746475287289335542016-10-30T19:51:34.158-03:002016-10-30T19:51:34.158-03:00Descobri o problema e mudei o meu código. A função...Descobri o problema e mudei o meu código. A função base64_encode não retorna corretamente o primeiro byte codificado, por isso a função validar_usuario sempre recebia a string "out" errada. Tive que trocar a função base64_encode para uma que retornasse o valor inteiro de "out" codificado. Dai minha função validar_usuario ficou assim:<br /><br />boolean validar_usuario(char * linebuf) {<br /> char usuario_senha[] = "admin:admin"; //"admin:admin";<br /> byte t = strlen(usuario_senha);<br /> int tamanhoEnc = (((t-1) / 3) + 1) * 4; //tamanho da string codificada<br /> char *out = base64_encode(usuario_senha, t);<br /> char out2[tamanhoEnc];<br /><br /> for (t=0; t<(tamanhoEnc); t++) {<br /> out2[t] = linebuf[21+t];<br /> }<br /> return (strstr(out2, out)>0);<br />}rdfloreshttps://www.blogger.com/profile/13410914794028862471noreply@blogger.com