Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

products:laboratory_iot_c:exp39 [2024/11/24 11:13] – создано labuser30products:laboratory_iot_c:exp39 [2024/11/24 11:15] (текущий) – [Программный код эксперимента] labuser30
Строка 17: Строка 17:
  
 ==== Программный код эксперимента ==== ==== Программный код эксперимента ====
-<file python Exp39.py[enable_line_numbers="2", start_line_numbers_at="1"]> +<file arduino Exp39.ino[enable_line_numbers="2", start_line_numbers_at="1"]> 
-import time +#include <OneWire.h> 
-from machine import I2C, Pin +#include <DallasTemperature.h>
-import onewire +
-import ds18x20 +
-_init()+
  
-# the device is on GPIO12 +#define BUS_PIN 12 //the device is on GPIO12
-ow = onewire.OneWire(Pin(12))+
  
-# create the onewire object +OneWire oneWire(BUS_PIN); 
-ds = ds18x20.DS18X20(ow)+DallasTemperature sensors(&oneWire);
  
-roms = ds.scan() +void setup() { 
-ds.convert_temp() +  Serial.begin(9600); 
-time.sleep_ms(750+  sensors.begin(); 
-  +} 
-for rom in roms: + 
-    print(ds.read_temp(rom))+void loop() { 
 +  sensors.requestTemperatures();  
 +  float temperatureC = sensors.getTempCByIndex(0); 
 +  Serial.print(temperatureC); 
 +  Serial.println("ºC")
 +  delay(1000)
 +}
 </file> </file>