Issues installing emonESP firmware to Sonoff20 (Solved)

Great! could you update your device module to v1.2.1 Release V1.2.1 · emoncms/device · GitHub hopefully the notice should then appear.

I tried compiling with platformio earlier and while it did compile and upload, the user interface was very sluggish ultimately crashing all together. I went back to the Arduino IDE and it all worked fine. I’ve copied bin and spiffs compiled for esp8285 to the github repo here compiled for esp8285 · openenergymonitor/EmonESP@42054c9 · GitHub

I havent yet worked out how to upload these via command line:

esptool.py write_flash 0x000000 src.ino.bin 0x300000 src.spiffs.bin

does not seem to address the right locations for a 1MB (512kb) configuration.

esptool also reported my board as 8266 not 8285, but the 8285 version works fine… not sure what’s going on there.

Hi Trystan

I hadn’t switched beta on. Once I did that the switch appeared.

How do you update just the demand module? I haven’t updated to 9.9.7 yet, waiting for a week or so while I concentrate on getting best out of Octopus Agile.

Geat

This should do it:

cd /home/pi/demandshaper
git pull

Hi Trystan

This installation is fighting me all the way!

pi@emonpi:~/demandshaper $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
pi@emonpi:~/demandshaper $ git pull
fatal: unable to access 'https://github.com/emoncms/demandshaper.git/': Could not resolve host: github.com

Can you ping github.com? Might have been a glitch at that moment.

I’ve worked out the correct addresses for the precompiled firmware upload:

esptool.py write_flash 0x000000 src.ino.bin 0x7B000 src.spiffs.bin

Id be interested to hear @ian if that works with your sonoff S20 plugs even though you noted the board version was 8266 not 8285.

I’ve compiled it for the esp8266 too: EmonESP/compiled at master · openenergymonitor/EmonESP · GitHub

It seems that the higher upload speeds also work:

esptool.py -b 230400 write_flash 0x000000 src.ino.bin 0x7B000 src.spiffs.bin
esptool.py -b 460800 write_flash 0x000000 src.ino.bin 0x7B000 src.spiffs.bin
esptool.py -b 921600 write_flash 0x000000 src.ino.bin 0x7B000 src.spiffs.bin
esptool.py -b 1500000 write_flash 0x000000 src.ino.bin 0x7B000 src.spiffs.bin

Im glad you got me to try this, its going to make my life much easier :slight_smile:

2 Likes

Still a problem.

pi@emonpi:/var/www/emoncms $ ping github.com
ping: github.com: Temporary failure in name resolution
pi@emonpi:/var/www/emoncms $

However if I try this on my Node-Red server (different pi same network) it works fine.

pi@piserver:~/EmonESP $ ping github.com
PING github.com (140.82.118.4) 56(84) bytes of data.
64 bytes from lb-140-82-118-4-ams.github.com (140.82.118.4): icmp_seq=1 ttl=53 time=26.3 ms

Not sure what to do next.

Update is affected as well.

 sudo apt-get update
Err:1 http://raspbian.raspberrypi.org/raspbian stretch InRelease
  Temporary failure resolving 'raspbian.raspberrypi.org'

More than likely to be an issue with your internal network. I presume you have tried a reboot of the Pi. Reboot the router (power off power on)?

Yes I’ve seen that error quite a few times with github, usually goes away with time or with measures @borpin suggested.

At last success! My board is esp8285. Nothing happened when I uploaded precompiled esp8266 so I tried esp8285 and at last the AP appeared. Interesting nothing appeared on the serial port until after I had filled in SSiD and connected.

Some people are never satisfied. I cannot connect to my MQTT broker as although I can enter server URL there is no provision for port number and I use non standard port number for security reasons. Is there a way to enter port number? I tried 192.168.1.??:20??

Still having git pull issues. Setting up a new SD so I can backup and restore.

Getting there!

1 Like

Hello @ian, after you mentioned that you had no issues with the tasmota firmware I thought I would have a look at their platformio.ini file to try and compile using it. I removed the unused language flags, changed the flash size + a couple of other minor modifications and it worked! The tasmota platformio specified the build environment in more detail and included the flash size.

I’ve uploaded the platformio.ini file to the EmonESP repository. Would you be able to test it?

I had to update platformio as well:

pio update
pio upgrade

then:

pio run -t upload
pio run -t uploadfs

I have copied the compiled binaries to the compiled folder.

Hi @TrystanLea

I did a git pull and got the ini changes.
My platformio was up to date. I then ran the uploads to my S20 plug. It immediately appeared as an AP. Entered SSid and password and it came up on the network. I can switch on and off no problems. It appeared as an input requesting connection to be allowed. I had hard coded the MQTT port so I can control it from emonCMS demandshaper interface!

I am pleased to say it past my test.

If the MQTT port was configurable from the web interface (and possibly name and node number) it think it should now just run on any installation.

2 Likes

Fantastic, I will look into adding that in

1 Like

I’ve added the MQTT port option.

It defaults to 1883 if the value in the EEPROM is 0. I needed to click on Factory Reset to fully reset the EEPROM so that the default is applied. I havent yet implemented the transfer of the port setting from the demandshaper module as part of the auto authentication process, so you will need to set the port manually in the EmonESP interface.

I’ve also added an ID based on the ESP chip ID (its shortened by dividing by 5120)

The compiled binaries have been updated and the old arduino IDE versions removed.

Hi Trystan

As a true test I cloned.

pi@piserver:~ $ git clone https://github.com/openenergymonitor/EmonESP.git
Cloning into 'EmonESP'...
git checkout timer
Branch timer set up to track remote branch timer from origin.
Switched to a new branch 'timer'

I think there might be some files overlooked in the new platformio.ini

src/mqtt.cpp:32:107: fatal error: PubSubClient.h: No such file or directory
In file included from src/web_server.cpp:31:0:
src/web_server.h:30:25: fatal error: ESPAsyncTCP.h: No such file or directory
stry!

*********************************************************************
compilation terminated.

Ah it looks like lib_deps was removed from platformio.ini

I’ve just added it back

lib_deps = [email protected], ESP Async [email protected], [email protected]

Please try $ git pull then $pio run again to test.

This is one of the best features of platformio to be able to specify exactly which libs we want and which version.

Looking at the new platformio file it looks like most of these options which have been exposed are just the default settings for the ESP. As a result it looks unnecessarily complicated! I’ll take a look to see exactly what is needed. Was just specifying board esp01_1m not enough?

Just tested and it seems esp01_1m was all that’s needed. I’ve just successfully uploaded to an S20 and it seems to be working fine It’s just connected to WiFi

env_default = sonoff
data_dir = src/data


[common]
version = -DBUILD_TAG=2.3.0
lib_deps = [email protected], ESP Async [email protected], [email protected]
monitor_speed             = 115200
upload_speed              = 115200
upload_resetmethod        = nodemcu

; *********************************************************************

[env:sonoff]
platform = espressif8266
framework = arduino
board = esp01_1m
lib_deps = ${common.lib_deps}
src_build_flags = ${common.version} -DESP01 -DENABLE_DEBUG
monitor_speed = ${common.monitor_speed}
upload_resetmethod = ${common.upload_resetmethod}
upload_speed = ${common.upload_speed}

Much simpler :+1:

I’ve committed my changes, please let me know if you have the same experience:

I dont see any harm having the additional detail, you can see exactly which version of the core esp8266 its using etc, the flash size setting Teagle.flash.1m512.ld and DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY