Show Posts
Pages: 1 2 [3] 4 5 ... 17
31  Using Arduino / Programming Questions / Re: What happens when you hit "send" in the serial monitor? on: January 27, 2013, 12:29:35 am
Quote
Exactly, I need the arduino to send the "s" command to start communications.

What's that got to do with hitting send on the serial monitor then?

I'm out...

Because I need unit B to act as if it was sending the "s" command from the serial monitor.
32  Using Arduino / Programming Questions / Re: What happens when you hit "send" in the serial monitor? on: January 27, 2013, 12:26:48 am
Quote
When pressing enter on the serial monitor, what is actually being sent?

What is in the text box of the serial monitor is sent, plus the option selected at the bottom of the serial monitor.

"s" is the only character.

serial monitor options are as follows:

autoscroll is checked
"No line ending" selected
115200 baud rate.
33  Using Arduino / Programming Questions / Re: What happens when you hit "send" in the serial monitor? on: January 27, 2013, 12:12:43 am
Here is the full RX (unit B) code. The TX unit isn't in Arduino IDE code so I'm not going to bother to post it, plus it's really long.


Code:
#include <TextFinder.h>
#include "PCD8544.h"

TextFinder finder(Serial);
const int NUMBER_OF_FIELDS = 24; // how many comma-separated fields we expect
int fieldIndex = 0; // the current field being received
float values[NUMBER_OF_FIELDS]; // array holding values for all the fields

// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 4, 3);
int batPix = 0; //Pixel for battery graphics
int craftHeading = 0;
int alarmHeading = 0;
int craftAlt = 0;
int alarmAlt = 0;
float craftBattery = 0;
float alarmBattery = 0;

void setup()
{
Serial.begin(111111); // Initialize serial port

  nokia.init();
  nokia.setContrast(45);
  
  Serial.print("s\r");
  
nokia.setCursor(0, 0);
nokia.print("Connecting to Craft.......");
nokia.display();
  
}

void loop()
{
  nokia.clear();
for(fieldIndex = 0; fieldIndex < 24; fieldIndex ++)
{
values[fieldIndex] = finder.getFloat(); // get a numeric value
}
//Serial.print( fieldIndex);
//Serial.println(" fields received:");

craftHeading = values[3]; //Serial.println(" Heading");
craftAlt = values[4]; //Serial.println(" Altitude");
craftBattery = values[22]; //Serial.println(" Volts");

nokia.setCursor(0, 0);
nokia.println("CRAFT    STTNG");
nokia.setCursor(6, 9);
nokia.print(craftHeading);
nokia.setCursor(33, 9);
nokia.print("HDG");
nokia.setCursor(61, 9);
nokia.print(alarmHeading);

nokia.setCursor(6, 18);
nokia.print(craftAlt);
nokia.setCursor(33, 18);
nokia.print("ALT");
nokia.setCursor(61, 18);
nokia.print(alarmAlt);

nokia.setCursor(0, 27);
nokia.print(craftBattery);
nokia.setCursor(33, 27);
nokia.print("BAT");
nokia.setCursor(58, 27);
nokia.print(alarmBattery);

nokia.setCursor(0, 38);
nokia.print("E");
nokia.setCursor(78, 38);
nokia.print("F");

nokia.drawline(8, 36, 69, 36, BLACK);
nokia.drawline(8, 47, 69, 47, BLACK);
nokia.drawline(69, 36, 69, 47, BLACK);
nokia.drawline(8, 36, 8, 47, BLACK);
nokia.drawline(70, 38, 72, 38, BLACK);
nokia.drawline(70, 45, 72, 45, BLACK);
nokia.drawline(73, 38, 73, 45, BLACK);

nokia.fillrect(9, 37, batPix, 10, 1);
nokia.display();

fieldIndex = 0; // ready to start over
}
34  Using Arduino / Programming Questions / Re: What happens when you hit "send" in the serial monitor? on: January 27, 2013, 12:06:37 am
But Serial.print sends from the Arduino to the monitor...

 

Exactly, I need the arduino to send the "s" command to start communications. Just assume I have two arduinos connected via serial. Unit A is waiting for the "s" command to come from the serial before it will start streaming data to Unit B. Unit B upon boot up will send the "s" command via serial to A to let it know that it is ready. So I do need unit B to Serial.print.

I have tested unit A through the serial monitor and it works fine.

But thank you anyway.
35  Using Arduino / Programming Questions / What happens when you hit "send" in the serial monitor? on: January 26, 2013, 11:48:02 pm
I'm having trouble with what I thought was a simple item.

I have a device that is waiting for "s" to be sent via serial before it will start transmitting data.

I assumed the correct way was

Code:
Serial.print("s\r");
but this does not get the job done.

When pressing enter on the serial monitor, what is actually being sent?

Thanks everyone.
36  Using Arduino / Programming Questions / Re: Floats stored in an array? Having troubles on: January 19, 2013, 02:06:04 pm
Paul, I guess I was trying to say that somewhere a int was being converted to a float. So the 11.3 >int = 11> float = 11.00.

Thanks Coding Badly. That worked perfectly.
37  Using Arduino / Programming Questions / Floats stored in an array? Having troubles on: January 19, 2013, 12:35:46 am
When I try to store float variables in an array, I get a int values with a few decimal places after them. The code will work with int variables however, that is not what I need. So where is the number getting truncated?

Code:
#include <TextFinder.h>

TextFinder finder(Serial);
const int NUMBER_OF_FIELDS = 28; // how many comma-separated fields we expect
int fieldIndex = 0; // the current field being received
float values[NUMBER_OF_FIELDS]; // array holding values for all the fields

void setup()
{
Serial.begin(57600); // Initialize serial port to send and receive at 57600 baud
}

void loop()
{
for(fieldIndex = 0; fieldIndex < 28; fieldIndex ++)
{
values[fieldIndex] = finder.getValue(); // get a numeric value
}
Serial.print( fieldIndex);
Serial.println(" fields received:");
for(int i=0; i < fieldIndex; i++)
{
Serial.println(values[i]);
}
fieldIndex = 0; // ready to start over
}

Variables I was using...

Code:
0,0.02,-0.01,9.82,2.0,0,1500,1500,1500,1000,1000,2000,0,0, 1000,1000,1000,1000,0,0,0,0,11.3,0\r\n

Any help would be great! thanks!
38  Using Arduino / Programming Questions / pyFirmata on: November 08, 2012, 09:34:17 pm
I know this is not exactly the right place to ask, But google searches have yielded nothing useful and I don't want to join a Python forum to ask a single question.

I'm trying to install pyFirmata to use with my arduino but I can't get it to install. I'm using Python 3.2.3, have pyserial installed and want to install this:

https://bitbucket.org/tino/pyfirmata/overview

I get the following when trying to install from the command prompt (windows 7 64bit)

Code:
C:\Python32>cd pyfirmata

C:\Python32\pyfirmata>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    import pyfirmata
  File "C:\Python32\pyfirmata\pyfirmata\__init__.py", line 2, in <module>
    from boards import BOARDS
ImportError: No module named boards

C:\Python32\pyfirmata>

Any ideas? I have been trying to get python to talk to the arduino for the last two weeks and have no success with any of the methods!!!!
39  Using Arduino / Networking, Protocols, and Devices / Re: Server haulting after 4 days on: October 11, 2012, 05:11:26 pm
Thanks guys.

Tim, this is a crappy modem/router. There is no way to fix the ip as static... If I use a static IP declared in the code the router refuses to "see" the arduino, although I can ping and access it locally by typing in it's IP via a web browser.

Zoomkat, the arduino is connected to a AT&T/2 Wire Gateway DSL modem/router... AKA garbage. Are you saying that the router would be in charge of the IPs if it was between the modem and arduino?
40  Using Arduino / Networking, Protocols, and Devices / Re: Server haulting after 4 days on: October 10, 2012, 09:15:41 pm
So I changed out some of the obvious stuff that was eating up memory. The code went from 400 bytes free to 630 bytes free.

The code froze after 10 days of running. The free memory never dropped below 630 bytes (that I am aware of).

Something did come to me. I had the code running for weeks at my house. When I installed it in it's permanent location, it is connect through a AT&T gateway which requires that the code request an IP using DHCP rather than pushing one with a IP declared in the code. At my house, I did not use DHCP.

My understanding is that IDE 1.0 had included the DHCP support and there were some improvements.

Do you guys think that this could be the cause? I'm going to try to get the code working in v1.0 or v1.0.1...

Code:
#include <memoryfree.h>
#include <Ethernet.h>
#include <TextFinder.h>
#include "DHT.h"
//#include <avr/pgmspace.h> // for progmem
#include <Dhcp.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>


