I have a Raspberry pi connected to an Arduino over i2c. I am attempting to pass a string to the pi.
My 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(38400); // 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, 1, 1, tStr);
dtostrf(humidity, 1, 0, hStr);
Serial.print(tStr);
Serial.print(' ');
Serial.print(hStr);
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;
}
}
}
The error I am getting is:
readTemp_ino1.ino: In function 'void readData()':
readTemp_ino1:94: error: invalid conversion from 'char*' to 'char'
readTemp_ino1:94: error: initializing argument 1 of 'void writeData(char)'
readTemp_ino1:97: error: invalid conversion from 'char*' to 'char'
readTemp_ino1:97: error: initializing argument 1 of 'void writeData(char)'
What am I doing wrong?
Jim