• I need two battery powered buttons that will change the change the state of a variable within a single node js script.
    So what I'm currently planning is ordering two esp wifi units: https://shop.espruino.com/espruino-wifi

    Then figuring out how to power them, figure out how wire up a push button and having them each make an HTTP post request to a server running the script when each button is pressed. The script will be monitoring the state of the variables and use the Twilio API to send me a text when they are at a desired state.

    Is this the best solution? How hard would this be for someone with little to no electronics experience?

    I'm not familiar with how to power the boards, it's via pins? Any recommended push buttons?

  • You will have fun with the Espruino-Wifi boards... you can run them from a USB power bank - the things you use to give more talk time to your cell phone. Adding the buttons is easy too: just connect the one side of the push button to an input pin and the other one to ground. The input pin you configure to use the internal pull-up resistor. You are obviously familiar w/ js... which makes getting the software going quickly.

    Questions I have are:

    • How quickly after the pressing of the button has the node.js server to get the post (or get request)?
    • How often are these buttons pressed? ...one and the other?
    • Is Twilio doing a push-notification? ...or do you think about pulling? (Espruino-Wifi has two LEDs - green and red - that could indicate the state of each of the variables: steady: on, blinking: off... if they are booleans)

  • Thanks for responding! Great news about the easy setup of the button.

    Both buttons will be pressed pretty frequently. Maybe 10-20 times each per minute.
    Ideally the lag between a button press and the variable change is < 2 seconds.

    Twilio would be sending a basic SMS text message when the variable (integer) are at a specific value.

    EDIT: It would be awesome if the script could run locally on one of the boards if it minimized delay, but then I would somehow have one board send the HTTP request to the other board running as an Express server or something. Is this possible?

  • Espruino-WiFi can also run as a http server... simultaneously with sending http requests (posts/gets). On boot up of the button devices, they could register with your node.js server, so status could then be sent to just all of the button devices.

    My question about the frequency was because of power supply. With expected frequency and expected minimal latency, disconnecting and powering off of wifi, and on button press, powering on wifi and reconnecting is not an option. I would have to measure stand-by power consumption... From reading between the lines and absence of any requirements regarding physical size, mobility, disconnection from a wall outlet, though, I assume power is not an issue....

    Is your node.js server and its function - or a test version of it - Web accessible? If so I can give it a shot, shoot a clip and post. i need only the url and what to post... I can even post the phone no for the sms you want to send so it is sending it to that me.

  • Sorry I should've been more clear about size, the idea of powering them from power banks would be doable with my size requirements I think. Preferably they would be smaller than the amazon echo buttons.

    I haven't coded any of the server for testing, but I can tomorrow with the URL and request format. It would be something like this:

    const express = require('express');
    const app = express();
    const parser = require('body-parser');
    let variableToChange = 0;
    app.listen(8080, console.log('Listening on 3000'));
    app.get('/theEndPoint', (req, res) => {
           .then(() => {
  • ...there you go... never go with requirements that include a solution (hint)... which in this case is Wifi...

    Wifi has much higher power requirements (500ma+ on calibration when establishing connection with access point).

    Amazon Echo Buttons use Blue Tooth (BLE, Blue Tooth Low Energy?) which can run on way much lower power, just check out the Espruino puck.js: the Espruino puck.js is what you are looking for...

    You still need something that connects you to Wifi to talk to your node.js server... I assume... except your server is so close and supports BLE,... or another Wifi connected device that runs BLE and can communicate with your button device... such as your Alexa station does... Any Wifi and BLE enabled device - such as a running lap top / BLE HID - can do what Alexa station does in combination with a Espruino puck.js.

    Puck.js comes with one built in physical button... if you can live with a short press for detecting press of logical button 1 and a longer press for press of logical button 2, you are just fine (think about Adam L Morse, who had one button communicated a whole character set...)

    With Espruino puck.js you may not even have to touch any hardware from the inside...

    If your server is not able to do BLE and you do not want to have a general purpose device between puck and server, take another puck to be the base station, connect it up to a few $ ESP8266 and you most likely have what you are looking for...

  • I'd just posted a reply on your reddit post: https://www.reddit.com/r/espruino/commen­ts/8ye7sr/is_espruino_the_right_solution­_for_my_project/

    But as @allObjects says if you're happy with a Node.js server and using Bluetooth LE then it may be that Puck.js does exactly what you want without having to do any hardware work at all and while being really low-power. There's even a tutorial here showing you how to use Puck.js as a simple button with some Node.js code to get the state back.

    Otherwise if you want WiFi, since it's connected all the time (because you'd be pressing the button so often) I'd say Espruino WiFi plus a USB power bank would be really straightforward. POST is done just like in Node.js:

    function postMe() {
      content = "Hello";
      var options = {
        host: 'your_server',
        port: '80',
        headers: {
      require("http").request(options, function(res)  {
        // ...
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Is espruino the right solution for my project? (Needs wifi - I've never soldered)

Posted by Avatar for user91917 @user91917