Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not read device content after long time #6

Open
jlit opened this issue Feb 19, 2024 · 0 comments
Open

Could not read device content after long time #6

jlit opened this issue Feb 19, 2024 · 0 comments

Comments

@jlit
Copy link

jlit commented Feb 19, 2024

I have an implementation that runs fine for days but eventually throws an error. Obviously, nothing changes with the wiring, attached sensors, etc. Any ideas?

image

const tempSensors = require('ds18x20');
const TEMP_CHECK_INTERVAL = 10000;
const INSIDE_TEMP = '28-3c90f64927d0';
const OUTSIDE_TEMP = '28-3c61f649a53e';
let serverState = {};

const checkTemperature = () => {
  try {
    //console.log('list: ', tempSensors.list())
    tempSensors.getAll((err, temps) => {
      if (err) { throw err; }
      serverState.tempInside = Math.min(Math.max(temps[tempInsideProbeId], -40), 60);
      serverState.tempOutside = Math.min(Math.max(temps[tempOutsideProbeId], -40), 60);
      log(`Ambient temps (C): Inside: ${serverState.tempInside} Outside: ${serverState.tempOutside}`);
      // Send in F so we get better resolution with an integer
      sendCSECommand({
        id: CONSTANTS.CSE_CAN_COMMANDS.GPIO_AMBIENT_TEMP_CHANGED.code,
        data: Buffer.from([Math.round((serverState.tempInside * (9/5)) + 32), Math.round((serverState.tempOutside * (9/5)) + 32)])
      });
    });
  }
  catch (err) {
      console.log("Error getting ambient temps: " + err);
}

this.tempCheckInterval = setInterval(() => {
        checkTemperature();
      }, TEMP_CHECK_INTERVAL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant