ポジローぽけっと

昨日より今日、今日より明日を信じて、トライトライ

第十五回スパルタンプログラミング

いっしーからの初受注

時間

受託開発なので、時間は重要。いかに短く上げられるかが重要。

  • 8/15: 17:00-19:00 実働2h
  • 8/16: 11:00-18:00 実働6h

8h*2000=16000円です!

内容

開発メモ

何がしたい?

ATサーミスタ、103AT-2(10K)、のデータロガーをくみ上げたい。

何が問題?

メモ

  • PC側XBee個別ID: 0013A200 /[40B40F6B]
  • ArduinoXBee個別ID: 0013A200 /[40B415B1]
  • PAN ID:[1111]

つまづき

  • 1対1通信のテストができずにつまづいた。
  • 原因:PC側もArduino側もROUTER ATだったため。
  • 解決:PC側をCOODINATOR ATに変更。

Zigbee Networking with XBee Series 2 and Seeed's Productsの画像で気づいた。

test code

#define Road 10.0
#define RowMax 6

double tempMap[RowMax][2] = {
                {5.827, 40.0},
                {8.313, 30.0},
                {10.00, 25.0},
                {12.09, 20.0},
                {17.96, 10.0},                
                {27.28,  0.0}
};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Measurement Start");
}

void loop() {
  // put your main code here, to run repeatedly: 
  unsigned int val, i;
  double volt, road, temp;
  
  val = analogRead(0);
  Serial.print("Analog Read:");
  Serial.println(val);
  //アナログ入力値を電圧に換算
  volt=(float)val*(5.0/1023.0);
  Serial.print("Voltage[V]:");
  Serial.println(volt);
  //抵抗値の算出
  road=volt/(5.0-volt)*Road;
  Serial.print("road[Korm]:");
  Serial.println(road);  
  //マップから温度を取得
  for(i=0;i<RowMax;i++)
  {
    if(road>=tempMap[i][0] && road<tempMap[i+1][0])
    {
      break;
    }
  }
  Serial.print("temp[degC]:");
  if(i<RowMax){
    //線形補完
    float a = (tempMap[i+1][1]-tempMap[i][1])/(tempMap[i+1][0]-tempMap[i][0]);//傾き
    temp = a*(road-tempMap[i][0])+tempMap[i][1];
    Serial.println(temp);
  }else{
    Serial.println("void");
  }
  delay(1000);
}