Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Send sensor data over a socket using CuHead V1.0 Wifi Shield on: May 17, 2014, 05:22:23 pm
I am working in a project where i need to collect some data from my sensor and get this in my computer to generate some spreadsheets. I am using a CuHead V1.0 wifi shield with Arduino Uno and the library is pretty old and I can't find a lot of support googling for it. So... My problem is that I can't find a way to get this data and send it using a socket.

This is the arduino code:
 * Socket App
 * A simple socket application example using the WiShield 1.0

#include <WiShield.h>
#include <HCM5883L.h> //MY SENSOR LIBRARY


// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {XXXXXX}; // IP address of WiShield
unsigned char gateway_ip[] = {XXXXX}; // router or gateway IP address
unsigned char subnet_mask[] = {XXXXX}; // subnet mask for the local network
const char PROGMEM ssid[] PROGMEM = {"XXXXXXX"}; // max 32 bytes

unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const char PROGMEM security_passphrase[] PROGMEM = {"XXXXXXXXX"}; // max 64 characters

// WEP 128-bit keys
// sample HEX keys
const char PROGMEM wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;

void setup()

void loop()
And the significant part of CuHead library code:

  Filename: socketapp.c
  Description: Simple socket programming example for the WiShield 1.0


  TCP/IP stack and driver for the WiShield 1.0 wireless devices

  Copyright(c) 2009 Async Labs Inc. All rights reserved.

  This program is free software; you can redistribute it and/or modify it
  under the terms of version 2 of the GNU General Public License as
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  more details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59
  Temple Place - Suite 330, Boston, MA  02111-1307, USA.

  Contact Information:

   Author               Date        Comment
   AsyncLabs 06/06/2009 Initial version


 * This is a short example of how to write uIP applications using
 * protosockets.

 * We define the application state (struct socket_app_state) in the
 * socketapp.h file, so we need to include it here. We also include
 * uip.h (since this cannot be included in socketapp.h) and
 * <string.h>, since we use the memcpy() function in the code.
#include "socketapp.h"
#include "uip.h"
#include <string.h>
#include <Arduino.h>

 * Declaration of the protosocket function that handles the connection
 * (defined at the end of the code).
static int handle_connection(struct socket_app_state *s);
 * The initialization function. We must explicitly call this function
 * from the system initialization code, some time after uip_init() is
 * called.
void socket_app_init(void)
  /* We start to listen for connections on TCP port 1000. */
 * In socketapp.h we have defined the UIP_APPCALL macro to
 * socket_app_appcall so that this function is uIP's application
 * function. This function is called whenever an uIP event occurs
 * (e.g. when a new connection is established, new data arrives, sent
 * data is acknowledged, data needs to be retransmitted, etc.).
void socket_app_appcall(void)
   * The uip_conn structure has a field called "appstate" that holds
   * the application state of the connection. We make a pointer to
   * this to access it easier.
  struct socket_app_state *s = &(uip_conn->appstate);

   * If a new connection was just established, we should initialize
   * the protosocket in our applications' state structure.
  if(uip_connected()) {
    PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));

   * Finally, we run the protosocket function that actually handles
   * the communication. We pass it a pointer to the application state
   * of the current connection.
 * This is the protosocket function that handles the communication. A
 * protosocket function must always return an int, but must never
 * explicitly return - all return statements are hidden in the PSOCK
 * macros.
static int handle_connection(struct socket_app_state *s)
  PSOCK_READTO(&s->p, '\n');
  PSOCK_SEND_STR(&s->p, "Hello ");
  PSOCK_SEND_STR(&s->p, s->inputbuffer);
  memset(s->inputbuffer, 0x00, sizeof(s->inputbuffer));


I was trying to get the data at the handle_connection(...) function, but I couldn't do it. Is it possible to get and send the data on arduino code instead? How?
2  Using Arduino / Programming Questions / Re: How Arduino IDE pre-processing work? on: April 01, 2014, 09:35:19 am
Is there any way to take a look inside the drivers who creates the Atmel machine code?
The compiler, avr-gcc,  is supplied as binary executable, but the sources will be somewhere on the Web.

Thank you. I'll take a look at both datasheet and avr-gcc this week.
3  Using Arduino / Programming Questions / Re: How Arduino IDE pre-processing work? on: April 01, 2014, 09:26:39 am
The hex file which gets loaded on the processor contains Atmel machine code. You can read the datasheet for the opcodes.

Is there any way to take a look inside the drivers who creates the Atmel machine code?
4  Using Arduino / Programming Questions / Re: How Arduino IDE pre-processing work? on: April 01, 2014, 09:01:49 am
Thank you all for answer me about preprocessor and sorry about my late response.

So, now that i understand what preprocessor is, what is running inside the ATMEL?
5  Using Arduino / Programming Questions / How Arduino IDE pre-processing work? on: March 30, 2014, 11:07:32 am
Hi! I was reading some topics and I found this:

The main sketch is C++, however the IDE does do a certain amount of pre-processing (in particular, generating function prototypes for you) before submitting the code to the main C++ compiler.

Could be found here.

Someone know how this "pre-processing" works? The code is converted to some low level programming language before load the microcontroller with my program? How?
6  Using Arduino / Sensors / Re: Magnetic sensor to car detection on: March 28, 2014, 01:47:12 pm
Any magnetometer suitable for an electronic compass (i.e. sensitive enough to easily detect the Earth's magnetic field) will detect vehicles a few meters distant. The vehicle will introduce easily detectable variations in the direction and magnitude of the local field. I used this magnetometer to make a "driveway alarm" which warns us of visitors.

So, i can "easily" use this magnetometer to detect if a car is over the sensor? My intention is to use arduino just to build a prototype so I can develop my final product.
7  Using Arduino / Sensors / Magnetic sensor to car detection on: March 28, 2014, 01:14:39 pm
Hi! I am doing a project in college that involves some kind sensor to detect vehicles, like in a parking lot. I was thinking about a magnetic sensor based on magnetoresistors to detect variations on earth's magnetic field or maybe something using inductive loops. Someone could help me with this indicating me some way to make this sensor or point to somewhere I can buy a few...
8  International / Portugues / Voltímetro com Arduino UNO on: August 15, 2013, 07:33:44 am
Tudo bem com vocês? Estou fazendo um trabalho para a matéria de eletronica aqui na universidade e preciso fazer um voltímetro com o Arduino para enviar a tensão de saída de uma fonte de tensão variável e simétrica (-20v até +20v). O problema é que não tenho ideia de como vou fazer a leitura dessa tensão através das portas analógicas. Sei que não posso ligar direto os 20v no analógico, então teria que bolar um circuito para reduzir a tensão proporcionalmente e dentro do arduino fazer umas contas para saber qual a tensão real. Me indicaram usar amplificadores operacionais, mas ainda não estudei isso.

Alguma sugestão?
9  International / Portugues / Software para "modelagem" robótica on: November 17, 2012, 04:14:32 pm
Boa noite pessoal! Estou a procura de algum software que me permita modelar, por exemplo, um braço robótico. Gostaria de criar minhas próprias peças, mas preciso de um software que já tenha alguns produtos disponíveis para "montagem" como um servo motor.

Pensei em utilizar o Google Sketchup, mas acho ele muito limitado e também não sei se possui alguns itens básicos...

Caso não tenham entendido minha dúvida, é só falar que tento explicar novamente.
10  International / Portugues / Re: LED + Resistencia on: November 16, 2012, 03:27:39 pm
Como eu verifico a queda do led? Da para fazer isso com um multímetro?
11  International / Portugues / LED + Resistencia on: November 16, 2012, 10:25:02 am
Boa tarde pessoal! Vi que em alguns tutoriais é usado o led no pólo + e em outros no pólo - do led. Qual seria a diferença? Se eu tenho um led de 4,5V e uma fonte de 5v, uma resistência de 100Ohms serve?
12  International / Portugues / Re: Ferramentas para eletrônica on: November 12, 2012, 06:56:12 pm
O que estou querendo é o necessário pra começar com o básico. Itens mais caros, como o osciloscópio, posso utilizar na universidade sempre que necessário. A princípio, devo comprar as "ferramentas" em minha cidade mesmo. Se o preço for muito elevado, corro para o eBay smiley
13  International / Portugues / Re: Regulagem receptor IR on: November 12, 2012, 06:51:07 pm
Funcionou certinho. Obrigado pessoal!
14  International / Portugues / Ferramentas para eletrônica on: November 12, 2012, 11:25:30 am
Boa tarde a todos! Vou montar um conjunto de ferramentas para trabalhar com eletrônica e queria que vocês me dessem sugestões do que eu devo comprar. Já está em minha lista: Ferro de solda, jogo de chaves, multímetro e caixa organizadora.

Alguém gostaria de sugerir algum item? Se possível, me mande link de algum site que venda o produto ou apenas uma foto, só para eu ter noção do que é e não comprar errado.
15  International / Portugues / Re: Regulagem receptor IR on: November 12, 2012, 10:25:44 am
Arrumei esse da direita

 Vou testar mais a noite. Será que não é necessário ter aquela "capa" da metal por cima?
Pages: [1] 2