#define DHTPIN 5
#define DHTTYPE DHT22
//-----------------------------------------------------------------------

// nRF24L01(+) radio attached to SPI and pins 8 & 9
RF24 radio(8,9);
// Network uses that radio
RF24Network network(radio);
// Address of our node
const uint16_t this_node = 1;
// Address of the other node
const uint16_t other_node = 0;

//-----------------------------------------------------------------------
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0xCA };//= { 0xC5, 0xA1, 0xDA, 0x00, 0xE3, 0xA3 };
char buffer[8]; // buffer holding the requested page name
Server server(80);
int relayPin = 3;
int switchPin = 2;
int ledPin = 4;
int val5 = 0;
int val = 0;
int stat = 0;
int doorStat;
int doorStat2;
int doorStat3;
int humid;
//int t;
int temp;
int t2 = 0;
int h2 = 0;
const unsigned long interval = 2000;
unsigned long last_sent;

DHT dht(DHTPIN, DHTTYPE);
//--------------------------------------------------------------------------

struct message_t
{
uint16_t temp_reading;
uint16_t humid_reading;
uint16_t doorStat_reading;
message_t(void): temp_reading(), humid_reading(), doorStat_reading() {}
};

struct door_t
{
uint16_t door_reading;
door_t(void): door_reading(0) {}
};
//--------------------------------------------------------------------------

void setup()
{
//        Serial.begin(9600);
while (Dhcp.beginWithDHCP(mac) != 1)
{
delay(15000);
}
delay(1000);

server.begin();
dht.begin();
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
delay(3000);
pinMode(relayPin, OUTPUT);
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(relayPin, HIGH);
digitalWrite(switchPin, HIGH);

}

