The Nano Peripheral Update

I mentioned recently in an entry aimed at beginners, that I’ve been installing “the script” and my ESP8266 code on various devices. I now have three Raspberry Pi 2 boards set up for testing, all with the latest Raspbian on them and running “the script”.

I have a number of ESP8266 boards running with my general purpose code on them, all identical other than ID. Add to that one to dozens of my Nano peripheral…

Nano peripheral

I mentioned also my NANO peripheral. This is an Arduino-compatible (1.50 sterling from AliExpress) board, programmed up as a general purpose I/O expansion for the ESP8266 and it does the job well. as you can see this does not need any support components to talk to the ESP8266 (other than a couple of i2c pullups – let’s say 2k2).

Running off the same 5v that supplies the  ESP8266 and connected by I2c (don’t forget pullups), the ESP provides i2c – it is all in my standard code - on GPIO4 and 5, at the Arduino end it is pins A4 and 5 (the Arduino is the slave). Unlike the ESP8266 boards which have unique IDs, these peripheral boards by default are device number 9 (you can change that from 1-127 in software) so if you really must, you can add up to 127 of these to your ESP8266, ending once and for all any discussions about lack of IO.

As well as simple digital input (with optional internal pullups) and digital output, this incredibly cheap Nano peripheral gives you several PWM outputs as well as soft-fade PWM output (the ESP code can do this standalone but on far fewer pins (three to be exact). Also on offer are multiple 10-bit A/D convertors, programmable beep outputs, servo control, infra-red (not heavily tested yet) and serial output, currently set at 11500 baud (though in a future release this might be made programmable… trivial to do, I just didn’t initially think of that.

The board also handles up to two Dallas DS18B20 chips for temperature readings. Today I’ve been playing with the soft-fade PWM outputs, an example of which is running dead centre of the image above.

The experiment

You may not realise it from the mess above but this is in fact two separate experiments.. the left third of the board is an ESP12-based WEMOS D1 Mini + SSD1306 display which apart from sharing the same USB power has nothing to so with this entry.

Over on the right of the breadboard is a similar Wemos board, connected via I2c to another SSD1306 display, to an off-screen BME280 temperature/humidity/pressure board and to (in the middle of the board) the Arduino Nano clone-based Nano peripheral - again running off the same USB connection used for power only here. in the background you see three Raspberry Pi boards, one of which is communicating with this lot via Node-red and MQTT.

The only individual programming is in Node-Red and is fairly trivial (and being a lash-up, pretty awful).

The centre Arduino-type board gets 5v power and i2c and has attached an INFRA-RED 38Khz receiver and a LED which is getting soft-fade commands. Unlike the ESP where my software allocates input or output status for varius pins, the Nano pin use is more flexible and functionality is determined in Node-Red with no changes needed to the firmware on any of the boards.

Node Red code

The commands over on the right initialise and periodically output data from the BME280 referred to above. At the bottom a general set of nodes (three and a debug output) initialise any ESP boards and provide them with time/date/dusk/dawn information on a regular basis.  Top left are test inputs and a BIGTIMER talking to the ESP8266 board and hence indirectly to the Nano peripheral.

When experimenting I find it useful to put a LED on one of the outputs.

Rather than get repetitive, I’m linking here to the software for the various boards. The script for (in this case) the Raspberry Pi is here, self-documented. https://bitbucket.org/snippets/scargill/ekon6o/the-script

My ESP8266 code (along with WORD document detailing compatible peripherals and commands) is here https://bitbucket.org/scargill/esp-mqtt-dev2 – you will find source which needs a programming environment and binaries which do not.

The Arduino-compatible code for the Nano peripheral (instructions in the code as to commands and what you will need to fire at it from Node-Red) is here https://bitbucket.org/snippets/scargill/yR5nkB/nano-peripheral-ir-in-progress A (really)trivial example of using the Node-Red dashboard is included here.

The UI

This looks like an academic lash-up but it is not a big stretch to add an uninterruptible power supply, wire the boards properly, substitute relay boards for the LEDs (to control air-con and lighting, maybe heating etc.) and add more functionality.

No programming outside of Node-Red is required. Scaling up, you might imagine the Raspberry Pi (2 or better) or similar driving dozens of the ESP boards, each in turn using zero to dozens of the Nano peripherals.

If you’re interested, the files and docs linked to above go into great detail about the overall home control project driving this as well as details about each part of this.

I just upped the game a little.. the Nano peripheral is able to do soft PWM fades. Add to that my code’s ability to send multiple MQTT messages to the same topic in one go..

PWM multi-channels

Here we have one inject command telling one light to fade up and another to simultaneously fade down. Works a treat. Expand that to three channels for RGB and double up and you have the Nano able to soft-fade two separate RGB LED strips (maybe with different values) at once.

One could be soft-fading from magenta to yellow while the other is soft-fading from cyan to green.. I have to say, I am excited. If more PWM channels are needed, add more Nanos to an ESP…. Add to that the Node-Red Dashboard colour wheel which Dave-C-J is helping me get right at this minute and you have proper lighting control for very little and using nothing more than the Node-Red dashboard.

All of this of course pales into insignificance compared to the fact that I just typed all of this using both hands while hardly realising I was doing this, a feat impossible only days ago..

Facebooktwittergoogle_pluspinterestlinkedin

11 thoughts on “The Nano Peripheral Update

  1. Hi Pete,
    It's great to see you back. Just wanted to drop you a line to let you know that what you do is appreciated. I've been using 'TheScript' for a while now and it is very helpful. I just added SonWEB yesterday and I didn't have any trouble. If you are interested in adding it to TheScript, it is at https://github.com/reloxx13/SonWEB.

    Anyway, keep up the good work and stay away from the hospital. 🙂

  2. Hi Pete, great to have you back 🙂

    Just a thick question, could you achieve the same results with an MCP23017 over i2c instead of a nano? Just asking as I ordered one MCP2317 for a separate project and was accidentally sent 10 🙂

      1. Ah good to know, I got the bare chip DIP versions and to be fair, due to a shipping error I got them for 9.9 pence each 😉

        I'm making a home controller for the wife who is, how can I put this delicately? a little technologically adverse 😉

        The idea is, there a 10 way selector switch, a push button and a rotary encoder. This sends MQTT messages via an ESP 12-E running espeasy firmware, to node red that toggles what she wants on and off, set the selector to, say, TV, press the button and the TV turns on, set it to lights, press the button et voila the lights come on.

        The rotary, I originally designed to change the volume to whatever the rotary value was but settled on turn it left and volume goes down by 10% and vice versa as she was happy with that.

        It's eventually all going to be mounted inside a vintage bakelite radio housing with some WS2812B's to give it a glow behind the old dial 🙂

        It looks an atrocious mess in it's prototype form atm but works like a charm!

  3. Hi Pete
    Thanks for the great blog,
    I've been playing with your examples and have achieved full RGB alexa & dashboard colour wheel control over a nano mood light set up, so I can tell alexa to set the mood lights to orange etc and I thought you and your readers might be interested in how I achieved it.
    For alexa I used the home skills node and set up a device, this requires setting up an account.
    The output of the SetSolorRequest is in HSV format but needs the saturation & brigtness multiplied * 100 I then I convert that to RGB using another node downloaded called color-convert and then its off to the nano's

  4. Hi Pete. I am planning to use these PWM outputs to control dimmable 230Vac regular and Edison led bulbs. Most have a small built-in converter, tentatively a current driver.
    Any suggestion for a reliable driver for said leds?

Leave a Reply

Your email address will not be published. Required fields are marked *