maccoylton / homekit_wifi_thermostat

A thermostat for controlling central heating - on and off trigger switching the heating on and off via events in the home app to a switch accessory
Apache License 2.0
17 stars 11 forks source link

restarts problem #1

Closed Kristian8606 closed 5 years ago

Kristian8606 commented 5 years ago

With what esp you use this code? My esp will restart if the display is connected.

maccoylton commented 5 years ago

I use the ESP8266MOD AI-THINKER

maccoylton commented 5 years ago

Here's a picture of the prototype, you can see the temperature, humidity, target and mode on the screen

img_2310

Kristian8606 commented 5 years ago

Wonderful! I still can not understand why my esp is restarted when the display is connected

Kristian8606 commented 5 years ago

b9a635a5-a47b-49af-9b5b-ee5b9236f0b8 ![Uploading 512C6679-C981-433A-AAF2-590DE718E012.jpeg…]()

Kristian8606 commented 5 years ago

972ba576-3552-4c95-af54-fbdd89ce0b53

Kristian8606 commented 5 years ago

I get a white screen and constant restart Could the problem be in the display model?

it works with other examples ssd1306

maccoylton commented 5 years ago

What resolution is your screen, mine is 128x64

Do you have enough power? I use a separate 1A power supply?

Difficult to tell from your picture but the wiring doesn't look the same as in mine, therefore I suspect you are not running the firmware as provide but something you have compiled yourself, the issue could in your code, compile or library version related.

The firmware requires the SCL to be connect to pin 14 and the SDA to ping 4. The temperature sensor a DHT22 is on pin 4

maccoylton commented 5 years ago

Also assuming based on the example code you posted https://github.com/maximkulkin/esp-homekit-demo/issues/143#issuecomment-439689728 I'd recommend changing the stack size to 512 rather than 256 on the screen task, seem to remember having problems with that

Kristian8606 commented 5 years ago

for my convenience connected pin 5 and 4 but i tried even pin 14 but the problem remains. The power supply is 2 А

maccoylton commented 5 years ago

so does the call to create task use 256 of 512 in the code your are running?

Kristian8606 commented 5 years ago

I'm using your code. My code was just a try

Kristian8606 commented 5 years ago

which library you use

maccoylton commented 5 years ago

can you try wiring as per my setup and flashing the compiled firmware .. that will tell us if its a compile problem

Kristian8606 commented 5 years ago

dad0ee4b-1bd0-478a-a2a4-259de9817dcf

Kristian8606 commented 5 years ago

define I2C_BUS 0

#define SCL_PIN  14
#define SDA_PIN  5
Kristian8606 commented 5 years ago

your code with the same wiring

Kristian8606 commented 5 years ago

SDA -> pin 5 SCK -> pin 15

maccoylton commented 5 years ago

Are you powering this off your programmer? Not recommended if you are. I always use a separate power supply.

Is his my .bin file flashed using the OTA mechanism or did you still build and flash your own .bin?

BTW above I assume above you mean SCL -> pin 14 ... not SCK -> pin 15

Kristian8606 commented 5 years ago

SCL -> pin 14 sorry. I am currently powered by power supply 2a I do not use the OTA mechanism, I use a flash programmer i run your code.

Kristian8606 commented 5 years ago

094c4b30-9d0b-4203-8b36-f28092e93ac2

consumption does not exceed 110 ma

maccoylton commented 5 years ago

So I would recommend you flash the BIN file using the OTA mechanism and then report back what happens

Kristian8606 commented 5 years ago

I apologize for the stupid question but can you refer me to flash tips through OTA

maccoylton commented 5 years ago

follow the wiki :- https://github.com/maccoylton/homekit_wifi_thermostat/wiki let me know if its not clear and I'll update it

Kristian8606 commented 5 years ago

I succeeded through OTA thanks! Is it possible to make small changes to the code? I tried uploading a BIN file with minor changes to my storage but ESP failed. Can you help me upload my BIN file through ОТА?

maccoylton commented 5 years ago

I'm happy to take code improvements if they are in line with what I am trying to achieve.

You could fork, makes your changes and then flash from your own GitHub repository

Otherwise if you just want to do a flash without the OTA then you would need to change the makefile, I suspect previously your were flashing to the wrong base address

Kristian8606 commented 5 years ago

your code is great and I am very happy. The only change I want to make is to change the font size. when I change font_builtin_fonts [16] I compile and do OTA from my repository then OTA continues for hours without success.

maccoylton commented 5 years ago

For your forked repository did your erase the flash completely and start again?

The other possibility is there is a bug in the OTA firmware, described here:- https://github.com/HomeACcessoryKid/ota/issues/3 that can sometimes cause it to loop. HomeACcessoryKid is woking on a new version which I will move to soon, and can be found here:- https://github.com/HomeACcessoryKid/life-cycle-manager