void loop(){

//    Serial.print("freeMemory()=");
//    Serial.println(freeMemory());
 
//-------------------------------------------
humid = dht.readHumidity();
//t = dht.readTemperature();
temp = (dht.readTemperature() * 1.8 + 32);

//----------------------------------------------
// Pump the network regularly
network.update();

// If it's time to send a message, send it!
unsigned long now = millis();
if ( now - last_sent > interval )
{
last_sent = now;


RF24NetworkHeader header(/*to node*/ other_node);
door_t door;
door.door_reading += relayPin;
bool ok = network.write(header,&door,sizeof(door));
relayPin = 3;
}


while ( network.available() )
{
message_t message;
RF24NetworkHeader header;
network.read(header,&message,sizeof(message));
t2 = (message.temp_reading * 1.8 + 32);
h2 = (message.humid_reading);
stat = (message.doorStat_reading);

delay(1000);
}
//----------------------------------------------

Client client = server.available();
if (client) {
TextFinder finder(client );
int type = 0;
while (client.connected()) {
if (client.available()) {
// GET, POST, or HEAD
if(finder.getString("","/", buffer,sizeof(buffer))){
if(strcmp(buffer,"POST ") == 0){
finder.find("\n\r"); // skip to the body
// find string starting with "pin", stop on first blank line
// the POST parameters expected in the form pinDx=Y
// where x is the pin number and Y is 0 for LOW and 1 for HIGH

//------------------------------------------------
while(finder.findUntil("pinD", "\n\r")){
relayPin = finder.getValue(); // the pin number
val = finder.getValue(); // 0 or 1
digitalWrite(relayPin, val);
delay(1000);
digitalWrite(relayPin, HIGH);
}

//------------------------------------------------------------
}

//client.print("<meta http-equiv=\"refresh\" content=\"10\">");
sendHeader(client,"Votto Vines Warehouse");
client.println("<h1><center>Votto Vines</center></h1>");
client.print("<center><IMG SRC='http://24.34.89.0:85/VVwh.jpg' ALT='Image'></center>");
client.println("<br />");
client.println("Warehouse 1 Temperature = "); client.print(temp); client.print("*F");
client.println(", Humidity = "); client.print(humid); client.print("% RH");
client.println("<br />");
client.println("Warehouse 2 Temperature = "); client.print(t2); client.print("*F");
client.println(", Humidity = "); client.print(h2); client.print("% RH");
//-------------------------------------------------------------------------
//Door 1
client.println("<h3>Warehouse 1</h3>");
client.print("<form action='/' method='POST'><p><input type='hidden'name='pinD3'");
client.print(" value='0'><input type='submit' value='Operate Door'/></form>");

client.print("Door is ");
if(doorStat == 1){
client.println("OPEN!");
}
else{
client.println("CLOSED");
}
client.println("<br />");

//--------------------------------------------------------------------------------
//Door 2

client.println("<h3>Warehouse 2</h3>");
client.print("<form action='/' method='POST'><p><input type='hidden'name='pinD4'");
client.print(" value='0'><input type='submit' value='Operate Door'/></form>");

client.print("Door is ");
if(doorStat2 == 1){
client.println("OPEN!");
}
else{
client.println("CLOSED");
}
client.println("<br />");

//--------------------------------------------------------------------------------
//Door 3

client.println("<h3>Warehouse 3</h3>");
client.print("<form action='/' method='POST'><p><input type='hidden'name='pinD5'");
client.print(" value='0'><input type='submit' value='Operate Door'/></form>");

client.print("Door is ");
if(doorStat3 == 1){
client.println("OPEN!");
}
else{
client.println("CLOSED");
client.println("<br />");
client.println("<br />");
client.print("Memory Free =");
client.println(freeMemory());
}
client.println("<br />");

//--------------------------------------------------------------------------------
client.println("</body></html>");
client.stop();
}
break;
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}


val5 = digitalRead(switchPin); // read the input pin
digitalWrite(ledPin, val5); // sets the LED to the button's value
if(val5 == LOW){
doorStat = 0; // low = closed = 1
}
else {
doorStat = 1;
}
//------------------------------------------------------------


//----------------------------------------------

switch(stat)
{
case 0:
doorStat2 = 0;
doorStat3 = 0;
break;
case 10:
doorStat2 = 1;
doorStat3 = 0;
break;
case 01:
doorStat2 = 0;
doorStat3 = 1;
break;
case 11:
doorStat2 = 1;
doorStat3 = 1;
break;
default :
break;
}

}

//----------------------------------------------------------------

void sendHeader(Client client, char *title){
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<meta http-equiv=\"refresh\" content=\"10\">");
client.print("<html><head><title>");
client.print(title);
client.println("</title><body>");
}
41  Using Arduino / Installation & Troubleshooting / Re: Mega Pro 16 mHz/5v not uploading... on: October 02, 2012, 10:40:39 pm
Yeah, slowing it down didn't help... I only tried it in 1.0, it may work in 22 but all of the code I want to upload it 1.0 based.

I just bought this board, so I think it will be going back...
42  Using Arduino / Installation & Troubleshooting / Re: Mega Pro 16 mHz/5v not uploading... on: October 02, 2012, 10:35:10 pm
Try turning down the upload speed in the boards.txt:
mega2560.upload.speed=57600

My reasoning is that the Mega1280 had an FTDI on it as well.

The board is clearly not auto resetting... unfortunately. Is there a fix for that?
43  Using Arduino / Installation & Troubleshooting / Re: Mega Pro 16 mHz/5v not uploading... on: October 02, 2012, 09:16:56 pm
Spoke too soon... Still doesn't work with 1.0 IDE.

It works with v 22 but I get two "avrdude: stk500_2_ReceiveMessage(): timeout" before it uploads.
44  Using Arduino / Installation & Troubleshooting / Re: Mega Pro 16 mHz/5v not uploading... on: October 02, 2012, 08:30:40 pm
Quote
Yes with a very well timed reset button push, I got it to upload once... But that, to me, eas luck and certainly not how it should be

Really?  Try this.  Upload your sketch again with the normal Arduino Mega2560 board with the reset button held down and watch the Tx LED on the FTDI breakout board.  The moment you see *2* flashes on the Tx LED, release the reset button.

Reburned the fuse and bootloader using my USBtinyISP and AVRdude... Appears to be working well now.

Thanks for your help
45  Using Arduino / Installation & Troubleshooting / Re: Mega Pro 16 mHz/5v not uploading... on: October 02, 2012, 10:38:19 am
Quote
I can bootload through a USBtinyISP. Could I just use the normal Mega 2560 bootloader?

That would be just fine.  Did you try the normal "Arduino Mega2560 ADK" board with your sketch and FTDI?  That one would be the 5v/16MHz board settings.

Yes with a very well timed reset button push, I got it to upload once... But that, to me, eas luck and certainly not how it should be
Pages: 1 2 [3] 4 5 ... 17