Introduction (Latest update February 01, 2020)
Minor update here – I’ve gone back to SDK 2.1 for now as RBOOT will just not reliably OTA on SDK 3.1 – and there is nothing wrong with SDK 2.1
Sick of reading about other people’s home control? Want to make your own? Got some electronics and software experience? You’re going to LOVE THIS! Rock-solid home control, flexible, low cost, DIY.
On October 28 2018 I added the ability to optionally make gpio12 a temperature port (DS18b20, DHT22 etc) leaving 2 and 14 as de-bounced key inputs, from version 2.7.01. Also as of March 2019, optionally gpi4 and 5 can be set as inputs and can then produce automatic debounced status data – handy for up/down buttons for thermostats etc. See input45 and input54 commands in the WORD doc in the ESP-GO BitBucket repository. By the time you look at the diagram above it will likely be out of date as new features are added (no indication of deep-sleep capability in here for example) and OTA using Espressif SDK 2.1 now works a TREAT (RBOOT-based OTA in SDK 3.1 version works but not every time so for now I’m sticking with SDK 2.1) – thankfully there’s a WORD manual along with source code and diagrams available online and kept up to date. This is all free incidentally and without warranty. Software, diagrams, board layouts… and this blog has a range of articles on the subject. The main ESP8266 software is freely available, called ESP-GO (also ESP-GO-3 repository but note comments above about OTA – something to do with SDK 3.1 and RBOOT) and is available on this BitBucket repository
The diagram pretty much says it all – a Raspberry Pi (2, 3 or 4 – I recommend 3 or 4) or similar (Orange Pi Plus 2E works well as do some FriendlyArm boards), talking to your PC and/or smartphone via a range of potential technologies – and using a simple yet powerful communications protocol (MQTT) over WIFI to talk to small yet incredibly powerful ESP8266 units – these can be bought very cheaply (WEMOS D1 Mini etc.) and programmed – or you can take our board designs and have some boards made in China if you really want to DIY. This is all free and open source but don’t expect support on the boards.
There are no real limits to the number of ESP-8266 boards you can have talking to the central controller – that is down, in the main, to your WIFI network which could cover one room or extend across the globe.
In my own system I have 2 properties talking to each other – one in the UK, one in Spain. No matter where I am, I have full access – great fun, great utility, low cost. Who wants to pay £30 to control a light! This is definitely aimed at the DIYer.
In the coming link there is a complete project, suitable for Windows development using the ESP8266 “Unofficial Development Environment” for the ESP8266 – but that won’t stop Linux users from bending the makefile to their will!!
Here is the master repo https://bitbucket.org/scargill/esp-go/src/master/ See the doc file which is fully up to date with all commands which the ESP8266 software accepts – this blog entry just shows a selection. Even if you ignore or don’t understand the source and just download the ROMS available – you’ll be able to keep up to date via OTA (over the air updating) – and you’ll need that manual!
You may also need some new – and very useful skills as you’ll see the term Node-Red appear very often throughout the considerable range of blog entries in here – this is by NO means a single item – there’s a Nextion-based, prize-winning WIFI touch display blog and a range of discussions (and there are LOTS of valuable comments) throughout the blog – enjoy learning and please do feel free to share knowledge – there is SO much more we can do with this.
Update on flashing ROMS here: https://tech.scargill.net/esp8266-home-control-update/ – Blog reader Jay has written a great blog on setting up the programming environment for Windows.
What is missing from the diagram above is my first experiments with SPI. Utilising GPIO13 to 16 on the ESP8266 (this is all in ESP-GO) , I have a 320*240 display working experimentally as a fast scrolling terminal on the ESP8266. Handy for debugging the system without tying up your PC monitor. I also have working drivers for the likes of ILI9341 (not the touch part).
How useful this is depends on how many other pins you need! If need an ESP8266 with many more IO pins – for around £1.50 (AliExpress) you can use my “universal peripheral” – using a simple Arduino Nano clone talking to the ESP8266 or indeed any I2c setup.
Background: I’ve been using ESP8266 chips since they first came out – and I have the development kit for that and the ESP-32 –just waiting for some decent, seasoned software tools to emerge for the ESP-32 but right now the ESP8266 is a lot of fun and that’s part of what keeps this all going. In the summer of 2015 I made myself so visible on the ESP8266 front that I was invited to be part of an Espressif-led delegation to MIT in Boston for the FAB11 Conference – demonstrating the ESP8266 with MQTT and Node-Red and how to build this into practical systems. Some time ago I was involved in a project in Spain for the MOD researching ESP8266 and IOT security and more. If you wish, follow my ramblings on the subject of control using these chips in THIS blog – and also on Twitter (@scargill), Facebook (esp8266wifi and IOT pages) and LinkedIn.
Regular readers will know that the ESP8266 boards are still unbeatable if you take price into account and don’t need Bluetooth (ESP32). I’ve long-since scrapped various other radio designs (NRF24L01 etc.), blighted by short range or lack of network ability – and have gone “hell for leather” into using these boards.
The original plan involved an Arduino Mega as a “master controller” and Arduino “slaves running over an NRF24L01 mesh network. Here in this link is one of my first attempts at blogging on the subject – along with pictures of the original “Appcon” system from back in the ‘90s.
The original Arduino-based system worked well worked and indeed controlled heating and lighting for a couple of years at my home, but the controller went out of the window when the Raspberry Pi 2 came out which was dirt cheap but with more than enough power to control a house or ten. Now of course we have the RPI4 and other exciting boards such as the FriendlyArm NanoPi K1+ and others.
Hardwired to Ethernet (the main controller, not the ESPs), the system allows for a comprehensive wireless home control setup and to answer any questions about ESP8266 reliability – with the code you’ll see in here, I can say with a lot of experience, that the ESP8266 units given reliable power, are rock solid – stunning considering the price.
The ESP8266 boards provide a very low-cost entry solution into the world of IOT making it possible to create in the simplest sense an Internet-controlled LED for under £2 (it could just as easily be a 2KW heater of course for a little more outlay) or more likely a WIFI-controlled LED STRIP with various sensors etc.
There are a number of variations on the ESP8266 boards, the first shot at this being the old ESP-01 – a simple board with power, a couple of IO lines and serial in and out. The thing is – they all use the same chip and that particular board (the ESP-01) is very I/O and FLASH limited – and for no good reason – the ESP-12 and variants for example have access to the A/D converter, several IO lines, have more FLASH memory and cost the same amount!
The only downside to the latter is 2mm spacing pins but for VERY little you can buy adaptors to 0.1” or better yet a Wemos C1 Mini or similar– i.e. a board that will take the ESP-12 or the ESP-12E (which is the same – but with a few extra essentially useless pins) – same price. There are also a number of ESP-12-based boards today which offer 0.1” spacing. For this reason I’ve long since given up on supporting the ESP-01 with it’s limited FLASH memory though as you’ll see in another blog entry, with a steady hand and fine soldering iron it is trivial to replace the old 1MB Flash on the ESP-01 with a cheap 4MB Flash making it more compatible with ESP-12 etc. (well, you still have hardly any pins to use).
Oh, here’s a link to the various source files. Here are original Board files designed by Aidan Ruff (NO WE DON’T SELL BOARDS). No guarantees – not even any guarantee they won’t change or disappear if we find bugs. Since this article was started I’ve added I2c and a software serial port (optional) on GPIO4 and 5 to control Nextion serial displays directly as well as an Arduino NANO (or Pro) clone board which I’ve programmed up as a general purpose I/O expander for the ESP. Instructions here may not be fully up to date but always check the WORD document in the repository.
Also check elsewhere in the blog to see what we’ve done with the Itead Studio Sonoff boards and their plug-in-the-wall remote mains socket. All of this stuff works together as a whole or you can cherry-pick. Today I would suggest using Tasmota firmware on Sonoffs as the designer has put a lot of work into that.
I’ve added i2c to the ESP8266 software which as you’ll see in the picture at the start of this blog as made a big difference to the number of supported devices. What a roller-coaster this has been an a great way to learn all about i2c – I’ve improved the original Espressif offering a lot! I’ve recently added version numbering to power up info and a powerful debug command and also, the power-up info indicates which GPIO is currently used for Web setup and which pin for the visual LED or RGB LED indicator. At the time of writing the code is using Espressif SDK version 2.0 as the later version is too-RAM-hungry for no real benefit.
The later PCB you see here was designed (by Aidan Ruff) for my award-winning (ok I had to get that in) Nextion Serial Terminal which in April 2016 grabbed second prize at the esp8266.com 1st Annual awards. The last update to this board includes the option to use an RGB LED as the status indicator – something I see as becoming the standard – once you have a selection of colours an intensities to indicate status, all of a sudden a normal LED looks boring.
Flashing ESP-GO
This is for the people who’ve been trying out my software (or thinking of trying it out) on the ridiculously cheap (£1.40) but very reliable, powerful and comprehensive ESP12 WIFI processor board and those who’ve gone ahead and gotten some boards we made – all referenced in earlier blogs. For the latest on how to FLASH the chips see this blog update.
Essentially the assumption here is that you have an ESP-12F-based (or variation such as ESP-12E) board of some description and that GPIO0 is used as a programming button (held to ground to program etc.) – and also as a web setup button.
Let me explain the difference between programming and setup. GPIO0 is set up permanently by Espressif as the pin to hold LOW before and during power-up to put the board into programming mode to replace the firmware (which may or may not exist on purchase… could be that AT-Command firmware, LUA or something else). Web setup is just something myour software does – it’s not the only software to do so. It may use GPIO2 or more likely GPIO0 AFTER power-up to put the unit into a mode where it acts as an access point, allowing setup for, for example SSID and password.
Note: These blog entries will never all be up to date – too many of them – the WORD manual that comes with the ESP-GO source code on BitBucket is the most up to date available.
All other I/O pins are available for one use or another including GPIO16 – take note of other blogs describing wiring and power unless you’re using something like a node-mcu board which just plugs into USB. The software works alongside Node-Red – again described in the home control blog – what’s new here is that OTA now works and you don’t need a development environment to program up the code which I developed with lots of help from others, using the unofficial Development Kit in Windows, as you can just use the latest ROMS. The software will react to MQTT commands and also commands coming into the serial line at 115k baud (serial commands are the same as MQTT payloads but no topic required).
I worked with Richard Burton to get RBOOT working with ESP-GO – it is his software which allows for OTA (remote updating) when developing, in my case, in C on the ESP8266.
With OTA working (including from an external location) I thought I might try taking the ROMS and blowing a chip from them rather than from the editing system – that way others can benefit. Note the main rom is now called rom.bin not romx.bin – location is the same however at 0x2000.
Well, I went to get the NODEMCU flasher which was always good – so after a couple of blind alleys – I got to this link..
As you can see, with the flasher, the RBOOT rom loads at 0x00000 and ESP-GO main code runs at 0x02000. Unlike me, make sure BOTH ROMs are ticked on the left.. as the first one is so short it shows little or no sign of activity. I found I could flash at 468kbaud, you may or may not wish to play safe at 115k baud. You may also note there is an additional file needed above – in SDK 2.0 and above, on first installation this is needed.
So – you blow the software onto the ESP8266 board (here is the link to the NodeMCU – no guarantees as it isn’t mine), now what?
A reminder – what will ESP-GO do?
- Turn outputs on and off with optional timeouts
- Read inputs
- Handle RGB Serial LEDs (up to 300 of them assuming you have enough 5v power)
- Handle PWM 12v LEDs (assuming you have a 12v source and driver hardware such as Mosfets)
- Act as a LED clock (and a nice one too) with 60 serial LEDs.
- a TON of other things including handling DS18B20, DHT11, DHT22, talking to Nextion displays (see the Serial Nextion blog), talk to various I2c devices and displays, talk to some SPI displays and WAY more .. Add to that the power of Node-Red and you have the basis for a very good and reliable complete home control system.
But first the unit needs to be setup. After programming and then resetting or power-cycling the ESP12 (suggest hooking a LED and resistor to GPIO13 and down to ground) – the light will start flashing – within a second or so – hold GPIO0 (or GPIO2 depending on defaults in the current ROMS – see power-up messages coming out of the serial at 115k baud) to ground for say 10 seconds and let go (DON’T press for the first 100ms of turning on – JUST after turning on or resetting will do – if you come in early (and if the current pin in use is GPIO0) it will go into programming mode – of course if you don’t program it, no harm done – just reset and try again).
NOW you can access the board with your mobile phone WIFI as “hack-Setup” and once connected use the phone browser to go to 192.168.4.1/wifi/wifi.tpl and you get that nice setup on the right above which needs at least one router SSID and password, two if you have them available (second is a backup) – the address of an MQTT broker and username and password and that’s really all that is essential to start off.
Once everything is up and running , the LED on GPIO13 should be flashing very briefly (i.e. off most of the time) – a variation you can setup by commands uses an RGB LED to give more meaningful use (yellow power up, green working, orange working on it, red dead – throw in the bin etc).
You can now talk to the board via MQTT… or the serial port at 11500 baud (you could use my serial terminal.
If using the serial, fire {debug} at it – if using MQTT – then assuming you’ve given it the name “fred” then the same command would be – topic: fred/toesp and the payload would be {out4;1} or {out4:0} to flick GPIO4 on or off (or if your board is mis-labelled as some are – GPIO5). The Home Control blog entry goes into the rest of this in detail.
Note that if you DON’T set up an MQTT broker, the unit will try to connect to MQTT and eventually reset and start again. This is deliberate. You MUST setup an SSID, an MQTT broker and once running you should use the ESPLOGIN mode or similar to send the time to the unit shortly after power up then every 12 hours or so. Again this is detailed in the home control blog… it’s quite simple.
The rest is up to you. I use this with my Node-Red software and I have a node for setting up the time and date on the boards… it is called node-red-contrib-esplogin,
That log-in node incidentally is available here.
That’s it for now… I’m quite chuffed the OTA now works. This of course is directly relevant to the Nextion WIFI Display project.
You can get the three BIN files from roms.scargill.net:
roms.scargill.net/esp_init_data_default.bin
(for Espressif SDK 3.1 there’s a slight variation of that last file name)
IMPORTANT NOTE: If you choose to use ROMS rather than compiling code, you will need to keep up with the BITBUCKET repository changes as these ROMS will be updated when I make changes – for example it is now standard to use GPIO0 as an input only with GPIO16 being used as an output. There is also a DOC file in the Home Control blog and that is the only up to date guide to the ever increasing instruction set. Here is the project itself. https://bitbucket.org/scargill/esp-go/src/master/
No longer showing passwords in the web setup page so you must put those in every time you use the setup page – otherwise you end up with blank passwords – which you might want. Added several new commands like cpu_clock so you can double the clock speed – documented… ROM updated. DEFAULT pin for web updating is generally GPIO0 but on power up you’ll see serial messages which TELL you which pin to use. You can change this to GPIO14.
Update 24/07/2016: See the changes in blog above, rendering some of the comments below obsolete.
Update 11/07/2017: Code updated to version 2.1.0 to work with the new release of the Espressif SDK version 2.1.0 – this is no longer compatible with the ESP-01 or other boards with less than 4MB of FLASH.
Update 01/10/2017: Fixed some SSD1306 sillies – added great new commands, updated manual. Also, some new WEMOS boards seem to need a slightly different programming method. If boards persistently refuse to operate – even after programming – check out the mode- there is a QIO mode – and a DIO mode. The default is QIO – however some WEMOS boards need DIO – check out this entry.
Update November 2018: Version 2.7.1.0 now supports more inputs – see manual… making better use of GPIO0
The Boards
For the reasons stated I’ll discuss here the ESP-12 (and variations, ESP-12F having a marginally better antenna) as that is my favourite sub-module – but the same code applies to other variations where pins allow. We have working software – and circuit boards to go with it. For reasons best known to my pal Aidan we called this original the Hackitt & Bodgitt board. We have a variation with an RGB LED as the status indicator on GPIO13.
If you are in any way unhappy using 240v AC mains power, you may want to give this a miss or fit one of those 12v to 5v down-converters so cheap and popular on EBay – I do this to power ESPs from a solar-charged deep-discharge battery in some cases. This version does NOT tie GPIO16 to reset (the saving in power on this board wasn’t really worth the bother – and note that GPIO16 is usable as an output). On new boards and in general we’re using GPIO16 as the default relay output – freeing up GPIO0 to be an input only (programming – and web-setup).
Here is the rear view. Note the MOSFETS on the back (this is looking straight through hence letter reversal)
Note that a nice feature of this board is that it can be programmed from a standard, cheap 5v FTDI.
So in terms of “Features”, the diagram at the start of this blog entry says a lot – but for clarity:
- Mains-powered WIFI controller board (or use standard boards)
- FTDI-compatibility
- Accommodation for solid state or mechanical relay output
- Temperature sensing using DS18B20
- Temperature and pressure sensing using the BMP280
- Temperature, pressure and humidity sensing via the BME280
- Temperature and humidity using the DHT-22 or DHT-11
- Our own board has signals brought out to edge connectors
- De-bounced input with automatic de-bounce and messaging
- Analog in for checking battery state etc., will handle up to 20v
- Several Outputs expandable via I2c
- RGB WS2812b output on most pins able to handle 300 or more serial LED STRIP
- 3 outputs for high definition PWM – with MOSFETS to control LED STRIP
- Talks WIFI and MQTT – ideal for being controlled by a Raspberry Pi or similar using, say, Node-Red
- Flashing status (software supports both simple LED and serial RGB LED) indication that the unit is functioning and has the correct time which it maintains internally in between updates*
- Second (software) serial output to support Nextion displays (see the Nextion WIFI Touch Display project)
- Software mono-stable out for use as a watchdog
- Outputs can be timers for watering systems for example
- OTA updating from internal or external website
- I2C support for an ever-increasing range of devices
- Hitachi LCD and Seeed OLED support
- 16-channel 12-bit PWM support via I2c
- 4-channel 16-bit ADC support via I2c
- A new NANO-based peripheral via I2c with GPIO/PWM (inc fade), ANALOG in and SERIAL OUT
- Support for various displays, SSD1306, SSD1351 and others
- INA219 voltage/current sensor support
- Deep sleep support < 7 hours at a time
- GY30 luminance sensor board support
- Simple GPIO10 support for some DIO-programmed boards
- A new SPI-based scrolling terminal (which fits on the ESP8266)
- and more to come…
* (The time comes from an MQTT broker, for example using a Raspberry Pi or similar running Node-Red – see below)
** I now use Node-Red on the Pi to do thermostatic control. Consider the thermostat code to be legacy.
And another board: we’ve also put together a board for the Nextion displays – but WELL suited as a general purpose board and it is detailed on the WIFI Nextion blog entry but I’ve included a picture here for reference. I can see a variation on this one being my main board eventually – just needs an add-on with a couple of relays and 3 MOSFETs to make it a perfect development board. There is a cap on the reset line so that typically an FTDI is able to reset it automatically. Note: The current revision of the board has extra grounds and 4 way sensor connector (DS18B20, DHT22 etc.). Note that an even later version optionally uses an RGB LED for a status indicator – WAY better idea.
The Controller
We have chosen to commit to a communications protocol called MQTT as reliable code for this is freely available, MQTT “brokers” are also freely available and once you spend a little time on the subject it is both easy and the obvious way to control stuff in a network. Lookup “tuanpm mqtt” on Google.
As MQTT is so central to this, I’ll go into this in a little depth. There are many ways you could have units talking to each other – a mesh network, a radio network, polling etc…over time I have come to see MQTT as the ideal tool for home control because it is simple, the tools are free and it WORKS.
Essentially an MQTT broker is a piece of software – a server if you like, available online or (my preference) on the likes of a Raspberry Pi inside your network) which monitors incoming messages and sends messages out according to who they are for. Addresses are simply text. Messages are simply text. MQTT clients (software that receives MQTT messages for one unit and sends messages out to an MQTT broker) are available freely for the likes of Arduino, ESP8266 and in Node-Red. It really is all very simple once you get playing. So MQTT is an incredibly simple yet powerful format comprising a message “topic” and a message “payload” both in the form of simple text. Units can “subscribe” or listen for specific topics. A great way to play with this is to use an online free MQTT broker – and something like MQTT-SPY which is a free “client” which runs for example on a PC.
The ESP-12-based controller has a number of inputs and outputs which can be controlled equally well by MQTT commands or serial data – by the current software.
To talk to the unit wirelessly (WIFI) via the popular MQTT message protocol, a message can be sent to the topic “toesp” to send to all units in the network or to a specific unit by prefixing the topic with the unit ID, or example “kitchen_light/toesp”. The only difference between these two topics is that the former will go to all units yet never elicit a response from any unit, the latter will go to unit “kitchen_light” only and MAY, depending on the context, elicit a response from unit “kitchen_light” – unit ID is simple, programmable text.
My Node-Red ESPLOGON mode will respond to incoming MQTT topic “logon” from any ESP8266 sending it’s data in the payload (see esp-go software, the boards do this on powerup) ) and the node will send back time and date to that specific board. The node will also send, every 12 hours, such time/date/dusk/dawn info to ALL boards by sending the generic toesp topic and time/date/dusk/dawn info.
Finally hte node can be made to send:
topic: toesp
payload: {heartbeat}
every minute. All the boards will see this – and all will pre-set a counter in themselves – which if allowed to drop to zero will re-initialise the MQTT code. In the event that boards lose the WIFI for some time, they may reset their WIFI – then reset the MQTT code. Reset is used only as a last resort and the software can handle up to two SSIDs in case you happen to have two access points. If one fails it will try the other.
Hence in theory they should be bullet-proof. In practice they are bullet-proof unless of course the power goes off. In the summer of 2016 in Spain I endured horrendous WIFI and power issues and the current code stood up to this and has done ever since – learned the hard way. That experience is also why I worked hard to ensure the OTA works so I can update the units remotely.
Each COMMAND or payload starts with an open brace and ends with a closing brace (my choice, kind of like JSON). In the case of MQTT, this information is stored in the message “payload”. For serial, there is no “topic” – just the message (payload) which you can fire into the serial port at 115k baud.
An example of a simple command might be to turn output 4 ON (out12 goes to pin GPIO12).
{out4:1}
It is possible to send multiple commands at once by separating them with semicolons. i.e.
{out4:1;out4:0}
So to use serial – this is all that is required (newline delimiter) – for MQTT – the topic should be as referred to earlier and the payload should be in the format shown just above.
For more on MQTT go here. http://mqtt.org/
I chose to use a Raspberry Pi 3 (you could use 2 but 2 is ok) as my controller – and chose to use Node-Red as the controlling software when this was a project unknown to most – turns out I picked a winner as Node-Red is now embedded in “Raspbian” on the Pi and is hence guaranteed a well-deserved and bright IOT future though I always do my own install using “the script”. It is also wonderful and really NOT hard to use. Want to play with Node-Red without even doing an install? https://fred.sensetecnic.com/ – enjoy.
The following document details the commands the ESP units will respond to – the actions which will occur along with any return serial message or MQTT message created as a result of the incoming command. But please – read the manual.
The Pins
Here we see a drawing of an ESP-12 board, please note there is a question mark over the positioning of GPIO-4 and GPIO-5 – on many units, these are reversed.
You are looking at the FRONT of the unit with the metal cover visible.
Note: Contrary to the diagram, in prototyping I’m using a 1k to pull GPIO15 down as it’s still a grey area (some say the board won’t program unless GPIO15 is held down) – it does NOT have to be fully grounded and as you’ll see in fact I added PWM output on it (March 26, 2015).
Preliminaries
The ESP-12 units operate on 3v3 – NOT 5v. Extensive experience suggests a good 3v3 linear regulator fed from, say a 5v supply provides more reliable results than a 3v3 switched-mode supply – but that will vary with suppliers. I’ve recently been part of a project where we used WELL over 100 ESP-01 units all attached to one 20 amp switched mode power supply – they worked well… but I personally prefer per-unit linear regulation.
We done just that in all our own boards, using a cheap switched-mode mains to 5v supply (or DC/DC convertor for 12v use) with a 3v3 linear regulator. I suspect most queries about ESP reliability boil down to power supplies. I can honestly say – that having used countless ESP boards since they came out – I’ve not once come across a bad board!!
To talk to these units from any 5v system through serial, you should ensure that inputs to the ESP-12 never exceed 3v3 (resistive divider). Typically the serial output will work just fine fed into, say the serial input of a 5v Arduino – I have NEVER had any trouble with this at 115k baud. Simple resistive level conversion can easily be implemented so that a 5v FTDI will talk to the serial without issue. In practice I’ve yet to see a 5v FTDI destroy an ESP8266 but if you go without the divider, be it on your head.
NOTE: If you want to experiment with Deep sleep – you need a board without regulator or USB convertor – the latter in particular can consume up to 10ma !!! There is a command in ESP-go which disables GPIO16 so that you can attach it to RESET for deep-sleep support – during which the processor turns off – and only a simple real-time-clock survives, sufficient to use GPIO16 to force a reset and bring the board back to life.
Certain pins are special and in particular, grounding GPIO-0 on power-up is used to trigger “flash” programming of the chips and also used to put the units into access point mode for setup – so you should be aware of this. When designing outputs I base all of mine on Vcc. So for example when driving a LED…
Why do I do that? Well, when the unit powers up – GPIOs are all input – and if you preset them to “1” on power up you’ll not get any flashing lights as the units boot up.
Below describes SOME of the commands currently implemented. We have both WEB-based and SERIAL setup, full MQTT integration and the development focuses on using NODE-RED – specifically but not exclusively on Raspberry Pi (I’ve installed Node-Red on many SBCs and consider it as standard as adding Apache and PHP. We’re using the free and excellent Mosquito for the MQTT “broker” on the Pi (i.e all units connect to this “broker” by address and password” and the broker stores and releases on request stored messages – hence any unit can talk to any other unit as well as making requests of the Pi).
The WORD manual that comes on BitBucket with the code is way more comprehensive than this blog in terms of commands.
Command set
The commands below merely represent a subset – the WORD MANUAL is your up to date source of information.
Controlling and monitoring outputs
The potential outputs are GPIO0 (that’s the one on the board with the relay – future boards of ours will not use GPIO0), GPIO4, GPIO5, GPIO12[1] GPIO13[2] and GPIO16. These are referred to as OUT0[3], OUT4, OUT5, OUT12 OUT13 and OUT16. You can also use GPIO2 as an output via a command – normally the latter is used with the likes of temperature sensors.
Typical outputs respond to the commands {outX:1} , {outX:0} etc where X is the GPIO number. If requesting the status of an output this form is used {outX?} where X may be 12 for example
There are 3 variations on this:
{out13} (GPIO13) by default should not be used as its main purpose is that of a LED “status” indicator (though you can override that) (see the relevant command).
{out12:Y} responds to the following for Y:
0 – off (if command “invert=1” then the state of that output is inverted (for positive-based relays) – see the invert command…
1 – on (see above)
2 – on from dusk till midnight (see above)
3 – on from dusk till dawn (see above)
4 – on from dawn till dusk (see above)
5 – under local thermostatic control – see relevant command (see above)
6 – timer for output. Another parameter determines ON time in minutes – i.e. {out0,6,100} sets the output on for 100 minutes.
There are a set of related commands for reading the state of outputs – these are {out12?} etc. Should unit “kitchen_light” be asked for the state of out12 – the MQTT message sent back will be in the form
topic: kitchen_light/fromesp/out12
and the payload will contain the appropriate value.
Outputs can be inverted by the invert command by setting bits 0,1 and 2 etc., in the invert command. See the manual.
PWM
You can use a command to send PWM onto 4,5 and GPIO15 using the Espressif library which allows for up to around 95% duty cycle at very high resolution (14 bits) for the cheap 12v serial RGB LED STRIP though we have brought that down to 100 smoothly transitioning levels – but decent levels (i.e. non-linear – with more emphasis at the bottom end for smooth transition). Attached to a logic-level control MOSFET you can drive a 12v LED strip with this – initially off, use the command {pwm:X,Y,Z,I} where X,Y,Z are 0-99 for duty cycle and I is false if you want instant transition, or any value if you want a smooth transition.
For example if I =50 (50ms) then 0-99 would take 5 seconds. A lookup table is used to get a reasonably smooth fade. Due to the Espressif library, you can get up to around 90% or so duty cycle at value 99 – but you really would not notice the extra on a light. Note also that the PWM even when off is still technically running – so if you run PWM with a board, don’t expect reliable SERIAL RGB LED operation as the PWM has a minor effect on really critical timing as needed for serial RGB LEDs.
Heating controls
In controlling heating, the unit will generally use the internally connectable (on GPIO2) temperature sensor DHT22 (which also handles humidity) or the Dallas DS18b20 or DS18b20p. These heating commands are deprecated as it is a lot easier to do heating controls in Node-Red.
It is possible right now to set the maximum temperature, the fall-back temperature, frost temperature and 2 on-off times per day locally. Of course using an external MQTT control the possibilities are endless.
Relevant commands are (X is general a value, degrees C or minute after midnight):
{peak:X}
{off-peak:X}
{frost:X}
{on_1:X}
{off_1:X}
{on-2:X}
{off-2:X}
Time settings
The ESP units are able to keep time but clearly do not have a source of time – this can be provided to each unit separately or more sensibly to all units at once by Node-Red.
{time:X} standard Unix time value the number of seconds since January 1970
{dawn:X } number of minutes past midnight considered “dawn” or street lights off time
{dusk:X} number of minutes past midnight considered “dusk” or light up time
{When they power up, units attempt to log on. This is an ideal time to send them the time.
The ADC
The internal analog to digital convertor in the ESP reads from 0 to 1.024 volts and outputs a signal accordingly. This can be read by the {adc?} command.
Debugging
From the serial console, we can view various settings by using the command {debug}.
Temperature and Humidity
The relevant commands here are {temperature?} and {humidity?} They will send out, by return, for example in the case of unit 999 :
Topic: 999/fromesp/temperature
Data: X where X is in degrees C
Humidity follows the same format but is a percentage.
Expansion
If we want the unit not to respond to a command but to pass everything on to the serial line to control, say an Arduino, use the EXT command followed by a string – this can be used part way through a multi-line command if required.
{out15:1;out2:0;ext:”out12:1”}
The two outputs will be switched and the command {out0:1} will be send out of the serial port.
Of course, one COULD send these commands off to an Arduino – OR you could send them off to another ESP-12 with it’s WIFI disabled… the logic of that? It’s cheaper than an Arduino and faster!!
The above is left in for compatibility but now, the sensible way to expand the ESP is by using the new NANO peripheral, a cheap £1.50 Arduino Nano clone (there is an even cheaper PRO variation with no USB connection) for which I’ve published software.
You can develop in the C language for the ESP boards using the unofficial Eclipse development environment.
http://programs74.ru/udkew-en.html
and you can learn more about my own work at https://tech.scargill.net
Setting up for WIFI
There are commands to set the unit ID (defaults to “999” note this is a string not a number), ssid, ssid2, pass, pass2, mqtt_host, mqtt_port, mqtt_user and mqtt_pass. In each case surround the argument with double-quotes.
i.e.
{id:”123”}
You can also optionally set “desc” for a short description and “attribute” for any short message like “Dallas” to indicate what facilities the board has.
The above can also be set by WIFI. Turn the device on and immediately short GPIO0 to ground AFTER power up for several seconds. This will put the unit in to web setup mode. Have your laptop, tablet or phone browser log into Hack-setup and go to 192.168.4.1/wifi/wifi.tpl to set everything up.
There are two SSID and passwords – the idea being that if the unit fails to get through to an access point it will try the second one, if that fails it will go back to trying the first one etc.
Reset
If for any reason we want to reset the device, the {reset} command will do that.
Inputs
GPIO14 is an input. We can read the state with the {in14?} command.
It is also de-bounced and you can read (and simultaneously reset) the count using the in14_count? command. The inbounce:X command will let you set the bounce value in milliseconds.
When the state of the input changes (de-bounced) an MQTT message will be send out in the form of TOPIC: XXX/fromesp/in14 where XXX is the unit ID and MESSAGE: 1 or 0
There is also a bounce value for in2 – i.e. {in2_count?}
RGB LEDs
One of the more useful features of the board is to be able to directly control an array of WS2812B LEDs. Right now, overall control is implemented including programmable fade-in and fade-out and a “rainbow” effect. However, buffer space is available to implement full individual control of up to 900 LEDs (warning use separate 5v supply for these – current can be up to 5amps for such a run). Note you cannot reliably run PWM and RGB LEDS at the same time. Initiating PWM starts a timer that disrupts RGB timing and a reboot is needed between these. That is one reason I developed the Nano peripheral which will talk to 6 PWM outputs (2 RGB PWM sets).
The RGB command takes the form of:
{rgb: port,red,green,blue,number,duration}
So if we want to go to bright red over 10 seconds and you’ve attached an array of 20 serial LEDs to the output GPI12, the command is:
{rgb:12,255,0,0,20,10}
And that will happen and we can do other things while it is fading in. The duration is a 32 bit number.
For amusement purposes we can also try {rainbow: port,number_of_leds,duration[,timer speed in ms]}
A neat toy: requires 60 RGB LEDs and can run on a port pin… a clock… {clock: port} if is 255, the clock is not running else runs on the relevant port.
If you want to just light up SOME LEDs in a strip – the command {rgbset: start_led, number, r, g, b} will let you set up various LEDS to various colours and the command {rgbgo: port,number_of_leds} will start the ball rolling. That number should not exceed 300 (not for any reason – I could have made it larger).
If you want to play with animation… {rgbstart: port,number_of_leds} will clear a command buffer so you can interactively add sequences {rgbadd: start_led,number_of_leds,r,g,b,milliseconds} and when you want it all to end, {rgbstop}. These commands can be sent via serial of MQTT.
Other
When an ESP board powers up it sends a message “esplogin” and in the payload the ID with a slash after it.. so “999/”. This can be read to send the board, say, the time. See the next section.
I’ve implemented {sleep:x} where x=microseconds (32 bit number) hence 10000000 is 10 seconds. You need GPIO16 attached to reset and that just isn’t worth the saving on this particular board but it’s in there for completeness. This is deprecated.
Node-Red
Originally we’d planned on using something like OpenHab for home control and of course anyone armed with the software can do just that. But for our purposes we like Node-Red as it is extremely flexible and becoming more powerful by the day. If you have a Raspberry Pi2 or better – you can run Node-Red on that but it also runs on Linux, PCs etc.
Node-Red allows one to “program” using visual boxes via a web interface– so an MQTT input box can respond to a particular topic, you can then do something with that and send a message back – or elsewhere – or maybe send a TWEET, or store some info in a database or send an email – honestly it is VERY simple to use and very powerful once you get to grips with it.
If you look at my earlier blogs I’ve written about graphing locally, using data pulled in by Node-Red and stored in a SQLITE database with ease )I avoid MySQL on the Pi to keep writes down somewhat). There are alternatives – I’ve written a “node” for Node-Red to let you simply send data to Grovestreams.com and others have written nodes for the likes of EmonCMS which has some very pretty dials.
Here’s an old screenshot of my Emoncms data and yes, the battery is really flat – due to this being solar charged out in Spain – and it is 6am in the morning – clearly the day wasn’t that sunny. Today I use Grafana locally for all graphing.
Node-Red has a timing module… when lets you trigger things at certain times. It also has available a suncalc which sets a flag when it is sunset. I’ve improved this significantly in a very popular node called BIGTIMER (see http://flows.nodered.org/ – check out my bigtimer, esplogin and grove nodes– my contributions – for example – “npm install node-red-contrib-esplogin”) – to produce an output directly suitable for the current design – to log the boards in and to tell them about the time, sunset and sunrise.
The esplogin node can send time updates when Node-Red powers up and on a regular basis (every 12 hours)to all boards – but also send to a specific board on request, and all boards will happily send that request when they power up – so typically a few seconds after power-up the boards know what time it is and what dusk and dawn times are.
Here’s what it looks like in action.. MQTT coming in from boards in the form of a json payload (purple), esplogin node in yellow doing the time/dusk/dawn updating and outputting the relevant MQTT back to the board (or in the case of time top-ups – all boards). The outputs from esplogin are, in order..
1. MQTT output
2. Output for a MYSQL database (legacy)
3. Output to a straight text logging file
4. Output to a SQLITE database
The login node now has an additional (5th) output which is the same as the first but in valid JSON format. The ONLY output you need is the first one,
All boards subscribe to “toesp” – and to a version of that with their name (ID) prefixed – so for example fred/toesp. That way I can talk to any board – or all of them.
When the board first powers up – it sends… in the case of board “fred” which has description “my board”
Topic: esplogin
Payload: {“id”:”fred”,”desc”:”my board”,”attribute”:””}
Desc and attribute at not important but can be shoved away in a database if you like. So that sets off the esplogin node putting info to its outputs – I only use the SQLITE output and that ends up in a database – that’s up to you but my setup is in the Raspberry Pi script referred to elsewhere.
So assuming the node gets that login – it will send a bunch of time info back to the ESP board in question at login – and will also do that every 12 hours to all boards. This stops the boards from watchdog resetting and ensures they always have the correct time without needing a real time clock etc.
See the time, dusk and dawn commands – the time in the ESPs can be used reliably though right now this isn’t necessary as the home control software on the Raspberry Pi is doing all the work.
How to get all the software the easy way
In order to use these boards effectively – you’ll need a Linux setup (a Raspberry Pi 2 or 3 for example) with MQTT, NODE-RED and preferably other stuff like PHP, SQLITE etc. Personally I’m not a Linux lover!!! And so I like things to be easy – so we made THE SCRIPT. You can grab a Raspberry Pi2 or 3 (B+?) and put everything on there. The script works with JESSIE or later version of Raspbian. Read more about the script here...
I use the Pi3 – after testing many boards this seemed a while ago to be the best for the job IMHO because of the very easy SD backup – and for reliability use a good SD such as Samsung EVO and to make life really easy. If you have a Pi3 all the better.
For controlling and monitoring – I am currently using the Nextion (serial) touch display boards for the wall and vary between using Blynk Android/IOS app for remote control, the node-red-dashboard and ImperiHome. All work well depending on your requirements.
You’ll read about all of this stuff elsewhere in the blog – use the search facility – there is a LOT of info.
Notes:
[1] GPIO5 (out5) can be manually over-ridden by the input and the “override” command.
[2] GPIO13 (out13) is generally used as an indicator to show that all is well. It activates on receipt of the correct time either serially or via MQTT and will flash briefly once every couple of seconds from there on. This activity can be disabled by a command. Increasingly we’re using a serial RGB LED on this pin to provide more comprehensive status info.
[3] We have generally scrapped using GPIO0 as an output and merely use it for programming and setup. GPIO16 makes a good relay output as it is not much use for other types of output.
Haptic feedback – when the board is being used in “Nextion” mode – we use GPIO12 as a beeper – simply fasten one of those cheap round haptic feedback devices to it and glue that to the back of the board. Also note that with limits (the line buffer is only 80 characters in length) you can concatenate commands so that for example if you want to turn GPIO12 on and get feedback as to the state at the same time {out12:1;out12?} – note the two payloads are joined together by the semicolon. I also use this catenation with the Nano peripheral and RGB PWM.
The REAL source of info on commands is in the WORD manual with the project – that is where you go to keep fully up to date.
Enjoy!
Hi all
Has anybody else had issues with a new Nextion 5″ basic display failing.
I was using a 4.3″ display and decided to go for a 5″. I ordered one from ITead direct and it arrived just before Christmas.
I ported over my project to the 5″ and all was well.
I decided to move a few items about on the display to tidy it up a little but when I tried to upload the modified project to my display it failed!
I was using the same SD card as before and i have tried many others, I’ve also tried a usb adapter and that failed too, no matter what baud rate I used. (Nearly 6 hours to upload it on the slowest setting).
All my SD cards work with my original 4.3″ display as does my usb adapter.
After some testing I have discovered that the display will now only accept a TFT file of less than 2400KB.
As you can imagine I’m not a happy bunny as the display is only a couple of months old.
I opened a support ticket on the Nextion support page and basically they are saying it’s down to my SD card or my usb adapter and closed the ticket.
Check the power supplies on the board to ensure they are correct. Be sure to check the power at the SD card slot too.
Hi Dave
Thanks for the reply.
I have tried everything power supply is good 3.31 volts at the card slot I assume that is correct.
I have now tried 20 sd cards of various brands and capacity at the last count.
I’ve used the supplied adapter for the power, and I still get the same result, if the tft file is less than 2400KB it will work anything bigger fails.
Also note that ITead say they will fix the display if I pay for the return shipping and the cost of the repair. I guess they don’t honour any kind of warranty as its only two months old.
I won’t be buying any more of their products that’s for certain!
I’ll be sticking with 4D Systems displays from now on more expensive but like the saying goes you get what you pay for.
Hi Pete.
First of all a BIG thank you for all the hard work you everyone else involved have put in to make an amazing project.
I am all up and running to a point but I’m now stuck
I am using a Nexton display and I can send out MQTT messages from node red to set text using this message:- {to_nextion:”t0.txt=\\”Saturday\\””}.
I can change pictures using this message:- {to_nextion:”pIcon.pic=33″},
but for the life of me I cannot create a message to change the text on the fly using data from another message i.e DarkSky weather temperatures.
Keep up the excellent work
Happy to say I’m no longer stuck.
I was going completely wrong(too much Arduino and
Not enough JavaScript).
Thanks again Pete for all your hard work.
I like to get rid of the auto_temperature MQTT message. ( 4/30/2019, 4:47:08 PMnode: 36df16d0.f0001a
ESP8266-01/fromesp/auto_temperature : msg.payload : string[1]
“0”)
Is there a command to stop all messages from this when there is no sensor connected?
I just had some trouble with latest update of ESP-GO. After the update I had to cycle the power(easiest way to do) to get a connection from Node-RED. I have one node that is still on 1.9.33 and that one was OK because that node cannot be updated via OTA and it is in an awkward place to do it by serial. Please have a look at this phenomena yourself as this might heart you too.
I can’t check OTA (which was working fine a week ago – I did lots of OTA) as I have a subnet issue in here, most of my boards have disappeared into 192.168.10.x (I use 192.168.14.x) – they work just fine via MQTT but can’t seem to get to the outside world. I also changed ROM location back to http://roms.scargill.net as I had reliability issues with the free storage they were on. Not sure which of these is my issue but I’m sure it’s just local. I’ll have Aidan test when he gets back from hols.
Just did an otaupdate with new location, 3.1.0.3>…4. No problems after this. messsage for success and new version reported.
Possibly an incidental mishap with the free server.
LEO – after making sure you have a backup could you please try an OTA in which case you should have version 3.1.0.5 compiled under SDK 3.1
Let me know.
My Experience with an update from 2.5.0.5 to 3.1.0.8 is not completely OK. It is spawning . This is just a fresh Mini D1 hanging on a microUSB cable. Cannot do otaupdate too. DNS problems.
This is a log:
(21:54:16.709) (COM10) {debug}
(21:54:16.787) (COM10) Time and date: 21:54:16 25/03/2019
(21:54:16.787) (COM10) Dusk: 19:01 Dawn: 06:33
(21:54:16.787) (COM10) Up Time: 0:08:29
(21:54:16.787) (COM10) IP: 192:168:0:48
(21:54:16.787) (COM10) ID: ESP8266-WMP (ARPS_0053CABE)
(21:54:16.787) (COM10) Desc: ESP8266-12F
(21:54:16.787) (COM10) Flags:
(21:54:16.787) (COM10) Comment: omment
(21:54:16.787) (COM10) SSID: hoekbrwr Pass: ???
(21:54:16.787) (COM10) SSID2: hoekbrwr_z24 (Active) Pass2: ???
(21:54:16.787) (COM10) MQTT Host: 192.168.0.3 Port: 1883 User: hoekbrwr
(21:54:16.787) (COM10) OTA Host: roms.scargill.net Port: 1966080
(21:54:16.787) (COM10) Code Version: 3.1.0.8: Previous Version: 05
(21:54:16.787) (COM10) SDK Version: 3.1.0-dev(8a853d3)
(21:54:16.787) (COM10) RSSI: -71
(21:54:16.787) (COM10) Out4: 0 (0 with invert)
(21:54:16.787) (COM10) Out5: 0 (0 with invert)
(21:54:16.787) (COM10) Out12: 1 (1 with invert)
(21:54:16.787) (COM10) Out15: 0 (0 with invert)
(21:54:16.787) (COM10) Out16: 1 (1 with invert)
(21:54:16.787) (COM10) Sensor Type: Dallas 18B20(P)
(21:54:16.787) (COM10) GPIO0 is an input
(21:54:16.787) (COM10) Temperature Port: None
(21:54:16.787) (COM10) GPIO13 available for general use: No
(21:54:16.850) (COM10) GPIO2 is an input
(21:54:16.850) (COM10) GPIO4 and 5 are outputs
(21:54:16.850) (COM10) GPIO12 is output
(21:54:16.850) (COM10) GPIO15 is output
(21:54:16.850) (COM10) Sonoff setting: 0
(21:54:16.850) (COM10) WiFi button: 0
(21:54:16.850) (COM10) Invert settings: HEX( 0)
(21:54:16.850) (COM10) Serial2 settings: 0
(21:54:16.850) (COM10) RGB Indicator: 0
(21:54:16.850) (COM10) Electrodragon: 0
(21:54:16.850) (COM10) LED Clock on port: 109
(21:54:16.850) (COM10) CPU frequency: 160Mhz
(21:54:16.850) (COM10) Free Heap: 7688 bytes
(21:54:16.850) (COM10) Used user area: 3340 bytes
(21:54:16.850) (COM10) +
(21:54:17.006) (COM10) +
(21:54:17.209) (COM10) +
(21:54:17.412) (COM10) +
(21:54:17.600) (COM10) +
(21:54:17.803) (COM10) +
(21:54:18.006) (COM10) +
(21:54:18.209) (COM10) +
(21:54:18.412) (COM10) +
(21:54:18.490) (COM10) {otaupdate}
(21:54:18.600) (COM10) Attempting OTA update
(21:54:18.600) (COM10) ESP8266-WMP/fromesp/otaupdate=Attempting OTA
(21:54:18.600) (COM10) +
(21:54:18.803) (COM10) +
(21:54:19.006) (COM10) +
(21:54:19.209) (COM10) +
(21:54:19.412) (COM10) +
(21:54:24.209) (COM10) +
(21:54:24.412) (COM10) +
(21:54:24.600) (COM10) +
(21:54:24.803) (COM10) +
(21:54:25.006) (COM10) Connection error: Not connected.
(21:54:25.006) (COM10) OTA Update failed
(21:54:25.006) (COM10) +
(21:54:25.209) (COM10) +
This is it for today!
I would fully endorse Antonio’s comments regarding Home Assistant, it really is very good and extremely flexible. I have also recently added ESPHome to my mix of node-RED, Grafana, Tasmoadmin, etc. I also have a secure link via 1 forwarded port to my mobile devices.
The things I particularly like are the ease of doing backups via ‘snapshots’ locally, these can easily be copied or backed up to an external device. Updating things like node_RED is a breeze as the addons change colour when an update is available, so simple.
moving from one system to another is equally easy. I moved my HA set up from a dual boot PC running Ubuntu 18.04 to an Intel NUC running Ubuntu 18.04.1 with ease and I am far from a Linux expert and I have had more than a little help from Antonio along the way!
There is no reason why you couldn’t run Peter’s excellent system too and have them communicate via MQTT. I don’t mean to imply both systems would be on the same PC or Raspi but more likely on two devices. Awesome potential!
backups: you can even have them automatically generated AND uploaded on dropbox or gdrive, there are addons for that 🙂
tasmoadmin: it stresses tasmota devices too much and they tend to restart or have problems… don’t leave it there opened all time, or try the alternative, TDM, Tasmota Device Manager: https://github.com/jziolkowski/tdm
install hassio: just install an ubuntu 18.04 on whatever device, even each SBC that has Armbian support, then run this script by Frenck, one of the major HA addon developers, and you’re good to go: https://gist.github.com/frenck/32b4f74919ca6b95b30c66f85976ec58
the point is: it’s not an alternative to nodered, no religion wars here… they can coexist beautifully, there’s excellent support via nodered nodes to recall home assistant services, so you can do all or part of your logic on nodered as always, or now with esphome (or tasmota rules) inside small devices themselves, so if main controllers are down you’re not blocked completely 🙂
Hi Pete!
Probably a dumb question but I am adding a couple of ILI 9340 displays to esp-go boards I have built to play with and learn how I might use them for temperature displays.
I have got the boards working in a basic form but now I am turning my attention to sending data to them in a more sophisticated form via Node-Red (still learning) to get similar good looking displays to those you have achived.
You give an example flow on page 32 of the manual, Pergola ILI Display which I have tried unsuccesfuly to emulate with mixed results. Do you have that flow written up somwhere on the blog that I could learn from. Tried searching but can’t find anything.
Hi Pete!
I managed to get it working in SDK version 2.0.0 but not in SDK version 2.1.0…
Any ideas why?
The error message:
… xtensa-lx106-elf/bin/ld.exe: build/app_0.out section `.text’ will not fit in region `iram1_0_seg’
did you know that nRF24L01 can be used to emulate BLE beacons? I don’t… this can be very useful for low energy devices reporting little data…
https://github.com/cbm80amiga/BLE_beacon
https://d.lij.uno/misc-nrf24-ble.html
Hi Pete from a sunny Morpeth. I’m a beginner at most of this stuff but working on it as a winter project. I’ve been through the Script and ESP Go articles and waded through the comments a couple of times and managed to get a nodemcu and wemos mini up and running and starting to look at Node Red. I’m wanting to publish a couple of temps and humidity to Thingspeak, and there’s a NR node for that which works on a W10 node red installation but I can’t get it working on the Pi 2 as the node red Manage Palette fails to install the node. Any advice? Thanks.
Hi Pete,
I red your older blog from 2015 about Domoticz. Have you used it since?
I became a homeowner recently and in the process of remodeling the house, will be automating everything I can think of. Out of the box “smart” switches are pretty expensive and no guarantee they will be supported/updated 3-5 years from now. I decided to go for complete diy. As of right now, I replaced old mechanical timer with nodemcu esp-12e and 6channel relay, created a flow in Node-RED with Big-Timers controlling various relays at different times. Works great.
But as I’m thinking forward, I would like to have better dashboard, integrate security cameras (trigger something on motion), irrigation controller, mobile presence, geo location, etc. I came to the conclusion that Node-RED is not the right tool for the job. I can build a house but I can’t write a single line of code.
If you don’t know what you’re doing loading sketches on esp is not an easy task and time consuming, that’s why I tried espeasy and was surprised how easy it is to get going, while digging through esp settings I was introduced to controllers. Started with OpenHAB, wasted 6 hours, didn’t get anywhere. Next was Domoticz. So far so good.
Managed to add API for my existing Honeywell thermostats (not ready to diy mission critical devices). Moved my relays to Domoticz, but can’t find anything similar to Big-Timer, except Blockly. I might as well keep Node-RED flow to control relays and update Domoticz over MQTT. Even got a Telegram bot setup for push notifications to smart phone.
Could you advise on how to move forward?
Is there other controllers? or maybe completely different approaches?
Any Dos and Don’ts?
If some articles come to mind that will answer my questions or some of them. Please share
Not used Domoticz recently – happy with Node-Red Dashboard for my thermostat – Blynk for just about everything else – all based on Node-Red. Also the Amazon node for Node-Red lets me talk to everything.
Suggest trying Home Assistant… Support for tons of hardware, you can integrate with native devices or with hacked ones via MQTT (ESP-GO, Tasmota, Espurna, Espeasy), you can write automations in YAML (not a real programming language…) or use the excellent nodes for nodered and use HA as frontend and NR for automation, or mix both, as you like… Very popular these days is the EspHome firmware, which allows to write gpio manipulations in YAML itself, and uses HA api instead (or in addition to) mqtt, for easier integration in HA…
I use HASS.IO as HA setup, and use nodered via its addons store, everything interconnected out of the box, easy to manage backup system via snapshots
Thank you for responding guys
I have no choice but to try Home Assistant as i just discovered a major flaw in domoticz, by default it expects values from sensors and APIs in Celsius and if i change settings to Fahrenheit it doesnt let values through but converts it with (value*9/5+32).
Not intended for US market at all.
However, since i already have domoticz setup and working for notifications to Telegram and i have no clue how to do it in Node-RED or else where. I’ll get one more RPi, install HA, start adding new devices or cominicate with existing thru mqtt until i get more comfortable.
If i understood correctly, i can have multiple “controllers” subscribed to any amount of sensors/devices and let them do what they do best.
or you can test it in a virtual machine…
about multiple controllers: sure, you can even forward mqtt between 2 brokers, if you want…
Pete,
I’ve had a Sonoff socket (with esp-go) running a heater outside controlled by node red and a temperature monitor for a while now and I noticed it had stopped working a couple of days ago, completely dead! I opened it up and checked all the voltages and all was OK so I re-flashed it wit the latest ROMS of your site 2.7.2.0 is reported from a {ver?}.
I noticed that the button on the socket no longer controls the relay although I do get a “trigger” MQTT message, has it fallen off the table on the latest update?
Button should work as before…
Ok, I’ve put in the garage so can’t test it immediately and I don’t really need it as the control is via MQTT but I’ll have another check when I can.
Hello
first time posting,
ESP-GO, well this has been a journey, learnt so much but am still nowhere,
attempting to serial flash an ESP, tried from raspberry pi as no FTDI, got so far then failing, tried from windows with recently acquired FTDI, again got so far then looping on boot, all power related problems, lessons learnt.
Next had a wemos D1 clone, flashed it, just couldn’t get it into AP mode to set the config, what am I doing wrong, Ali had just sent me some naked ESP’s, was looking them over, face palm moment, surely not, doh the pin out on the clone was incorrectly marked.
Thanks for the experience and knowledge, I’m sure I’ll be back with questions, mqtt and node-red challenges next….
I imagine that it may be more down to the quality of the power supply used – although a PCB design with very thin power tracks would be more vulnerable.
I do tend to make power tracks a lot thicker than signal tracks, plus I go very heavy on the grounding
I guess you use another supply regulator than AMS1117 because these are very bad regulators! Of course, it is a combination of a number of factors! Did you really check the supply voltage at the ESP8266? In the video of Andreas it has been shown that there are substantial voltage drops that can brownout the ESP.
Having real problems with ESP-Go, managed after a few tries (ie blanking and re-flashing my ESP) got it to connect to MQTT without constant errors but not it will not stay connected to my WiFi (the ap is less than 30cms away) Message i get is No heartbeat – switching to AP: {my secondary SSID} then that times out and restarts. I don’t seem to be able to find any documentation on what should be happening so really struggling at the moment.
I guess you have supply problems! Use a rock solid supply as test case and look what happens.
On all of my recent PCB designs, I’ve upped the value of the decoupling capacitor right next to the ESP8266 module. I’ve found that 47uF works really well. Otherwise, you can get some odd crashes once the wifi starts up as it takes quite a bit of current – I’ve measured pulses of up to 300mA
Andreas Spiess made some video on this matter and found out that you need to use 1000uF to be on the safe side! See this https://www.youtube.com/watch?v=wf_msvWv1jk&t=3s
As you can hear in this it also depends on the type of board you use for your ESP8266!
Chris, do you have the node -red setup with at the very least Pete’s login to be able to communicate with the boards? The ESPs need to get a reply back from the MQTT server* or won’t stay alive for long.
Have a mqtt listener node subscribe to “esplogon” and connect it to the login node, and that in turn to a mqtt publisher sending to “toesp”.
*also needs to be setup, both server and the ESPs, which need to point to the server correctly, auth and all.
Tasmota had to split the software into modules.
I simply dont support OTA on the Sonoffs as they only have 1 meg of flash snd I’m using more than half of it.
ESP-GO is oriented to general ESP-12 boards and hence has many features that Tasmota and others do not… a reminder..
OTA on 4MB boards
I2c
SPI
RGB with optional fading – for up to 300 RGB LEDS
RGB serial including 60-LED clock software and with optional fading
White control in Kelvin
pushbutton debounced inputs
Support for various OLED displays
Support for various LCD displays
VT100 Terminal mode
Deep sleep mode
Support for various temperature/humidity/pressure/light devices
Frequency doubling to 160Mhz
Support for Sonoff inc button
Support for Electrodragon
Support for IA219
Static or dynamic addressing
Support for “Nano peripheral”
Support for parallel and serial 7-segment displays (Hitachi)
RGB sequencing
Nextion support
Hi
I’ve just upgraded my sonoffs to 2.7.01 and cannot get the pushbutton (GPIO0) to toggle the relay. I’ve tried all sorts of variations. Am I missing something? If this functionality is gone where can I find the older ROMS.
thanks
I’m not convinced that I ever did implement that on the sonoffs. You don’t say what you have upgraded from?
Pete
Correct that, I did implement it and the new version has indeed screwed it up by not checking for sonoff before using gpio0. Fixing that now.
2.7.1.0 will have the fix
how do you check the device type, some sort of autodetection? Because, for example tasmota, the others let YOU choose which model you’re using…
Thanks Pete
2.7.1.0 fixed it.
If anyone has too much spare time and wants to help… I just upgraded ESP-GO again to 2.7.0 – new GPIO15 abilities. I have almost all routines in FLASH, but keep running near the limit for .text space (not variables, functions….) – on SDK 2.1 – 2.2 and now 3.0 say not enough room, apparently I should be able to upgrade and get the room back but I’m rubbish at makefiles and linkers.. using the unofficial Cherts setup on Windows and would really appreciate if someone could step in here…
From the Espressif forum:
Did you read and implemented all of the required changes in your code to be using V3 at all? That would be the starting point.
Only after that, try to find out what functions end in IRAM and try to cut down on them. If you run the linker with a loadmap, you can spot which ones end up in IRAM and which ones in IROM.
V3 needs specific changes in the loader script, otherwise many functions that are not marked as “IRAM” end up there.
I did this. Also you need to use “-ffunction-sections -fdata-sections” as compiler options. And don’t try to use -O2 or -O3, it will generate larger code but it’s not faster. Use -Os and only that. Contrary to what the manual says, you can’t use -O2 or -O3 together with -Os, the last used option will always win. So only use -Os.
diff –git a/loadscript-template b/loadscript-template
index 74f8a59..c91dbd0 100644
— a/loadscript-template
+++ b/loadscript-template
@@ -151,6 +151,28 @@ SECTIONS
} >dram0_0_seg :dram0_0_bss_phdr
/* __stack = 0x3ffc8000; */
+ .irom0.text : ALIGN(4)
+ {
+ _irom0_text_start = ABSOLUTE(.);
+ *libmbedtls.a:(.literal.* .text.*)
+ *libat.a:(.literal.* .text.*)
+ *libcrypto.a:(.literal.* .text.*)
+ *libespnow.a:(.literal.* .text.*)
+ *libjson.a:(.literal.* .text.*)
+ *liblwip.a:(.literal.* .text.*)
+ *libmesh.a:(.literal.* .text.*)
+ *libnet80211.a:(.literal.* .text.*)
+ *libsmartconfig.a:(.literal.* .text.*)
+ *libssl.a:(.literal.* .text.*)
+ *libupgrade.a:(.literal.* .text.*)
+ *libwpa.a:(.literal.* .text.*)
+ *libwpa2.a:(.literal.* .text.*)
+ *libwps.a:(.literal.* .text.*)
+ *libm.a:(.literal .text .literal.* .text.*)
+ *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .flash.rodata)
+ _irom0_text_end = ABSOLUTE(.);
+ } >irom0_0_seg :irom0_0_phdr
+
.text : ALIGN(4)
{
_stext = .;
@@ -198,14 +220,6 @@ SECTIONS
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
} >iram1_0_seg :iram1_0_phdr
–
– .irom0.text : ALIGN(4)
– {
– _irom0_text_start = ABSOLUTE(.);
– *libmbedtls.a:(.literal .text .literal.* .text.*)
– *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .flash.rodata)
– _irom0_text_end = ABSOLUTE(.);
– } >irom0_0_seg :irom0_0_phdr
}
/* get ROM code address */
And for the linker do not forget -Wl,-gc-sections
Yes of course, I totally forget to mention, that’s actually the one I meant, “-ffunction-sections -fdata-sections” is only slightly relevant. Thanks for mentioning.
BTW Espressif made this change to actually get more free IRAM space, but if you don’t follow the required steps, you’ll end up with a lot less 😉
@ts did you already implement a partition table and callback?
Then I guess you’ll have to rely on the one that maintains your environment to make it suitable for SDK V3.
—–
I’m sure all of the above makes sense to Linux seasoned techies but was as clear as mud to me. I use R Burton’s rboot – at 0000 and everything else (all pure C code, no Arduino, plus SDK nonos, starts at 0x2000h). Currently I use maybe 700k and using RBOOT can OTA into the second meg… don’t use 3rd or 4th MB of ESP12. I can keep expanding this massive effort but eventually the .text limit (only goes to 0x8000) will likely hit me.
I understand my code really well but that’s where it ends… R Burton helped set up OTA, user data near top of 1st (and I guess 2nd) meg, just below the ESPRESSIF data.
in case someone needs a json parser AND code producer! 🙂
https://arduinojson.org/v5/assistant/
you paste in your json code, it puts out the arduino code needed to parse that json!
Just like the editor really. I use it for JavaScript, php etc, and it even handles node-red. The Platformio ide handles Arduino and related ESP projects. I also like the way it integrates with git.
It can all be done with eclipse, so this is not an issue as such – more of an interest. I shall plug away at it, but thought someone might be able to help shortcut it. If I am successful – I’ll probably write it up.
Hi Pete,
Glad you’re back in full swing – good to have you back.
I am using previous versions of the ESP-GO software built on Eclipse following the excellent instructions of Makerjay.
I recently tried VSCode (which is used to build the Sonoff/Tasmota software) and have tried to port your software to it.
Basically I have had no success so far, so was wondering if one of your readers has had success. Fundamentally my tired old brain had trouble enough with Makefiles, let alone setting up anything else — so question is:
Has anyone built the ESP-GO code in the VSCode environment?? If so can they pass on some tips.
Thanks for a great blog Pete!
Regards
Why bother to switch to VSCode if you have a working environment?
I’ve just setup my Sonoff 433 RF bridge with Tasmota and playing with node red to monitor the side gate and shed door using a couple of these 433MHz door contact transmitters https://www.banggood.com/Digoo-DG-HOSA-433MHz-Window-Door-Sensor-PIR-Detector-Wireless-Remote-Controller-External-Siren-p-1163239.html?rmmds=myorder&cur_warehouse=CN
and realised that they make great little controllers because of their small size and the little button on the front which I assume is the setup button when used with the security system, anyway thought it was worth a share.
Hi,
I have what may be a stupid question but does the OTA work out of the box with the settings already entered in the firmware? or do I have to setup and enter in my own server details?
The OTA settings should be in there already.
roms.scargill.net
OK just wanted to check, I tried it with a Wemos board without success it just said no change but I tried it again a couple and it was successful on the second attempt. Thanks.
BTW I have one node which does not upgrade from 1.x.xx to 2.x.xx. Is that typical or is there something special to do?
I’ve just dug out a Sonoff1 that I’d flashed with ESP-go some time ago but noit used for a while so I updated the firmware to 2.4.02 but I cannot get it to get a heartbeat from my Pi.
I have another device, a Wemos1 working fine and I see the esplogon but not from the Sonoff, I can see the topic esplogon ‘{“id”:”Sonoff1″,”desc”:”Sonoff1″,”attribute”:””,”fail”:”0″,”boot”:”4″}’
using my Cloudmqtt websocket page but it’s not being seen by my Pi for some reason? any suggestions on what I might look for? this socket has worked before.
Current version of ESP-GO is 2.5.05 . No idea what that is… not my mqtt setup for sure
I didn’t think it was as it was sending out the ID :-).
I added an MQTT node with # as the topic and it then started to work ???? but I still cannot see the esplogon message from the esplogon node for the Sonoff in the debug node, a strange one indeed, I’ll keep playing but it’s working OK for now and I’ll also update to the latest version.
I found the problem, me, I had the incoming topic for the esplogon set to “fromesp” instead of “esplogon”
many thanks Phil for posting your solution, I was also having the same problem between the chair and the keyboard
Glad I could post something useful for a change 🙂
Hi,
I just came across this video about the shelly 1, a device that is a very small version of a Sonoff switch witch is ideal to put inside a light switch box. As this will take the Tasmota firmware I’m sure it will use esp-go as well.
Peter i think you should modify published date of modified articles so they’ll jump on top of the blog homepage… i’ve seen that this article is modified today just because i saw your latest tweet about your new domain http://www.esp-go.com pointing to this site…
Are these available for sale?
No, not unless Aidan has any spare.. you are at liberty to take the info we’ve put up and replicate our boards
Zolon,
I have some spare boards if you’re interested.
Pete, This is a fantastic resource I have stumbled across, its really great to see so many worked examples.
I have been having a play around with the binaries and all is working great so I thought I would try to compile the code in order to make some changes for my application, I am having an issue which I don’t seem to be able to resolve when compiling, I have checked all my file paths in the make file, checked im using version 2.1 of the dev kit.
I am sure your extremely busy but if anybody could point me in the right direction I would be extremely grateful.
I have resolved the issue, if anybody else has a similar problem, the libcirom.a file needs to be located in the SDK/libs folder. I am now able to build the solution.
Excellent
Look in previous comments, solution was already there 😉
I just realised that I posted a picture of my display in an earlier post (Nov 15 2017) and that displays “41.3”. I thought this was from my ESP8266 running your code, I suppose it wasn’t.
Philip,
{hightemperature?} returns a value with more precision (temperature*10), so with maths will give you one decimal place, perhaps you used that command before ?
Perfect DoH! I remember reading that command but it didn’t click that it meant that, thanks, it wasn’t that I used though but I will now cheers Allan
Thanks for confirming that, it’s just that I was sure that I had seen values previously that had 2 decimal places ….. it was probably when I was using an Arduino instead of an ESP8266
Hi,
Can anyone confirm the resolution of the auto_temperature value, I’ve just rebuilt my Pi setup and got it up and running and noticed that the temp. value is always an integer, I’m sure it used to be two decimal places.
auto-temperature in indeed an integer. I’ve never seen the point of recording room temperature to better than integer resolution.. 2ft higher or lower it is typically 1 degree or more at variance anyway. Accuracy – now that’s another matter.
Hi,
I trying to rebuild my node red flows at the moment due to a series of cockups on my part I didn’t have the important bits backed up.
Anyway can anyone help with the syntax for sending a value to an ESP node, I want to send a temp. value to a OLED remote display, I want to send via MQTT
{sd1306:”$S1;$F1;” + msg.payload + }, the payload being a temperature value, I can’t remember how I did it last time and it’s been a while.
Cheers
Sorted it out, I forgot the magic escape character.
Peter, take a look at this… don’t know if it’s useful for esp8266, too… LONG RANGE wifi mode…
https://blog.hackster.io/long-range-wifi-for-the-esp32-9429ab89f450
Years ago people were getting 1km line of sight from esp01
mmm, now that you wrote it, i remember some videos about this… sorry, then 🙂
Here is the video:
Thanks once again for your earlier help, I now have a fully functioning door control unit with a relay board to trigger outside lights from Dusk til midnight and also an electronic door release (I can’t get used to a Yale lock after years with a front door I had to lock manually, three times locked out and counting, but no more!).
My next project using your excellent code is to try and get a background light and notification panel for my work desk, using a WS2182b strip and a D1 Mini as a controller, but again seem to be hitting a wall. I know the strip works as I can load a demo sketch in the Arduino IDE and get a series of sample effects running, but can’t seem to do the same with the ESP-GO (nice branding btw) code. I have the board running from a 5v supply and the LED strip powered from the same, with the control pin connected to gpio 16. the MQQT message I am sending is {rainbow: 16, 6, 1000, 20} as a test (6 LED string) but get no activity from the strip at all. The D1 is freshly flashed with the latest firmware from your ROM library. If you (or anyone else!) can help point me in the right direction I would be very grateful!
Pete, You’ve really taught me a bunch (node-red, rpi, and lots of misc) – thx.
I didn’t follow your ESP8266 stuff until today and instead have been separately exploring ESP8266 on my own using arduino.
Why did you chose “Unofficial Development Kit for Espressif ESP8266” instead of Arduino?
What do you see as the differences?
lots of differences. Unofficial is C, Arduino isn’t. Yes I use the unofficial dev environment.
There is one thing I really do not understand!
When I send a MQTT command to the nodes like the payload {ver?} on what topic do I have to subscribe in NodeRed/MQTT-SPY to see the response?
When I send this on the serial connection I get “(unit ID)/fromesp/ver=xx.xx.xx”. I subcribed to that topic when sending via MQTT and does not see any message in MQTT-SPY.
Anyone who can explain how that works to get me going. Some Blog where it has been explained.
I need to read the value of PWM outputs on the NANO!
start subscribing to UNITID/# or UNITID/fromesp/# and see what arrives, then you’ll find what you’re looking for…
OK that gives some light at the end of the tunnel! Thx!
There are numerous blogs about this in here. See this one https://tech.scargill.net/32mb-esp01/. Or do search on Sonoff in this blog!
Im a late comer to this blog so please excuse the question if its been answered somewhere else. But First I want to pass on my best wishes to Pete and wish him a speedy recovery. Kudos to you Pete for a great repository of information. I have been messing around with the ESP-12F from China for about a year. A great little device. I was trying to get MQTT and Node-Red to install and work properly on a RPi when I found “The Script.” Dang! It worked. So easy. And as Pete would say, Bob’s Your Uncle!!! So funny. Well that propelled me ahead light years in my quest to replace my cludge of Insteon/ISY99, Alexa, Hue, ESP stuff and Sonoff with a more robust controller. The question is will your .bin firmware that you developed for the ESP stuff work well on a Sonoff device??? Right now I’m using Tasmota firmware and am pretty happy with it, but I want to use the same firmware across all my ESP IOT devices. So thats the question. It sure would be easier for me to manage one firmware instead of two and would satisfy the OCD part of my personality. Any insight will be appreciated. Thanks! And again, Get Well Pete!!!
Yes I works on the ESP devices, I have programmed a few of my Sonoffs with this code.
not if you don’t change the EEPROM… the stock one is 1Mb, you need a 4Mb one (32mbit): https://tech.scargill.net/32mb-esp01/
but as sonoffs do only few things (a button, a led and a relay), you can do as Peter does and install Tasmota firmware on them, then connecting with nodered, if you want…
Hi All
Pete is in hospital at the moment – he’s had a stroke, so he’s not ignoring you!
He’s responding very well to treatment, so fingers crossed he’ll be blogging again soon. We took him his laptop into hospital, so with a bit of luck, he’ll get bored and start writing
Aidan
Thanks for the update Aidan, it’s good news his responding well to treatment.
I thought this morning it was unusual for an unannounced absence.
Wishing you Pete a speedy recovery.
best wishes for a full and fast recovery Peter… a big hug to you and Maureen, we’re waiting you’re back soon 🙂
Thanks for letting us know, please pass on best wishes for a full and speedy recovery, let’s hope he’s already done his Christmas shopping 😁
Really sorry to hear about that. Please pass on my best wishes. Pete’s creativity and knowledge are legendary and much loved in the community.
Please also pass on a msg to Mrs Scargill if you can – that Pete’s endless hours of messing with hardware and software are not wasted but rather are welcomed by so many people. 🙂
Pete, all the best for a speedy recovery.
I know this is probably a daft question, but will your code run on an ESP32? I ordered one of these https://www.aliexpress.com/item/Lolin-ESP32-wemos-ESP32-WiFi-Modules-Bluetooth-Dual-ESP-32-ESP-32S-ESP8266-X-Battery-Shield/32808400447.html
and ordered the ESP32 version.
First things first, love the blog, really inspired me to try all this again after giving up about a year ago.
However, I think I must be going mad.
I have a couple of Wemos D1 Mini’s I got to do some testing with.
I have blown the code onto them and all seems fine. The board booted, I managed to put into AP mode and put in my wifi details, the boards login on NodeRed and will respond to status queries (e.g. {out16?} ) I can send a topic to the board {out16:1} and when I query it shows the change from off to on (and vice-versa). However, the signal from the output pin is not changing. Pin 16 stays high, Pin 14 stays low for example. Is there something obvious I am missing? I have looked through blog entries, read the DOC file and still can’t seem to find the answer. I know it is going to be something blindingly obvious but I just can’t seem to spot it. (I am trying to control a relay board fwiw, but am just trying to read a change first to make sure it is working!)
I’ll investigate here.
So blindingly obvious that I’d forgotten about it myself..
{enable16:1}
do that once – reboot – GPIO16 will work.
I’ve updated code and manual to make that more obvious and to set the state when using {enable16} so you don’t have to reset
Arrrggghhhh!!! It was the reboot that got me, I tried the enable and was getting nowhere!
Thank you for the clarification, I knew it would be simple!
any idea why I get this error when building
C:/Users/doug/Downloads/scargill-esp-mqtt-dev2-f4db82bcb950/scargill/Makefile:240: recipe for target ‘user/webpage.h’ failed
process_begin: CreateProcess(NULL, C:\Python27\python.exe web_page_convert.py firmware/webpages.espfs user/webpage.h, …) failed.
make (e=2): The system cannot find the file specified.
mingw32-make.exe: *** [user/webpage.h] Error 2
this is my first day using eclipse
web_page_convert.py should really have been in your project folder …. here’s a link
https://www.dropbox.com/s/5qsf2ruryubx9d8/web_page_convert.py?dl=0
Pete,
As you know, after the recent Espressif updates to NONOS_SDK there was an iram issue when compiling your code.
I see you have now resolved this by rewriting some of your code, but when I try to compile it I get the following:
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.1.0/../../../../xtensa-lx106-elf/bin/ld.exe: cannot find -lcirom
This was using the latest update from Espressif GITHUB and your code for v2.3.15.
Did you modify anything else.
Thanks
Allan
Hi Allan
I didn’t solve it. In the process, I saved some space by moving to lciron – but I STILL cannot get enough space back for the (what seems like a backward move) latest.. so I’m still on SDK 2.0 which is fine as there’s nothing wrong with it….
You’re right you’re missing that file and I have no idea who sent it to me.. but
C:\Espressif\xtensa-lx106-elf\xtensa-lx106-elf\lib
Grab this file and that should sort you out… it merely leaves more RAM- which means I can keep expanding….
https://www.dropbox.com/s/pjsbl466j3w80pp/libcirom.a?dl=0
Thanks Pete, libcirom.a added and compiled ok using SDK 2.0
Yes, that would need to be set in the configuration but if there should be only one then maybe a poll to add the most used? I vote the OLED screen on a wemos board 🙂
Well, immediately that opens a can of worms. My WEMOS board says D1 and D2 – which in reality are GPIO4 and 5… other WEMOS boards use other pins (see elsewhere – like GPIO14… I use GPIO14 as an input.
I would leave it up to you to decide, it was just an idea 🙂
Pete,
I’ve now got several ESPs up and running with your code some controlling relays (sonoffs) and a couple reading temperature and a couple operating as displays for the temp’s.
As a future feature maybe would it be possible to setup the node as having a display and then getting it to report WiFi/MQTT connection status when it’s connected, maybe a one off message that would stay until other messages were sent via MQTT after powerup or reset.
But what KIND of display??
Maybe a 1K pull down on GPIO15 as well. Also, try a 47uF capacitor on the VCC pin to ground right next to the ESP module.I think that some of the ESP modules have this on, but some don’t and you can get odd effects with out it
Some later modules have the various pullups and pulldowns onboard as well
Thanks I will give it a go. It is working off one of those cheap AC/DC psu’s so perhaps its a little noisy. I did notice that the GPIO4/5 seems reversed. When I switch one the other changes although they are marked correctly on the bd which is a little strange.
I reverse GPIO4 and 5 because some earlier boards had those reversed….
Hi, Im having problems with my esp’s. When I program them with your code and set them up everything works but after a while they seem to switch back into Hack_setup mode. They still log in but I get the ++++ in the serial. The GPIO0 is not at ground and has a pull up resistor. If I power down for a while, it recovers but then will return to Hack setup mode. this has happened on two devices now what do you think is going on?
Depending on the mode they may be using GPIO0 or GPIO2 for WIFI access point. I generally have pullups on both. I can think of no other reason why they would be doing this – a wild guess – power issues? I’ve loads of them dotted around here and Spain and not seeing this – I don’t think anyone else has mentioned this so unless it’s a bad batch, power or pullups would be my first port of call.
Pete,
Just to let you know how I’m using the code you worked to develop.
A smart plug based on the body of a defunct WiFi extender (£13 from Ebuyer now) and a 3D printed replacement face a Wemos Clone and a Microduino OLED display. This is displaying the hot water temperature, my plans are to add a touch switch behind the cover and an RGB LED and maybe a buzzer. (hopefully an image is attached)
Oh that’s NICE. Well, my 3D printer is on the way. I might come back and ask you for a copy of the plan for that case…
Thanks, I only printed the front plate, the rear part is the WiFi extender body which includes a 5V power supply, one of these https://www.amazon.co.uk/Edimax-EW-7438RPn-Wireless-Extender-Network/dp/B00NBKAATC/ref=sr_1_1?ie=UTF8&qid=1510773583&sr=8-1&keywords=wifi+extender+booster+edimax
I can upload the front panel to thingiverse if you’re interested.
Bugger !*%*^*$£%*%
Just tried it again now I’m at home and it works fine ….ARGHHHH it’s hard enough without this, I tried loads of times to do that this morning but it wouldn’t work.
Oh well, it works now. thanks.
Not sure what you mean, I initially put in two SSIDs in every board, each with their own passwords. I then tried to edit/overwrite the second SSID in one board via the serial link and it doesn’t update.
Hang on – I’ll give it a shot just in case….
{ssid:”fred”}
reboot
Waiting for Access Point Fred
Yup… working a treat.
Pete,
Having got the firmware up and running on a few ESPs and displaying data on a screen I tried to get it working at work by using my Android phone hotspot.
I cannot change the ssid away from those I originally entered, I’m using commands via the serial port and getting an “OK” response then resetting or unplugging but when it powers up it still looks for the original ssids, should this work?
my version:
Firmware version 2.3.13
SDK Version: 2.1.0(116b762)
I’m going to take a guess that the boards are using the second ssid and you’re updating the first. Put in user passwords for both ssid and ssid2
Hi Peter,
I was going through your ROM site and I read that the version is updated to 2.2 version. But if i download the three file and update it the ver command returns me 1.9.3
What I’m doing wrong?
Kind regards
Andrea
There is a new version in the bitbucket. You probably took the old one. This is the latest url: https://bitbucket.org/scargill/esp-mqtt-dev2 Remark the 2 in the end!
Ok thank you. Anyway I downloaded from http://roms.webutu.com/
I was thinking it was updated
btw now on 2.3.13
The blog has now been updated to point to the later boards (2 changes)
Thank you for all the work you share with us!
Oh, right – on the subject of retention and QOS – these two pages I’m using as reference – I’m no better off given experimental results – but they’re worth reading.
https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels
https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages
Hi Peter
Thank you for sharing all of your great work!
I have one question regarding stability: How do you cope with loss of wifi signal in the middle of a command from MQTT? Your ESP firmware does not seem to support QoS?
Best wishes
Mathias
Mathias – I could well use QOS – certainly Mosquitto supports it – but I’ve never found it to be an issue. MQTT tends to be rock-solid. Also many of my commands use Bigtimer to trigger events and these are often used with repeat set.
The ESPs are also ultra-reliable when fed proper software and supplies and tend not to miss messages.
Thanks a lot for clarifying!
Indeed, it seems that your software is very steady together with Bigtimer and MQTT, and the repeat-output would solve any issues for switching a lamp on and off.
But what if you need to send a pulse to, say, a pump for watering the plants, and the wifi signal to the ESP drops just when MQTT sends out the command?
I know it can be solved in several ways, I’m just curious to hear your thoughts and experience.
Ok Mathias…. this one deserves to be a blog entry in it’s own right – so I hope everyone else is reading (pay attention….)
What do I know about MQTT. Well, apparently a lot less than I thought I did this morning.
So – we have two things – we have QOS and we have RETENTION.
If anyone wants to learn along with Peter and Mathias 🙂 go here…
http://www.hivemq.com/demos/websocket-client/
Open up TWO browsers… click on the default connection and you will have TWO clients for MQTT (on their servers). You can subscribe to anything you like but I suggest you make it something unique or you’ll be seeing a hell of a lot of messages. Maybe start with your name or something else unusual and put some numbers after it.
So – QOS. This is an interesting one because there is SUBSCRIBED QOS and there is PUBLISHED QOS and they are NOT the same… If you SUBSCRIBE to say, QOS2 then you might reasonably expect incoming messages to come in at that level – erm, but they don’t – if the other client sending you a message sends it at QOS0 – then you get it at QOS 0.
But here it gets worse – QOS2 in the simplest documents says you will always get a message no matter what. I’m here to say if you get cut off and reconnect – same client ID – you will NOT get that message. But it gets worse, if you tell the server to RETAIN a message – you’ll get it if you are not around at the time… the only way to get rid of it is for the sender to send a BLANK message to that topic… but not just any blank message – a RETAINED blank message – a blank message non-retained does NOT kill the original – I tested this on Mosquitto and the server I’ve just pointed you to. It all seems a bit… odd.. Before anyone challenges any of the above – try using HiveMQ….
SO – I don’t want to use RETAINED as message might be old – for example I send time information to all my boards on a timeout – if a board is not logged in at the time – when I logs in – I read the login and send a new time code to it (that is the purpose of my NODE-RED esplogin node. If I used RETAIN, I could be sending time to a unit that was an hour out of date.
So someday when I get to the bottom of the point of QOS2 given that it does not seem to send to units that are temporarily disconnected (try it yourself, disconnect the client and reconnect but past in the original clientID)…. I’ll stick with simple QOS zero with other appropriate measures in the place.
If all of that is clear to you – you’re doing better than me, I’m wishing I’d never started testing.
I may do a video on this…
Hi Peter – this is great – let’s dig into it!
First of – It is perfectly clear to me – might just be luck 😉
Second – RETAINED messages – I agree with you, they should be used only with extreme caution – or not at all!
So QoS…….
As far as I have tested, QoS works as expected BUT:
– The QoS flag has to be set in both ends
– “Clean Session” must be turned OFF for message to be queued for offline clients.
This is why it don’t work on Hivemq
Ah, edge cases, gotta love em!
Yes, QoS refers to messages where the client is online. It is not for cases where the client is not available for some reason. That is what retain is for.
If you need something more robust, you are looking at an enterprise service bus rather than the IoT focussed MQTT standards.
In regard to retain. Yes, you do indeed have to be careful because it is a pain to go through and remove a load of retained topics you didn’t really want! I know because I’ve done it a few times.
I you want a relatively easy way, you can use a script in MQTTspy or, of course, command line MQTT from Mosquitto. Spy lets you save all the topics though in a file so it is relatively easy to then feed it back. I think there is a script in one of my GitHub repos somewhere (see TotallyInformation on GitHub).
But retain is massively useful where you do indeed always want a newly (re)connecting client to get the last output. I use it with my HA system in Node-RED so that, on restart, the last commands get sent back out to get everything back into a known state. I also use it for tracking the last update timestamps for sensors. So even if the system goes down, I still know the last updated date/time. I can use that to make sure that out of date data is highlighted.
Well, here’s something I learned TODAY. QOS 1 and 2 messages WILL INDEED be stored up for clients which are offline (you might want to check Julian as I think this contradicts your sentence) – but only if they have a “persistent session”.
Read near the end of this page (ignoring comments – just the main article)
https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels
I’m PARTICULARLY interested in this page describing the persistent session.
https://www.hivemq.com/blog/mqtt-essentials-part-7-persistent-session-queuing-messages
I have to say, I don’t use the Hive Stuff generally, I’m a Mosquitto type of person – but their documentation is bloody marvellous – I’ve learned more on the subject today than in the last 6 months just reading through the links I’ve put in here.
I’m going to have a tinker in the next few days but right now – a good night’s sleep I think. I’m not sure if the MQTT client software we use on the ESPs is up to this …. the broker handing it subscriptions on reconnect.. can it really do that??? I certainly have never tried that as I didn’t know it could be done….
Peter, yes I totally agree! I am sure it can be done in your software, as it only requires the QoS flag to be set. The “persistent session” can be set in Node-Red (Clean session=OFF) and I THINK that should be it..
I know you don’t use the Arduino libraries, but this guy demonstrates perfectly working QoS (skip to 07:50)
Let me know if I can assist you digging more into this..
Best
Mathias
Hi Mathias
Happy to have a play – however, not sure what the persistent session in Node-Red has to do with anything – Mosquitto is not running in Node-Red, it is stand-alone…
What am I talking about – it is the clients that matter… and Node-Red is one of then – you’re right – no I was thinking more of the ESP8266 – contact between Node-Red and Mosquitto is unlikely to be lost as they are on the same machine – but the ESPs are wireless. Not that I have lost info in living memory …. yup the documentation says the persistent session has to be set up in the client.. ES8266 – I use Tuan’s MQTT – I think that’s the same code they use on Arduino/ESP.
You are right of course – this IS slight confusing!
Hi again Peter
I have now tested QoS in several setups, and the ONLY way I was able to make it work was with IDE library “AsyncMqttClient”. All my other scenarios failed. So I’m not sure it’s worth struggling with yet..
PS: I like your software a lot!
One function I would love in a later update is timer output not only in minutes and seconds, but also milliseconds, ie {out4:6,1000600} = 600 millisecond pulse.
Best
Mathias
Interesting – thanks for that Mathias… well, I’ve just spotted another message indicating that QOS doesn’t always work in ESP scenarios… but at least the fog is clearing 🙂
I don’t recall seeing any setup like that in the code used on the ESPs (clean session etc)…. – I could be wrong. Yes, understand QOS at both ends – my understanding is that if the QOS on the client is set to 0, messages will come in at QOS 0 regardless of what the other end wants. QOS 2 is clearly the answer – if supported at both ends – but again I should say, I can’t point to any problems I’ve had in all this time re: unexplained lost messages…
I actually do this – use a timed pulse to trigger the watering. I have a humidity probe in the soil. I take a sample from the ADC connected to the probe and then decide to water or not. If watering is needed, I send a 10 seconds pulse command eg {out0,6,10010}. That way, so long as the command gets through, you’re guaranteed not to leave the water running.
I’ve actually done a version of our design specifically for my watering system and a 3D printed box that holds a 12V cheapie solenoid valve on the outside to switch the water on and off.
I can send them to Pete to be made available if anyone is interested
not related directly to Peter’s work, but to domotic in general: in this video there’s a very good explaination of how to setup a domotic house, with evolution during the years… long but well done: https://www.youtube.com/watch?v=YQCaBXJ9sSM
Hey Peter. I took the liberty of setting up my development environment according to the instructions provided by Jay. And attempting to use ‘rebuild’ under the ‘Build Targets’ in eclipse, I get the following error:
CC user/petes_code.c
In file included from user/petes_code.c:18:0:
user/rboot-ota.h:12:23: fatal error: rboot-api.h: No such file or directory
compilation terminated.
E:/BitBucket/scargill-esp-mqtt-dev-b7de8c23b776/Makefile:160: recipe for target ‘build/user/petes_code.o’ failed
mingw32-make.exe: *** [build/user/petes_code.o] Error 1
‘E:/BitBucket’ of course is where I placed your source code.
Any ideas? I did find rboot-api.h in the rboot/appcode folder, however not sure how to get eclipse to parse that folder for the includes (been a long time for me using eclipse.)
Hi there
Well, for starters that code is now old and dead – there’s a new repository esp-mqtt-dev2. Normally this would be in the \users\whoever\workdata folder – or at least brought into that by Eclipse – I can’t really advise on any other environment as that’s the one I use (unofficial Cherts). So regardless of where the project startt, tell Eclipse to import, general, existing projects into workspace…. you should see your project ticked once you’ve found the original folder… and it will end up in Eclipse’s workdata folder. The rboot-ota c and h files are in there… but get esp-mqtt-dev2 from Bitbucket first – just put it somewhere – anywhere to start the ball rolling – oh and make sure you have SDK version 2.1 – not the VERY latest – but the one JUST before that….
Ok, thanks. Yea, Jay’s post had your old code linked so was not aware of the ‘dev2’ fork. Anyway, I downloaded the code, and also uninstalled the latest version of the SDK and installed version 2.1. Followed the remaining instructions and reloaded your sources as advised above. Two questions remain. Do I modify lines 20 and 21 (UTILROMS, and VERFILE) to point to my eclipse workspace (and your source?) And the ‘Makefile.windows’ in your source. Is THAT the makefile I use instead of ‘Makefile’? In other words, rename the two to correspond to the correct environment?
Currently running into:
LD C:/Users/jerbo/Workspace/esp_mqtt_dev2/build/rboot-stage2a.elf
E2 C:/Users/jerbo/Workspace/esp_mqtt_dev2/build/rboot-hex2a.h
CC rboot.c
rboot.c:13:25: fatal error: rboot-hex2a.h: No such file or directory
Makefile is the actual one, the other 2 are templates in case to switch to linux for what ever reason. Check if all files are present and if all folders correspond to your situation, then it should work. Don’t touch anything below ESPTOOL2!!!
I just made a copy and had no trouble. I suggest you check all your references in the Makefile. There is a file missing because you used the wrong name for your base folder I suspect! It is under subdir appcode!
Pete,
what script do you run on the Arduino pro-mini you use as GPIO extender that you attach in I2C?
thanks
Marcello
I don’t use an Arduino Pro Mini – I use a Nano clone from the likes of AliExpress or Ebay generally – usually well under £2 – look up “nano peripheral” on the blog. It’s all there.
Hi Pete,
Look at these cheap/small ESP8266/ESP32 boards with integrated microUSB & 0.91″ OLED display:
https://www.aliexpress.com/item/ESP8266-WIFI-Chip-0-91-inch-OLED-CP2014-32Mb-Flash-ESP-8266-Module-Internet-of-things/32826990581.html
https://www.aliexpress.com/item/Lolin-ESP32-OLED-V2-0-Pro-ESP32-OLED-wemos-pour-Arduino-ESP32-OLED-WiFi-Modules-Bluetooth/32824819112.html
Hi
I’ve yet to see the merits (for me) of using the ESP32) as I’m no-where near out of steam on the ESP8266… and that link of yours for the ESP8266 is not by any means the cheapest I’ve seen – BUT – and it’s a big BUT – the ESP8266 board is different to the rest. Up to now they have the ESP-12 STUPIDLY on the FRONT, HIGHER than the display – making it all difficult to fit in a box with a hole for the display. The board YOU have identified appears to have the ESP etc on the BACK. A shame they’d not put the CONNECTOR on the back – because of you plug a micro-USB plug into there – you’re back to square one with that being higher than the display – but with a pair of wires providing power, this might just be a little winner!
The OLED display is 1.40mm height above the PCB, a microUSB B connector is 2.60mm, and the SKSGACE010 buttons are also 1.40 mm (with actuator). This means that the USB is 1.20 mm above the screen top, so not flush, but close!
Of course, if you put it into a transparent case, there will be a 1.20 mm gap between the case and the screen, but if you have an opaque casing and cut it to put a transparent window, you can play on the windows thickness to compensate the difference.
I wish they had a mid-mount micro USB connector like the one used in the STM32 Blue Pill boards…
EDIT: you could also put a 1.20mm thick spacer under the OLED display…
OR the OLED on one side and EVERYTHING else on the other side – maybe we should write to someone and suggest they do that….
Yes, but unfortunately, I have zero influence whatsoever on those cheap module Chinese designers 😉
You may well say that – but so did I until I started writing to one or two of them and found that some of my ideas were ending up in their products :-)…
The problem is to get a hold on them: those you find typically on AliExpress are only reseller, they are not the original manufacturer, unlike for the higher-end ARM Cortex Ax boards.
For example, it is now granted for years that the USB pull-up resistor value R10 on the STM32 “Blue Pill” board is wrong, but no one has been able to contact an actual manufacturer, and all the BP boards you can find still suffer this problem, requiring either to replace a small 0603 resistor, or put a big through-hole one in parallel!
Good point I’d forgotten about that resistor – and yes, AliExpress do just move stuff on…
My biggest problem with the STM32 Blue Pill cheap boards – is that there is only one complete library for those things (Arduino IDE) and it does NOT include them – the others don’t support slave mode – I got really excited about that board as an alternative to the Nano – but the I2c slave mode sent me down a long learning curve at the end of which I put it back in the cupboard….
I am just trying to implement I2C slave mode into STM32Duino code… I will let you know if I am successful running your slave I2C sketch into the BP board, of course!
Oh excellent… if that would run on the cheap board it could be expanded to do much more.
I prefere this one:
https://www.aliexpress.com/item/Lolin-ESP32-wemos-ESP32-WiFi-Modules-Bluetooth-Dual-ESP-32-ESP-32S-ESP8266/32807483723.html
since the ones with the screw near the antenna doesn’t give me confidence on the range.
That’s the one I have – but the chip is higher than the display… which makes it a pain when it comes to putting in a box with a hole for the display. Nice board though.
The link in: “There is a DOC file here”
points to: “…/esp-mqtt-dev/…”
why not to: “…/esp-mqtt-dev2/…”
Because it is virtually impossible to keep all documents up to date – the -dev/ is the version which I stopped working on – perfectly working but I was running out of space due to the way the original memory layout was – making it work great with ESP-01 (without OTA) but restricting what I could do with ESP12.
I will however fix that link now, thank you.
Noticed that the URL of this post says 2016. Thought I’d mention it, just in case you want to make it 2017 instead. That aside, thanks for the tremendous quantity and quality of work you’ve done bringing this project to its present state.
i suppose that changing the url will just loose all the google cached searches and SEO, so not a smart move to do…
Hi John
And this is the problem with updating older posts. I’ve changed the title to 2017 but if I change the permalink then lots of links to this, all over the world, will instantly become dead. So I’ve left the permalink as it stands – but rest assured, whenever I get a chance – I try to update the content of blog entries.
This is how a two years of fun and hard work looks like. Congratulation Peter and Aidan for the great work.
Peter I’ve started http://iotcentral.eu where you can download the binary for an MQTT broker that is running on an ESP8266. I will publish also a version for ESP32 ( funny that the first version was for ESP32, but I’ve accepted the ESP8266 as a challenge).
I know that I still have to add some examples for Arduino IDE and the normal SDk, but for someone with your skills will not be a problem to give it a try. Also the users of the “Bondar” ESP8266 MQTT broker have access to the cloud MQTT provided by the iotcentral.eu since the Bondar is bridging data to cloud instance also.
I still need to make the OTA to work, moving the server from PHP to NodeJS/Express breaked this functionality.
If you have time to give it a try I will be honored. Your advices are more than welcome. It is not necessary to post this message on the blog.
My email address is bcatalin@gmail.com and my blog is
http://myesp8266.blogspot.com
Thanks a lot,
Catalin
Hi
My understanding from elsewhere is that an MQTT broker for the ESP8266 will necessarily be limited to talking to a few devices due to limited RAM on the device.
Hi Peter,
Is somehow limited, but to 24 devices one bridge connection to the cloud and one websocket for the mobile phone.
See here https://myesp8266.blogspot.ro/2016/11/mqtt-broker-on-esp8266-5.html 25 connections made with mosquitto_pub/sub and here
https://myesp8266.blogspot.ro/2016/02/mqtt-broker-on-esp8266.html
how fast are flying 1000 messages from my phone to router – ESP8266 Broker – Router and back to my phone ( second video)
So just so we understand this – it sounds like in this case the ESP8266 is not actually the broker but the gateway to a cloud broker – in which case what is the advantage over just going straight to the cloud broker – or having a local broker on, say a Raspberry Pi etc? Or have I missed the point here? Please do elaborate.
No, It is an fully MQTT broker. You can use it without the cloud MQTT broker. You can subscribe and publish to it exactly like you are doing on the mosquitto on Raspberry Pi.
Having the bridging functionality allows users when are not at home to connect from their smartphone to the cloud instance and from there to the house. This system is working for the past 2 years on my house and II can operate remotely the irrigation system based on ESP8266, lights, fishing tank, plugs, AC etc.
In fact the core code for broker is mosquitto based. So , yes I can say that is running a mosquitto MQTT broker on ESP8266.
Imagine that you internet connection is down and you can’t operate your devices from your mobile app. In this case the mobile app is connecting to the ESP8266 broker over the websockets ( in the same way as its connect to the cloud MQTT instance) and you will be able to turn off or on your devices without any problem ( it happened to me few times and was a pleasure to have continuous operations)
Making the local websocket connection was a bit challenging since is using the same port 1883 for it but now the ESP broker can differentiate between an MQTT message and an WS connection.
If your internet connection is down and you don’t have a local broker ( ESP or raspberry pi mosquitto) your devices are not able to talk to each other. This $3 ESP8266 can replace an $70 raspberry pi that is used just for MQTT. Also the power drained be ESP8266 is far less then the 4W consumed by the Raspberry.
You make a very good point Kata – I am going to stick this on an ESP8266 and give it a whirl. Thank you for the clarification – and of course you are right – if you are doing nothing but MQTT – no Node-Red or other servers then for a smaller installation it would indeed appear to make sense (provided your WIFI is reliable) to make use of a dirt cheap ESP8266.
Ok, downloaded, off to find my favourite flashing utility.
Thanks Peter,
Don’t forget to create an account to iotcentral.eu other wise it will not get authenticated.
So, first create the account then enter the credentials on the ESP8266 web page setup.
You will find some nice stuff in the serial output of course.
or a cheap nanopi or whatever small sbc with wifi, doing wifi hotspot itself and put as second wifi on your firmware 🙂
If you take a look – you’ll see I’ve done a blog entry for this subject alone – tested the software and have some questions which will also interest others??
Comments in there???
Hello Pete, I have a few questions:
1) How to defferentiate different home control 2016 states/errors using the LED status indicator on GPIO13?
2) MQTT /lwt message: could you please add board id before /lwt message so we one can differentiate LWT messages from different boards (e.g device1/lwt) ?
3) I need one more input to use in my home project. Is it possible to add the functionality that changes/switches the output’s (e.g GPIO4/GPIO5) to the input bahaviour like GPIO14 is?
1. Never thought to detail that.
2. I don’t do let as no-one has ever asked for it.
3. 4 and 5 are multi purpose inc I2c. Would need to investigate.
Thanks for your replies!
Some more comments
1) What is the purpose of the GPIO13 LED blinking? What does the blinking means – is it always blinking with constant frequency, could it stop blinking or could it be steady light on?
2) Sometimes the unit stops sending stats to MQTT or just disconnects from WiFi – this feature will let me or someone else know that certain device is out of reach so and the commands send to this device won’t be executed, you see?
The LED blinks generally to let you know that all is well. This is now historical as the focus on the current boards and software is making use of an RGB LED to show different states in different colours.
You can turn the LED off – see manual.
It should NOT stop sending information to MQTT – check version is up to date and check your power supply. My units are on 24-7.
I have an issue with the status LEDs on the clients.
Today I renamed my pi from raspberrypi to homepi with 2 clients connected and after restart the status leds keep on fast blinking although reconnected to WiFi and broker. When I power cycle client it keeps on fast flashing even after reconnecting.
I already noticed before when connected and disconnected fom the broker or homeserver goes down they keep on slow blinking as if everything is OK.
Just checking – you HAVE set them to the correct type? The board supports both RGB serial LED (default now) and normal LEDs – the output is very different depending on the setting.
Sorry to be a bit late. Now I am so far to test normal 12V leds as a replacement of Halogen bulbs. I have made a very small driver with the help of a Mosfet and I am very happy with the very low resistance of it. You can switch Amps with it without noticing real heat on the surface. But I have to supply PWM to control the luminousity of them like a dimmer. I cannot figure out how your PWM command works. I have connected the control lead to GPIO15 and give the command {pwm:0,0,50} for 50% lum on the 3rd parameter(assuming this is GPIO15(BLUE). Nothing happens. I realise this is originally meant for RGB leds with 4 leads and I already used your clock on different ports with the 60 serial leds, but I like to use the ESP as a dimmer. How to??
Hi – so firstly you cannot do PWM and serial LEDs at the same time – the PWM affects the timing on the serial LEDs. That is a limitation of the technology as the serial LEDS run at very high speed and that is not configurable as the LED timings are not flexible. The PWM should work as your example above.
Yes I was aware of that, but then another ESP. See below!
I found out 2nd parameter is GPIO15. Please define in doc the assignment of parameters! With a little bit of programming in a function we can make 3 dimmers. Works as expected!
All is fine now! All my clocks sync on different units with NTP. I have set PI to sync with NTP. No more trouble missing the start of the news, haha!
to update – simply install again in your node-red directory – npm install node-red-contrib-esplogin
Thanks I will look for that.
But… you have to look at your esplogin node code, because it gives out the same message for a complete minute!
Give it an hour – new version has second-accuracy output to ESPs.
Fine! I will start reading your blog about automatic updating!
My Pi is synced to NTP once a day – check WEBMIN – there is an option there to set the time from NTP – I do it 3am every morning.
ESPLOGIN gets the time from the system as and when needed.
This timemaster should be Pi(synced to NTP). Does this recipe work to keep in sync? https://victorhurdugaci.com/raspberry-pi-sync-date-and-time .
Still your esplogin node changes time only once a minute!
Sorry for the late follow up, but I have been working to correct this flaw.
Have you seen my picture in the link? There you can see that the time in the time: toesp stays the same until the next minute+ 1 second. So in practice the clock is in average 30 seconds slow. I have now split your time/dusk/dawn message with a separate message for time and one for dusk/dawn.
All my computers are in sync as I can see by looking to the detail and I can use it as a source. I suppose the Pi is synchronized to NTP at startup. I have this separate ESP with a synch to NTP that generates a Mqtt msg with time, so that will be my time master. I will communicate with that ESP for time to all ESP’s in the home control. So Node-Red can generate a request to that time master to get the NTP time every 12 hour. Then this time master sends a Mqtt time master to all clients.
All this is not yet realized but in the end I will generate dusk/dawn message from esplogin node and time from this timemaster.
Oh, but then I sync my PIs via NTP – you may not do that – in which case – they could be wrong.
So if I will implement your clock near the TV I will always be late for the news on TV.
You’ve managed to lose me – you were talking about ESPlogin – and the ESP units don’t use the time. Node-Red has the time!
Oh THAT Clock!!
Erm the ESPs should be up to date – they are updated every day from the login node.
Any chance your controlling Pi or whatever is wrong – that’s where the time is coming from.
Actually time is always 1 second in the minute and only updated every 60 sec, not getting time from NTP when esplogon is coming in?
It NEVER gets the time from NTP – it gets the time from the system – which in my case is synced to NTP.
I noticed some strange behaviour of your esplogin node. I managed to get the Mqtt message on a ESP8266 not running your SW. I wanted to use your Mqtt time. However it stands still for quite some time( I have seen 40 sec). In that period it just gives the same value. Meaning it is most of the time way after NTP time.
See here an example: https://leovanderhoeknl.tinytake.com/sf/MTE4MTcwOV80NTgxNzky
Is this normal behaviour?
I have never done programming in C or C++, but what I understand from the differences you can read on Internet C++ is not the right language for this project. I’v done VBA and it looks like it’s the difference like VB to .NET. So somehow I still like to use this display and control it from Node-RED. Any guidance what route to go? Maybe investigate MQTT libraries for Arduino?
C++ (or C#) is basically what they use in the Arduino setup. I use C – using the unofficial development kit for ESP8266 on a Windows PC – it’s all down to taste really. VBA is very different to either of them. The easiest route I guess would be the Arduino route as there will be libraries for it. There is an MQTT library for ESP8266 in the Arduino/ESP setup which seems pretty reliable (another reason I’ve stuck with the basic SDK and C is I get utter reliability from the WIFI and MQTT and don’t want to chance going backwards).
On the subject displays. I could not get anything usefull from your seed class onto SSD1306 blue/yellow 128×64. However do you know about this: https://github.com/squix78/esp8266-oled-ssd1306?
I have made very nice displays with it. Why not integrate in your MQTT software instead of the seed thing you are experimenting with. I use this https://www.aliexpress.com/item/Free-shipping-Yellow-blue-double-color-128X64-OLED-LCD-LED-Display-Module-For-Arduino-0-96/32665937977.html?spm=2114.13010608.0.0.mDEoS5 part(less than 3€!
Here: https://drive.google.com/file/d/0B9JhUQDijic0X2gxNlVyTkRmaUU/view?usp=sharing is the ino with the code and this looks very much like your code which includes in assembler written routines. Detail, i have tried with fps=60 so very smooth and bright. For other applications this could be down to much lower fps.
Hi Leo
Two reasons I’ve not done this – I have one of those displays – ordered one to do just that – then I discovered that they have a short life – and lost interest. Also – the assembly code. I’m getting adept at converting C++ back to C for the Eclipse/unofficial compiler environment but last time I tried converting some assembler, I failed miserably.
Peter, any plan to add support for displays using MAX7219 or TM1637 chipsets? I think they’re cool to display small info like temperature, umidity, etc… just asking 🙂
max7219, 8 numbers, cascadable modules
https://it.aliexpress.com/item/MAX7219-LED-Dot-Matrix-8-Digit-Digital-Tube-Display-Control-Module-For-Arduino/32638121832.html
tm1637, 4 numbers, smaller display
https://it.aliexpress.com/item/Free-shipping-4-digital-display-with-adjustable-brightness-LED-module-clock-Point-Accessories-Blocks-for-arduino/1961805015.html
tm1637, 4 numbers, bigger display
https://it.aliexpress.com/item/4-Digit-LED-Display-Tube-7-segments/32591091564.html
Well, that would be good – but I can’t go buying up every display and I2c gadget on the planet on the off-chance they may prove useful 🙂
Currently that larger display from China would take 30-50 days to get here to the UK!
as I said, just asking, maybe you had them already 🙂
no problem
Hi Peter
I want to change the separator on the commands by ‘:’ via ‘-‘ or other. So can you guide. me
I’m not quite following this – more detail please.
I wan’t to change “:” in command to esp. Ex: {out0:1} -> {out0-1}. How i can do this ?
I want to change “:” in command to esp. Ex: {out0:1} -> {out0-1}. How i can do this ?
Well, you’ll obviously need to recompile the code – part of the problem there might be that the line parser accepts negative numbers however. i.e. xxx:-1 is valid. So you’d need to do a tiny bit of work in that area – it is all in the same area in petes_code.c
Start looking around line 2503 and 2518 – those line numbers of course only apply to the current version which at the time of writing is 1.6.57
Thank you very much.
Sorry to say, but that would be the only concise document to find out how things are working together! All “documentation”is loose sand scattered across the internet, blog, bitbucket, youtube all as separate items. Your doc is also not describing the procedure to come from scratch to a working system. I had to look at Peter Oakes’s video to find out how to configure all ESP units. There are too many gaps in the description.
I found it anyway by googling a bit, but this is better for newcomers like me.
Came a little closer to a working Pi3B. There is the issue with the serialport which gives a fault when starting Node-Red. I do not know what to do to correct that. I have read and see the reason for the problem, but what to do to get this fixed for your system on a Pi3?
I’ve read this http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/. I am not enough informed to understand all of it. I think it needs some text in your WORD doc.
At least I want to have my Pi3 start without fault messages.
I really are starting to learn about Node-Red and your contribtions to it. What I cannot find is the Flow for the Node-Red, but where can I find your central system??? Is it in one of your blogs referenced?
I am absolutely not planning to put up my flows for the house control – because they are very much specialised for my own needs and would need WAY too much explaining.
Serial port – likely using it before it is set up – put a delay initially on any serial port access of a couple of secs…
Hi Pete,
please check your link to the SCRIPT in JESSIE Raspbian. It is a dead link now.
I decide to start using your HomeControl for many reasons and especially because of the DIY possibilities in Node-Red.
Got my Pi3B running and now I am reading, reading and reading about how to go on.
Fixed – thank you.
The documentation does assume a certain knowledge of ESPs and Raspberry Pi – but very little knowledge of, say, Linux.
Hi Peter,
Brilliant set of pages that are so inspiring to read.
I have created a small circuit with an ESP 12 module with a relay driven off GPIO4 and a switch on GPIO2. I would like to toggle the output with a debounced switch movement AND send a message back via MQTT about the change ( so that the unit will switch manually without the network being operational )
I have read through the instructions and can’t see a way to do this – am I missing something or could you make an adaptation?
hi peter,
i want procces on hex string data like …
B6 F3 10 FD 00 00 FB CB BA 77 CA CA CA C0 0A CC 00
how i can split every part of data in hex and procces in node red function
Thanks
Look up the split method.
have you seen itead LED driver!
Just ordered two as it looks like it will make a nice under cupboard lighting in the kitchen.
just got to see if your code can be modified to suit it.
side note! your code is running in an esp1 which fits nicely in an old 433MHz remote control plug. have 2 more to modify as general purpose switch units.
Hi,
I’m looking into building a relay board (I’m really enjoying the SONOFFS… just bought loads of them) but I want to build some with an LCD, solid state relay and some other things.
Is there are chance I can see your schematic. I want to try and work out why I’m getting rebooting when controlling a relay. so i’d like to study your schematic if possible.
many thanks
Andrew
I don’t have any Sonoff schematic that isn’t on their site..
Oh I see – in the Home Control article there are links to schematic and board files.
Hi Peter, here reading all your good work, and testing some Wemos D1 mini Pro.
A little correction, where it says:
“Payload: {“id”:”fred”,”desc”:”my board”,”attribute”,””}”
It should be:
“Payload: {“id”:”fred”,”desc”:”my board”,”attribute”:””}” , with a colon , isn’t it?
Thanks for the info ! we’ll be in touch!
Javier Unamuno
Yes you are right and I have updated the blog – thanks.
hi Peter, i had mqtt set up with no passwords required and and all the sonoff’s connected and responding to commands.
I wanted to just set the mqtt user and password via mqtt using mqtt_pass and mqtt_user. i tried and then issued a reset command even got off the settee and recycled power. enabled passwords in mqtt but they would not connect.
did the same commands via the serial port without removing power and they connected no problem?
safe trip no need for a quick response.
Just playing with your raspberrypi script with set up passwords for the mosquitto server and all the light switches disconnected from the mqtt network and would not reconnect.
To save getting off the settee I thought that i’d remove the password requirement and set the mqtt user and password via mqtt with no success after rebooting.
sad to say I had to get off the settee and go and get all the light switches and update mqtt user and password via the serial connection.
Can this be performed over the mqtt link or did i miss something?
As a side note i’m running the code on two standard sonoff’s and one modified as per your info to 4MB software so far appears to be rock solid.
It must be too early in the morning (I’m up doing emails before my good lady gets up as we’re off on a long drive up Spain to meet friends today) – as it seems like you’re asking if you can setup the MQTT user and password over MQTT. Well, if you’re connected to MQTT you can indeed change the username and password – but you obviously need to be connected in the first place. You can set them up over WIFI but you’d still have to get off the settee to press the web programming button while applying power…. if I’m way off base try again but I may not answer immediately 🙂
is there a way to set the state of a output on power up?
Don’t follow – outputs are on power up as you left them last time.
think i found it…. invert?
Would it be possible to add a toggle option on the out command: Eg, using for example {out16:8} would toggle the output from it’s current state? This would be handy for push button switches where we only have a single state output. My Enocean switches have 4 buttons so this would allow me to control 4 lamps from ON and OFF with 1 button.
Of course, I could handle this in Node-red but it would be easier if this was in the module itself.
Actually, it would only need to apply to the relay output as that is the most likely one you would want to toggle on and off.
Well, I was feeling generous this morning so I’ve added it to all outputs (not the I2c ones which are still experimental).
It is command -1 as 7 onwards has other uses.
So {out12:-1} will toggle 12 on and off.
Just trying out OTAUPDATE and I have put the file on my website server. From Chrome I can confirm that it does pass this as a binary file so I know that the web server can send the file. I get the following errors in the serial output.
Attempting update
bedroom1/fromesp/otaupdate=Attempting OTA
E:M 5856
Tick
OTA succeeded to ROM 1
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 1340, room 16
tail 12
chksum 0xe9
ho 0 tail 12 room 4
load 0x3ffe8000, len 660, room 12
tail 8
chksum 0xcb
csum 0xcb
rBoot v1.4.1 – richardaburton@gmail.com
Flash Size: 32 Mbit
Flash Mode: DIO
Flash Speed: 40 MHz
rBoot Option: Big flash
Rom 1 is bad.
Booting rom 0.
„ãìÃgäÛsƒòn|ä$d$l`„ã{“dŒþ
———————
ESP Starting…
GPIO4 and 5 are outputs.
Current web programming pin: 0
GPIO13 is a LED indicator.
Software version 1.6.0
SDK Version: 2.0.0(5a875ba)
Use the {debug} command for more information.
STATION mode
Web page control enabled
Connected as 192:168:1:148
MQTT connecting
MQTT Broker connected
Device ID is bedroom1
–>
Ok
Ok
–>
Time: 00:00:00 00/00/00
Time Code: 0
Dusk: 11:52 Dawn: 11:46
On1: 08:00 Off1: 12:00 On2: 15:00 Off2: 23:00 Peak: 23c Off-peak: 19c Frost: 14c
IP: 192:168:1:148
Internal ID: ARPS_0019487B
ID: bedroom1
DESC: empty
FLAGS:
SSID: ________ (Active) Pass: ________
SSID2: ________ Pass2: ________
MQTT Host: 192.168.1.146 Port: 1883 User: admin
OTA Host: http://www.axoninstruments.biz Port: 80
Code Version: 1.6.0
SDK Version: 2.0.0(5a875ba)
RSSI: -57
Out0: 0 (1 with invert)
Out4: 0 (0 with invert)
Out5: 0 (0 with invert)
Out12: 0 (0 with invert)
Out15: 1 (1 with invert)
Sensor Type: Dallas 1880
Temperature Port: GPIO2
GPIO13 available for general use: No
GPIO2 is an input
Sonoff setting=0
WiFi button=0
Invert settings=HEX( 1)
Serial2 settings=0
RGB Indicator=0
Electrodragon=0
No LED clock
CPU frequency: 80Mhz
Free Heap: 16592 bytes
Up Time: 0:00:00
But did you try the SAME code on my site FIRST? And did it work? And I have TWO files not one – rboot.com is also there. Only the one gets updated but I’ve never tried not having the other one there.
And are you trying this on a 4MB part and did you try the same part with the same software on scargill.net first?
Yes. I simply cloned and built it. No changes. The download only looks for the romx.bin if the large_flash option is enabled. These are 4MB devices.
I’ll go and download your binaries and give them a try just to be sure.
I enabled some debugging in rboot_api.c and there is an error when it tries to write to an address. It’s the same error and same location each time.
write addr: 0x00234e58, len: 0x05b4
write addr: 0x0023540c, len: 0x05b4
write addr: 0x002359c0, len: 0x05b4
E:M 5856
write addr: 0x00235f74, len: 0x05b4
write addr: 0x00236528, len: 0x05b4
write addr: 0x00236adc, len: 0x05b4
Bye the way, the very first time I used this new board (Amica ESP12) it worked and completed the OTA. The issue is that it won’t work anymore. I’ve tried numerous times. It does the same on a second board of the same type and on 2 LoLin boards I have.
Hi Peter, I cloned the latest code and then rebuilt it. When I flash this to an ESP8266 board and then reboot the device, I see the usual messages about wifi etc and after all that finishes, I see a series of + signs scroll up the display. I can’t find reference to them but after little while they do stop.
Just change i2ccheck to i2c_check – I’ve updated the code as per the manual. OTA code will follow shortly.
The + signs mean that whatever is set as the web programming button – it thinks it is held low. By default it is GPIO2 and you can change that to GPIO0. Reboot after you’re done.
Hi Peter, in the document it shows a command “i2c_check” which generates and EH? response. The code itself shows this to be “i2ccheck”
Hi Pete,
are there any updates on a mains powered board since 2015, or you completely switched to the nextion one?
And one more question: do you have a bill of materials for the mains powered board?
Thank you.
No updates – the boards work fine and we’ve had no reason to change it – talk to Aidan Ruff about boards – I’m guessing he’ll say the part values are in the schematic. Funny I’ve just been updating the software on the mains ones here in Spain – I used these 24-7 without a hitch and have done since we made the first ones (well, not the VERY first one which shorted GPIO16 to +V).
I also use the mains board with the 12v-5v DC convertor to run my external lighting from a 12v camping battery – every day winter and summer without issue. Would have been nice if we’d put just a couple more ground, 5v and 3v3 pins on them… and I’m not using GPIO2 as web programming button any more – so at some point we may revise the board – better to leave GPIO as an input for web programming and output toggling – like Sonoff do… and use say GPIO16 as relay output – because that’s all it can be used for – can’t be an input.
Thanks, I’m going to order pack of them now, hope I’ll be able to assemble them and they will work 24×7 for me too.
BTW: In your dropbox there are two brd files. I opened them both with EAGLE and it seems that “ESP-01-and-12-Development.brd” is DEV6 board, while “ESP-01 and 12 Development.brd” is DEV7. Maybe you could rename them, so their names will be more distinct?
And here is exported schematic for this board https://i.imgur.com/HXMGZZP.png
(In your dropbox are two bottom images of the board and no schematics).
I have a updated version which is ESPDEV9 – I’ll send Pete the files for upload. Only minor tweaks
Aidan
Hey Peter, can i by chance get a link to the Hackitt & Bodgitt EAGLE files? Many thanks in advance, Levi
Dropbox link is in this blog!
Ok ok… got it sorted now, link was not working for me,
Maybe i didn’t download the interweb correctly..
Yes.. ID-10-T error.. most likely Pebcas..
Cheers!
Hi Peter,
Long way since those old PIC boards of the APPCON but I am mightily impressed with Node-red and your work on the ESP12 code. At least I don’t have to run miles of 4 core alarm cable anymore 🙂
Anyway, what is needed to run this on an ESP8266 board (Sparkfun ESP8266 Thing)?
I have ordered a couple of ESP12 based boards until my custom boards are ready and in the mean time I wanted to try things out with the ESP8266 I have lying around.
PS. When I make changes to the user_config.h file and then use this to load to the board, the settings seem to still be from you original code. This could be an issue with the ESP8266 I am trying to run this on though.
Yup, we’ve come a long way. So in total you need a Pi with Node-red and MQTT and my esplogin node…. and you need an ESP12 or similar… You would typically not make changes to the config.h file but through serial or the web interface (serial is easy – 115k with your FTDI or whatever you are using) just enter the commands (no topics needed as you’re talking directly to the device) to set up ID, your SSID, pass, mqtt server address and pass…. erm, that’s about it.
I’ll wait for the ESP12 modules to arrive and send off my custom boards soon.
Node-Red is already up and running with your scripts etc. Using the Enocean switches I can switch the devices on and off. Totally with Node-red now as my choice for HA and the PC running Homeseer will be shutdown once I have migrated everything over to Node-red. Cheers for all the hardwork and taking the time to document and share it. I will owe you a few beers if we meet again.
Hi Pete,
Just stumbled on a small bug… The ota_port can not be changed via serial (or mqtt). Looking at the code, the port number is an integer, but the program is working hard writing a string to the memory, crashing the ESP without fail…
Cheers
You are of course absolutely right. And that fix will go out in the next update. Thank you.
FYI Peter – the tab for this page shows the incorrect name ERSP8266 in Google Chrome – looks like the Title Element is incorrect
Craig
Strange that – must’ve been a late night editing session – I’ve fixed that tag now, Craig – cheers.
Yep looks fine now – well done – timely as ever !
Peter,
Is there somewhere that talks about the actual setup of the environment – in particular i am looking at the ESPLOGIN node and what it is expecting in and what it is sending out (topic wise etc) – but i am sure there are many more of these interaction. Obviously the ESPLOGIN module is the start of the chain and then i am sure many more would come up after that ?
Craig
The script for the Pi has a lot of info about setup. The ESPLOGIN node is available here
http://flows.nodered.org/node/node-red-contrib-esplogin
I’ll amend “Home Control 2016” to refer to the esplogin node.. It’s main purpose is to ensure that the units have the time initially and to refresh that from time to time.
Some progress:
If you don’t have the MS Visual C++ redistributable bundle installed on your system (ie: on a fresh Win 10 box), you at least need the **32-bit** version of msvcr100.dll to accompany esptool2.exe in c:\esptools, otherwise the utility won’t run and Eclipse just errors out without a helpful message.
You can pick up the file from here (scroll down past the paying bit) https://www.dll-files.com/msvcr100.dll.html
That fixes the ‘make’ issues with rboot
I’m still getting the segfault in petes_code.c though 🙁
Hi Pete,
I have just setup the development environment from scratch on a different PC and downloaded your repo and I am getting a build error:
Makefile:113: recipe for target ‘D:/scargill-esp-mqtt-dev/build/rboot-hex2a.h’ failed
mingw32-make.exe[1]: *** [D:/scargill-esp-mqtt-dev/build/rboot-hex2a.h] Error -1073741701
mingw32-make.exe[1]: Leaving directory ‘D:/scargill-esp-mqtt-dev/rboot’
D:/scargill-esp-mqtt-dev/Makefile:204: recipe for target ‘firmware/rboot.bin’ failed
mingw32-make.exe: *** [firmware/rboot.bin] Error 2
I know this has come up in the past and I see some comments elsewhere online about it, but I can’s see a specific fix so any help appreciated.
Strangely enough compiling works on the old machine which was setup in the same way a few days back and also runs Win10.
(Be gentle with me – I am new to the Eclipse environment!)
I never set anything up in Eclipse – it always just ran – as the work is in the Makefile…
I’m at a loss as to why RBOOT would be giving you any trouble – it’s all there in the repo.
Just for the sake of it -I doubt this is it – but my repo is in d:\git\esp-mqtt-dev
Might want to stick it in there, import and compile?
Hmm. I have redownloaded the repo….
Opening the folder as project leads to the aforementioned error. If I import the project, compilation starts but I get a segfault!
14:38:46 **** Build of configuration Default for project hackitt_mqtt_dev ****
mingw32-make.exe -f D:/git/scargill-esp-mqtt-dev/Makefile all
OC build/libmain2.a
CC driver/i2c.c
CC driver/ssd1306.c
CC driver/i2c_master.c
CC driver/BME280.c
CC driver/spi.c
CC driver/gpio16.c
CC driver/uart.c
CC driver/user_display.c
CC driver/ds18b20.c
CC mqtt/proto.c
CC mqtt/utils.c
CC mqtt/config.c
CC mqtt/mqtt_msg.c
CC mqtt/queue.c
CC mqtt/ringbuf.c
CC mqtt/mqtt.c
CC user/aidans_code.c
CC user/httpd.c
CC user/heatshrink_decoder.c
CC user/cgiwifi.c
CC user/petes_code.c
user/petes_code.c: In function ‘readDHT’:
user/petes_code.c:723:5: internal compiler error: Segmentation fault
temp_p /= 10.0;
^
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
D:/git/scargill-esp-mqtt-dev/Makefile:296: recipe for target ‘build/user/petes_code.o’ failed
mingw32-make.exe: *** [build/user/petes_code.o] Error 1
14:38:52 Build Finished (took 5s.751ms)
I might have to start from scratch – I wonder if something did not install properly?
i think there’s a typo in section “Command set”
at point 6 {out0,6,100} should be {out0:6,100}
You are right – and now it is fixed 🙂
i see it still there, in this page 😉
just before the pwm section
Not seeing it – page number?
Ok, found several – that’s what I get for cut and paste – also fixed the odd i.e.
Search right in this page, it’s still there
Hi Pete, here is my code, you may see any number of different ways to accomplish this, im not an experienced programmer but it gets done what i want of it.. heres the code..
/* Generator Start Controller – BY LEVI MADELEY
* Single pin input for ease of contol
inputPin LOW/ HIGH for startup sequence and shutdown respectively
* serial control for startup and shutdown based on single letter commands
“S” for start, “s” for stop and “R” for reset arduino module
UNO – ESP8266
*
————————————————————————————–
GLOW = glow timing
using millis time the glow plugs for cold
start sequence
—————————————————————————————–
START = start timing
* using a for loop to run through the start sequence until the alternatorPin reads voltage then go to Running state
—————————————————————————————-
RUN = run state
* running of engine
* 8r timeout for fuel purposes
——————————————————————————————–
SHUTDOWN – sequence for shutting down normally 15min minimum total run timer
prevents shutdown straight after unit has started.
…FUTURE DEV.. 60second no load timed shutoff
——————————————————————————————-
FAIL – shutdown and lockout sequence for when things go wrong
or for when emergency stop button is pressed
immediate shutdown
———————————————————————————————
OFF
sequence for any maintanance activity to be performed by controller whilst machine is off.
—————————————————————————————-
*/
// system states
#define OFF 1 // machine is off
#define GLOW 2 // glow plug timing for cold start (comment out for petrol engine)
#define START 3 // starter crank run
#define RUN 4 // engine running, timer for fuel
#define SHUTDOWN 5 // engine shutdown timers (15 minute minimum run time and 60sec no load
#define FAIL 6 // emergency stop lockout mode
#define GLOW_PLUG_HEAT_TIME 3000
#define MIN_RUN_TIME 900000 // MINIMUM genset run time before shutdown
#define RUNNING_TIMEOUT 28800000 //000 // changed from 10 min to 8 hrs.lm 28800000UL = 8hrs
#define CRANKING_TIMEOUT 2500 //STARTER CRANKING TIMEOUT 2.5 SECONDS(2500).lm
#define TOTCRANK_TIMEOUT 17000 //TOTAL STARTER CRANKING TIMEOUT 18 SECONDS.lm
const int ledPin = 13; // to led display
const int resetPin = 12; // to reset on board MUST BE SETUP AS output HIGH /pullup/
const int starterPin = 11; // to Startermotor via Relay
const int ignitionPin = 10; // to ignition via Relay
const int inputPin = 9; // to initiate start/ stop sequences via NodeMCU
const int emergencyPin = 8; //to Emergency stop button
const int GlowPlugPin = 7; // to glow plug via Relay
const int alternatorPin = 4;// yellow
//Flags
byte byteRead;
byte last_state1 = 0;//flag for VOID LOOP
byte last_state2 = 0;
byte last_state3 = 0;
byte last_state4 = 0;
byte last_state5 = 0;
byte last_state6 = 0;
byte last_state7 = 0;
byte last_state8 = 0;
byte last_state9 = 0;
byte last_state10 = 0; //flag for Serial.print
byte last_state11 = 0; //flag for Serial.print
byte last_state12 = 0; //flag for Serial.print
byte last_state13 = 0; //flag for Serial.print
byte last_state14 = 0; //flag for Serial.print
byte last_state15 = 0; //flag for Serial.print
byte last_state16 = 0; //flag for Serial.print
int state = OFF; // master variable for the state machine
unsigned long StartingTime; // When did we power up the engine? Need this to time the starter timing.lm
unsigned long RunningTime = 0; // When did the engine start? Need this for the 8hr timeout
boolean haveFailed = false; //flagged true if handleFAILstate is run
boolean failPrompt = false; //serial print for reset module
void setup()
{
digitalWrite(resetPin,HIGH);//pullup
pinMode(ignitionPin,OUTPUT);
pinMode(starterPin,OUTPUT);
pinMode(ledPin,OUTPUT);
pinMode(alternatorPin,INPUT);//pulldown
pinMode(GlowPlugPin,OUTPUT);
pinMode(inputPin,INPUT);
pinMode(resetPin,OUTPUT);
pinMode(emergencyPin,INPUT);
// Make sure everything is set correctly
Serial.begin(9600);
}
void loop()
{
if (last_state1 == 0)
{
Serial.println(“Welcome to Generator Manager…. By Levi Madeley and James Smith”);
Serial.println(” “);
Serial.println(” Serial commands list.. “);
Serial.println(” ‘S’ = Start Genset”);
Serial.println(” ‘s’ = Shutdown Genset”);
Serial.println(” ‘R’ = Reset Control Module”);
Serial.println(” ‘e’ = Emergency Shutdown”);
Serial.println(” Waiting 5 sec for wifi to boot and connect”);
delay(5000);
// command();
(last_state1 = 1); }
command();
switch(state)
{
case OFF:
handleOFFstate();
break;
case GLOW:
handleGLOWstate();
break;
case START:
handleSTARTstate();
break;
case RUN:
handleRUNstate();
break;
case SHUTDOWN:
handleSHUTDOWNstate();
break;
case FAIL:
handleFAILstate();
break;
}
}
void handleOFFstate()
{
if (digitalRead(alternatorPin)== HIGH && digitalRead(ignitionPin)== HIGH)
{
Serial.println(“handleOFFstate state=SHUTDOWN”);
state=SHUTDOWN;
}
if (digitalRead(inputPin)== HIGH && digitalRead(ignitionPin)== LOW) // future -temp sensor code here
{
Serial.println(“Wifi Start Sequence Initiated… .. .”);
delay(200);
state=GLOW; }
if (digitalRead(inputPin)==LOW && digitalRead(ignitionPin)== LOW) state=OFF;
//if (digitalRead(inputPin)== HIGH) Serial.println(“inputPin=HIGH”); //debugging
if (digitalRead(inputPin)== HIGH && last_state16 == 0)
{
Serial.println(“inputPin=HIGH”); //debugging
last_state16 = 1;
}
if (last_state2 == 0)
{
Serial.println(“Command to off state”); //DEBUGGING
last_state2 = 1;
Serial.flush();
}
}
void handleGLOWstate(){
if(haveFailed){
if(failPrompt == 0 ){
Serial.println(“FAILED: Please Reset Controller”);
failPrompt = 1;
}
return;
}
Serial.println(“Power up”);
StartingTime=millis();
digitalWrite(ignitionPin,HIGH);
Serial.println(“Heating Glow Plugs”);
digitalWrite(GlowPlugPin,HIGH);
delay(GLOW_PLUG_HEAT_TIME);
digitalWrite(GlowPlugPin,LOW);
state=START;
if (last_state3 == 0)
{
Serial.println(“Command to Glow State”); //DEBUGGING
last_state3 = 1;
Serial.flush();
}
}
void handleSTARTstate()
{
if(haveFailed){
if(failPrompt == 0 ){
Serial.println(“FAILED: Please Reset Controller”);
failPrompt = 1;
}
return;
}
Serial.println(“Starter cranking”);
digitalWrite(ignitionPin,HIGH);
int x;
for( x = 1; x RUNNING_TIMEOUT)
{
Serial.println(“handleRUNstate Running Timeout”);
state=SHUTDOWN;
}
}
if (digitalRead(alternatorPin) == LOW && digitalRead(ignitionPin) == HIGH) //it has stopped by itself for one reason or another and needs to be physically attended to
{
state=FAIL;
}
//command();
if (last_state6 == 0)
{
Serial.println(“Command to run state”);
last_state6 = 1;
Serial.flush();}
}
void handleSHUTDOWNstate()
{
if(millis()-RunningTime > RUNNING_TIMEOUT)
{
if (last_state4 == 0)
{
Serial.println(“Running Timeout”);
last_state4 = 1;
Serial.flush();}
state=FAIL;
}
if (digitalRead(alternatorPin)==HIGH && digitalRead(ignitionPin)== HIGH && digitalRead(inputPin)== LOW)
Serial.println(“will shutdown but now in cooldown mode “);
Serial.flush();
{
//WARM/COOLDOWN TIME — LOAD DISCONNECT RELAYPIN GOES HERE(future development)
if (RunningTime=millis() >= (MIN_RUN_TIME))
{
Serial.println(“Shutting Down, after min runtime”);
digitalWrite(starterPin,LOW);
digitalWrite(ignitionPin,LOW);
delay(5000);
state=OFF; }
}
if (last_state7 == 0)
{
Serial.println(“Command to shutdown state”);
last_state7 = 1;
Serial.flush();}
}
void handleFAILstate()
{
if (last_state8 == 0)
{
Serial.println(“handlefailstate”); //DEBUGGING
last_state8 = 1;
Serial.flush();
}
if (last_state9 == 0)
{
Serial.println(” GENSET LOCKOUT MODE – CHECK FUEL AND/OR ENGINE!!”);
last_state9 = 1;
Serial.flush();
}
// command();
if (last_state10 == 0)
{
Serial.println(“Command to fail state”);
last_state10 = 1;
Serial.flush();}
if(digitalRead(alternatorPin)==LOW)
{
digitalWrite(starterPin,LOW);
digitalWrite(ignitionPin,LOW);
digitalWrite(13, HIGH); // turn the LED on
delay(2500);
digitalWrite(13, LOW);
delay(250);
}
state=FAIL;
haveFailed = true;
}
void command() {
if (last_state11 == 0)
{
Serial.println(“Command interface”); //DEBUGGING
last_state11 = 1;
Serial.flush();
}
if (digitalRead(inputPin)==LOW && digitalRead(alternatorPin)== HIGH)
{
Serial.println(“wifi initiated shutdown sequence”);
state=SHUTDOWN;
}
;
if (Serial.available())
{
/* read the most recent byte */
byteRead = Serial.read();
}
if (byteRead==82)
{ /*Listen for R which equals byte code # 82 */
Serial.println(“Resetting Genset Control Module… .. .”);
digitalWrite(resetPin,LOW);
delay(500);
digitalWrite(resetPin,HIGH);
}
if (byteRead==115) { /*Listen for s which equals byte code # 115 */
Serial.println(“Shutdown Sequence Initiated… .. .”);
// delay(200);
state=SHUTDOWN;
Serial.println(“Going to shutdown state”);
}
if (byteRead==101) { /*Listen for e which equals byte code # 101 */
Serial.println(“Emergency Shutdown Triggered.. .. .”);
//digitalWrite(emergencyPin,HIGH);
//delay(200);
state=FAIL;
Serial.println(“Going to fail state”);
}
if (byteRead == 83)
{
(digitalRead(alternatorPin)== LOW && digitalRead(ignitionPin)==LOW);
Serial.println(“Start Sequence Initiated… .. .”);
// delay(200);
state=GLOW;
failPrompt = 0;
Serial.println(“Going to glow state”);
}
// next few lines are here incase of module RESET while genset running ..system STATE check.. and emergency shutdownPin..
if (digitalRead(alternatorPin)==HIGH && digitalRead(ignitionPin)== HIGH) {
state=RUN;
if (last_state12 == 0)
{
Serial.println(“going to run state”);
last_state12 = 1;
Serial.flush();}
if (digitalRead(alternatorPin)==LOW && digitalRead(ignitionPin)== HIGH) {
state=FAIL;
if (last_state13 == 0)
{
Serial.println(“going to fail state…”);
last_state13 = 1;
Serial.flush();}
}
if (digitalRead(alternatorPin)==LOW && digitalRead(ignitionPin)== LOW) {
state=OFF;
if (last_state14 == 0)
{
Serial.println(“going to off state…”);
last_state14 = 1;
Serial.flush();}
}
if (digitalRead(emergencyPin)==HIGH)
{
state=FAIL;
if (last_state15 == 0)
{
Serial.println(“going to fail state…”);
last_state15 = 1;
Serial.flush();}
}
}
}
i really love what you have done here. the Software works like an OS for the esp platform, and it has made my transition over from arduino soo much easier.
I have written a little program that you may benefit from, see my home runs on solar (with a Diesel back up Generator) and i built a startup controller for it using a UNO and a Node MCU, it controls the operating functions so my inverter can start it when its req’d via mqtt.
its very basic but i reckon it could well operate without the UNO, performing all functions on the NodeMCU.
happy to share if it will be of use to anyone, might even fit in your ESP OS. id add it myself if i knew how .. lol. WAAAY to many if functions in that one for me to understand Peter!
any how, one more idea i had was an esp8266 running an Mqtt broker.. is that even possible? dont reckon thered be much room for anything else but Like you Peter, i’m always interested in saving money!
Cheers From Down Under!, Levi
In reverse order – nothing is impossible but I would suggest that it is highly unlikely that an ESP8266 could run as an efficient MQTT host – but then you can get a FriendlyArm unit for a tenner that will do that – if a Raspberry Pi is considered too expensive.
If you want to give us more details on what you’ve done in here – fire away.
Pete.
Hi Pete. I’ve built up one of the boards with the Nextion attached and I can control it through serial and Nextion however I am struggling with the syntax in OpenHAB. Do you have any pointers? I have a relay attached to GPIO15 and want to setup a switch in OpenHAB to control it (board id MastBed) normally I would configure OpenHAB with a Switch Item and the MQTT instruction could be
{mqtt=”>[mymosquitto:MastBed/toesp/{out15:1}:command:ON], >[mymosquitto:MastBed/toesp/{out15:0}:command:OFF]”}… Is this correct? Normally OpenHAB knows how to control a switch and sends ON / OFF commands or 1 / 0 to control it, however because of the bracketed “{out15:1}” instruction it can’t do that. Am I making sense? Anyone else out there with Openhab that can help me? Many thanks! Regards, Andrew
Hi there
Sorry I gave up on OpenHab a long time ago as being too convoluted… let’s hope others can help here.
Ok. Thanks anyway.
Found something! Looks like someone else is using your code with OpenHAB!
I will try this when I get chance.
https://community.openhab.org/t/send-a-in-a-mqtt-command/10629
Basically you need to map the command ‘ON’ to {out15:1} and ‘OFF’ to {out15:0} in the transforms section. Lets see if it works!
My version is pretty simple:-
I can’t put up a graphic of the nodes, but here’s a text version.
[MQTT Node, with topic ‘esplogon’] —>[Function to speak login] —> [Ivona Speech Node]
The function node to speak the login has the following code:-
—————————————————————————————–
var load = JSON.parse(msg.payload);
// Remove any special characters from the device ID
load.id = load.id.replace(“_”, ” “); // remove underscore
load.id = load.id.replace(“-“, ” “); // remove dashes
if (load.attribute !== “”)
{
load.attribute = load.attribute.replace(” “, “”); // remove any whitespace
var attribList = load.attribute.split(‘,’); // Split Separate out the various attributes
for (i = 0; i < attribList.length; i++)
{
var attr = attribList[i].split('='); // Now extract the various values
if (!attr[0].localeCompare("voice")) // Got a Voice directive
msg.topic = "ivona/" + attr[1];
}
}
msg.payload = load.id + " logged on";
return msg;
——————————————————————————————-
The above will generate the code to say whichever device has logged in. As a little extra, if you set one of the device attributes in your ESP device to 'voice=Emma' or whatever voice you want, then each of your nodes can different voices! Make sure that the voice name matches up with the Ivona voice types or it'll just use the default
If you also want to save the the login to the database, then also feed the MQTT esplogon node output to an 'esplogin' node and take the bottom output to a MYSQL node. I think that Pete has detailed the standard form of the database elsewhere on the blog.
If you want me to email you a picture of the nodes from Node Red, just send me your email address to aidan@ruffs.org
Thanks Pete
But that code is for the full blown “queueing”
I simply wanted to know what you did to parse the incoming login which is depicted above.
Any chance of the code within the parser between login and speech?
Thanks Guys.
Aidan your proposal looks plausible in principle. Although, I don’t have practical experience with MQTT to evaluate the mechanics of the workable implementation.
Mechanism of integrating 2 brokers and switching/selection between brokers and connection from clients would have to be automatic and reliable.
As Aiden has pointed, would be important to generate alerts to the Administrator on different levels of abnormal operation.
Regards
John
OK, let’s imagine that we start with 2 working Pis running mosquitto. The main one is unit 1 and the backup is unit 2.
All of the remote devices have unit 1 as the primary mqtt server and unit 2 as the backup.
Initially they log on to unit 1, but fallback to unit 2 after a few failures to logon. They carry on using unit 2 until told otherwise or until unit 2 itself fails, at which point they have another go at unit 1.
Unit 1 could subscribe to, say, ‘reset_watchdog’ topic on unit 2, and unit 2 could subscribe to ‘reset_watchdog’ on unit 1. They could send each other regular message to clear a watchdog timer. If this zeroed out, then the surviving server could send a failure email or pushbullet to the administrator.
If Unit 1 failed, then within say 5 minutes all remote devices would be logged on to unit 2. If a mains watchdog managed to reset unit 1, then it would re-contact ‘reset_watchdog’ on unit 2 and then unit 2 would send a message to all of the units that were then logged on to it and tell them to go back to unit 1 – or we could add in a ‘broadcast’ subscription that all units would subscribe to when they log on, just like ‘/toesp’…call it’broadcast_command’ for example.
So,
topic:broadcast_command
payload:{revert_mqtt}
or to avoid the extra subscription
topic:/toesp
payload:{revert_mqtt}
In fact, both servers could have exactly the same flows loaded into Node Red, the determination of which server is which would be defined when you configure each remote device.
Does any of that make sense to anyone else?
It is VERY early in the morning as I read this – but looking near the start – the reset watchdog and messages… is that not the purpose of the last will and testament?
Pete and I were doing some software updates last week and we discussed the possibility of adding a fallback MQTT server as well as a fallback wifi access point.
So, currently the software attempts to login every minute until it gets through and then logs in once per day to synchronise the time (Pete, can you confirm this, I’m not sure about the login interval).
However, there’s no reason that we couldn’t add in a second MQTT server address to each of the units.
Ideally, the servers would handle the switchover, but currently we can only connect to one MQTT server at a time. However, if we dropped the login time to say a couple of minutes, then perhaps after 3 unsuccessful attempts to re-login, the remote units would swap to the alternate server.
So, after 5 minutes the system would recover as each individual unit swapped over to the backup server.
If the 2 servers were subscribed to each other, then they could also have a timeout and could then send an email to inform that one of the servers had gone down if it stopped replying.
We have already implemented a system whereby a mains unit is pinged to keep a mains unit active so long as Node Red can ping an external address and then cycles the power of the Raspberry Pi in an attempt at reseting it – mainly because Petes house in the UK has unreliable broadband, but this has been working for months now.
If the primary server then came back up again, once it established comms with the backup server, the backup could issue a command via MQTT to tell all of the units to swap back again. This would be useful if you’re doing any data logging to the primary unit.
Does that all sound logical?
Yes, attempts to log in every minute until it gets through -from there on in – it is sent the time every day by the node and of course when it logs in. There IS no reason why I can’t add in a second MQTT unit – BUT…. let’s say ONE of the units has an issue – whatever it is – and cannot get through – it might then try the second unit – bear in mind that the OTHER units will be talking to the original MQTT unit – that might pose a problem… it would take some thought as to under what circumstances the units would swap over.
@John, Thanks for raising the practical concerns for a real life system. @Pete thanks for your replies and sharing your experience (in fact, all through this blog)
I was also concerned about this and as of now do not have a clue for failsafe MQTT. Though redundant AP makes wifi more reliable. I was thinking on the lines of nodes publishing and subscribing to two brokers and modifying the codes to test the primary and making decisions accordingly. Still, this is just a primitive idea. Any better suggestion is welcome.
And yes, Peter I am yet to check your contributions of node flows. I did refer to your page related to Orange PI. Now coming to your recent comment on the reliability, do you mean the reliability only in case of RasPi or either? After having overcome the installation and software / driver issues, do you consider Orange Pi PC as a viable alternative or only vouch for RasPi
Hi – well as you know from the blog I have reviewed MANY boards and there are more coming – I just received the FriendlyArm M2 and a friend dropped off a CHIP and I have 2 more different boards on the way. My experience so far can be summarized as this.
The Pi is not the fastest hardware – for example the FriendyArm T3 can run Android video FLAT OUT without thinking about it and for general use their M1 board – I have 2 of them running Node-Red 24 hours a day rock solid. But – facts are facts – there is more available community support for the Pi than just about any other board out there. The Orange Pi, now that recent changes have reduced the temperature a little – is no doubt excellent for the job – but I will not buy from them because their customer interaction is precisely ZERO – they have never answered any of the miriad of questions I’ve left – I suspect there is one hired in techie who can’t be bothered but that’s just a guess. Their operating system images are an unfinished MESS – but third parties have stepped in and I believe ARMBIAN works… so that’s great (bear in mind the FriendlyArm stuff is just about as cheap). Right now I’m getting a little help from the Node-Red community in getting Firmata talking to the Pi – I doubt very much if I went to them with any of these other boards whether they’d be able to help.
In addition to that, I have 1 PI in Britain that has ran night and day for a year now and 2 here in Spain that have been running since April – of course I sometimes reboot one of the two as I experiment on it but it has never failed of it’s own accord. It may be that we can achieve similar reliability with other boards but I don’t have that experience to vouch for them – I suspect the NanoPi M1s (which in addition are running on WIFI, not wired) will cut the mustard… looking forward to writing up the M2s I have in front of me.
I am still looking at building a wireless control network, it has to be wireless and preferably WIFI because of the location/setup of various controlling devices.
From what I have read so far, MQTT ticks most of the boxes in terms of integration and ease of operation, provided that it works reliably and there are no critical single point failures.
With most typical WIFI star networks, Single AP or router is the critical single point. Add to this a single MQTT broker and you have another critical single point that can bring down the whole network if they fail. Clients should not be a major problem as multiple clients can exist on same MQTT network.
How to deal with these possible single point failures when you want to implement an automatic fail-safe network?
Multiple WIFI AP’s can operate in sort of parallel with same SSID name, but clients still need capability to roam or switch from one failed AP IP to another.
It is also possible to bridge MQTT brokers, but information for lower end setups becomes murky and very scarce.
So far I can’t find any meaningful information on how or if anyone has dealt with same issues, as far as building an automatic redundant MQTT WIFI network on a lower level like sort of home automation. I’m sure there will be commercial high end setups.
Basically, would need a WIFI network with at least 2 AP’s (Access points) and 2 MQTT brokers. If brokers are bridged, must exchange data or have same data. Clients to automatically connect/switch to active broker.
Would appreciate if anyone has implemented something similar or has additional information.
Regards
John
Well, my software uses 2 access points, if the board fails to get to one it will go to the other. It would be quite simple to add an optional second MQTT broker.
With Raspberry Pi (and pretty much ONLY the raspberry Pi when it comes to these little Linux controllers) there is a DEAD-easy backup system as of just a few weeks ago so making a duplicate system is a snap. So here in the cave I run 2 Raspberryt Pi 2 machines – identical other than the fact that I keep experimenting on one of them. Both have my Node-Red setup, both have MQTT brokers – both are wired into the network so are immune to WIFI access point issues. Couple that with the stunning reliability I’ve been getting, might be something to add in at a future date – MQTT redundancy as well as access point redundancy. This of course would also mean that if the main PI fell over completely, the other one could take over. I’m not too concerned about that as I’ve never had one fall over (I use only the best SDs).
But then if the main router fell over…. or the power went dead for any length of time…
But as the main
Forgot to put this in:
var bed_temp = context.get(‘bed_temp’)||16;
if (msg.payload == “up”) {
bed_temp += 1;
// store the value back
context.set(‘bed_temp’,bed_temp);
msg.payload = bed_temp;
return [msg];
} else {
if (msg.payload == “down”) {
bed_temp -= 1;
// store the value back
context.set(‘bed_temp’,bed_temp);
msg.payload = bed_temp;
return [msg];
}
return [ msg, null ];
}
hi
i was using three ===, because i didn’t know better, copied this off node red help:
if (msg.topic === “banana”) {
return [ null, msg ];……….
trying to learn if,then,else in java.
now got this far and all devices/UI’s seem to increment/decrement in Sync, i have nextion, node red UI slider & gauge, plus a up and down inject in Node red itself. all synced. is there an easier way than lots of if’s and then’s to add upper and lower limits to the set temp?
i will move on tomorrow to try and do the compare and switching.. then its on to incorperate your big timer!
Don’t know if you watched the election thing the other night, but the BBC were using what looked like a Node Red gauge and slider, to show how the voting was going !
many thanks for all your work and help.
Chris
Hi
My heating system is in the UK and I’m in Spain right now (no need for heating here). Its a while since I did the coding but why are you using three === ??
my heating is implemented in node-red – with the Nextion merely being used as controls and visual feedback. I looked at Martin’s wifi-thermostat – looks good but I’m quiet happy with the reliability I get out of Raspberry Pi + Nextion + my own code on the ESP8266s – which is rock solid (the PI is running hardwired as I was not happy with the reliability of early WIFI on the Pi – probably fine by now).
I simply have a load of global variables – settable by buttons – for times and temperatures. I look up the current time – look to see what the current temperature should be, ensure I only turn the heat on or off no less than once per minute, add in any offset variable (manual override), flatten that variable every change of temperature time zone… that’s about it.
Hi
i am trying to get my head round how you are controlling your heating. i ordered a Nextion display in April,
that took over a month to come, but when it arrived i was so impressed i ordered 2 more. Just got back from a week in Spain, and they not only arrived, they sent 4! result. so back to the heating. i have a Nextion set up with your UI, and am slowly fumbleing my way along. i have the temperature/humidity updating every 5 mins from a dht, the time displaying (hh:mm)and updating every miniute. all my updating is done with inject nodes…(interval), but i’m sure there is a better way, but it will do for now.
i also have now got the set temperature displaying and updating (changing) with a node red UI slider.
when i press the up and down buttons on the Nextion it sends the respective up/down payload to topic “nextion” which i can see comming in in the debug panel.
The next thing i am trying to do is increment / decriment a number (set temp) using these buttons that i can later compare to the actual room temp from the dht turning the heating on and off accordingly.
But once again my very limited Java script is in the way.
var j = 10;
if (msg.payload === “up”) {
var j = ++j;
msg.payload = j;
return [msg];
} else {
if (msg.payload === “down”) {
var j = –j;
msg.payload = j;
return [msg];}
return [ msg, null ];
}
this obviously does not work as it resets j to 10 every time it runs, so i get an 11 or 9. and if i remove the var j = 10 i get an NaN error. but looking at it, can you sort of see what i am trying to do ?.
is there any more infomation on your blog how you have implemented your thermostat/heating?
i am currently using http://harizanov.com/2015/02/wifi-thermostat-with-weekly-scheduler/ which is very good, except it looses connection now and again. it would be superb if it had the rock solid connection of yours. I think the scheduler part is open source maybe worth a look.
I eventurly want to put a thermostat in every room, but just one going would be a start.
thanks again for a great project. i have just ordered 20 of your new boards so goodbye vero board.
Chris
Im still having a problem understanding the {rgbset: start_led, number, r, g, b} and {rgbgo: port,number_of_leds} commands.
My setup is:
15 LED’s working fine with {rgb:port,red,green,blue,number,duration}
However when I try to use the rgbset / rgbgo commands the results are not as expected.
I am assuming that {rgbset:5,5,255,0,0} means set LED5 to LED9 to RED but Im not sure what ‘number_of_leds’ means in the rgbgo command, as I assumed that is what ‘number’ meant in the previous command.
I initially read rgbset as being able to preset different LED’s to different colours, with multiple rgbset commands, then using the rgbgo to apply.
I hope it’s just me having a bad day.
Thanks
See the updated manual – I’ve a simple police flasher example in there now under rgbstart etc.
Thanks for example, all understood now.
Peter,
I have succesfully been able to control my WS8212 Led’s using the rgb command, but having problems in getting the rgbset & rgbgo to work. Can you please confirm the parameters, as it appear to turn LED’s off, but not to the colour selected.
Should the command {rgbset: start_led, number, rgb} be {rgbset: start_led, number, r,g,b} or is that expecting a hex value.
Thanks
I’ve amended the manual and thanks for bringing that to my attention. that should be r,g,b where each of those values is 0-255.
Thanks for the prompt reply.
Have been through similar quest as Peter, looking for reliable and functional wireless “Mesh” networking automation system.
Probably the most successful “commercial” system that I have used has been from Synapse Wireless
http://www.synapse-wireless.com/iot-products/core-iot/ ,based on their proprietary 2.4Ghz RF modules (similar to Zigbee) using full Mesh protocol and minimum Python based operating system. My main issues with Synapse are generally expensive modules by 2016 standards about Us$30, locked to commercial proprietary product, limited signed 16bit integers and other functionality of limited Python OS system. Fully automated Mesh and self healing network generally works OK but for static network there are limited options to manually define routing. Lack of manual routing setup, Mesh will very frequently go through routing requests causing unnecessary latency.
Anyway, I have been watching ESP8266 for a while now but have been concerned about using WIFI network for automation due to complexity and perceived possible reliability. I am now considering getting my feet wet by trying MQtt option using RPi as a local broker. In fact I am still investigating the setup of 2 brokers as a contingency for possible critical single point failure.
I have red through Peters Blog and the comments which have provided a lot of valuable information.
Since I have never really got deeply involved in detailed computer networking wired or wireless, I still have a fair bit to research and learn.
Anyway, would appreciate if someone can answer couple of questions that have probably been covered to some degree but did not sink in yet.
1. I am initially only looking at setting up “basic” Local only, wireless Mqtt based network using 1 and expanding to at least 2 (to eliminate single point network failure) Mqtt RPi (or compatible brokers) and multiple ESP8266 client nodes based on Arduino code.
2. Have any of you set up your network with RPi set up as WiFi access point (AP) as well as Mqtt broker, without other external WiFi Router or AP? This would be my preference and would appreciate pointing in the right direction with RPi setup as WiFi access point plus Mqtt broker.
3. As mentioned previously, have any of you set up 2 or more RPis as Access points and Mqtt brokers?
I would like my network to be extra reliable by having more than one Mqtt broker, to eliminating single point of failure. At this stage I don’t want to connect to the Internet and/or on line based Mqtt brokers.
Regards
John
My quick comments as I am on mobile. Recommend WIRED Pi using best SD you can get.. Samsung EVO good. With new Debian you can now easily make identical backup. Just change hostname.. I have 2 setups like this, 100% reliability over months. Indeed I’d be more worried about wifi connections to my esps but now I am also getting 100% from them. Ensure Pi has battery backup as per my usb power article or similar.
As for esp and mqtt and arduino IDE I cannot vouch for reliability long term you will have to suck it and see.
Pete
Seen this morning another [supposed to be] smart hub, available also for RPI, advertised by RPI on Facebook: https://prota.info/
Have you already taken a look at it? Not sure if it works just with its “microbots” or with other devices too.
Hi – thanks for that – took a quick look – at a bit of a loss actually as how that varies from a normal router. I connect all my Pis and other stuff together – and access remotely…. just a normal Draytek router..
Hah! We’re all the same, it’s a bloke thing.
RTFM!
Thanks
i had been looking for a list of all commands and couldn’t find it. Now i realise its in a word doc, as part of what i originally downloaded. I need to start reading through all the doc’s and blogs about this instead of racing ahead of myself in exitment and asking dumb questions on here.
Hah. I do that all the time.
is it possable to have more than one DS18B sensor connected to the GPIO, like arduino ?
If you look in the manual under temp_type, you’ll see that you need to tell the board which type of sensor you’re using.
So, for a DHT22 send:-
TOPIC my_module/toesp
PAYLOAD: {temp_type:1}
So, in this way you can select any of a DS18B20, a DHT11 or a DHT22 or over-ride the pin to be an output
When you want to read values back, send:-
TOPIC mymodule/toesp
PAYLOAD {temperature?;humidity?}
This will send back to messages reading the temperature and the humidty.
hi
iv’e connected a DHT22 to GPIO2, when i send {temperature?} i seem to get a random -number, do i need to send somthing to esp to tell it to use that port for a particular sensor ?
thanks Chris.
Pete, the PWM pins are set for 4,5 and 15 in the code. Is it easy to change (or make configurable) for this device:
http://www.aliexpress.com/item/rgb-strip-WiFi-controller-1-port-control-15-rgb-lights-communicate-with-Android-phone-to-dim/32301423622.html
Which uses the following pins:
// RGB FET
redPIN 12
greenPIN 13
bluePIN 15
// White FETs
w1PIN 14
w2PIN 4
Thanks
Tony
I know – I set them that way 🙂
I’m thinking of pulling out the existing stuff and using the easyGPIO. For our purposes we’re sticking with GPIO4 and 5 for our boards – others can do as they wish of course… the source is there…
Pete, what about a set of download links in a download area on the blog?
Already did – see latest blog on the subject – picture and download link in place for new design.
Pete – any chance of a link to the 3 bins needed for this? I’m struggling with the makefile on OSX and eclipse!
The BIN files (there are two not three) are linked to in one of the blogs..
You will need the doc file from the source.
Thanks Pete – I missed that one!
Pete is is possible to get more than two digit accuracy on a DS18B20?
See manual on BitBucket – just spent all day re-writing and adding in the new commands…. that was HARD work!
Hi Pete,
I can’t find anyway how to set board so when the input 14 changes to send a mqqt message. If I send {in14?} I get a message, but I need the board to send me automatically the status when it’s changed.
Any idea how to do that? Thanks
Right now the board does not do this. No reason why not – it just doesn’t.
Peter this is amazing work that I have just been turned on to. Having a simple set of commands makes automation so much easier. I do have a question, is it possible to define a default state for outputs? So that on power restore the output is placed in the default state. (I am using the ESP-12 to drive an LED strip and would like it to be back “on” if I have a power outage.)
Well certainly in my software, the state of simple outputs is preserved – i.e. if GPIO0 is on and you get a power cut, it will come back on as it was before the power cut. That is implemented using the system command to store a block of data into Flash. There is a failsafe mechanism whereby it uses 2 blocks – and if the save fails it simply uses the previous version. I’ve never lost any settings.
Thank you for the incredibly quick reply. Answered my questions perfectly.
Hi Pete,
There is any way I can have a DHT and a DS18b20 sensor connected on the same board? Or any way I can do this with MQTT commands?
Thanks.
There is no reason you could not have both on the same board. I’ve just not implemented it as I chose to reserve GPIO2 for use with temperature sensing. As the DHT22 (NOT the 11 which is rubbish) gives as good a show as the DS18B20 I didn’t see any point.
I have a few DHT11 and wanted to pair them up with DS18B20. Now I ordered a few DHT22.
There is a typo in the temperature example on topic you have “999/fromext/temperature” but should be “999/fromesp/temperature”. I kind of lost a few minutes because of this! 🙂
Anyway… thanks for this firmware, it make my life easier.
Hah! Well spotted – fixed. Yup – DHT22 definitely a better bet. I’ve been using them for a long time and find them reliable.
I tend to prefer using RabbitMq – mainly because of its’ lovely web admin and monitoring interface. You can set up a federation between two servers fairly easily I gather, but I haven’t actually tried it 🙂
Thanks.
What I actually wanted is not to bridge the two systems as they don’t really need to “know” of each other, but to have access to them simultaneously. Locally and/or remotely, possibly using the same UI.
Hi Pete,
first of all I’d like to thank you for your incredibly valuable work, time and energy spent on this project.
I am still on my learning curve on different home automation and its different systems, observing several solutions like OpenHab, MySensors, Souliss and EspEasy, but none of the documentations read brought me closer than yours.
I wonder what your suggestions would be regarding the issues below:
-first, I do agree with you that a home automation system must run as a standalone with no cloud services and such involved. Looking deeper to details, thinking about a light in a room I faced the same problem.
What I’d like to have is a regular button on the wall (latching replaced to a momentary of course) we all got used to which triggers one pin on the very local node turns on the light using an other pin (through a relay, transistor etc…). Optionally the node reports the state-change of the pin to the controller via MQTT and makes remote controlling possible.
It means as long as power is present I may control the light manually even if the wifi (node’s connection, controller or the router itself) is down.
As I see people suggest to give contoller total control, like pressing the button sends a request to the controller, then the controller turns on the light through the very same node… I don’t really like that idea to be honest.
Besides in some forum topics people report strange behaviour of their ESPs like spontaneous resets, unpredictable state of pins during and after reboot even in systems claimed to be pretty stable (not prototypes on breadboards with loose wires and such). Now these people suggest to use arduinos with ESP hooked onto them for nodes with critical tasks; -well, who would want to see the garage door opening without a reason just because the ESP went crazy for a moment? Have you experienced such things?
The other issue is the possibility of multiple instances of controllers (whether it’s NodeRed or other).
When I get to the stage to set up my system, I’d like to have two. One in my home and an other one in my workshop. They would be separated, actually a half town away from each other and I’d like to be sure to chose the right system capable of handling both, obviously one at a time locally and the other through the internet; -or both through the internet in case I’m at a different location.
Do you think it can be done with NodeRed?
Thank you for your time in advance and sorry for my bad grammar. I am not native English.
And yes, a forum would be a brilliant idea.
Best regards,
G.
Gerley
Some comments for you: if indeed people in some forums are reporting strange behaviour like spontaneous resets, unpredictable statef of pins etc – they are doing it wrong – or using the wrong tools or rubbish power supplies or no decoupling or any combination of the above – I have several ESPs running in 2 installations one of which has atrocious power reliability. They are all operating perfectly and have been for months.
Two installations: Have an agreement between the two MQTT servers to send data back and forth – but only data that is relevant i.e. only certain topics go back and forth.
There is no reason why you could not have an ESP with a relay and an input which allows for local control override but still allowing external setting and firing off the button state to MQTT
Thank you Pete, convinced me, so I keep on marching.
Well, the way to have that egreement between the servers is still over my sight, but hopefully I get there soon.
So on machine 1… node red publishes items to server 2.. prefixing them with “server2/” for example…
On the second machine it sees incoming message, strips off “server2/” and resends them locally. Any responses known to be for server1 – have “server1/” attached to the topic. etc etc…
There is another way which I’ve never tried.. http://stackoverflow
.com/questions/24109306/bridge-between-two-mosquitto-brokers
Thank you Pete. Solution is often more simple one would think.
Hi
Can somebody explain the detailed steps for getting Petes code into a working Eclipse setup for the Eclipse challenged!
I have a working Eclipse following CHERTS instructions and video and have managed to alter, compile and flash the mqtt example but with only a very basic understanding of how Eclipse works.
Regards
Ian
OK, I’ve actually managed to sync the repos and have pushed web_page_convert.py to the root folder of the repo. Just copy it into your \espressif\utils directory.
Hi. Pete is travelling back from Spain tonight so he probably won’t be able to publish the python file. I would do it myself, but our source files are a bit out of sync at the moment as I’m working on incorporating DNS lookup for the servers.
I’m happy to email you the source file (complete with indentation!)
Drop me an email to aidan@ruffs.org and I’ll send it
No worries, I got it compiled now. I’m not a Python expert but it was not that hard to fix 🙂
Don’t forget that web_page_convert.py should be placed in your \espressif\utils folder. I put it in there so that it would be available to other projects, but if you want to place it in the same folder as your project, you’ll simply need to amend the WEBTOOL define at the top of the makefile to the correct location
That explains a lot- here is the .py file.
# Returns error codes:
# 1 = couldn’t open input file
# 2 = couldn’t open output file
import sys
# Do we have any arguments? 1):
if (len(sys.argv) == 1):
print “Usage: web_page_convert.py
try:
in_file = open(sys.argv[1], “rb”)
except IOError:
print “Couldn’t open “, sys.argv[1]
exit(1)
else:
try:
in_file = open(“webpages.espfs”, “rb”)
except IOError:
print “Couldn’t open webpages.espfs”
exit(1)
print “Input from webpages.espf in current directory”
if (len(sys.argv) > 2):
try:
out_file = open(sys.argv[2], “w”)
except IOError:
print “Couldn’t open output file “, sys.argv[2]
exit(2)
else:
try:
out_file = open(“webpage.h”, “w”)
except IOError:
print “Couldn’t open output file webpage.h”
exit(2)
print “Output to webpage.h in current directory”
out_file.write(“#ifndef USER_WEBPAGE_H_\n”)
out_file.write(“#define USER_WEBPAGE_H_\n”)
out_file.write(“static const uint8_t ICACHE_RODATA_ATTR web_page[] = {“)
items_per_line = 30
byte_count = 0
beginning = 1
while True:
# if this isn’t the start then put in a comma separator
# – used to avoid a trailing comma at the end of the file
if beginning != 1:
out_file.write(“, “)
else:
beginning = 0
# read and output the next byte
next_byte = in_file.read(1)
# at EOF?
if (next_byte == ”):
break
out_file.write(str(ord(next_byte)))
byte_count += 1
if byte_count > items_per_line:
out_file.write(“\n”)
byte_count = 0
#end of while loop
out_file.write(“};\n”)
out_file.write(“#endif /* USER_WEBPAGE_H_ */”)
in_file.close()
out_file.close()
print “File System Conversion finished”
exit(0)
Any chance you upload it to bitbucket? Python cares about indentation which got lost here and there seems to be an issue around line 9 as well where the string constant is not closed.
I’m using an OTA approach that lets you update code and espfs separately (using an adjusted version of rboot but not using the rboot OTA capabilities).
Especially during debugging that appeared to be beneficial to update only code or only espfs but thinking about it now that was probably driven by the long download time through UART which is less of an issue with OTA 🙂
Excellent point. I’m using an OTA approach that lets you update code and espfs separately (using an adjusted version of rboot but not using the rboot OTA capabilities – scroll down for details).
Especially during debugging it appeared to be beneficial to update only code or only espfs but thinking about it now that was probably driven by the long download time through UART which is less of an issue with OTA 🙂
I can’t find the python script on bitbucket. Where did you put it?
I’m using a similar set of components (rBoot, Tuan’s MQTT stack, espfs, …) all modified to my needs but I’ve chosen a setup with three ROM slots where one is reserved for kind of a “factory default firmware” that lets you configure a fresh device (ssid, pw, mqtt broker, ota server, …) and provides OTA capabilities to flash into the other two slots. As long as the factory FW is coded and tested properly it’s almost bullet proof even if you push a very bad ROM through OTA because you don’t rely on the OTA functionality being part of the other ROMs. I’ve adjusted rboot so that it always boots into the factory ROM on a power cycle and boots into the “last known good” ROM on all other reset causes… The factory rom checks with the “update server” if there is a newer version so all you need to recycle from a bad ROM is put a new version on the update server and do a power cycle (worst case pulling a fuse for devices that are not easily accessible). If there is no new version the factory ROM soft-resets the esp and rboot happily boots the last known good rom.
So far so good – problem is the reset cause detection seems not to be really reliable which kind of breaks the entire concept 🙁
oops, sorry for the copy/paste text duplication in the post above…
Great article – and great HW/SW package!
I can’t build it to see it in action though as I’m missing this utility:
WEBTOOL ?= c:\Espressif\utils\web_page_convert.py
Looking at the commits it seems like you added this in after the initial commit few days ago. Seems like it’s pushing the espfs content as a byte array into webpage.h. Can you share some background on what the benefit is vs. having ESPFS_POS unset so that the espfs content is automatically placed right after the code?
The PY file should be up there now… if not I can make it available.
The original system generates a separate file for web pages and that is inconvenient for OTA – so we figured, convert it into a FLASH array and make that an H file as part of the project – hence one file. If you have a better way while still generating one rom – happy to hear all about it 🙂
And don’t ask me any questions about MAKE files as I’m terrible at them.
Here is what I did in another project to get a single bin file for code and filesystem. I don’t recall where I got the idea from – could be the original esphttpd makefile…
The trick is to transform the filesystem file generated with mkespfs into another library and then include it with the code libraries as part of the main linking process:
$(FS_0): fs
cd fs; find | ../../$(MKESPFS) > ../$(FS_0); cd ..
$(FSLIB_0): $(FS_0)
$(OBJCOPY) -I binary -O elf32-xtensa-le -B xtensa –rename-section .data=.irom0.literal $(FS_0) $(FSOBJ_0).tmp
$(LD) -nostdlib -Wl,-r $(FSOBJ_0).tmp -o $(FSOBJ_0) -Wl,$(FSLD_0)
$(AR) cru $@ $(FSOBJ_0)
$(TARGET_0): $(FSLIB_0) $(APP_AR_0)
@echo “LD $@”
$(LD) -L$(SDK_LIBDIR) -L$(BUILD_BASE) $(LD_SCRIPT_0) $(LDFLAGS) -Wl,–start-group $(LIBS) $(APP_AR_0) -Wl,–end-group -o $@
$(FW_ROM_0): $(TARGET_0)
@echo “E2 $@”
../$(ESPTOOL2) $(ESPTOOL2_ARGS) $(TARGET_0) $@ $(ESPTOOL2_SECTS)
Here’s the most important part. I can share the full makefile but it’s a sub-makefile only that is based on a lot of variables defined in the main makefile… Happy to help if questions!
$(APP_AR_0): $(OBJ) $(FSOBJ_0)
@echo “AR $@”
$(AR) cru $@ $^
Simply WOW.
Regards
Paul
That would be great and a doddle to implement if it wasn’t for the power consumption of the ESP8266!
However, if you could get either mains or 12V to the valve, then there’s no reason why not
Pete & Aidan, this is great work 🙂
What I’d *love* to see is something like this extended to control RF based radiator valves – take a look at Honeywell Evohome and you’ll see what I mean.
Cheers
Robin
Yay! That was it! Thank you.
(NB – for any other readers – don’t copy and paste the entire code above – just the bit with the notes “added in SDK 1.4.0”. Otherwise the periods in the int os_snprintf(char *str, size_t size, const char *format, …) __attribute__ ((format (printf, 3, 4))); line will come out differently and cause an error.)
Just back to the problem at line 132 of the Makefile now…
FW firmware/app.bin
C:/Users/john/Documents/ESP8266/hackitt_mqtt/Makefile:132: recipe for target ‘firmware/app.bin’ failed
process_begin: CreateProcess(NULL, C:/esptools/esptool2.exe -quiet -bin -boot2 -512 build/app.out firmware/app.bin .text .data .rodata, …) failed.
make (e=2): The system cannot find the file specified.
mingw32-make.exe: *** [firmware/app.bin] Error 2
Its wierd. I tried running the code under SDK 1.3 and got the same error. I thought you’d be running under 1.4 so I downloaded it and installed it and it did not produce that error – however it did throw up en error when trying to write out the compiled files down at line 132 of the Makefile.
There was a change for 1.4 – I think I noted it when I updated the code… so under 1.4 are you getting that zalloc error or a different one?
So I recall writing to my friend the following..
***********************************
1.40 has an issue with a zalloc command – they’ve changed something and our code won’t work so I’m sticking with 1.3 until they fix it.
void ICACHE_FLASH_ATTR QUEUE_Init(QUEUE *queue, int bufferSize)
{
queue->buf = (uint8_t*)os_zalloc(bufferSize);
RINGBUF_Init(&queue->rb, queue->buf, bufferSize);
}
Sadly as I have no idea what the zalloc command is actually returning I can’t replace it.
***************************
But since then I HAVE moved onto 1.4 – hang fire while I go look to see how I found out how to change it..
Ok, then I wroet this..
***********************
Good evening
Code updated – a change to ESPMISSINGINCLUDES.H was needed. Code will no longer compile with SDK 1.3 and earlier – grab SDK 1.4
All seems to be working well.
Pete.
***********************
Ok, make sure your espmissingincludes.h is the same as this..
#ifndef ESPMISSINGINCLUDES_H
#define ESPMISSINGINCLUDES_H
#include
#include
//Missing function prototypes in include folders. Gcc will warn on these if we don’t define ’em anywhere.
//MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler.
typedef struct espconn espconn;
int atoi(const char *nptr);
void ets_install_putc1(void *routine);
void ets_isr_attach(int intr, void *handler, void *arg);
void ets_isr_mask(unsigned intr);
void ets_isr_unmask(unsigned intr);
int ets_memcmp(const void *s1, const void *s2, size_t n);
void *ets_memcpy(void *dest, const void *src, size_t n);
void *ets_memset(void *s, int c, size_t n);
int ets_sprintf(char *str, const char *format, …) __attribute__ ((format (printf, 2, 3)));
int ets_str2macaddr(void *, void *);
int ets_strcmp(const char *s1, const char *s2);
char *ets_strcpy(char *dest, const char *src);
size_t ets_strlen(const char *s);
int ets_strncmp(const char *s1, const char *s2, int len);
char *ets_strncpy(char *dest, const char *src, size_t n);
char *ets_strstr(const char *haystack, const char *needle);
void ets_timer_arm_new(ETSTimer *a, int b, int c, int isMstimer);
void ets_timer_disarm(ETSTimer *a);
void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg);
void ets_update_cpu_frequency(int freqmhz);
int os_printf(const char *format, …) __attribute__ ((format (printf, 1, 2)));
int os_snprintf(char *str, size_t size, const char *format, …) __attribute__ ((format (printf, 3, 4)));
//void pvPortFree(void *ptr);
//void *pvPortMalloc(size_t xWantedSize);
//void *pvPortZalloc(size_t);
// void vPortFree(void *ptr);
// void *vPortMalloc(size_t xWantedSize);
// memory allocation functions are “different” due to memory debugging functionality
// added in SDK 1.4.0
void vPortFree(void *ptr, char * file, int line);
void *pvPortMalloc(size_t xWantedSize, char * file, int line);
void *pvPortZalloc(size_t, char * file, int line);
void *vPortMalloc(size_t xWantedSize);
void pvPortFree(void *ptr);
void uart_div_modify(int no, unsigned int freq);
uint8 wifi_get_opmode(void);
uint32 system_get_time();
//int os_random();
int rand(void);
void ets_bzero(void *s, size_t n);
#endif
I do! Downloaded both this afternoon
Hi Pete,
I thought I’d take a look at your project again and downloaded the Hackitt_mqtt. It looks like you’ve been busy!
I tried to compile it (with SDK 1.4.0) and it failed. I also read that you had had to make some header file changes – I wonder if they have been uploaded yet?
The error I got was:
In file included from mqtt/queue.c:38:0:
mqtt/queue.c: In function ‘QUEUE_Init’:
c:\espressif\include\mem.h:9:27: error: too many arguments to function ‘pvPortZalloc’
#define os_zalloc(s) pvPortZalloc(s, “”, 0)
^
mqtt/queue.c:42:25: note: in expansion of macro ‘os_zalloc’
queue->buf = (uint8_t*)os_zalloc(bufferSize);
^
In file included from mqtt/queue.c:32:0:
include/espmissingincludes.h:34:7: note: declared here
C:/Users/john/Documents/ESP8266/hackitt_mqtt/Makefile:160: recipe for target ‘build/mqtt/queue.o’ failed
void *pvPortZalloc(size_t);
Does that look familiar??
Thx John
Oh dear.. yes I do indeed remember it, I just don’t remember what the fix was. The thing is – I’ve just started using 1.4.0 – so it’s not a fix to the SDK – and you’ve obviously grabbed the code I’m using….. which makes me wonder why that error would come up. Just to confirm, you have the latest SDK and the latest code – from bitbucket?
Ok got a bit further today, Makefile for linux now as follows:
Compiler output:
So it now appears as the compiled code is too large to fit on the ESP ROM or I need to tell the compiler something else any help appreciated
As you may have realised – we use a bootloader….which shoves everything down at the bottom – and we manage to fit the code in with lots of room to spare. The standard “stick it at 0x40000” is no good. Trust me there is lots of room. We use Richard Burton’s RBOOT.
eagle.app.v6.ld needs to look like this at the start..
/* This linker script generated from xt-genldscripts.tpp for LSP . */
/* Linker Script for ld -N */
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40202010, len = 0x68000
/* irom0_0_seg : org = 0x40220000, len = 0x58000 */
}
Why not just use github, phpforums just puts extra pressure on you to maintain and github has specific issues section which is well laid out and easy to follow.
The move is so easy
http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
Simple Johnny – I don’t wish to use Github! Looked at it, didn’t like it, preferred BitBucket. This is about having fun not doing something I don’t want to 🙂 You’re probably right about the forums though. Well, in the years I’ve been running this forum I’ve seen a very long post like that last (quite welcome) post once… so I guess it’s not a big issue.
Hi Pete,
Sorry to start off with a nag but I wish you would switch your code repository to github as there is no means of tracking any issues on bitbucket . . . frankly its a bit naff having to post this here in among 74 other posts.
Problem compiling under Linux (the whole point of this is they should compile no matter which OS you are using, I had to modify the Makefile to closely resemble your windows one. I’m also on SDK 1.3.0 :- sorry about the long output but someone here may be able to help. ta
john@dc7700p2 ~/hackitt_mqtt $ make clean
john@dc7700p2 ~/hackitt_mqtt $ make
CC driver/ds18b20.c
driver/ds18b20.c: In function ‘ds_init’:
driver/ds18b20.c:35:2: warning: implicit declaration of function ‘PIN_PULLDWN_DIS’ [-Wimplicit-function-declaration]
PIN_PULLDWN_DIS(DS18B20_MUX);
^
driver/ds18b20.c: In function ‘reset’:
driver/ds18b20.c:206:3: warning: implicit declaration of function ‘ets_delay_us’ [-Wimplicit-function-declaration]
os_delay_us(2);
^
CC driver/gpio16.c
CC driver/i2c.c
driver/i2c.c: In function ‘i2c_init’:
driver/i2c.c:60:5: warning: implicit declaration of function ‘ets_isr_mask’ [-Wimplicit-function-declaration]
ETS_GPIO_INTR_DISABLE();
^
driver/i2c.c:85:5: warning: implicit declaration of function ‘ets_isr_unmask’ [-Wimplicit-function-declaration]
ETS_GPIO_INTR_ENABLE();
^
driver/i2c.c: In function ‘i2c_start’:
driver/i2c.c:100:5: warning: implicit declaration of function ‘ets_delay_us’ [-Wimplicit-function-declaration]
os_delay_us(I2C_SLEEP_TIME);
^
CC driver/uart.c
driver/uart.c: In function ‘uart_config’:
driver/uart.c:47:5: warning: implicit declaration of function ‘ets_isr_attach’ [-Wimplicit-function-declaration]
ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, &(UartDev.rcv_buff));
^
driver/uart.c:53:3: warning: implicit declaration of function ‘uart_div_modify’ [-Wimplicit-function-declaration]
uart_div_modify(uart_no, UART_CLK_FREQ / (UartDev.baut_rate));
^
driver/uart.c: In function ‘uart0_rx_intr_handler’:
driver/uart.c:230:3: warning: implicit declaration of function ‘iprintf’ [-Wimplicit-function-declaration]
iprintf(DEBUG,”FRM_ERR\r\n”);
^
driver/uart.c:236:3: warning: implicit declaration of function ‘ets_isr_mask’ [-Wimplicit-function-declaration]
ETS_UART_INTR_DISABLE();/////////
^
driver/uart.c:266:2: warning: implicit declaration of function ‘ets_isr_unmask’ [-Wimplicit-function-declaration]
ETS_UART_INTR_ENABLE();
^
driver/uart.c: In function ‘uart_init’:
driver/uart.c:289:3: warning: implicit declaration of function ‘ets_install_putc1’ [-Wimplicit-function-declaration]
os_install_putc1((void *)uart0_write_char);
^
CC user/aidan_and_petes.c
In file included from user/auth.h:4:0,
from user/aidan_and_petes.h:31,
from user/aidan_and_petes.c:7:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
user/aidan_and_petes.c: In function ‘iprintf’:
user/aidan_and_petes.c:14:3: warning: implicit declaration of function ‘ets_vsnprintf’ [-Wimplicit-function-declaration]
ets_vsnprintf(buf, sizeof(buf), fmt, args);
^
user/aidan_and_petes.c:16:3: warning: implicit declaration of function ‘uart0_tx_buffer’ [-Wimplicit-function-declaration]
if (debug_type & enable_debug_messages) uart0_tx_buffer(buf,os_strlen(buf));
^
CC user/aidans_code.c
In file included from user/auth.h:4:0,
from user/aidans_code.c:28:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
user/aidans_code.c: In function ‘MQTTLogonTimerCb’:
user/aidans_code.c:50:12: warning: unused variable ‘resetCnt’ [-Wunused-variable]
static int resetCnt=0;
^
user/aidans_code.c: In function ‘setupwebpage_init’:
user/aidans_code.c:88:5: warning: unused variable ‘reset_count’ [-Wunused-variable]
int reset_count = 0;
^
CC user/auth.c
In file included from user/auth.h:4:0,
from user/auth.c:21:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
user/auth.c: In function ‘authBasic’:
user/auth.c:48:3: warning: implicit declaration of function ‘iprintf’ [-Wimplicit-function-declaration]
iprintf(INFO,”Auth: %s-%s, %s\r\n”, userpass, user, pass);
^
CC user/base64.c
CC user/cgi.c
user/cgi.c: In function ‘cgiLed’:
user/cgi.c:69:1: warning: pointer targets in passing argument 2 of ‘strcmp’ differ in signedness [-Wpointer-sign]
if (!strcmp(buff, sysCfg.web_pass)) // Password OK
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from user/cgi.c:16:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:28:6: note: expected ‘const char *’ but argument is of type ‘uint8_t *’
int _EXFUN(strcmp,(const char *, const char *));
^
user/cgi.c: In function ‘tplLed’:
user/cgi.c:148:3: warning: pointer targets in passing argument 2 of ‘ets_sprintf’ differ in signedness [-Wpointer-sign]
os_sprintf(buff, sysCfg.base);
^
In file included from user/cgi.c:23:0:
include/espmissingincludes.h:19:5: note: expected ‘const char *’ but argument is of type ‘uint8_t *’
int ets_sprintf(char *str, const char *format, …) __attribute__ ((format (printf, 2, 3)));
^
user/cgi.c: In function ‘cgiReadFlash’:
user/cgi.c:178:6: warning: implicit declaration of function ‘iprintf’ [-Wimplicit-function-declaration]
iprintf(DEBUG,”Start flash download.\n”);
^
CC user/cgiwifi.c
user/cgiwifi.c: In function ‘cgiWiFiConnect’:
user/cgiwifi.c:220:4: warning: pointer targets in passing argument 1 of ‘ets_strcpy’ differ in signedness [-Wpointer-sign]
os_strcpy(sysCfg.sta_ssid, essid); // Save the SSID into the main variables structure
^
In file included from user/cgiwifi.c:26:0:
include/espmissingincludes.h:22:7: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *ets_strcpy(char *dest, const char *src);
^
user/cgiwifi.c:224:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “sta_pwd”, sysCfg.sta_pwd, sizeof(sysCfg.sta_pwd));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:226:2: warning: pointer targets in passing argument 2 of ‘ets_strncpy’ differ in signedness [-Wpointer-sign]
os_strncpy((char*)stconf.ssid, sysCfg.sta_ssid, sizeof(sysCfg.sta_ssid));
^
In file included from user/cgiwifi.c:26:0:
include/espmissingincludes.h:25:7: note: expected ‘const char *’ but argument is of type ‘uint8_t *’
char *ets_strncpy(char *dest, const char *src, size_t n);
^
user/cgiwifi.c:227:2: warning: pointer targets in passing argument 2 of ‘ets_strncpy’ differ in signedness [-Wpointer-sign]
os_strncpy((char*)stconf.password, sysCfg.sta_pwd, sizeof(sysCfg.sta_pwd));
^
In file included from user/cgiwifi.c:26:0:
include/espmissingincludes.h:25:7: note: expected ‘const char *’ but argument is of type ‘uint8_t *’
char *ets_strncpy(char *dest, const char *src, size_t n);
^
user/cgiwifi.c:229:2: warning: implicit declaration of function ‘iprintf’ [-Wimplicit-function-declaration]
iprintf(INFO,”\r\nCONNECT: SSID=%s, PWD=%s\r\n”,sysCfg.sta_ssid, sysCfg.sta_pwd);
^
user/cgiwifi.c:236:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “mqtt_pass”, sysCfg.mqtt_pass, sizeof(sysCfg.mqtt_pass));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:237:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “mqtt_user”, sysCfg.mqtt_user, sizeof(sysCfg.mqtt_user));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:238:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “mqtt_host”, sysCfg.mqtt_host, sizeof(sysCfg.mqtt_host));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:240:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “mqtt_device_name”, sysCfg.base, sizeof(sysCfg.base));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:251:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “mqtt_device_description”, sysCfg.desc, sizeof(sysCfg.desc));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:252:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “mqtt_device_attribute”, sysCfg.attribute, sizeof(sysCfg.attribute));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:259:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “web_user”, sysCfg.web_user, sizeof(sysCfg.web_user));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:260:2: warning: pointer targets in passing argument 3 of ‘httpdFindArg’ differ in signedness [-Wpointer-sign]
httpdFindArg(connData->postBuff, “web_pass”, sysCfg.web_pass, sizeof(sysCfg.web_pass));
^
In file included from user/cgiwifi.c:24:0:
user/httpd.h:43:23: note: expected ‘char *’ but argument is of type ‘uint8_t *’
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
^
user/cgiwifi.c:203:6: warning: unused variable ‘i’ [-Wunused-variable]
int i;
^
user/cgiwifi.c:200:7: warning: unused variable ‘passwd’ [-Wunused-variable]
char passwd[128];
^
user/cgiwifi.c: In function ‘tplWlan’:
user/cgiwifi.c:346:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ [-Wformat=]
os_sprintf(s,”%d”, sysCfg.mqtt_port);
^
CC user/espfs.c
In file included from user/espfs.c:48:0:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
CC user/heatshrink_decoder.c
In file included from user/heatshrink_decoder.c:1:0:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
user/heatshrink_decoder.c:9:0: warning: “_STDINT_H” redefined [enabled by default]
#define _STDINT_H
^
:0:0: note: this is the location of the previous definition
CC user/httpd.c
CC user/httpdespfs.c
user/httpdespfs.c: In function ‘cgiEspFsHook’:
user/httpdespfs.c:60:2: warning: implicit declaration of function ‘iprintf’ [-Wimplicit-function-declaration]
iprintf(DEBUG,”====OPENING THE FILE 1 ====\r\n”);
^
user/httpdespfs.c: In function ‘cgiEspFsTemplate’:
user/httpdespfs.c:110:8: warning: unused variable ‘p’ [-Wunused-variable]
char *p;
^
user/httpdespfs.c: At top level:
user/httpdespfs.c:35:16: warning: ‘html_buf’ defined but not used [-Wunused-variable]
static uint8_t html_buf[1000];
^
CC user/io.c
In file included from user/auth.h:4:0,
from user/aidan_and_petes.h:31,
from user/io.c:19:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
CC user/petes_code.c
In file included from user/auth.h:4:0,
from user/aidan_and_petes.h:31,
from user/petes_code.c:8:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
In file included from user/petes_code.c:10:0:
./include/driver/i2c_oled_fonts.h:14:2: warning: missing braces around initializer [-Wmissing-braces]
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
^
./include/driver/i2c_oled_fonts.h:14:2: warning: (near initialization for ‘F6x8[0]’) [-Wmissing-braces]
user/petes_code.c: In function ‘mqttDisconnectedCb’:
user/petes_code.c:222:16: warning: unused variable ‘client’ [-Wunused-variable]
MQTT_Client* client = (MQTT_Client*) args;
^
user/petes_code.c: In function ‘mqttPublishedCb’:
user/petes_code.c:228:16: warning: unused variable ‘client’ [-Wunused-variable]
MQTT_Client* client = (MQTT_Client*) args;
^
user/petes_code.c: In function ‘readDHT’:
user/petes_code.c:330:3: warning: implicit declaration of function ‘ets_delay_us’ [-Wimplicit-function-declaration]
os_delay_us(250000);
^
user/petes_code.c: In function ‘WS2812OutBuffer’:
user/petes_code.c:581:4: warning: implicit declaration of function ‘ets_intr_lock’ [-Wimplicit-function-declaration]
ets_intr_lock();
^
user/petes_code.c:599:5: warning: implicit declaration of function ‘ets_intr_unlock’ [-Wimplicit-function-declaration]
ets_intr_unlock();
^
user/petes_code.c: In function ‘mqttDataCb’:
user/petes_code.c:1077:7: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.base, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1098:7: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.desc, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1108:7: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.attribute, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1116:6: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.sta_ssid, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1120:6: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.sta_pwd, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1124:6: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.mqtt_host, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1132:6: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.mqtt_user, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1136:6: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
strcpy(sysCfg.mqtt_pass, strValue);
^
In file included from /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:10:0,
from /opt/esp-open-sdk/sdk/include/osapi.h:8,
from user/aidan_and_petes.h:14,
from user/petes_code.c:8:
/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/string.h:30:8: note: expected ‘char *’ but argument is of type ‘uint8_t *’
char *_EXFUN(strcpy,(char *, const char *));
^
user/petes_code.c:1588:6: warning: implicit declaration of function ‘sntp_get_current_timestamp’ [-Wimplicit-function-declaration]
current_stamp=sntp_get_current_timestamp();
^
user/petes_code.c:1590:6: warning: implicit declaration of function ‘sntp_get_real_time’ [-Wimplicit-function-declaration]
iprintf(RESPONSE,”sntp: %d %s \r\n”,current_stamp, sntp_get_real_time(current_stamp));
^
user/petes_code.c:758:12: warning: variable ‘noArgs’ set but not used [-Wunused-but-set-variable]
uint8_t noArgs;
^
user/petes_code.c:754:11: warning: unused variable ‘argType’ [-Wunused-variable]
int8_t argType;
^
user/petes_code.c: In function ‘bounce_cb’:
user/petes_code.c:1802:10: warning: variable ‘pin2changed’ set but not used [-Wunused-but-set-variable]
int8_t pin2changed;
^
user/petes_code.c: In function ‘mqtt_setup’:
user/petes_code.c:2150:5: warning: pointer targets in passing argument 2 of ‘MQTT_InitLWT’ differ in signedness [-Wpointer-sign]
MQTT_InitLWT(&mqttClient, “/lwt”, “offline”, 0, 0);
^
In file included from user/aidan_and_petes.h:15:0,
from user/petes_code.c:8:
mqtt/mqtt.h:127:24: note: expected ‘uint8_t *’ but argument is of type ‘char *’
void ICACHE_FLASH_ATTR MQTT_InitLWT(MQTT_Client *mqttClient, uint8_t* will_topic, uint8_t* will_msg, uint8_t will_qos, uint8_t will_retain);
^
user/petes_code.c:2150:5: warning: pointer targets in passing argument 3 of ‘MQTT_InitLWT’ differ in signedness [-Wpointer-sign]
MQTT_InitLWT(&mqttClient, “/lwt”, “offline”, 0, 0);
^
In file included from user/aidan_and_petes.h:15:0,
from user/petes_code.c:8:
mqtt/mqtt.h:127:24: note: expected ‘uint8_t *’ but argument is of type ‘char *’
void ICACHE_FLASH_ATTR MQTT_InitLWT(MQTT_Client *mqttClient, uint8_t* will_topic, uint8_t* will_msg, uint8_t will_qos, uint8_t will_retain);
^
user/petes_code.c: In function ‘mqtt_init’:
user/petes_code.c:2186:2: warning: implicit declaration of function ‘sntp_setservername’ [-Wimplicit-function-declaration]
sntp_setservername(0,”us.pool.ntp.org”);
^
user/petes_code.c:2188:2: warning: implicit declaration of function ‘sntp_init’ [-Wimplicit-function-declaration]
sntp_init();
^
CC user/stdout.c
CC user/user_main.c
In file included from user/auth.h:4:0,
from user/user_main.c:56:
include/httpdconfig.h:6:0: warning: “ESPFS_POS” redefined [enabled by default]
#define ESPFS_POS 0x70000
^
:0:0: note: this is the location of the previous definition
user/user_main.c: In function ‘user_init’:
user/user_main.c:66:2: warning: implicit declaration of function ‘petes_initialisation’ [-Wimplicit-function-declaration]
petes_initialisation(); // Sets up the ports and initialises various values needed by the MQTT call backs, time etc
^
user/user_main.c:67:2: warning: implicit declaration of function ‘setupwebpage_init’ [-Wimplicit-function-declaration]
setupwebpage_init(); // Set up the configuration/control web pages – or not
^
CC user/wifi.c
user/wifi.c: In function ‘wifiInit’:
user/wifi.c:22:2: warning: implicit declaration of function ‘iprintf’ [-Wimplicit-function-declaration]
iprintf(DEBUG,”\r===== WiFi Init =====\r”);
^
user/wifi.c: In function ‘setup_wifi_ap_mode’:
user/wifi.c:85:2: warning: pointer targets in passing argument 1 of ‘ets_sprintf’ differ in signedness [-Wpointer-sign]
apconfig.ssid_len = os_sprintf(apconfig.ssid, WIFI_AP_NAME);
^
In file included from user/wifi.c:5:0:
include/espmissingincludes.h:19:5: note: expected ‘char *’ but argument is of type ‘uint8 *’
int ets_sprintf(char *str, const char *format, …) __attribute__ ((format (printf, 2, 3)));
^
user/wifi.c:86:2: warning: pointer targets in passing argument 1 of ‘ets_sprintf’ differ in signedness [-Wpointer-sign]
os_sprintf(apconfig.password, “%s”, WIFI_AP_PASSWORD);
^
In file included from user/wifi.c:5:0:
include/espmissingincludes.h:19:5: note: expected ‘char *’ but argument is of type ‘uint8 *’
int ets_sprintf(char *str, const char *format, …) __attribute__ ((format (printf, 2, 3)));
^
user/wifi.c: In function ‘setup_wifi_st_mode’:
user/wifi.c:126:3: warning: pointer targets in passing argument 1 of ‘ets_sprintf’ differ in signedness [-Wpointer-sign]
os_sprintf(stconfig.ssid, “%s”, sysCfg.sta_ssid);
^
In file included from user/wifi.c:5:0:
include/espmissingincludes.h:19:5: note: expected ‘char *’ but argument is of type ‘uint8 *’
int ets_sprintf(char *str, const char *format, …) __attribute__ ((format (printf, 2, 3)));
^
user/wifi.c:127:3: warning: pointer targets in passing argument 1 of ‘ets_sprintf’ differ in signedness [-Wpointer-sign]
os_sprintf(stconfig.password, “%s”, sysCfg.sta_pwd);
^
In file included from user/wifi.c:5:0:
include/espmissingincludes.h:19:5: note: expected ‘char *’ but argument is of type ‘uint8 *’
int ets_sprintf(char *str, const char *format, …) __attribute__ ((format (printf, 2, 3)));
^
AR build/httpd_app.a
LD build/httpd.out
build/httpd_app.a(aidans_code.o):(.irom0.text+0x20): undefined reference to `MQTT_Connect’
build/httpd_app.a(aidans_code.o):(.irom0.text+0x24): undefined reference to `MQTT_Disconnect’
build/httpd_app.a(aidans_code.o): In function `MQTTLogonTimerCb’:
/home/john/hackitt_mqtt/user/aidans_code.c:58: undefined reference to `MQTT_Connect’
/home/john/hackitt_mqtt/user/aidans_code.c:64: undefined reference to `MQTT_Disconnect’
/home/john/hackitt_mqtt/user/aidans_code.c:74: undefined reference to `sysCfg’
/home/john/hackitt_mqtt/user/aidans_code.c:82: undefined reference to `CFG_Save’
build/httpd_app.a(aidans_code.o): In function `setupwebpage_init’:
/home/john/hackitt_mqtt/user/aidans_code.c:100: undefined reference to `CFG_Save’
build/httpd_app.a(cgi.o):(.irom0.text+0xc): undefined reference to `sysCfg’
build/httpd_app.a(cgi.o): In function `cgiLed’:
cgi.c:(.irom0.text+0x148): undefined reference to `sysCfg’
build/httpd_app.a(cgiwifi.o): In function `cgiWiFiScan’:
/home/john/hackitt_mqtt/user/cgiwifi.c:126: undefined reference to `sysCfg’
/home/john/hackitt_mqtt/user/cgiwifi.c:129: undefined reference to `sysCfg’
/home/john/hackitt_mqtt/user/cgiwifi.c:131: undefined reference to `sysCfg’
build/httpd_app.a(cgiwifi.o):/home/john/hackitt_mqtt/user/cgiwifi.c:134: more undefined references to `sysCfg’ follow
build/httpd_app.a(cgiwifi.o): In function `cgiWiFiConnect’:
/home/john/hackitt_mqtt/user/cgiwifi.c:227: undefined reference to `CFG_Save’
build/httpd_app.a(petes_code.o): In function `mqttPublishedCb’:
petes_code.c:(.irom0.text+0x4c): undefined reference to `MQTT_Subscribe’
petes_code.c:(.irom0.text+0x50): undefined reference to `MQTT_Publish’
petes_code.c:(.irom0.text+0x76): undefined reference to `MQTT_Subscribe’
build/httpd_app.a(petes_code.o): In function `mqttConnectedCb’:
/home/john/hackitt_mqtt/user/petes_code.c:206: undefined reference to `MQTT_Subscribe’
/home/john/hackitt_mqtt/user/petes_code.c:211: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:216: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:216: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:216: undefined reference to `easygpio_outputDisable’
/home/john/hackitt_mqtt/user/petes_code.c:217: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:217: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:217: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:217: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:217: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:217: undefined reference to `easygpio_outputDisable’
build/httpd_app.a(petes_code.o): In function `readDHT’:
/home/john/hackitt_mqtt/user/petes_code.c:316: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:331: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:332: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:394: undefined reference to `easygpio_inputGet’
build/httpd_app.a(petes_code.o): In function `lostThePlot_cb’:
/home/john/hackitt_mqtt/user/petes_code.c:1975: undefined reference to `easygpio_inputGet’
build/httpd_app.a(petes_code.o):/home/john/hackitt_mqtt/user/petes_code.c:1985: more undefined references to `easygpio_inputGet’ follow
build/httpd_app.a(petes_code.o): In function `lostThePlot_cb’:
/home/john/hackitt_mqtt/user/petes_code.c:1985: undefined reference to `CFG_Save’
/home/john/hackitt_mqtt/user/petes_code.c:1989: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1995: undefined reference to `easygpio_outputSet’
build/httpd_app.a(petes_code.o): In function `startup_cb’:
/home/john/hackitt_mqtt/user/petes_code.c:1629: undefined reference to `MQTT_Connect’
/home/john/hackitt_mqtt/user/petes_code.c:1630: undefined reference to `MQTT_Disconnect’
build/httpd_app.a(petes_code.o): In function `convertTime’:
/home/john/hackitt_mqtt/user/petes_code.c:274: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:279: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:291: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:299: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:306: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:308: undefined reference to `MQTT_Publish’
build/httpd_app.a(petes_code.o): In function `rtc_cb’:
/home/john/hackitt_mqtt/user/petes_code.c:2024: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:2033: undefined reference to `CFG_Save’
/home/john/hackitt_mqtt/user/petes_code.c:2042: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:2046: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:2047: undefined reference to `easygpio_outputEnable’
/home/john/hackitt_mqtt/user/petes_code.c:2052: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:2059: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:2061: undefined reference to `easygpio_outputEnable’
/home/john/hackitt_mqtt/user/petes_code.c:2066: undefined reference to `easygpio_outputDisable’
/home/john/hackitt_mqtt/user/petes_code.c:2082: undefined reference to `easygpio_outputEnable’
/home/john/hackitt_mqtt/user/petes_code.c:2090: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:2096: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:2110: undefined reference to `easygpio_outputDisable’
/home/john/hackitt_mqtt/user/petes_code.c:2118: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:2129: undefined reference to `easygpio_outputEnable’
/home/john/hackitt_mqtt/user/petes_code.c:2134: undefined reference to `easygpio_outputDisable’
/home/john/hackitt_mqtt/user/petes_code.c:2136: undefined reference to `easygpio_inputGet’
build/httpd_app.a(petes_code.o): In function `ok’:
/home/john/hackitt_mqtt/user/petes_code.c:605: undefined reference to `sysCfg’
build/httpd_app.a(petes_code.o): In function `HSV2RGB’:
/home/john/hackitt_mqtt/user/petes_code.c:690: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:690: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:690: undefined reference to `easygpio_pinMode’
build/httpd_app.a(petes_code.o): In function `mqttDataCb’:
/home/john/hackitt_mqtt/user/petes_code.c:719: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:849: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:876: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:886: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:919: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:928: undefined reference to `CFG_Save’
/home/john/hackitt_mqtt/user/petes_code.c:932: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:996: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1016: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1019: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1095: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1142: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1146: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1146: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1156: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1162: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1176: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1180: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1200: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1204: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1226: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1237: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1257: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1266: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1269: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1271: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1284: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1286: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1307: undefined reference to `CFG_Save’
/home/john/hackitt_mqtt/user/petes_code.c:1330: undefined reference to `MQTT_Connect’
/home/john/hackitt_mqtt/user/petes_code.c:1336: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1351: undefined reference to `CFG_Save’
/home/john/hackitt_mqtt/user/petes_code.c:1370: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:1372: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1372: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1377: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:1383: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:1386: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1387: undefined reference to `MQTT_Publish’
/home/john/hackitt_mqtt/user/petes_code.c:1387: undefined reference to `easygpio_inputGet’
/home/john/hackitt_mqtt/user/petes_code.c:1398: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1401: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1429: undefined reference to `MQTT_InitConnection’
/home/john/hackitt_mqtt/user/petes_code.c:1430: undefined reference to `MQTT_InitClient’
/home/john/hackitt_mqtt/user/petes_code.c:1430: undefined reference to `MQTT_InitLWT’
/home/john/hackitt_mqtt/user/petes_code.c:1430: undefined reference to `MQTT_OnConnected’
/home/john/hackitt_mqtt/user/petes_code.c:1431: undefined reference to `MQTT_OnDisconnected’
/home/john/hackitt_mqtt/user/petes_code.c:1431: undefined reference to `MQTT_OnPublished’
/home/john/hackitt_mqtt/user/petes_code.c:1432: undefined reference to `MQTT_OnData’
/home/john/hackitt_mqtt/user/petes_code.c:1433: undefined reference to `MQTT_InitConnection’
/home/john/hackitt_mqtt/user/petes_code.c:1433: undefined reference to `MQTT_InitClient’
/home/john/hackitt_mqtt/user/petes_code.c:1436: undefined reference to `MQTT_InitLWT’
/home/john/hackitt_mqtt/user/petes_code.c:1437: undefined reference to `MQTT_OnConnected’
/home/john/hackitt_mqtt/user/petes_code.c:1440: undefined reference to `MQTT_OnDisconnected’
/home/john/hackitt_mqtt/user/petes_code.c:1440: undefined reference to `MQTT_OnPublished’
/home/john/hackitt_mqtt/user/petes_code.c:1444: undefined reference to `MQTT_OnData’
/home/john/hackitt_mqtt/user/petes_code.c:1472: undefined reference to `CFG_Load’
/home/john/hackitt_mqtt/user/petes_code.c:1476: undefined reference to `CFG_Load’
/home/john/hackitt_mqtt/user/petes_code.c:1476: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:1483: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:1484: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:1485: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:1486: undefined reference to `easygpio_pinMode’
build/httpd_app.a(petes_code.o):/home/john/hackitt_mqtt/user/petes_code.c:1488: more undefined references to `easygpio_pinMode’ follow
build/httpd_app.a(petes_code.o): In function `mqttDataCb’:
/home/john/hackitt_mqtt/user/petes_code.c:1497: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1501: undefined reference to `easygpio_pinMode’
/home/john/hackitt_mqtt/user/petes_code.c:1503: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1506: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1509: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1511: undefined reference to `easygpio_outputSet’
/home/john/hackitt_mqtt/user/petes_code.c:1512: undefined reference to `easygpio_outputSet’
build/httpd_app.a(petes_code.o):/home/john/hackitt_mqtt/user/petes_code.c:1514: more undefined references to `easygpio_outputSet’ follow
collect2: error: ld returned 1 exit status
make: *** [build/httpd.out] Error 1
[2]john@dc7700p2 ~/hackitt_mqtt $
Hi John
Ok, first off – Github – tried it, don’t like it, prefer Bitbucket, sticking with it. So can’t help there. Also apart from working on Raspberry Pi, everything I do it in Windows – when I started all of this everything for the ESP8266 was Linux so I’m happy to redress the balance – the code should compile no problem in the Eclipse environment on a PC – having said all that if I can be of help to anyone using Linux – I will do my best. The EASYGPIO stuff – I’m pretty sure in the Windows Make file it is referred to – I have never touched the Linux make file in there so it is likely of little use. If anyone wants to make it work I’ll most certainly replace the one there. I added the easyGPIO stuff well after the makefiles were created and added the reference in only to the Windows version. Actually it’s mainly cosmetic – but I find actually understanding commands helps 🙂
CFG-Save is the relatively NEW function set in SDK 1.3.0 – was probably there earlier – it replaces TUANs original save functions. I note he’s done the same now but I just fixed them myself.
Some of the other items escape me – I hope someone else can help in here.
Hmm, this all makes me wonder if I shouldn’t start a forum in here… PHPFORUMS or something – so we could separate off subjects…. anyone think that’s a good idea?
New version of board coming up – discovered that it’s a good idea to put VDR on the relay contacts and for good measure we’re putting a 0.1u cap to ground on the reset to minimise noise pickup.
No, that’s just one PCB – although we are into the 8th version at the moment! The PCB will handle either the ESP-01 or the ESP-12.
The main reason for that is that if you put sockets in place of the ESP-01 and ESP-12 connectors then you can use the board as a programmer. There is an ATTINY-85 processor on board which handles the sequencing of the reset and GPIO0 signals to put the modules into programming mode. However, if you just want to use the board as a final, target unit, you can just drop in a pre-programmed ESP module and omit the ATTINY-85
Aidan
Your Dropbox page lists two board files, both named ESP-01 and 12 Development.brd. Which is the most current? Both say they were last modified 10 days ago.
Same board?
No, they seem to be different. However, I have no reference to see which is correct.
Peter,
Since discovering your site I have dusted off the RPi installed node red, bought the netio app, yes bought!! and now I’m slowly moving forward getting things talking to each other.
I want to learn about MQTT and I have a simple question but one that’s so obvious I can’t seem to Google the answer. My assumption is that I can install the mosquitto broker onto my RPi and run it stand alone from the RPi and configure node red MQTT nodes with the RPI IP address and port no.
Thanks
Hi
Your blog helped me a lot with developing for the esp.
I can’t figure out something.
In the “hackitt_mqtt_separate” app in the user_main.c which function acts as the “loop” function?
If I want to add functionality that listen to the serial port and if it detect something it does something, where best should I put it? Can’t seem to find an implementation for this in the “hackitt_mqtt_separate”.
Thanks
If you see any duplication in here it is because I have switched providers. Look at “Hackitt_mqtt” code – the original separate code is no longer being updated as it was basically the same but without the web support. Beware, right now I am making updates constantly to “hackitt_mqtt” as I find errors or add features. Use at your own risk and of course you’ll need MQTT support for it.
Hi Peter.
I need a SSL implementation for the MQTT I added this to code and also add it to the wifi.tpl.
I understand form another esp blog, that using SSL will need a lot more memory space than the 512 so my question is if the source code in the “hackitt_mqtt” – Makefile.windows will make use of the 4MB esp-12 module ?
Also If I delete some of the files and shorten the source code so after compilation I get a much smaller firmware do I need to change something accordingly in the Makefile.windows so it will fit a smaller firmware?
I’ve just used the 512K setup up to now and I have BAGS of room left. Not used SSL yet.
Congrats! Looks great. Now try and get my head around it.
Great stuff Peter. My own little project is now months behind yours, so I’m a tad jealous. But mainly grateful that you’ve shared your experience with us all. Thanks, and continued success.
Hi Peter, looks nice! I’ve been doing something similar but my constraints are a little different to yours. I’ve produced a board which has DHT11/22, DS18B20, a SSD1306 OLED, BMP180 sensor (or another I2C device) a 3A relay & a LED.
See it here: http://www.cse.dmu.ac.uk/~sexton/node/photos/newboard_a.jpg
Ultimately I determined that the cheapest PSUs are phone chargers! Less than £1 a pop 🙂 And I use a USB cable to provide the power connection (my boards need to be student safe). A simple linear regulator provides the 3v3
I also wanted to avoid surface mounted components AND stay within the 50×50 of DirtyPCBs. The USB connector & the regulator are the only SM components.
It’s looking good so far (got the PCBs last week)
I have some super simple devices too. For example, this is a ESP01 with a DHT11/22 attached on the back: http://www.cse.dmu.ac.uk/~sexton/node/photos/iphone1.jpg
Cheers
Hi Ian
Oled sounds good.. how many wires? Yes, cheapest usually are phone chargers but they vary SO VERY MUCH in quality – so easy to blow up – or rather make fail – the slightest issue and they’re dead. It seems the phrase “overload protection” is not something the Chinese chip manufacturers appreciate.
I’m using a SSD1306 I2C OLED – 4 wires in total: power & I2C 🙂
These things are only £3 on ebay – tiny but very crisp.
There’s a couple of threads on the ESP8266 forum about using them. Thanks to a recent one I have the Adafruit library working now.
Point taken re phone chargers!! I’ve had duds in the past…
So… something like this..?
http://www.ebay.co.uk/itm/0-96-I2C-IIC-128X64-Yellow-Blue-OLED-LCD-LED-Display-Module-for-Arduino-Serial-/191279261331?pt=LH_DefaultDomain_3&hash=item2c8921e693
HI Peter, could you fix your dropbox link for the .brd please? 🙂
Thanks
Link seems to work for me… here it is..
https://www.dropbox.com/home/public%20downloads#
Dropbox not working for me either. Seems that is your public download area. Dropbox asks for credentials when I click on the link. Of course, my credentials are not going to help because the file is not stored in my directory. Can you post a shared link for the file?
That’s what I did – I’ll try again. https://www.dropbox.com/s/tez56okl2nu8qev/ESP-01-and-12-Development.brd?dl=0
That’s it!
Thank you. Nice work. I am new to your blog and I have been reading back through it. You have done a lot of work and made it available to the public. It is greatly appreciated!
This is coming along really well, the only differences between what you have here and what I’d want is switching out the relay for a dpdt bistable one (so it can man-in-the-middle a lighting circuit) and having the adc hooked up to a CT to detect the current status of the lights. I’m actually doing something very similar to this right now to address my specific needs and I’ve added a local RTC (although there should be one on board I don’t know how to use it/where to put the crystal to make it reasonably accurate) set by NTP and the bistable relay. The CT is proving more difficult, the plan right now is to re-implement a subset of https://github.com/openenergymonitor/EmonLib specifically for the esp. Oh, and I’m doing this all in arduino because I’m lazy and it works fairly well.
All of my boards maintain an RTC inside, topped up at power on and once a day via MQTT. There is software in the ESP SDK to set the time – but it doesn’t do summer/winter time and it seems we are missing floating point maths functions – so that’s out.
Hello Evan, this has intrigued me, and sound like what I want to do, in that one wants to still be able to switch on/off at wall (replace with a push-button?), but be able to control lights from i.e. Node-Red with a UI, or some logic (switch all lights on). Your comment:
“dpdt bistable one (so it can man-in-the-middle a lighting circuit) and having the adc hooked up to a CT to detect the current status of the lights”
Could you elaborate further, maybe have you published the circuit somewhere, and could you point me to typical parts? Why not use an SPST bi-stable for instance? Could you please point me in the right direction? the ADC is also important to me, one needs to know if the lights ae on or off before switching from central. Thanks!
An update on this for interested bodies – we’re awiting a new board having made some mistakes on the earlier ones – I want to be able to incorporate 12v-5v convertors as well as mains power supplies in the space allocated for a supply. Also the software while working pretty well up to now, is having issues with SDK 1.10 – more on that in another blog assuming they are resolvable.
Brocashelm: Your queries – all I can say is that MYSQL works a treat – especially with Node-Red… I do have (as yet unfounded) concerns about SD lifespan when updating MYSQL, what I’d ideally like is the database held in RAM and updated nightly to SD.. if anyone has code for that do let me know. Yes, I have tables to store temperature and humidity – then I use a simple PHP/JS program using one of the many charts packages out there to display that data – I also log when a unit turns on and logs in – that all goes into SQL – to date I’ve had no problems at all and of course PHPMYADMIN is fine for creating tables etc – though I did just discover MYWEBSQL which on the surface looks even better.
MySql has several storage engines… most common are MyISAM and InnoDB, but there is one called MEMORY (https://dev.mysql.com/doc/refman/5.1/en/memory-storage-engine.html)
– You can use a temporary table with this storage engine, a once a day dump all data to final table, on normal storage engine, and thus, writing to SD.
A few ideas on top of this:
– partitioned table by range (for example, one partition for each day).
– redundant data on some cloud to prevent data loss on power failure (because current day will always be in MEMORY only).
I have an ideia to solve have MySQL to write to SD only once a day… mysql has several storage engines (myisam, innodb, etc) and one them is MEMORY (https://dev.mysql.com/doc/refman/5.1/en/memory-storage-engine.html).
You can use a MEMORY table and once a day dump all data to the final table (myisam for example).
a few ideias on top of this solution:
– the final table can be partitioned by range (one partition a day, for example) and make dump simply by exchanging partitions.
– have redundant data stored in some cloud for that MEMORY table, so that you never lose any data in case of power failure.
Ok SFAM, you’re NEARLY on my Christmas card list… for the benefit of those of us not 100% confident on the Pi yet (and for those who’ve not yet twigged that there is a problem) are you able to translate that into a simple, no-assumptions-made-about-Linux-knowledge series of instructions?
The only issue I can think of – is that this is for NEW tables…. and there’s a max-heap-table-size that might prove an issue. A way is needed to capture info – and then somehow dump it into the permanent tablets.. problem is – if you used SQL for this – ie updating the tablets in a loop – then you’re actually no better off.
Now, if the table size could be brought up to, say, 100 meg, I guess you could read the table from disk on power up /reset…. and every night overwrite the original table… there would need to be something that happens if you manually close down to ensure the table(s) is(are) updated.
This solution has nothing to do with linux or raspberry pi… only mysql. The simplest solution is to have 2 tables like this (pseudo-code – not tested) :
create table log_mqtt_today (
ts timestamp,
topic varchar(50),
message varchar(200)
) ENGINE = memory;
create table log_mqtt_all (
ts timestamp,
topic varchar(50),
message varchar(200)
) ENGINE = myisam;
– Each time a new mqtt message arrives:
insert into log_mqtt_today values ( now(), msg.topic, msg.payload );
– Trigger in node-red once a day (or manually before power down) something like:
insert into log_mqtt_all
select * from log_mqtt_today;
commit;
truncate table log_mqtt_today;
– This is supposed to only write to SD only once a day… but not sure if would be any better than writing each message to SD individually.
Sfam – I see your logic- and I see the concern – needs someone with more knowledge of MYSQL mechanics – would this result in LESS writes? I’m not sure. Good start though!!!
I recently begun my project and I’m still deciding exactly what to use as I’m still waiting for several stuff to arrive from China(like a bunch of ESP-12Es). A question that came up to me is the following:
Should I use a NoSQL DB like Mongo or should I stick with MySQL?
A database like Mongo has the advantage of being pretty simple to use and that you can scale the setup easily(with a cost of a risk of things getting out of hand).
A database like MySQL, considering you use it as it’s intended and not with a VARCHAR 255 to store the whole msg.payload(so you have to parse it every single time), has to be designed with future expansions in mind from scratch.
Now, the values you can get from ESP-12E are like 11, so setting up a table with id, timestamp, device-id and 11 more columns should be enough, right? Or for a more complex setup, you can have a table with the sensor values(temperature, humidity etc), one for the boolean values(lights on/off, open windows) and perhaps one for alerts(PIR sensors).
But if for example you use a future ESP-1000(pretty creative name :P) that has 1000 outputs, then what? Restructure the whole database?
On the other hand, and since MySQL is the usual database for everything, you can insert the data into tables inside a database that is used already by your front-end web application.
I’m really confused on what is the best option for what I want to do.
andyclimb: Others are experiencing the same problem, apparently in particular with the ESP-01: http://www.esp8266.com/viewtopic.php?f=13&t=1924
I can only say I have a BOATLOAD of ESP-01s and never had trouble with them.. Nor the ESP-12…
Hi,
I sent you a few msg on Facebook a while back was wondering if you got them. I was wondering if you might be able to give me some advice, or let me know if you’ve had any similar problems.
I’ve been building a variety of devices using the ESP-07 and ESP-12 that involved switching a 5V relay module. These are the modules you get on eBay, both SSR and the usual coil ones that have opts-isolation in them. I’ve got some ESPs, powered by a small 700mA power supply that looks very similar to yours, with a 5V to 3.3V regulator, 4 100uF Caps on each side of the 3.3V regulator. The ESP has RST pulled high, with a capacitor. the esp has a 10nF ceramic cap across it.
the problem is that when ever there is any power going through the coil relay Common-NC terminals of the relay the ESP reboots every few clicks. The moment I take away the live power, it runs just fine. This does not happen at all with the solid state relays. It occurs with independent power supplies. It happens with 3 different relay modules. Moving the components apart when >50cm seems to help, but it does not get rid of it.
I’m at a bit of a loss. I was wondering if you’ve tried your PCB with mains power being switched by your relay? Have you come across this before. I’m guessing it is an EMF problem, but I’m totally stuck… the main different between your project and mine is that I want to provide live mains out using the mains that comes into the device to power the ESP.
got any ideas? would appreciate some help, as my code is running like a dream… I’m just not able to make my idea!
Sorry didn’t see your messages – this is the place to discuss really I just use https://www.facebook.com/esp8266wifi as a place to announce updates etc. Well, I AM controlling mains gadgets with both solid state relays and normal 5v relays and I’ve not had issues. I’m assuming you’ve had a scope on the power supply of the ESPs when you are switching to see if there ia anything horrible going on? I have a 700ma or so supply and there is a 1000uf on the 3v3 linear regulator side – I would never consider running the ESP straight off a switched regululator. Up to now I’m not seeing any issues – I wonder if others have anything to say?
Ah ok, no problem.
I’ve scoped it, one of the first things I did and there was no changes that I could detect. I am using a linear 5V to 3.3V regulator AMS1117 i think it is. What I find curious is that there just has to be live power connected to the relay switching terminals for this to happen.
I’ve just gone ahead and bought some 1000uF capacitors. But there really is nothing else that I can try I guess! so weird…
This is a far cry from those original “wired” One Time Programmable PIC based systems of yours that I had dotted around the house and you are right, not SWMBO approved. I think I went through about 3 reels of alarm cable to install them all and most of it was hidden along the edge of the carpets. 🙂
Wireless of course is the only way to go these days. I also need battery powered so on the lookout for a suitable wireless system that can run off 2 AA batteries for touch panel input (Atmel cap touch) which fits in to some nice handheld enclosures that are held on the wall via neodymium magnets and a small metal plate fixed to the wall next to the light switches. It looks and gets SWMBO approval. 🙂
I’m taking the easy approach – as we move house I’m having cables buried in the wall! Hey that APPCON stuff was good fun.
Hi- I remember that in the previous (first) update about you pcb board you published the schematics also.
Can you do that again or you aren’t going to share it any more?
Thanks
Currently waiting for a set of boards to appear from China – which then need testing to make sure they work. I’ll do a write up once we have them assuming there are no bugs (that’s a big assumption). Right now I’m spending my time concentrating on getting to grips with Node-Red so that I can actually do something with them when they arrive.
Many thanks. Just the job!
Hi
Does anyone have link to a UK supplier of 2mm to 0.1″ PCB adaptors.
Regards
Ian
If you’re looking for something for ESP-7, ESP-12 etc.. this is the type I bought.. marvelous..
http://www.ebay.co.uk/itm/251797183621?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
This one looks nice, I’m ordering ten now: http://www.aliexpress.com/item/10pcs-lot-ESP8266-serial-WIFI-module-connecting-plate-applicable-to-ESP-07-the-ESP-08-ESP/32262406988.html
It’s such a pity these cannot be truely wire free. They use too much current, so your always going to have to have a mains power lead running to them 🙁
Not sure I agree with you there Glen. On my boards I’m hooking up GPIO16 and as you know once you do that you can put them to sleep for long periods. I’ve not tested this yet but others say you can get reasonably low current. Given a lithium battery and half decent solar cell it may well be possible. For my purposes I’m not that bothered about supply because just about everything I’m going to hook them up to is going to need power anyway.
I’ve kind of lost interest in Arduinos – I was keeping them around for PWM but I just figured out how to do that on the ESP – and it works well, I’ve a nice dimmer running as of 3am this morning (I know, sad).
NOW – IR control – I see that as a problem – timing-wise if you’re doing other stuff including WIFI…. I’d be happy to be proven wrong.
Since you are including attiny85, is it possible to use the attiny85 for IR control or other timing-critical part?
If the attiny85 is easily programmable and there is spare pin to be used for IR control then it might be useful there.
Will that standard IRLIB work – I don;t fancy developing IR – not my skill area.?? It’s a thought. A
Can’t wait for this to ripen. So long I’ll hack away at my ESP8266es. So lost my appetite for Arduinos.
One thing that I’d love to see but know its not easy is a Heat Pump IR control. The hardware is easy but the commands a nightmare.
Hasta la proxima
Oliver
One of the big questions will be – reliability of the little power supplies… they seem to work fairly reliably in the UK but in rural Spain where I spend some of the summer, the mains power there is more rubbishy and the Chinese power supplies have a tendency to give up, especially the 12v ones used to power LED strip. I’m looking at these little devils now…. http://www.ebay.co.uk/itm/31-Types-Switch-Power-Supply-Driver-5-12-24-48V-1-2-3-10-15-20-30-40-50-60-70A-/311001005100?pt=LH_DefaultDomain_3&var=&hash=item48691abc2c
Hi there,
Very interesting blogs, please keep on posting.
I’ve ordered the exact same AC/DC switching power modules, but I can’t find any footprint information. I would like to finish my PCB-design before I receive the modules (could take some weeks).
Can you help me out sending the footprint (or info) of the power module?
Another question… The Tantalums you placed on your board, have you placed them after meausuring the output of the AC/DC or are those a precaution? (i can’t find any specs….)
Best regards,
Edjeed
Thank you. I didn’t to the PCB and Aidan who did is on a ski holiday. Tantalums – switched mode power supplies ALWAYS generate noise. Given that we’re looking at a WIFI board (ie radio) – caps are pretty much essential I would suggest.
I also think thetantalums are needed, just curious how you determined the best values…
Hunch? Using electronics for decades…. certainly not by any rational scientific method 🙂
Developing electronics for years also, if no specs or measurements are available a hunch is indeed the only way.
Home projects with cheap chinese components is like using your intuition all the time 😉
Dear Pete,
This is excellent. Not just the board but the entire write up. Meticulously done and explained. Most of the critical aspects and caveats related to ESP8266.
The concept of board is awesome – even the concept of control of flashing by ATTiny. However, I was wondering about – if you would always (mostly) need to program and reprogram in a production environment. I was also working to make a slightly less functional board but with addition of a) external eeprom and rtc with backup button cell.
I had one concern in mind related to mqtt client implementation and that is – configuring / reconfiguring of subscribed topics in real life (I guess, this might require occasional changes as per the need of the system? Will it? ) In that case, the ease of programming will be of help.
Do you have any better idea for re-programming topics configuration, perhaps host, IP, ssid and password configs too ? I am keeping my fingers crossed.
So long as you are not finalizing the pcb layout / design etc. Do you intend to share the schematic? Perhaps you may also get some suggestions from learned readers.
Sorry, I saw the schematic in an earlier post of yours, which I checked later.
The point of using only 2 MQTT topics means that the actual instructions are in the body. These can be passed to the board, activating build in functions – or sending out to external boards such as Arduinos etc for further processing. Aidan has done the bit of programming, based on existing code, to allow you to set host, IP, SSID etc without programming, ie using the board as a WIFI access point initially for setup. I’ve yet to test this part of it but I’m assured it works. I’m concentrating on the actual instructions in the ESP8266 and ensuring everything is reliable.
I’m not sure that I understand your infrastructure. Surely you can ‘advise’ subscribers on which topics they should subscribe to? This is what I do. How do you identify newly connected devices?
Hi
What we have done is to subscribe each unit to a couple of topics such as:-
‘/toesp’ – message to an individual device
and ‘toesp’ – broadcast message to all devices
Devices respond on ‘/fromesp’ and can add additional subtopics such as ‘temperature’ – e.g. ‘/fromesp/temperature’ to return values
When a device first powers up, it sends a message to topic ‘esplogon’ which includes its’ device name and any attributes that you have set in the web setup page on first connecting the device to the local wifi network, things like ‘has_temperature_sensor’
We currently use Node Red to trap all ‘esplogon’ messages and make an entry in a MYSQL database the first time the device is seen. A return message is sent to ‘<device_name'/toesp which includes things like the current local time, plus dawn and dusk times.
The device will log on periodically and will receive the updated time. The last logon time is also noted, so that if a device isn't heard from for some time, you could log an error, send an error email or some such.
The advantage of having an automatic database entry is that you can just keep on adding units to you database but the setup is done locally in the device when you install it
Hope that helps!
Aidan
…meant to add that we’ve also done a Node Red node which will take messages from /fromesp/temperature and put them straight into the MYSQL database with device_name, time/date and temperature reading.
Pete is currently adding a periodic temperature reporting time which I will add as a parameter in the web setup.
This means that you could define a temperature reporting time of, say, 15 minutes and every time it sends the temperature it will be automatically added to the temperature log in the MYSQL database.
SO, you can then extract data along the lines of:-
“select * from temperature_log where device_name = whatever”
and then pass the info to a graphing routine for display.
Aidan
Hi Pete,
Will you be able to publish list of components and links to where you source it from? Maybe start getting ready for the board.
Nice Board,
What PSU are you using?
This is one of them – I believe the board can handle 2 different types including a smaller one but this is the one I’ve been using, then followed by a 3v3 linear regulator. http://www.ebay.co.uk/itm/CNZ-5V-1A-Built-in-Industrial-Power-Switching-Power-Supply-Board-Module-/121351057415?pt=LH_DefaultDomain_3&hash=item1c41163007
i suggest using HLK-PM01 as PSU , i tested my self for almost 4 months and running fine
it’s 5V 0.6A and i used MOSFET to drop it to 3.3V to power ESP8266 and some sensors and relays directly from the 5V.
http://www.aliexpress.com/item/5-pcs-HLK-PM01-AC-DC-220V-to-5V-Step-Down-Power-Supply-Module-Intelligent-Household/32319202093.html?spm=2114.32010308.4.19.8oKfZg&aff_platform=aaf&sk=RnieI6Mr7%3A&cpt=1453904318699&aff_trace_key=68870308031c409585abf54584b84f70-1453904318699-07722-RnieI6Mr7
Well they are certainly cheap enough!!! Well spotted.
Very impressive.
Will you be making esp code available?
Yes, once we get boards and actually have something real working [update – link for code is in this blog]. The last thing I want to do is to put out code that then encourages countless questions because of something we’ve messed up. Meanwhile some of the code is out there already – like the WS2812b code – I think our version which is little more than fix for what went before it, is the first to actually work and be tested to work flawlessly. I’ve done more of course – I have it sitting doing rainbow displays in the background but I wanted to put out the basics and see if anyone had any issues.
I know, I’ve tried the code, worked perfectly! But I was wondering if the board is going to be open source, I would love to get my DirtyPCB order out of the door 🙂
Excellent news… the board will become available but wait until we get the first lot back and tested. I’ve no plans to become a support centre and that’s what’ll happen if we put out something that isn’t tested. The first board as you saw needed a couple of wires and over the weekend we went through the Eagle files to ensure that we were both using the same port bits etc. I want it to be perfect for my own peace of mind as I’m moving house and right now the house we’re moving into is a building site – the ideal time to put boards etc into the rafters… but not without thorough checking. And yes, we’re using DirtyPCBs…
Cool! Really can’t wait! Hope to see it soon!
esp code for what? Source code has always been out there. Links in the home control 2016 page linked to on right menu.
Wow, that’s some impressive work. Well done!
Wow! This is perfect! Please tell me how I can get this board, I really want this board! Very nice!
Let me know if you need someone for testing this 🙂