Pesquisar este blog

segunda-feira, 10 de junho de 2013

Arduino Server and Client (ethernetShield)

Olá pessoal, nesse post estou compartilhando o código do "Zoomkat's" que mostra a implementação de como uma aplicação ser servidor e fazer request do tipo client em alguns momentos.


//zoomkat 7-03-12, combined client and server
//simple button GET with iframe code
//for use with IDE 1.0
//open serial monitor and send an g to test client and
//see what the arduino client/server receives
//web page buttons make pin 5 high/low
//use the ' in html instead of " to prevent having to escape the "
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 
  0xDE, 0xAD, 0xAD, 0xEF, 0xFE, 0xED }; //assign arduino mac address
EthernetServer server(80); //server port arduino server will use
EthernetClient client;
char serverName[] = "dene.pro.br"; // (DNS) zoomkat's test web page server
//byte serverName[] = { 208, 104, 2, 86 }; // (IP) zoomkat web page server IP address

String readString; //used by server to capture GET request 

//////////////////////

void setup(){
  Serial.begin(9600); 
  pinMode(5, OUTPUT); //pin 5 selected to control

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
  }
  else{
    Serial.println("DHCP ok");
    showIp();
  }

  server.begin();
  Serial.println("Send an g in serial monitor to test client"); // what to do to test client
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) 
  {
    byte inChar;
    inChar = Serial.read();
    if(inChar == 'g')
    {
      sendGET(); // call client sendGET function
    }
  }  

  client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
         // Serial.println(readString); //print to serial monitor for debuging 

            //now output HTML data header
          if(readString.indexOf('?') >=0) { //don't send new page
            client.println("HTTP/1.1 204 Zoomkat");
            client.println();
            client.println();  
          }
          else {   
            client.println("HTTP/1.1 200 OK"); //send new page on browser request
            client.println("Content-Type: text/html");
            client.println();

            client.println("<HTML>");
            client.println("<HEAD>");
            client.println("<TITLE>Arduino GET test page</TITLE>");
            client.println("</HEAD>");
            client.println("<BODY>");

            client.println("<H1>Zoomkat's simple Arduino 1.0 button</H1>");

            client.println("<a href='/?on' target='inlineframe'>ON</a>"); 
            client.println("<a href='/?off' target='inlineframe'>OFF</a>"); 

            client.println("<IFRAME name=inlineframe style='display:none'>");          
            client.println("</IFRAME>");

            client.println("</BODY>");
            client.println("</HTML>");
          }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on") > 0){//checks for on
            digitalWrite(5, HIGH);    // set pin 5 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") > 0){//checks for off
            digitalWrite(5, LOW);    // set pin 5 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
} 

//////////////////////////
void sendGET() //client function to send and receive GET data from external server.
{
  if (client.connect(serverName, 80)) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } 
  else {
    Serial.println("connection failed");
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read();
    Serial.print(c);
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop();

}

void showIp(){
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print("."); 

  }
  Serial.println(""); 
}






Download: http://dene.pro.br/download/Blog/WebServerEclient.zip

segunda-feira, 29 de abril de 2013

Unboxing PcDuino

Olá pessoal, vou mostrar pra vocês a minha mais nova aquisição, o PcDuino. Para quem não conhece ele é um computador portátil muito barato. O hardware é bem parecido com um smartphone, 1GHz ARM Cortex A8, 1GB DRAM, HDMI ...

O PcDuino é plataforma concorrente diretamente ao Raspberry Pi, entretanto ele possui um hardware um pouco mais fraco, veja abaixo uma tabela comparativa:


Com o PcDuino você consegue compilar os códigos do arquivo diretamente nele e utilizar as próprias portas como output, conforme mostra o vídeo abaixo:




Confira o unboxing =D




Nos próximos posts, vou ensinar a trocar o SO e compilar os skechs. Obrigado e até a próxima xD

domingo, 31 de março de 2013

Salvar variável na eeprom - Arduino (Save variable in eeprom)

Quando queremos persistir uma variável no Arduino, na primeira instancia é bem simples, basta utilizar o lib "", correto? Entretanto quando queremos gravar uma variável maior que 255, ou do tipo ponto flutuante (float, double) não é tão simples assim! 

