sensebox / React-Ardublockly

This repository contains the new senseBox learn- and programming environment powered by google Blockly and React
Apache License 2.0
2 stars 7 forks source link

[Blockly][Codegenerator] Water temperature sensor #316

Closed PaulaScharf closed 2 weeks ago

PaulaScharf commented 3 months ago

Water temperature sensor doesnt return its value.

Following blockly code: image

results in following arduino code:

#include <senseBoxIO.h>
#include <OneWire.h> // http://librarymanager/All#OneWire
#include <DallasTemperature.h> // http://librarymanager/All#DallasTemperature

#define ONE_WIRE_BUS 1
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float getWaterTemp(){
sensors.requestTemperatures();
sensors.getTempCByIndex(0);
}

void setup() {
SerialUSB.begin(300);
sensors.begin();

}

void loop() {
SerialUSB.println(getWaterTemp());
delay(1000);

}

I think getWaterTemp needs to return sth or Im completely misunderstanding this code.

Also potentially for the MCU-S2 the pin needs to change from 1 to 3 (and 3 to 5 and 5 to 7)

mariopesch commented 3 months ago

Extension of this issue:

Update the block and allow reading multiple temperature sensors attached to one onewire adapter board. It's possible to hook up to 6 Sensors to one board.