프로그램&회로

wifi 온습도계 사용..

엠칩 2025. 2. 25. 08:25
반응형

아직 물건을 받지못해 자료만 정리중이니 참고바랍니다.

 

const apiKey = 'YOUR_TUYA_API_KEY';
const deviceId = 'YOUR_DEVICE_ID';

fetch(`https://openapi.tuya.com/v1.0/devices/${deviceId}/status`, {
  headers: {
    'Content-Type': 'application/json',
    'client_id': 'YOUR_CLIENT_ID',
    'sign': 'YOUR_SIGN',
    't': Date.now(),
    'access_token': 'YOUR_ACCESS_TOKEN',
  },
})
  .then(response => response.json())
  .then(data => {
    const temperature = data.result.find(item => item.code === 'temperature').value;
    document.getElementById('temperature').innerText = `Current Temperature: ${temperature}°C`;
  })
  .catch(error => console.error('Error fetching data:', error));

 

반응형

'프로그램&회로' 카테고리의 다른 글

pdf 분할 _ 페이지 삭제 프로그램  (0) 2025.02.12
DeepSeek vs copilot  (0) 2025.01.28
아날로그 시계 코딩하기  (0) 2025.01.24
PDF merge & page delete 예제  (0) 2025.01.13
pyinstaller 고급지게 사용하기  (0) 2025.01.13