Have you also connected Ground on the sensor to ground on Puck.js? If you haven't, doing so would help a lot.
Also, it depends on your sensor, but you might need a pull-down resistor. You can turn Espruino's built-in ones on just by adding pinMode(D1,"input_pulldown")
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.
Have you also connected Ground on the sensor to ground on Puck.js? If you haven't, doing so would help a lot.
Also, it depends on your sensor, but you might need a pull-down resistor. You can turn Espruino's built-in ones on just by adding
pinMode(D1,"input_pulldown")