Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Last active September 13, 2017 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuc-arc-f/b3e1aaa30c88843150e70f5d4b4620ab to your computer and use it in GitHub Desktop.
Save kuc-arc-f/b3e1aaa30c88843150e70f5d4b4620ab to your computer and use it in GitHub Desktop.
arduino 3V3, LM60BIZ Sensor driver
//define
const int mVoutPin = 0;
uint32_t mTimerTmp;
//
long convert_Map(long x, long in_min, long in_max, long out_min, long out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
//
// reading LM60BIZ
int getTempNum(){
int iRet=0;
float fSen = 0;
unsigned long reading = 0;
for (int i=0; i<10; i++) {
int iTmp = analogRead(mVoutPin);
reading += iTmp;
delay(100);
}
int SValue= reading / 10;
//SValue = SValue * (3300 / 1000) ;
Serial.print("SValue=");
Serial.print(SValue);
int voltage=convert_Map(SValue, 0, 1000, 0,3300); // V
Serial.print(" , voltage=");
Serial.println(voltage);
int iTemp = (voltage - 424) / 6.25; //電圧値を温度に変換, offset=425
iRet= iTemp;
return iRet;
}
//
void setup() {
Serial.begin(9600);
Serial.println("# Start-setup");
}
//
void loop() {
delay( 100 );
int iNum=0;
if (millis() > mTimerTmp) {
mTimerTmp = millis()+ 3000;
int itemp= getTempNum();
Serial.print("itemp=");
Serial.println(itemp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment