-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AskSin++ for ESP MCU's (ESP32, ESP8266) #26
Comments
What's the need of using an ESP? Btw: An ESP is more expensive than a Mega328 and has a higher power consumption. |
There is no plan to add support for ESP MCU. You can try by yourself. The implementation of the STM32 port may give you hints where changes are needed. You can search for the ARDUINO_ARCH_STM32F1 define. It is used to integrate STM32 specific code. You should also look into the examples/stm32 folder, how the basic setup is done to use the STM32 stuff. |
Just for curiosity: What is the state of the stm32 port? Is this work in progress, or have you already used it to build a halfway working homematic device? |
The Switch example works very well. I plan to use the STM32 for a RGB dimmer, because it has more usable PWM pins. In the master branch there is also support for external EEPROMs (AT24C32) now. So the Flash-Hack for storing settings is no longer needed for STM32. |
Can you recommend this board for first steps with an STM32? Or another? |
This board is fine. I use it with an ST-Link for programming and debugging (inside Eclipse with OpenOCD-Plugin). You can also use the Maple Mini Board. It can be used like an Arduino - uploading the code by using the USB-Connection. It also has more flash memory (128k). There is a STM32duino Webpage with a lot of information. |
That's great. Thanks! |
Is it maybe possible that asksin++ can run on a STM8? |
Thanks guys for sharing your opinion and giving feedback. Just to answer to the question why I use ESP (32 or 8266, 8285) MCU's. I think they are perfect and very cheap IoT devices (WiFI & BTLE and an RTOS for free). They are fast and cheap (1,90 to 4€), so there is not a reason to talke about the price, they are all between 1,70 to 4,x€. Back to my request: Since I got the feedback, that ESP will not be supported, I will try first a supported MCU like the STM32. I have order already 10pieces meanwhile before I try to implement the ESP by myself, which I guess is not just easy (not having the background as the lead developer). I have not find any other good BidCos library to start for ESP MCU's. BTW: Another short question: As far as I have understood, AskSin expects an TI CC1101 transceiver right? I have a couple of RFM69 and RFM95 (868MHz) which are supposed to support better range and more transmission power (20db). How difficult is it to support also RFM transceiver like RFM69/95? Thanks! |
STM8 is not possible because there is no C++ compiler available and the library makes heavy use of C++. |
To replace the C1101 with any other hardware you need to implement the public API of the Radio class. To use your own implementation in a device you have to replace the Radio class in the HAL type def. In the FHEM Forum there are already some information about using RFM69 for Homematic. |
I'm working on a support for ESP32 and have resolved already most of the files. Currently I'm stuck at the AlarmClock class. The ESP32 seem to have quite good timer/internal RTC support but the class is probably to difficult for me to change. |
What is your problem with AlarmClock ? You only need to change Sysclock::init(), enable() and disable(). It generate TICKS_PER_SECOND interrupts. Same for RTC it should interrupt once per second. |
Why not use the ESP32 for your demanding e-paper application, use the AVR for Bidcos and connect them via SPI or any other interface that suits your needs? Guess that would be much less work than porting AskSinPP to ESP32. Just my opinion :) |
@pa-pa: Since you wrote the Alarmclock, you anderstand it. I have not yet understood it, thus it's not easy for me to change even the few methods. But I will look further if I find something from somebody before I give up using Asksin and switch to LoRa (MySensors has support for ESP32 + RFM95). I dont think it's the best solution to use two MCU's just one for the display. At least I don't really want to do it. But thanks for the idea! |
ok guys, I got something working with ESP32! I also have complete understanding problems with the RTC class: I hope you can and are willing to help so that I can successfully complete the AskSinPP ESP32 support. So far it looks already promising! below is the ESP32 serial monitor output.AskSin++ V2.1.3 (May 13 2018 20:08:54)
-> 13 76 A0 01 FD0001 345678 00 08 02 01 0A FD 0B 00 0C 01 - 22750 debounce debounce debounce ignore 0B FC A0 01 FD0001 5540A7 01 0E - 153533 |
This looks very good. The RTC is only needed for AVR because the "normal" timer is not usable when the CPU is in deep sleep mode. So for ESP you can ignore it. The storage class has to implement some persitent storage. For AVR we use the internal EEPROM. On STM32 there is a "hack" to use the flash as EEPROM od use the external at24c32/64 class to store the data into an external EEPROM. See stm32/HB-DoorBell example. |
@pa-pa : Thanks for your advise. I'll ignore the RTC class. because ESP have a working RTC time in deep sleep (5uA) and wake it up by itself afte every 30seconds or a minute and send the temp/hum/press values. Basically it does a restart after every deep sleep and run though the whole setup again. |
@knopserl Great, what you have done so far!
That means, that your message counter always starts with Maybe you should put the last value of the message counter to EEPROM or a config file in SPIFFS.
This is ok. It's a magic with the prefix |
As already written the restart will give problems. But the low-power code can wait until the rest of the systems works. |
@pa-pa thanks again for still helping me further. I admit, that I'm far from understanding a couple of the classes and still need some more hints from you. Hope you don't get bothered - just tell me then I'll stop asking :-) @jp112sdl Also thanks for your hints. Were do I get the message counter and how to restore? I have to explore the deep sleep mode of the ESP32 a little more, but I'm pretty sure that deep sleep or power off will cause a complete restart after wakeup. |
forgot to ask some more questions (in addition to the questions in my last post): |
The door bell example doesn't use any sleep code. There is a message type for for sending a timestamp. But I have never seen that message. The lib has also no code to handle this. |
Ok the key question is now if the Homematic/AskSin protocol/library is still a good choise for my relativly simply use case? It's all about good quality climatic sensors (two: SHT31, BME280) battery usage with thus with an energy efficient display (e-paper). I want to show set temperature, current temp/hum/press and date/time. Should not be rocket sience. So what is currently open: If I want to save power, I have to set the ESP in any sleep mode. I have three main options: light sleep (0.8mA = 800uA), deep sleep (5uA) and power off 0.1uA or 800nA). I'm wondering how e3Q does it with their thermostat and the LCD display (I think they use an STM MCU) and the display is updated at least once a minute. So what are your hints? |
You have two simple options. Use a supported hardware or port the library. |
Something like that I was suggesting earlier, using ESP32 for e-paper and AVR for Bidcos. |
@pa-pa before I switch to another transmission protocoll(not using AskSin): I kindly ask for a further hint: I should call the tigger(..) method before I go to light sleep. Heer is my setup and loop initDisplay(); const GFXfont* f = &FreeMonoBold12pt7b; sdev.initDone(); //---------------------------------------------------------------------------------- |
You can simply use the sysclock and convert the seconds to ticks. Then the trigger will called by the sysclock. if( worked==false && poll==false) { |
Thanks for your patience and your further hints. I'm trying to follow your hints but I#m not sure if I can follwo you. So here is the Sleep class and I have only changed/partially understood the doSleep part. #ifdef ARDUINO_ARCH_ESP32
} template |
doSleep should pause the CPU as long as possible. It gets the ticks until the next timer is ready to work. For ESP it may look like this:
|
the question was more on the Sleep class declaration which gives compile errors: #ifdef ARDUINO_ARCH_ESP32 I get this error: class Sleep : public Idle { so it look to me, that the "idle" is not known and that comes from the the LowPower class (which is not ESP compatible) or from the Activity class itself? |
Ah, you don't need to inherit Idle. So you also don't need to use a template.
|
Hey pa-pa, that was helpful and what I was looking for. The full declararion of the sleep class inclusing the uint32_t sleeptime = ticks2millis(ticks) because otherwise I would have required the redefinition of the period_t from the LowPower.h (which I actually don't need anymore). The class has now compiled without errors but when I use it the the main program I get still a few errors D:\mcdev\arduino\portable\sketchbook_ESP32\ESP32_HM-WDS10_ePaper\ESP32_HM-WDS10_ePaper.ino: In function 'void loop()': ESP32_HM-WDS10_ePaper:334: error: 'as::Sleep' is not a template here is what the class Sleep() looks like, but I'm sure I have also remove some code from the powerSave method (like dealing with offset and correct millis2ticks or so) #ifdef ARDUINO_ARCH_ESP32
} template |
The Sleep class is no longer a template. Simply change the loop call to hal.activity.savePower<Sleep<>>(hal); Please add also a empty method static void waitSerial () {} to your Sleep class. This is on AVR for waiting that the serial buffer is empty before got to sleep. May be not needed on ESP. |
I added the empty wait serial and one error is gone. ESP32_HM-WDS10_ePaper:334: error: 'as::Sleep' is not a template AI added a picture of my prototype I'm using for this testing. I'm also working with ransey (he is doing a couple of very good PCB's for e.g. MapleCUL/CUN and mySensors) to get a PCB for the ESP32 using this kind of small boards to build Homematic, ESPnow or LoRa solutions with a single PCB layout. |
Sorry Cut&Paste error. It has to be hal.activity.savePower< Sleep >(hal); |
Ok, done. There are still some things which do not fit. Something around the Saver template class in hal: D:\mcdev\arduino\portable\sketchbook_ESP32\ESP32_HM-WDS10_ePaper\ESP32_HM-WDS10_ePaper.ino: In function 'void loop()': ESP32_HM-WDS10_ePaper:334: error: no matching function for call to 'as::Activity::savePower(Hal&)' D:\mcdev\arduino\portable\sketchbook\libraries\AskSinPP/Activity.h:212:8: note: candidate: template<class Saver, class Hal> void as::Activity::savePower(Hal&) |
Sleep is needed as template argument to the savePower() method. |
that compiles without error! thanks. One reason might be, that I have to replace the rtc.add by sysclock.add(*this) here:? But since I don't see trigger gets called, it might not change/solve the problem? Is it that setting in the sketch? I have not seen this interval been followed. Attached the startup log (with some loop log lines with no sleep) and I have also attched my Activity.h and my sketch if you're willing to take a look. It is derived from the HM-WDS10-TH-O sketch. rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
I had a short look into the code. You need to replace the rtc with the sysclock, because the RTC is not implemented. See also the HM-WDS100-C6-O-2 example. It doesn't use the RTC. |
should I then rather use then the HM-WDS100-C6-O-2 as template rather then already used HM-WDS10-TH-O? Or just go ahead and exchange the RTC with sysclock? And I hope the trigger() is then called. |
May be switching the example is more easy. |
Ok, I'll try it with the HM-WDS100-C6-O-2. Any answer to the transmissing of float values? I have so far seen only values from type int. Is there something to consider as I looks like its avoided in the samples? |
You only can transmit int values. |
@jp112sdl thanks! I have already assumed something like that and was considering a multiplier by 10, but was wondering how to tell the typical receiver I'm using (e.g. HomeGear, RedNode, OpenHAB) ,that the values are float/decimals and have to be divided by 10. |
Hello, I urgently need a library to build homematic devices, which are not available by Homematic.
I was happy to find AskSin or AskSinPP.
I need to work with ESP (Espressif) MCU's preferable ESP32 and unfortunatly AskSinPP does not support it.
I have commented out alls avr/... libs, EnableInterrupt.h, LowPower.h, as they are all not compatible with Espressif MCU's. I guess they might also not required (as the ESP32 has featues already in the internal RTOS)?
So would it be possible to get a AskSinPP version which supports ESP32/ESP8266 MCU's which are the MCU's my friends and myself are using for mos projects?
I'm using boards like: WeMos Lolin32
https://www.aliexpress.com/item/4-MB-Flash-WEMOS-Lolin32-V1-0-0-WIFI-Bluetooth-Card-Based-ESP-32-ESP-WROOM/32823891656.html
https://www.aliexpress.com/item/LOLIN32-Wifi-Bluetooth-Development-Board-Antenna-ESP32-ESP-32-REV1-CH340-CH340G-MicroPython-Micro-USB-Lithium/32846143452.html
Anything I can do to create motivation (e.g sponsor you boards?) :-)
regards Heinz
The text was updated successfully, but these errors were encountered: