Here is an example using a Node MCU board. The firmware used is:
1v85 Copyright 2016 G.Williams
I have 2 DS18s20 connected to pin D1 (with the pullup resistor), and led connected via a 330Ohm resistor connected to pin D2.
The led is flashed ever 5 seconds, and the temperatures of each of the sensors echoed.
The [Flash] button on the board is watched, and this also toggles the state of the LED.
_____ _
| __|___ ___ ___ _ _|_|___ ___
| __|_ -| . | _| | | | | . |
|_____|___| _|_| |___|_|_|_|___|
|_| http://espruino.com
1v85 Copyright 2016 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
WARNING: the esp8266 port is in beta!
Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
>echo(0);
=undefined
0: 85
1: 85
0: 26.75
1: 26.25
0: 26.8125
1: 26.3125
0: 26.8125
1: 26.3125
button
0: 26.875
1: 26.375
0: 26.9375
1: 26.4375
>
var led = Pin(NodeMCU.D2);
var toggle=1;
var ow = new OneWire(NodeMCU.D1);
var sensors = ow.search().map(function (device) {
return require("DS18B20").connect(ow, device);
});
function updateLed(){
digitalWrite(led, toggle);
toggle=!toggle;
}
setInterval(function() {
updateLed();
sensors.forEach(function (sensor, index) {
console.log(index + ": " + sensor.getTemp());
});
},5000);
function button_down() {
updateLed();
print('button');
}
setWatch(button_down,NodeMCU.D3, {repeat:true, edge:"falling"});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Here is an example using a Node MCU board. The firmware used is:
I have 2 DS18s20 connected to pin D1 (with the pullup resistor), and led connected via a 330Ohm resistor connected to pin D2.
The led is flashed ever 5 seconds, and the temperatures of each of the sensors echoed.
The [Flash] button on the board is watched, and this also toggles the state of the LED.
I hope someone finds this useful!