Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f kuc-arc-f/LM60BIZ.ino
Last active Sep 13, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.