hi everyone?
Can you help me with this problem. I don't know why my serial monitor did't print anything while i using arduino yun to run it. But if i use the arduino uno, the serial monitor was giving the sensor reading. I really do not know what is the problem. Please help me.... below is my coding:
#include <TH02_dev.h>
#include <Bridge.h>
#include <Process.h>
#define SENSOR_COUNT (5)
#define VAR1_COUNT (SENSOR_COUNT+1)
typedef int (*pgetSensorValue)(void);
int getTempSensorValue();
int getSoundSensorValue();
int getHumiSensorValue();
int getLightSensorValue();
int getUVSensorValue();
int getPIRSensorValue();
const int LightSensorIndex = 1;
const int UVSensorIndex = 2;
const int THSensorIndex = 3;
const int pinLight = A2;
const int pinUV = A3;
const int pinPIR = 7;
const char* SerialVarList1[] = { "temperature", "humidity", "light", "uv", "pir"};
enum SENSOR {TEMPER=0,HUMI,LIGHT,UV,PIR,MS};
pgetSensorValue getSensorValueList[]={
getTempSensorValue,
getHumiSensorValue,
getLightSensorValue,
getUVSensorValue,
getPIRSensorValue,
};
int SensorValue[SENSOR_COUNT];
void printSettings(void){
Serial.println("The Sensors Value as follow:");
for(int i=0; i<SENSOR_COUNT;i++){
Serial.print(SerialVarList1[i]);
Serial.print(" = ");
Serial.println(getSensorValueList[i]());
}
}
//get Temperature Senso value
int getTempSensorValue(){
int temper =(int) TH02.ReadTemperature();
SensorValue[TEMPER] = temper;
return temper;
}
//get Humidity Senso value
int getHumiSensorValue(){
int humidity =(int)TH02.ReadHumidity();
SensorValue[HUMI] = humidity;
return humidity;
}
//get Grove-Light Sensor value
int getLightSensorValue(){
return (SensorValue[LIGHT] = analogRead(pinLight));
}
//get Grove-UV Sensor value
int getUVSensorValue(){
return (SensorValue[UV] = analogRead(pinUV));
}
//Grove PIR Motion Sensor
int getPIRSensorValue(){
return (SensorValue[PIR] = digitalRead(pinPIR));
}
void setup()
{
Bridge.begin();
Serial.begin(9600);
printSettings();
}
void loop()
{
printSettings();
delay(1000);
}