0.0.71 • Published 5 years ago

homeduino v0.0.71

Weekly downloads
14
License
GPL-3.0
Repository
github
Last release
5 years ago

homeduinojs

Node.js library for using homeduino.

API

connect

homeduino = require('homeduino')
Board = homeduino.Board
board = new Board('/dev/ttyUSB0', 115200)

board.connect().then( ->
  #do stuff
).done()

readDHT(type, pin)

Read a dht sensor

board.readDHT(22, 13).then( (ret) -> 
  console.log ret.temperature, ret.humidity
).done()

readDstSensors (pin)

Returns all Dallas temp sensors on pin

board.readDstSensors(12).then( (ret) -> 
  console.log ret.sensors
).done()

readDstSensor (pin, address)

Reads a sensor with address on pin.

board.readDstSensor(12, '12312312333').then( (ret) -> 
  console.log ret.temperature
).done()

readDstAll (pin)

Reads all sensors connected to pin

board.readDstAll(12).then( (ret) -> 
  console.log ret.temperatures
).done()

rfControlStartReceiving(pin)

board.on "rfReceive", (event) -> 
  console.log 'received:', event.pulseLengths, event.pulses

board.on "rf", (event) -> 
  console.log "#{event.protocol}: ", event.values

board.connect().then( ->
  console.log "board ready"
  board.rfControlStartReceiving(0).then( ->
    console.log "receiving..."
  ).done()
).done()

pin read and writes

board.digitalWrite(4, 1).done()
board.analogWrite(1, 10).done()
board.digitalRead(4).then( (value) ->
  console.log value
).done()
board.analogRead(4).then( (value) ->
  console.log value
).done()
board.pinMode(1, 0).done()

REPL-Client

If a pimatic-homeduino instance is using the board make sure to shutdown pimatic as the board only allows for a single connection.

Setup:

git clone https://github.com/pimatic/homeduinojs && cd homeduinojs && npm install

Hint: If you want to use the client in a production setup you need to manually install the colors package as shown below.

cd ~/pimatic-app/node_modules/pimatic-homeduino/node_modules/homeduino/node_modules
npm i colors

Start the REPL-Client which is located in the lib directory:

# cd ~/pimatic-app/node_modules/pimatic-homeduino/node_modules/homeduino/lib in a production setup
cd homeduinojs/lib
sudo ./client.js /dev/ttyUSB0 115200

It will connect to the arduino and give you a prompt, where you can enter a javascript command. To start receiving RF data enter the command board.rfControlStartReceiving(0) or board.rfControlStartReceiving(1) depending on the receiving pin used in your setup

connecting to /dev/ttyUSB0 with 115200
raw data: "ready"
connected
homeduino> board.rfControlStartReceiving(0)
raw data: "ACK"
undefined
homeduino> raw data: "RF receive 516 1928 3880 9204 0 0 0 0 01020102010202020201010102010101010101010202020101010101010102010201020103"
processed: "pulseLengths":[516,1928,3880,9204],"pulses":"01020102010202020201010102010101010101010202020101010101010102010201020103"
matched proto: "weather1: {"id":120,"channel":1,"temperature":22.4,"humidity":42,"lowBattery":false}"
matched proto: "weather5: {"id":234,"lowBattery":true,"temperature":179.3,"humidity":40}"
matched proto: "weather16: {"id":234,"channel":1,"temperature":179.3,"humidity":164,"lowBattery":true}"

The output is colorized by default. You can disable colors by starting the REPL-Client with the option --no-color.

0.0.71

5 years ago

0.0.70

5 years ago

0.0.69

5 years ago

0.0.68

5 years ago

0.0.67

5 years ago

0.0.66

5 years ago

0.0.65

7 years ago

0.0.64

7 years ago

0.0.63

8 years ago

0.0.62

8 years ago

0.0.61

8 years ago

0.0.60

8 years ago

0.0.59

8 years ago

0.0.58

8 years ago

0.0.57

8 years ago

0.0.56

8 years ago

0.0.55

8 years ago

0.0.54

8 years ago

0.0.53

8 years ago

0.0.52

8 years ago

0.0.51

8 years ago

0.0.50

8 years ago

0.0.49

8 years ago

0.0.48

8 years ago

0.0.47

9 years ago

0.0.46

9 years ago

0.0.45

9 years ago

0.0.44

9 years ago

0.0.43

9 years ago

0.0.42

9 years ago

0.0.41

9 years ago

0.0.40

9 years ago

0.0.39

9 years ago

0.0.38

9 years ago

0.0.37

9 years ago

0.0.36

9 years ago

0.0.35

9 years ago

0.0.34

9 years ago

0.0.33

9 years ago

0.0.32

9 years ago

0.0.31

9 years ago

0.0.30

9 years ago

0.0.29

9 years ago

0.0.28

9 years ago

0.0.27

9 years ago

0.0.26

9 years ago

0.0.25

9 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago