pilotak / mqtt-weather-display

Simple weather and time display using ESP8266 and ILI9341
MIT License
6 stars 2 forks source link

cant compile with IDE Arduino #1

Closed Electronlibre2012 closed 5 years ago

Electronlibre2012 commented 5 years ago

Hello Pilotak,

sorry to bother you, i am relally interesting by your project but i dont suceed to compile your mqtt-weather-display.ino...lots of errors,

which library do you use for WifiManager.h and JC-button.h please?

And the TFT you use is I2c?, which one is it please?

I have a SPI one, doesnt work with your sketch i think.

Thanks

Olivier

pilotak commented 5 years ago

Hi, it was compiled with PlatformIO but i will try to guide you for Arduino IDE. Below is a list of required libraries:

Should you need also a DS3231 support https://github.com/JChristensen/DS3232RTC

next is to add macros at the line 20 (just after licence - really important to be a first code) https://github.com/pilotak/mqtt-weather-display/blob/7bc7cd1c3b728c838cd79f5a1a5e3076dacfbea5/MQTT_weather_display/MQTT_weather_display.ino#L20

#define DEBUG
#define ARDUINO_OTA
#define WIFI_MANAGER_MAX_PARAMS=5
#define NTP_SUPPORT
#define HAS_RTC // only if chip is presented

Compile and you should be done. As you can see from libs above it uses ILI9341 - SPI display

Electronlibre2012 commented 5 years ago

Hello,

a big thanks you for your reply! i appreciate that you share your experience! great!

BUT

1-what is "macros" i have to put at line 20? i dont understand the #define you give go at the top of the "const.h" ? or after the line 20?

2-I havent a DS3231, so i will buy one right now! but if i understand i can do whithout? just NTP time is ok? :

//#define HAS_RTC // only if chip is presented

3-If i use a wemos d1 mini is it GPIOs ? :

#define SDA_PIN 4
#define SCL_PIN 2
#define TFT_DC  16
#define TFT_CS  15
#define LED_PIN 5

/////////////////////////////////////////////////////////////////////////////////////////////////////// Edit : i install all libraries and compile with no sucess : only 1 error đź‘Ť

C:\Users\Popol Perso\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.hpp:12:25: fatal error: ESPAsyncTCP.h: No such file or directory

 #include <ESPAsyncTCP.h>

i download and put #include : 1 error same above and ask for

i download and put #include but i have tons of errors ....

what a noob i am lol...understand nothing...

pilotak commented 5 years ago

ok above libraries have dependencies, you also need

no need to #include. Just to recap things you need to do:

include

if defined(NTP_SUPPORT) || defined(HAS_RTC)

#include <Timezone.h>

endif

...


- compile with latest ESP8266 core - `ESP generic 4M (1M SPIFFS)` or` LOLIN(Wemos) D1 R2 & mini  4M (1M SPIFFS)` it doesn't matter
- nothing else (pins are correct)

I have just tried it so i know it works. It would be better for you to install PlatformIO core, you don't have to deal with all of those thing, all you would need is to compile - everything else is done automatically.

I also have a custom made PCB which you just put behind the TFT and you ready to go. I will upload it soon with pictures too.

You don't need the RTC it's just for me to have a time really precise even when without internet. If you want cheaper alternative use DS1307 (not temperature compensated, it would be easy to exchange library). I also use super-capacitor as backup for RTC but you could use coin cell battery too. Of course you don't need it at all, it will be synced with NTP that's why it's splitted into macros which you can comment out. (`NTP_SUPPORT` and `HAS_RTC`)

Just a quick note, you must have N-channel (logic level) and P-channel (logic level, and really important to have low on resistance otherwise backlight will be dimmed) mosfets for LED pin, you must not driver it with GPIO! you can use N&P channel combo https://www.onsemi.com/pub/Collateral/NTJD1155L-D.PDF but it is a small package to solder if you don't mind
Electronlibre2012 commented 5 years ago

Hello,

sorry again, but it doesnt compile....lots of error...i used all the libaries you put .

So i decided to try platformio core but i cant download the " get-platformio.py" ! the website doesnt respond : https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py

perhaps i try again tomorow...

thanks for your time and help anyway...

pilotak commented 5 years ago

you can also install with pip install -U platformio

pilotak commented 5 years ago

I also did travis build and that failed due to case sensitive. Could you please try that in case this was the problem. I use Windows where i don't have deal with such a thing

pilotak commented 5 years ago

Below you can find compiled binaries, you can flash them with esptool.py mqtt_weather_display.zip

Electronlibre2012 commented 5 years ago

Hello @pilotak !

thanks again, i see you make yur best! its better but an error occur :

Using 'COM10' as serial port.
Showing logs:
[15:33:58]rd[15:33:59][FS] mounting...
[15:33:59][FS] mounted
[15:33:59][FS] Reading config file...
[15:33:59][FS] Parsing JSON...
[15:33:59]{
[15:33:59]  "mqtt_server": "192.168.1.100",
[15:33:59]  "mqtt_port": 1883,
[15:33:59]  "mqtt_user": "",
[15:33:59]  "mqtt_password": ""
[15:33:59]}
[15:33:59][FS] JSON parsed
[15:33:59][MQTT] Setup
[15:33:59]*WM: [1] getCoreVersion():          2_5_2
[15:33:59]*WM: [1] system_get_sdk_version():  2.2.1(cfd48f3)
[15:33:59]*WM: [1] system_get_boot_version(): 31
[15:33:59]*WM: [1] getFreeHeap():             43696
[15:33:59]*WM: [3] allocating params bytes: 20
[15:33:59]*WM: [2] Added Parameter: mqtt_server
[15:33:59]*WM: [2] Added Parameter: mqtt_port
[15:33:59]*WM: [2] Added Parameter: mqtt_user
[15:33:59]*WM: [2] Added Parameter: mqtt_password
[15:33:59][WIFI] Connecting to: 
[15:33:59]*WM: [1] AutoConnect 
[15:33:59]*WM: [2] Setting hostname: mqtt-weather-display
[15:33:59]*WM: [2] Connecting as wifi client... 
[15:33:59]*WM: [1] STA static IP:
[15:33:59]*WM: [2] setSTAConfig static ip not set 
[15:33:59]*WM: [3] WIFI station disconnect 
[15:33:59]*WM: [1] No saved credentials, skipping wifi 
[15:33:59]*WM: [2] Connection result: WL_NO_SSID_AVAIL
[15:33:59]*WM: [3] lastconxresult: WL_NO_SSID_AVAIL

i have a static ip for my phone on the 192.168.1.100, but i changed i to 101, but the log is identical...

An idea?

pilotak commented 5 years ago

you need to ground IO0 for at least 1s to bring it to setup mode, this will create wifi AP (for creditals please see const.h) once connected with your phone/pc go to web browser, address is http://192.168.4.1 that's where you can setup wifi name, password and MQTT

Electronlibre2012 commented 5 years ago

you need to ground IO0 for at least 1s to bring it to setup mode, this will create wifi AP (for creditals please see const.h) once connected with your phone/pc go to web browser, address is http://192.168.4.1 that's where you can setup wifi name, password and MQTT

yes sorry..of course...already done this on another weather station from Squix78

Thanks i try!

Electronlibre2012 commented 5 years ago

Great it works! but the screen is white....

