Loading...
  Show Posts
Pages: 1 2 3 [4] 5 6 7
46  Using Arduino / Project Guidance / 5v down to 3.3v for 3.3v sensitive devices on: August 09, 2012, 12:56:03 pm
Just a simple question

If I  am using a 5v arduino and my sensor or device requires 3.3v for power + data lines what is the best way to do this?

Should one just use a voltage divisor with 2 resisters?

Should one use a 3.3v regulator for the power + 2 resisters for the data lines?

Should one use a 3.3 volt regulator for eveything?

Is there something else you should use?

I am just wondering as I have really only used the 3.3v line from Arduino + 2 resisters but is that a good method? Doesn't this waste energy as heat? Especially when running from battery power?

Chris
47  Using Arduino / Programming Questions / Re: Problems passings strings to function with variable args on: August 09, 2012, 02:28:15 am
You can't pass String types to *printf functions.  It does not know about the String type.  Instead you have to convert String back to a char array, and pass that to your function and use %s with it.

After reading this i found that I could simply change my array and it is all happy now

Code:
static char *XMLTagStrings[] = {
"xml",
"temperature",
"humidity",
"dateTime"
};

Thanks

Chris
48  Using Arduino / Networking, Protocols, and Devices / [SOLVED] Arduino Duemilanove - Ethernet Shield 1.1 - LocalIP() = 0.0.0.0 on: August 09, 2012, 02:17:01 am
I have never done anything with Arduino and Ethernet.

I have plugged in an ethernet shield and my network is on 192.168.2.x

The cable works fine issuing a DHCP address to my laptop.

But my arduino returns 0.0.0.0 in the setup routine (Ethernet.LocalIP()) and does not answer on the configured IP Address. I have chosen some random Mac Addresses incase of unknown conflict.

The Green LED on the Ethernet plug on the shield is lit. And the orange led is flickering so there is life. Also the power led on the ethernet board is lit.

I am using Arduino IDE 1.0.1

I am really not sure what to do?

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

byte mac[] = {  0xDD, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE };
IPAddress ip(192,168,2, 197);

EthernetServer server(80);

void setup()
{
Serial.begin(9600);

Serial.println("Ethernet Begin");
   Ethernet.begin(mac, ip);
Serial.println("server");
server.begin();

Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}

void loop()
{

  /* add main program code here */
// Is there any client requests?
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");      
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}

}

Any help appreciated.

Chris
49  Using Arduino / Programming Questions / Re: Problems passings strings to function with variable args on: August 08, 2012, 09:22:17 pm

Code:
#include <stdarg.h>

char *P(char *fmt, ... ){
   static char tmp[128]; // resulting string limited to 128 chars
   Serial.println("A");
   va_list args;
   Serial.println("B");
   va_start (args, fmt );
   Serial.println("C");
   vsnprintf(tmp, 128, fmt, args);
   Serial.println("D");
   va_end (args);
   Serial.println("E");

   delay(100);     
   return tmp;
}


void setup()
{
  Serial.begin(9600);
  Serial.println("Starting...");
}

void loop()
{
String XMLTagStrings[] = {
"data",
"temperature",
"humidity",
"dateTime"
};

  Serial.println("Before Call");
  delay(100);
char *data = P("%s",  "Chris");
//char *data = P("%s",  XMLTagStrings[1]);
  Serial.println("After Call");
Serial.println(data);
delay(1000);
}


This example shows the issue.

As is it will run but comment out the

Code:
char *data = P("%s",  "Chris");

and uncomment the

Code:
//char *data = P("%s",  XMLTagStrings[1]);

and you will see it never prints "A" inside the P function where it does with the previous call with a static string "Chris"

Hope this helps someone help me.

Chris
50  Using Arduino / Programming Questions / Re: Problems passings strings to function with variable args on: August 08, 2012, 09:02:51 pm
In the future, learn to use code tags (hit the '#' button), it helps people read your code.

Good call - I will keep it in mind.

Your problem is the tmp declaration is on the stack.  When you return, the stack is erased, and Serial.println will overwrite it.  I would suggest declaring it as:

Thanks but it does not fix the issue.

I think it may have something to do with passing a String to the function P

If I pass a constant string "CHRIS" then it works as expected, but if I put "Chris" into a String and pass that the function returns no data and for all I know never returns.

Any other ideas?

Chris
51  Using Arduino / Programming Questions / Problems passings strings to function with variable args on: August 08, 2012, 07:34:07 pm
#include <stdarg.h>

char *P(char *fmt, ... ){
   char tmp[128]; // resulting string limited to 128 chars
   va_list args;
   va_start (args, fmt );
   vsnprintf(tmp, 128, fmt, args);
   va_end (args);
   return tmp;
}

I am trying to pass a string from an array to this function

String XMLTagStrings[] = {
"data",
"temperature",
"humidity",
"dateTime"
};

char *data = P("%s",  XMLTagStrings[1]);
Serial.println(data);

I am not sure of the error as it compiles but I get nothing written to the serial port.

If I use the following it works, so I assume that the string below is passed as char *, whereas the other is a String

char *data = P("%s",  "Testing");
Serial.println(data);

I do not know how to translate this so it works with strings - any help appreciated.

Chris
52  Using Arduino / Motors, Mechanics, and Power / Re: Can I run an arduino from 240v on: August 03, 2012, 01:38:54 pm

Perhaps you could treat it like on of those cheap personal weather monitors. They often have just a long barrel jack cable running out a closed window. Plugged into the wall inside of course.

You may be right here - Quick and simple


Chris
53  Using Arduino / Networking, Protocols, and Devices / Re: nRF24L01 on minimum Mega328 breadboard; will it work? on: August 03, 2012, 12:02:57 am
Does anyone know if the nRF24L01 transceiver will work with the minimum breadboard configuration for the Mega328?  I'm running two breadboarded Mega328's with internal 8Mhz clocks but I noticed the nRF24L01's are running 16Mhz clocks...  having a heck of a time getting Maniabug's led_remote tutorial to run, so I'm wondering if it's the clock frequencies.  Do I need to use external 16Mhz crystals on the Mega's?

Can't answer that really - but since the NRF24L01 has its own timing so it should not matter what the ATMega328 is running at.

I put mine on a simple board with ATMega328 and it was runnning a 16Mhz Crystal and it worked with the board.

I did notice that the aerial's had to face each other. If they faced Up then they did not really communicate very well at all.

So if you haven't try that - ie line of sight!

Chris
54  Using Arduino / Motors, Mechanics, and Power / Re: Can I run an arduino from 240v on: August 02, 2012, 04:07:24 am
I assume you will also be measuring the current inductively to calculate usage?

No I am just simply counting pulses on the LED on the meter - 1600 per KWh

So far quite safe as I am keepiung away from the live wires.

It was just a thought as I am surrounded by power but none that I can use!

Chris
55  Using Arduino / Networking, Protocols, and Devices / Re: nRF24L01 Pins to ATMega328 on: August 02, 2012, 02:50:15 am
Also note that the pins are different on different hardware

See
 
http://arduino.cc/en/Main/arduinoBoardDuemilanove for Arduino Duemilanove

and for Arduino Mega 2560

http://arduino.cc/it/Main/ArduinoBoardMega2560

Chris
56  Using Arduino / Networking, Protocols, and Devices / Re: nRF24L01 Pins to ATMega328 on: August 02, 2012, 02:46:30 am
I'm trying out various tutorials on the nRF24L01 transceivers but in 99% of them, how to hook up the pins are hardly ever explained.  Being a newbie, I'm a bit lost.  Is it assumed that all the pins on the nRF24L01 are hooked up to the same corresponding pins on the Arduino (e.g. MOSI, MISO, SCK) but what about the CSN, CE and IRQ pins across all libraries for this transceiver? 

Yes generally you are correct. The IRQ pin is not needed based on what I read.

My Transmitter does not have it connected, but I do hvae it connected on my Receiver but it seems to work.

I'm assuming MOSI goes > MOSI, MISO > MISO, SCK > SCK, but what about the other pins?  In the setup, it specifies RF24 radio(9,10);  are these for CSN and CE?  If so, which pin is which?

I have recently been down this road and looking at the documentation really helps.

The docs are listed on the page you gave http://maniacbug.github.com/RF24/classRF24.html

http://maniacbug.github.com/RF24/classRF24.html#a8cd165a822c8f77e10782c6729c5b088

The first pin in the Constructor is the CE PIN followed by CS PIN

9 is CE Pin
10 is CS PIN (I assume also known as CSE)

These two pins seem to be able to be any general pins so 9 and 10 are not a hard coded set of pins.

CE = Chip Enable
CS = Chip Select

Hope this helps - I too am a newbe

chris
57  Using Arduino / Motors, Mechanics, and Power / Re: Can I run an arduino from 240v on: August 02, 2012, 02:33:58 am
No where. But seriously don't go reinventing the wheel when it comes to ac.

Also wasn't this a question if it can be done? Cuz it can

So can you help me out by giving me a circuit or maybe some links to look at?

Chris
58  Using Arduino / Motors, Mechanics, and Power / Re: Can I run an arduino from 240v on: August 02, 2012, 12:59:46 am
Well you could take the obvious route and gut out a wall wart.  smiley-wink

Where is the fun in that?
59  Using Arduino / Project Guidance / Re: Sleep and Millis() - I need both? on: August 01, 2012, 06:09:41 pm
I have not seen any - the only mode that maintained the millis function was SLEEP_MODE_IDLE when I did some testing.

Have you tried searching? There are quite a few power management libraries around.

http://www.engblaze.com/low-power-libraries-for-arduino-control-sleep-with-single-function-calls/

But do they give me access to a functioning millis() function?

I can't see how a library does as the chip disabled the timers?

I am at work so can not test until tonight!
60  Using Arduino / Motors, Mechanics, and Power / Can I run an arduino from 240v on: August 01, 2012, 05:55:24 pm
I have a project where my arduino needs to be sitting in the power meter box for my house. This is on the outside of the house.

There is only the meter in this box - no power socket for me to use, and batteries will be a problem with how long they last.

A case of Power Everywhere and no power for me to use - a bit like floating in an ocean with no water to drink!

Is there any way I can get 5-9v inductivly from the mains power?

Chris
Pages: 1 2 3 [4] 5 6 7