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…
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.
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.
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.
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..
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..