[16:26:37]*WM: [3] WiFi station enable 
[16:26:37]*WM: [3] enableSTA PERSISTENT ON 
[16:26:37]*WM: [1] connectTimeout not set, ESP waitForConnectResult... 
[16:26:37][WIFI] Disconnected
[16:26:41][WIFI] Connected
[16:26:41][WIFI] Local IP: 192.168.1.111
[16:26:41][MQTT] Connecting to: 192.168.1.100:1883
[16:26:41]*WM: [2] Connection result: WL_CONNECTED
[16:26:41]*WM: [3] lastconxresult: WL_CONNECTED
[16:26:41]*WM: [1] Connect to new AP [SUCCESS] 
[16:26:41]*WM: [1] Got IP Address: 
[16:26:41]*WM: [1] 192.168.1.111 
[16:26:41]*WM: [2] disconnect configportal 
[16:26:42]*WM: [2] restoring usermode STA
[16:26:42]*WM: [2] wifi status: WL_CONNECTED
[16:26:42]*WM: [2] wifi mode: STA
[16:26:42]*WM: [1] config portal exiting 
[16:26:42][WIFI] Ending configuration portal
[16:26:42][TIME] Got new NTP time: 14:25:46 07/09/2019
[16:26:44][MQTT] Connecting to: 192.168.1.100:1883
[16:27:13][MQTT] Connecting to: 192.168.1.100:1883
[16:27:43][MQTT] Connecting to: 192.168.1.100:1883
[16:28:13][MQTT] Connecting to: 192.168.1.100:1883

the screen refresh every minutes but nothing appear...just white screen

pilotak commented 5 years ago

double check wiring, i have uploaded source files

Electronlibre2012 commented 5 years ago

ok i found your page on Github...schématic and more...lol

I have only the time displayed on the screen...i put the automations....triggered them but nothing more the time and not the good one, 2 hours less, i am GMT+4 here.

sorry but i start from a web link of your project and now found your page on Github, and all is explained perfectly...

I need clientraw if i understood well?

pilotak commented 5 years ago

Sorry there was an old automation in README, i have updated it a up to date one.

As for timezone, you need to compile FW by yourself in order to accommodate your timezone and summer/winter daylight saving.

Clientraw is not needed it's just the way where i'm getting forecast from, but it's importat to have forecast icons corretly. It looks like i will have to do a wiki for that because it's not clear

Electronlibre2012 commented 5 years ago

No problem...i am a big noob...

i need an url for clientraw but wich one, i dont understand (again) sorry...

pilotak commented 5 years ago

You would use clientraw component only if you own professional weather station with such an output or it's anywhere near you. Clientraw is type of output for weather station!

You can use any weather forecast available for homeassistant (ie. yr.no) but you just have to adjust what you send to display, please see https://github.com/pilotak/homeassistant-clientraw README.md->Symbol codes

Electronlibre2012 commented 5 years ago

thanks understand for clientraw...

but i dont understand in your automations its sensor.clientraw_temperature_c

so i need to change by sensor.weather_temperature for exemple is i use Yr for weather forecast?

i have nothing for the moment instead the time. (and if i have understand i need to succeed in compile the .ino in platformio with adapt the good GMT).

Electronlibre2012 commented 5 years ago

i modify the automations but seems to doesnt work :

- id: weather_icon_changed
  alias: weather icon changed
  trigger:
    platform: state
    entity_id: sensor.weather_symbol
  condition:
    - condition: template
      value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  action:
    service: mqtt.publish
    data_template:
      topic: display/forecast
      qos: 1
      retain: true
      payload: >-
        {%- set symbol = states.sensor.weather_symbol.state -%} {%- if symbol
        is not none and symbol != "unavailable" -%}
          {"icon": {{ symbol }} }
        {%- endif -%}

a last help please, after i give up... :(

Thanks!

pilotak commented 5 years ago

If you use yr, homeassistant creates new sensor ie. sensor.yr_temperature so your automations.yaml should look:

- alias: Outside temp change
  initial_state: True
  trigger:
    platform: state
    entity_id: sensor.yr_temperature
  condition:
    condition: template
    value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/out-temp"
      qos: 1
      retain: true
      payload: >
        {%- set out_temp = states.sensor.yr_temperature.state -%}
        {%- if out_temp is not none and out_temp != "unavailable" -%}
          {{ out_temp }}
        {%- endif -%}

and so on with a difference in symbol which you will have ie. sensor.yr_symbol = 4 and you will have to translate (in payload of it's automation) to number 2 and cloudy picture will be loaded. You can simulate this in homeassistant under section MQTT->Publish a packet. Topic = mqtt-weather-display/forecast Payload = 2

I just had a look into timezone library and there seems to be a posibility to change a timezone on the fly so might add parameters to config to change that but that is a far future.

pilotak commented 5 years ago

look again in payload, i wrote that it was an old automation in readme, i uploaded a new

Electronlibre2012 commented 5 years ago

Thanks! it works for the manual part

Topic = mqtt-weather-display/forecast
Payload = 2

i have a cloud up left corner, and dont know why a house left down corner and a energy symbol right down corner? what is it for? home presence ?

thanks a lot for your patience and time!

i have still no value of temp or humidity but i will work on it tomorow!

pilotak commented 5 years ago

Glad you got it working. Don't give up you nearly there. If you only have a problem with time i can compile different timezone for you.

House left down in meant to be indoor temeprature (°C will be appended) and the flash is energy consumption (W will be appended) - i have a power meter mounted in fuse box

Outside temp:

Topic = mqtt-weather-display/out-temp
Payload = 12.5

Outside feels like temp (once you know how to compile, you can change that to humidity):

Topic = mqtt-weather-display/out-temp-feel
Payload = 11.5

Inside temp:

Topic = mqtt-weather-display/in-temp
Payload = 21.7

Power consumption:

Topic = mqtt-weather-display/power
Payload = 1685

Night mode

Topic = mqtt-weather-display/night
Payload = 1 or 0
- alias: Turn on night mode
  trigger:
    platform: time
    at: '00:00:00'
  action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/night"
      qos: 1
      retain: true
      payload: 1

- alias: Turn off night mode
  trigger:
    platform: time
    at: '06:00:00'
  action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/night"
      qos: 1
      retain: true
      payload: 0
Electronlibre2012 commented 5 years ago

Thanks a lot,

yes i ll try to compile but i am new in platformio...i have to learn a lot!

If you can compile a time zone like your previous .bin but +2 hours it will be great!

Thanks again! Nice work and nice project!

PS : i am on windows too and it seems to be the problem with this project...

pilotak commented 5 years ago

i need to know more about your timezone https://github.com/JChristensen/Timezone/blob/a9134007b3c5a5274450474343bcabe06bc16292/examples/WorldClock/WorldClock.ino#L23

shortcut (letters), when it's changing to summer time and when to standar time and hour & minute offset

Electronlibre2012 commented 5 years ago

its UTC +4

there is no change for summer ;) its always summer here, i am at RĂ©union Island in Indian Ocean, between Madagascar an Mauritius

Thanks!!!!!!

pilotak commented 5 years ago

Wow what a beatiful island, please try below mqtt_weather_display_RET_noDST.zip

Electronlibre2012 commented 5 years ago

thanks!!! your the boss! its good time now!

i learn on platform io now...there is 3 errors in the file weather-station about the include...need library installed with vcpkg ans VS Code said he dont find Arduino ide path...lol

pilotak commented 5 years ago

you only need to install PlatformIO core with PIP and in cmd enter:

Electronlibre2012 commented 5 years ago

ok i ll try your way, perhaps easiest than Platformio IDE... ;)

Electronlibre2012 commented 5 years ago

hey, i succeed with the automation :

- id: weather_icon_changed
  alias: weather icon changed
  trigger:
    platform: state
    entity_id: sensor.weather_symbol
  condition:
    - condition: template
      value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/forecast"
      qos: 1
      retain: true
      payload: >-
        {%- set symbol = states.sensor.weather_symbol.state -%} {%- if symbol
        is not none and symbol != "unavailable" -%}
          {"icon": {{ symbol }} }
        {%- endif -%}

my actual payload is code 3 (clouds) but the icon displayed is 0 (SUN)...an idea?

Electronlibre2012 commented 5 years ago

i have a look to your automation.yaml and deleted "icon" and now it works! yes

But still not work for the temp in / out value...

i modify the "payload: >-" to "payload: >" and the "condition: template" after "condition:" without a "-"

pilotak commented 5 years ago

What means "not work" where exactly did you fail? have you tried it through homeassistant publish packet service? i have it works!

ha

Electronlibre2012 commented 5 years ago

yes it work with through homeassistant publish

but when i triggered the automation it doesnt work for temp (in or ou) value, nothing append

i use :

- id: out_temp_changed
  alias: out temp changed
  initial_state: True
  trigger:
    platform: state
    entity_id: sensor.weather_temperature
  condition:
      condition: template
      value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/out_temp"
      qos: 1
      retain: true
      payload: >
        {%- set out_temp = states.sensor.weather_temperature.state -%}
        {%- if out_temp is not none and out_temp != "unavailable" -%}
          {{ out_temp }}
        {%- endif -%}

sensor.weather_temperature is at 17.7°C but it doesnt published when i triggered manualy this automation...dont understand why...

and if i try manually :

Topic = mqtt-weather-display/out_temp
Payload = states.sensor.weather_temperature.state

its display 0.0°C

same with

Topic = mqtt-weather-display/out_temp
Payload = sensor.weather_temperature.state

or

Topic = mqtt-weather-display/out_temp
Payload = out_temp

so i am stuck again...

any idea?

Thanks!!!!!!!!!!

pilotak commented 5 years ago

if you want to read data from sensor you need to use template

Topic = mqtt-weather-display/out_temp
Payload = {{ states.sensor.weather_temperature.state }}
Electronlibre2012 commented 5 years ago

yes i try, i read the mqtt page...it doesnt work in automation, just in manual...

When i triggered the automation, it doesnt work...i have the same :

action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/out_temp"
      qos: 1
      retain: true
      payload: "{{ states.sensor.weather_temperature.state }}"

i even try with

payload_template: "{{ states.sensor.weather_temperature.state }}" 

doesnt work

and

action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/out_temp"
      qos: 1
      retain: true
      payload: {{ states.sensor.weather_temperature.state }}

(whitout quotes) generate an error and HA wont restart

pilotak commented 5 years ago

you are mixing two things

This is for publish a packet under MQTT

Topic = mqtt-weather-display/out_temp
Payload = {{ states.sensor.weather_temperature.state }}

does this work if you put as payload number 0?

Automation

This is a minimal config

- alias: Outside temp changed
  trigger:
    platform: state
    entity_id: sensor.weather_temperature
  action:
    service: mqtt.publish
    data_template:
      topic: "mqtt-weather-display/out-temp"
      qos: 1
      retain: true
      payload: >
        {%- set out_temp = states.sensor.weather_temperature.state -%}
        {%- if out_temp is not none and out_temp != "unavailable" -%}
          {{ out_temp }}
        {%- endif -%}

note > after payload, you can try templates in HA too, just where you have a MQTT, there is a bookmark templates where you can try ninja2 template

You can't trigger automation by yourself, sensor.weather_temperature needs to change its value in order for this automation to run

Electronlibre2012 commented 5 years ago

yes understand. This is for publish a packet under MQTT : works perfect with 20.0 for exemple or {{ states.sensor.weather_temperature.state }}

In automations : there is the choice to triggered it manually, it doesnt work in this case?

I m used to test my automations like that...you confirm?

I see, you delete the condition...understand!

I want to do like this because there is nothing instead the hours on the TFT when i power on. Or i can do another automation to force the value perhaps, like envery 5 minutes...

pilotak commented 5 years ago

of couse you can do time trigged automation.

The whole point is to use retain: true. On every connection to MQTT, display will pick the latest data you sent there with homeassistant

Electronlibre2012 commented 5 years ago

i publish in_temp and out_temp manually : ok : value are displayed and good ones.

i modify automation for time triggered 5 minutes :

- id: in_temp_changed
  alias: in temp changed
  trigger:
    platform: time_pattern
    minutes: "/5"
  action:
    service: mqtt.publish
    data_template:
      topic: mqtt-weather-display/in_temp
      qos: 1
      retain: true
      payload: >
        {%- set in_temp = states.sensor.temperature_158d000349c288.state -%}
        {%- if in_temp is not none and in_temp != "unavailable" -%}
          {{ in_temp }}
        {%- endif -%}