Segue abaixo um vídeo tutorial que eu fiz, que mostra como resolver isso.

quinta-feira, 7 de março de 2013

Sensores sem fio - Arduino

Após alguns dias procurando, consegui comunicar com os sensores sem fios da central de alarme "Genno".




Os sensores encontrados são, magnético e o de presença além do controle remoto:


Ligação:



Módulo RF





Fiz um vídeo explicando esse funcionamento




Código fonte:
Link 1: http://dene.com.br/download/RF_HT6P20B_post_blog.zip

quarta-feira, 13 de fevereiro de 2013

Problema com GoPro Hero 2 v222

Caso você tenha atualizado sua GoPro e ao tentar fazer um downgrade ela ficou assim (não sai dessa tela):




Faça conforme descrito nesse vídeo que você irá recupera-la


O processo consiste em restaurar a câmera utilizando o software da goPro o "GoPro CineForm Studio". 

Para que você realmente consiga fazer o downgrade, troque a firmware que esta no cartão durante a restauração utilizando o "GoPro CineForm Studio" ou seja após a câmera desligar durante a atualização, remova o cartão, troque o arquivo HD2-firmware.bin que estará lá por outro mais antigo, ligue a goPro novamente e estará pronto.



Caso alguém tenha alguma dúvida poste abaixo. 

Fonte: GoPro HERO2 Unbrick and Downgrade Method - Firmware Bugs in v222

sábado, 12 de janeiro de 2013

Unboxing Kit FVP 900MHZ 1500mW HobbyKing [PT] [BR] [HD]

Olá pessoal, hoje fiz um um unboxing desse kit que comprei na HobbyKing, um ótimo kit para quem está começando.
Ainda não tive a oportunidade de testar, mas parece ter um alcance ótimo, por causa de dois fatores, 1° a potencia, que não é muito fraco, ele possui 1500mW e 2° por causa da frequência, como ele não opera em uma frequência muito alta, facilitando a penetração nos obstáculos.




Obs.: Não fui taxado.


Algumas informações:


12 Channel 900Mhz Tx/Rx video system with CCD camera.
A powerful 1.5W (1500mW) powered Tx! Unlike other generic systems, we have produced a wiring loom and included it with the camera so that the Tx and camera will be compatible and on the same voltage.
If you buy your camera and Tx seperately the plug polarity and voltages may be very different.

Included.
1 x SONY CCD 1/3inch Camera
1 x 900Mhz  8 channel Video Transmitter (1500mW)
1 x 900Mhz  12 channel Video Receiver 

Camera spec.
Image device: 1/3-inch Sony super HAD color CCDPixel: 752 x 582(NTSC)Synchronization: Internal synchronizationHorizontal resolution: 520TV LinesMinimum Illumination: 0.1Lux/F1.2S/N Ratio: Greater than 48dB(AGC OFF/B/W OFF)  
White balance: Auto Tracking White BalanceAuto backlight compensation: On/OFF switchable  Lens: 3.6-6mmInput voltage: DC12VElectric current: 80MA±5MAElectronic Shutter: Auto
PAL: 1/50 to 1/100,000 secondsVideo output: 1.0Vp~p75ΩOperation Temp.: -10~+50Size: 38 x 38mmPower supply: 12V/150mA
 
FPV Tx Spec.
Channel: 8-Ch, AV synchronization
Power: 1500mW
Input voltage: 12V
Weight: 18g
Size: 73x41x14mm
Frequency: 0.9G 0.910G,0.980G,1.010G,1.040G

Fonte: http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=21326



Qualquer dúvida poste abaixo xD 
Se inscreva no meu canal do YouTube, pois vou fazer mais vídeos como esses...
Até a próxima

segunda-feira, 7 de janeiro de 2013

Review Turnigy 9X

Olá pessoal, fiz um review do Turnigy 9X, um ótimo rádio, recomendo a todos que estão querendo comprar um rádio relativamente barato e bom ... =D


Dúvidas como sempre poste aqui no blog.... 

Ahh Visitem meu site dene.pro.br