Show Posts
Pages: [1] 2 3 ... 14
1  Using Arduino / Programming Questions / Re: Compile error with no message on: August 01, 2014, 02:01:21 pm
Thanks econjack, that did the trick!
Jim
2  Using Arduino / Programming Questions / Compile error with no message on: August 01, 2014, 12:36:26 pm
I have written the following
Code:
// read serial and repeat to serial with added string


void setup()
{
  Serial.begin(115200);
}

void loop()
{
 string message[30];
 string saluation[7];
 string fullString[40];
 int lf = 10;
 if (Serial.available() > 0)
  {
    Serial.readBytesUntil(lf, message, 30);
    saluation = 'I got ';
    fullString = saluation + message;
    Serial.println(fullString);
    delay(1000);
  }
}
When I try to compile, the orange bar says "error compiling", and there is no explanation below.
I know the way I'm doing this is kludgie, but I'm still new to C or C+.
Jim
3  Community / Local Groups / Re: Anyone in Denver or Colorado? on: July 14, 2014, 07:49:04 pm
I'm in Buena Vista. I just a advancing newbie. I sure wist there was a group here!

Jim
4  Using Arduino / Installation & Troubleshooting / Question about loading Atmel Sudio for Arduino on: April 02, 2014, 02:32:29 pm
I'm following the instructions at http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/. I get to the step where you load the <project_name>.cpp file(Step 6). I compiled the "Blink" example. There is a "Blink.cpp.d" file, a "Blink.cpp.eep" file, a Blink.cpp elf" file, a "Blink.cpp.hex" file, and a "Blink.cpp.o" file, but no "Blink.cpp" file, or even a "<name>.cpp". There are several other files with a "cpp.d" or "cpp.o" extension. Which is the one I want to copy?

Jim
5  Community / Products and Services / Re: Amazing Sale...Arduino's for $3!!! on: April 01, 2014, 07:37:50 pm
You had to register to get the deal. My email is so slow that the time limit was over befote I could register. Oh well,Boo Hoo
Jim
6  Community / Bar Sport / Re: whats with the attitude on: March 12, 2014, 04:00:38 pm
Example of the attitude, I had a problem with dtostrf, and asked for help in the programming forum. Some replies:
----------------------
Code:

Serial.println('   ');

What's that?
----------------------
 and
-----------------------
The argument to Serial.print() should be a double-quoted string when you wish to print a string literal, such as:

Code:

 
Serial.println("I'm here");


The "ln" at the end of Serial.println() means the next thing printed is on a new line. No need for the redundant blank space. Indeed, I'm not sure what the compiler does with the single-quote space.
-------------------------
and
Or, indeed, multiple single-quote spaces.
--------------------------

No one addressed my question, just picked nits with a small trivial error!!!

Jim
7  Using Arduino / Programming Questions / Re: dtostrf question on: March 11, 2014, 04:07:06 pm
Or, indeed, multiple single-quote spaces.
So spank me and send me to bed without dinner. What does this have to do with my question!

Jim
8  Using Arduino / Programming Questions / Re: dtostrf question on: March 11, 2014, 01:49:16 pm
Code:
Serial.println('   ');
What's that?
A blank line separator

Jim
9  Using Arduino / Programming Questions / Re: Arduino <> raspberry pi via i2c on: March 11, 2014, 11:34:07 am
Quote
In the writeData function.
Which wasn't even in the first code you posted. I've lost track of what your problem is.
I trying to pass data from arduino to rpi via i2c.

Jim
10  Using Arduino / Programming Questions / Re: dtostrf question on: March 10, 2014, 04:00:40 pm
We can't do much unless you post your code. Format it first in the IDE (Ctrl-T) and then post it using the code tags (the # icon). However, if I had to bet, my guess is that you set the width parameter to dtostrf() larger than you want.
Code:
/**
 * ReadSHT1xValues
 *
 * Read temperature and humidity values from an SHT1x-series (SHT10,
 * SHT11, SHT15) sensor.
 *
 * Copyright 2009 Jonathan Oxer <jon@oxer.com.au>
 * www.practicalarduino.com
 */

#include <SHT1x.h>
#include <Wire.h>
#include <UTFT.h>\
#include <stdlib.h>



// Specify data and clock connections and instantiate SHT1x object
#define dataPin  15
#define clockPin 14
#define SLAVE_ADDRESS 0x04
extern uint8_t BigFont[];
char tStr[7];
char hStr[4];

UTFT    myGLCD(ITDB32S,38,39,40,41);
SHT1x   sht1x(dataPin, clockPin);