I wait for automatic triggered, 15 minutes, see it triggered 3 times but nothing change on the display...

If i publish manually the temp go from 21.1 to 20.9°C on the display...good value again!

So, sorry to insist but automation doesnt work...something wrong

any idea? i m near to give up lol...8 hours today for a little result...lol

PS : strange thing for me : forecast automation is ok, but none of the automations temp works...

pilotak commented 5 years ago

Wrong mqtt topic should be mqtt-weather-display/in-temp

Electronlibre2012 commented 5 years ago

that'it! your the boss!!!

Thanks a lot, now i stop to disturb you!

Thanks again for your time and patience, you are a good person, really!

pilotak commented 5 years ago

No problem, hope you find this display useful as me.

Electronlibre2012 commented 5 years ago

Hello,

now its work like a charm but....

my 2 gateway mio xiaomi bug...no responding when the automations are ON....

i dont understand why...i think i will stop this project now...

If you have an idea that what could interfer betwin xiaomi gateway and the mqtt publishing...i will be happy to heard you...

have a good night

pilotak commented 5 years ago

have you got any devices connected to MQTT other than this display??

Electronlibre2012 commented 5 years ago

no

Le lun. 9 sept. 2019 Ă  10:24, Pavel S notifications@github.com a Ă©crit :

have you got any devices connected to MQTT other than this display??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pilotak/mqtt-weather-display/issues/1?email_source=notifications&email_token=AL4SIWLRWTHA6RD4AG7DZKLQIXT3FA5CNFSM4IPHF6PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6GL6FQ#issuecomment-529317654, or mute the thread https://github.com/notifications/unsubscribe-auth/AL4SIWJKULDSOFOL5CJILWTQIXT3FANCNFSM4IPHF6PA .

Electronlibre2012 commented 5 years ago

i have stop the automations and no more problem...i really dont understand what the weather station with mqtt do with the xiaomi gateway....

Le lun. 9 sept. 2019 Ă  10:24, Pavel S notifications@github.com a Ă©crit :

have you got any devices connected to MQTT other than this display??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pilotak/mqtt-weather-display/issues/1?email_source=notifications&email_token=AL4SIWLRWTHA6RD4AG7DZKLQIXT3FA5CNFSM4IPHF6PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6GL6FQ#issuecomment-529317654, or mute the thread https://github.com/notifications/unsubscribe-auth/AL4SIWJKULDSOFOL5CJILWTQIXT3FANCNFSM4IPHF6PA .

Electronlibre2012 commented 5 years ago

sorry i have a zigbee dongle zigbee2mqtt but for the moment nothing link.

Electronlibre2012 commented 5 years ago

i saw 2 connections on mqtt : one is the ip 192.168.1.112 is adresse of the weather station and the other is 172.30.0.2...i dont know exactly what is it...i read the docker container thing like that....because my mosquitto server mqtt is on my hassio...

Le lun. 9 sept. 2019 Ă  10:24, Pavel S notifications@github.com a Ă©crit :

have you got any devices connected to MQTT other than this display??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pilotak/mqtt-weather-display/issues/1?email_source=notifications&email_token=AL4SIWLRWTHA6RD4AG7DZKLQIXT3FA5CNFSM4IPHF6PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6GL6FQ#issuecomment-529317654, or mute the thread https://github.com/notifications/unsubscribe-auth/AL4SIWJKULDSOFOL5CJILWTQIXT3FANCNFSM4IPHF6PA .

pilotak commented 5 years ago

try create another login to Mosquitto so that dongle has it's own and display has it's own there could a collision. This is more likely problem with HA not with display i have 10 devices connected to MQTT with no problem and same credentials. Have tried to unplug the dongle?

pilotak commented 5 years ago

also set password for new login in case you don't have it. Don't forget to ground IO0 to change mqtt setting