I am working on a screen layout with ICONS rather than words, hope to have that down in a week or two.

Kristian8606 commented 5 years ago

I follow the instructions step by step. only your BIN file is running from my or your storage, but if I make only one font correction then OTA is running for hours without success

maccoylton commented 5 years ago

To be clear when you switched to your repository, you erased the flash completely, re-flashed the OTA firmware and then installed you BIN OTA? If so then you are likely encountering the bug mentioned above in the OTA

Kristian8606 commented 5 years ago

to do all the steps.   Your BIN has successfully fired from my storage several times. but when I create my BIN based on your code but with a font change, OTA fails

maccoylton commented 5 years ago

ok .. I hope to have a new version with graphics on screen rather than text very soon.

In the meantime try flashing your IN directly using this something like this:-

python /Library/Python/2.7/site-packages/esptool.py -p /dev/cu.usbserial --baud 230400 write_flash -fs 8m -fm qio -ff 40m 0x2000 main.bin

the important bit it to flash it starting at address 0x2000

maccoylton commented 5 years ago

New layout with icons and larger text implemented, give it a bash and see what you think

Kristian8606 commented 5 years ago

Great! Thanks for the wonderful work. I have two thermostats I intend to replace with your project, but for the beginning I will have to understand why OTA does not work from my storage. I will add a status change button if you did not add a configuration reset option. I have not yet seen what happens if I remove the thermostat home while offline. Will it be possible to select another WIFI connection if necessary? Also I will need a relay control pin. Once again, I thank you for the help and the nice project.

maccoylton commented 5 years ago

Great.

I plan to update the button handling to include and option to reset configuration. Until I do this, for now if you remove from home while offline, you would the need to erase the flash and start as if a brand new device.

I suspect the issue with OTA on your own repository is ether you are not completely erasing the flash prior to starting or it's the aforementioned bug in the OTA firmware, for which we will need to for the next version of HomeACcessoryKid

Kristian8606 commented 5 years ago

Hello! Based on yours code, I was able to make an example I added a button to restart the configuration, I formed the display in my style. I will finish the button will add a pin that will be connected to the arduino. At command, the arduino will send a nRF24L01 signal to another arduino to which a heater control relay will be attached. Is my question possible to send a command instead of an arduino to another ESP through a UDP protocol, you can help me? https://github.com/Kristian8606/homeKitThermostat

maccoylton commented 5 years ago

Not sure why your are going down the route of using an nRF to talk to a relay. If you want a wireless connection between the thermostat and the relay why not just use HomeKit end to end. In my case Inuse a sonoff basic running the my firmwaress the relay controlling the heater.

Kristian8606 commented 5 years ago

From translate i don't understand how you performed the thermostat wirelessly

Kristian8606 commented 5 years ago

I would like the display and the sensor to be away from the heater. Also, the thermostat should be independent of the iPhone and the internet, but can be managed by the iPhone

maccoylton commented 5 years ago

Homekit has the concept of a hub, this would be either an AppleTV or an iPad,so long as this hub device is at home then you can control devices while away from home, but also the hub will run any automations you have set up for you. So in my case the thermostat sends events, my AppleTV picks up those events and processes them. So if the thermostat sends an event for mode heat the appletv will then trigger an automation based on that event, which tells the relay to turn on. You can also have automations to tigger events. So my AppeTV triggers events at different times of the day to vary the temperature based on when I'm normally home, when I go to ded, when I get up etc

Kristian8606 commented 5 years ago

I understand, but that's not my goal

Kristian8606 commented 5 years ago

I pressed the buttons very quickly to increase and decrease the temperature and the ESP restarts. What could be the reason for this error?

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 2292, room 16

0x40100000: _stext at ??:?

tail 4 chksum 0x57 load 0x3ffe8000, len 772, room 4 tail 0 chksum 0x0b csum 0x0b

rBoot v1.4.0 - richardaburton@gmail.com Flash Size: 8 Mbit Flash Mode: QIO Flash Speed: 40 MHz rBoot Option: Big flash rBoot Option: RTC data

Booting rom 0. pp_task_hdl : 3fff0720, prio:14, stack:512 pm_task_hdl : 3fff0010, prio:1, stack:176 frc2_timer_task_hdl:0x3fff4ae0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Nov 29 2018 20:32:36 phy ver: 273, pp ver: 8.3

wifi_config: Initializing WiFi config wifi_config: Found configuration, connecting to Cveti Calling screen init fonts count 26 Screen Init SDK version:0.9.9 Screen init called manuf='Kristian8606' serial='84:F3:EB:B1:BB:EC' model='homeKitThermostat' revision='0.3.1' c#=3001 mode : sta(84:f3:eb:b1:bb:ec) add if0 Got readings: temperature 26.2, humidity 23.4 scandone add 0 aid 4 cnt