void setup()
{
  Serial.begin(115200); // Open serial connection to report values to host
  Serial.println("Starting up");
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);
  myGLCD.setBackColor(0, 0, 255);
  Wire.begin(0x04); // join i2c bus
}

void loop()
{
  float temp_c;
  float temp_f;
  float humidity;

  // Read values from the sensor
  temp_c = sht1x.readTemperatureC();
  temp_f = sht1x.readTemperatureF();
  humidity = sht1x.readHumidity();


  dtostrf(temp_f, 6, 2, tStr);
  dtostrf(humidity, 2, 0, hStr);
  Serial.print(tStr);
  Serial.println('   ');
  Serial.print(hStr);
  Serial.println('   ');
  myGLCD.print("Temperature: ",LEFT,0);
  myGLCD.print(tStr,15*13,0);
  myGLCD.print("Humidity: ",LEFT,15);
  myGLCD.print(hStr,12*13,15);
  delay(2000);
}

// callback for received data
void receiveData()
{
  char c = Wire.read();
///  Serial.println(c);
}



void writeData (char* data)
{
  Wire.beginTransmission(04); // transmit to device #04
  // device address is specified in datasheet
  Wire.write(data);             // sends value byte 
  Wire.endTransmission();     // stop transmitting

  delay(500);
}

// callback for received data
void readData ()
{
  int number;
  while(Wire.available())
  {
    number = Wire.read();
    switch (number)
    {
    case 1:
      writeData(tStr);
      break;
    case  2:
      writeData(hStr);
      break;
    }
  }
}

Relevant part is is loop function

Jim
11  Using Arduino / Programming Questions / dtostrf question on: March 10, 2014, 12:35:45 pm
I wrote this code which should display temperature with 2 digits after the decimal point and humidity with none on both a lcd and serial monitor. It displays correctly as written on the lcd
 71.23
29
the space in front of the 7 is to make room for a - sign, but on the serial monitor you get:
71.2384
298224
I am using the definition of dtostrf given at http://bradsduino.blogspot.com/2013/05/arduino-c-code-to-convert-float-to.html
I can't  understand why the two displays are displaying different.
Jim
12  Using Arduino / Programming Questions / Re: Arduino <> raspberry pi via i2c on: March 10, 2014, 11:48:04 am
Quote
and the general consensus was that the arduino is not passing good info.
Based on what evidence? Where do you (think you) actually send data to the I2C bus?
In the writeData function. It works in arduino code
Code:
#include <Wire.h>

#define SLAVE_ADDRESS 0x04
int number = 0;
int state = 0;

void setup() {
    pinMode(13, OUTPUT);
    Serial.begin(9600);         // start serial for output
    // initialize i2c as slave
    Wire.begin(SLAVE_ADDRESS);

    // define callbacks for i2c communication
    Wire.onReceive(receiveData);
    Wire.onRequest(sendData);

    Serial.println("Ready!");
}

void loop() {
    delay(100);
}

// callback for received data
void receiveData(int byteCount){

    while(Wire.available()) {
        number = Wire.read();
        Serial.print("data received: ");
        Serial.println(number);

        if (number == 1){

            if (state == 0){
                digitalWrite(13, HIGH); // set the LED on
                state = 1;
            }
            else{
                digitalWrite(13, LOW); // set the LED off
                state = 0;
            }
         }
     }
}

// callback for sending data
void sendData(){
    Wire.write(number);
}
pi code
Code:
import smbus
import time
# for RPI version 1, use "bus = smbus.SMBus(0)"
bus = smbus.SMBus(1)

# This is the address we setup in the Arduino Program
address = 0x04

def writeNumber(value):
    bus.write_byte(address, value)
    # bus.write_byte_data(address, 0, value)
    return -1

def readNumber():
    number = bus.read_byte(address)
    # number = bus.read_byte_data(address, 1)
    return number

while True:
    var = input("Enter 1 - 9: ")
    if not var:
        continue

    writeNumber(var)
    print "RPI: Hi Arduino, I sent you ", var
    # sleep one second
    time.sleep(1)

    number = readNumber()
    print "Arduino: Hey RPI, I received a digit ", number
    print


where result on pi is

  RPI: Hi Arduino, I sent you  2

Arduino: Hey RPI, I received a digit   2

  RPI: Hi Arduino, I sent you  9

Arduino: Hey RPI, I received a digit   9
Jim
13  Using Arduino / Programming Questions / Arduino <> raspberry pi via i2c on: March 09, 2014, 08:16:01 pm
I am trying to pass data to a rpi from arduino via i2c.The lcd is displaying the correct values at the arduino. i am getting this result from the rpi
quote]
    Enter Task
    1 Check Time
    2 North Garage Door
    3 South Garage Door
    : 1
    RPI:Hi Arduino, I sent you a 1
    Time is
    []

   Enter Task
    1 Check Time
    2 North Garage Door
    3 South Garage Door
    : 2
    RPI:Hi Arduino, I sent you a 1
    Time is
   
 Enter Task
    1 Check Time
    2 North Garage Door
    3 South Garage Door
    [][/quote]

Arduino code:
Code:
/**
 * ReadSHT1xValues
 *
 * Read temperature and humidity values from an SHT1x-series (SHT10,
 * SHT11, SHT15) sensor.
 *
 * Copyright 2009 Jonathan Oxer <jon@oxer.com.au>
 * www.practicalarduino.com
 */

#include <SHT1x.h>
#include <Wire.h>
#include <UTFT.h>\




// Specify data and clock connections and instantiate SHT1x object
#define dataPin  15
#define clockPin 14
#define SLAVE_ADDRESS 0x04
extern uint8_t BigFont[];
char tStr[7];
char hStr[4];

UTFT    myGLCD(ITDB32S,38,39,40,41);
SHT1x   sht1x(dataPin, clockPin);


void setup()
{
  Serial.begin(115200); // Open serial connection to report values to host
  Serial.println("Starting up");
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);
  myGLCD.setBackColor(0, 0, 255);
  Wire.begin(0x04); // join i2c bus
}

void loop()
{
  float temp_c;
  float temp_f;
  float humidity;

  // Read values from the sensor
  temp_c = sht1x.readTemperatureC();
  temp_f = sht1x.readTemperatureF();
  humidity = sht1x.readHumidity();


  dtostrf(temp_f, 4, 1, tStr);
  dtostrf(humidity, 2, 0, hStr);
  Serial.print(tStr);
  Serial.println('   ');
  Serial.print(hStr);
  Serial.println('   ');
  myGLCD.print("Temperature: ",LEFT,0);
  myGLCD.print(tStr,15*13,0);
  myGLCD.print("Humidity: ",LEFT,15);
  myGLCD.print(hStr,12*13,15);
  delay(2000);
}

// callback for received data
void receiveData()
{
  char c = Wire.read();
///  Serial.println(c);
}



void writeData (char* data)
{
  Wire.beginTransmission(04); // transmit to device #04
  // device address is specified in datasheet
  Wire.write(data);             // sends value byte 
  Wire.endTransmission();     // stop transmitting

  delay(500);
}

// callback for received data
void readData ()
{
  int number;
  while(Wire.available())
  {
    number = Wire.read();
    switch (number)
    {
    case 1:
      writeData(tStr);
      break;
    case  2:
      writeData(hStr);
      break;
    }
  }
}

Raspberry pi code
Code:
    import smbus
    import time
    # for RPI version 1, use "bus = smbus.SMBus(0)"
    bus = smbus.SMBus(1)

    # This is the address we setup in the Arduino Program
    address = 0x04

    def writeNumber(address, value):
        bus.write_byte(address, value)
        # bus.write_byte_data(address, value)
        return -1

    def writeChar(address, value):
        bus.write_word(address, value)
        return -1


    def readNumber(address):
        number = bus.read_byte(address)
        #number = bus.read_byte_data(address, 1)
        return number

    while True:
        print "Enter Task"
        print "1  Ckeck Time"
        print "2  North Garage Door"
        print "3  South Garage Door"
        var = input(": ")
        if not var:
            continue

        writeNumber(address, var)
        print "RPI: Hi Arduino, I sent you ", var


        # sleep one second
        time.sleep(1)

        number = readNumber(address)
        print "Arduino: Hey RPI, I received a digit ", number
        print


    def rdb():
        buffer[10]
        bus.read_block_data(address,buffer)
I posted this on the rpi forum and the general consensus was that the arduino is not passing good info. So I'd like your opinion.

Jim
14  Using Arduino / Project Guidance / I2c sniffer on: March 08, 2014, 02:10:13 pm
Is it possible to setup an arduino as a slave on i2c which monitors and displays all traffic on the bus on the serial monitor? It should probably look at the length to decide if it a string,word or byte and process accordingly. Has anyone done this?

Jim
15  Using Arduino / Programming Questions / Re: Trouble with i2c on: March 07, 2014, 03:47:28 pm
Thanks Pete, now I have to chase down logic (me dummy) errors
Jim
Pages: [1] 2 3 ... 14