Search code examples
soliditychainlinkchainlink-keepers

Can chainlink function read local data?


I try to use chainlink function to retrieve local data, but got an error of "Error: Import of module node-dht-sensor not allowed" . I'd like to know whether Chainlink Function can be used to get local live data.

const sensor = require('node-dht-sensor');

const DHT_TYPE = 11;


const DHT_PIN = 4;

function readTemperature() {
  return new Promise((resolve, reject) => {
    sensor.read(DHT_TYPE, DHT_PIN, (err, temperature, humidity) => {
      if (err) {
        reject(err);
      } else {
        resolve({ temperature, humidity });
      }
    });
  });
}

const { temperature, humidity } = await readTemperature();


const roundedfootprint = Math.round(temperature)

return Functions.encodeUint256(roundedfootprint)

Solution

  • Afaik, currently, Chainlink Functions do not support local live data. To achieve this, you need to update off-chain IoT data on a cloud-hosted database service, such as AWS IoT Core.