Darranking
Posts: 43
Joined: Thu May 31, 2012 9:14 pm

Node.js with i2c one wire

Mon Jan 08, 2018 8:18 pm

Hi

I am exploring using 1-wire temp sensors on an i2c interface.

I have one of these

https://www.modmypi.com/raspberry-pi/se ... ion-module

Now I can see the i2c device, in the os using i2cdetect address 1b. But my question is can someone point me in the right direction of a good tutorial for talking to the sensor attached to this using node.js

Heater
Posts: 8987
Joined: Tue Jul 17, 2012 3:02 pm

Re: Node.js with i2c one wire

Mon Jan 08, 2018 8:30 pm

Google is your friend. A quick search for "raspberry pi i2c" turns up tons of modules for using i2c from node.js and a lot of tutorials and blogs about it.

This looks like the best bet: https://www.npmjs.com/package/i2c-bus

Includes an example and wiring for a one wire sensor.

Darranking
Posts: 43
Joined: Thu May 31, 2012 9:14 pm

Re: Node.js with i2c one wire

Tue Jan 09, 2018 3:00 pm

Thanks for the reply

I have searched the internet and can find lots of examples using different packages, but they have one thing in common, the temp sensor is connected using the 1-wire implementation on the GPIO (4) pin.

I have the temp sensor attached to the i2c interface via the board. in my original post.

The link provided also shows a directly connected implementation.

I have also tried several of the packages on NPM and cannot get them to install properly, they fail when compiling.

I have RASPI-I2C package installed correctly and using the example code on the NPM site I am able to read the first byte of the sensor at address 1B on the i2c bus but I am not clear on how I can read the temperature from this.

If someone could point me in the correct direction from here I would appreciate it. In the meantime I will keep searching the net for examples.

zassx
Posts: 20
Joined: Mon Jan 15, 2018 4:37 pm

Re: Node.js with i2c one wire

Tue Jan 16, 2018 11:52 am

Check out my topic, I am doing exactly this. The topic contains a link to my source code so feel free to check out which libraries I am using and how am I reading temperatures and displaying everything on i2c OLED.

viewtopic.php?f=91&t=202603

Return to “Other languages”

Who is online

Users browsing this forum: No registered users and 2 guests