BlackboardT5 mit ESPEasy!

Begonnen von Reinhart, 24 Januar 2016, 10:46:49

Vorheriges Thema - Nächstes Thema

Reinhart

BlackboardT5 mit ESPEasy!

Angeregt durch ein Posting eines Users hier im Board habe ich mir bei den Chinesen 3 Stück Blackboard T5 gekauft. Das Blackboard ist ein Lernboard und man kann es auch auch als Kinderspielzeug bezeichnen, mit einer chinesischen App kann es per Internet gesteuert werden. Ansonsten erfüllt es keine sinnvollen Funktionen. Die Platine selbst ist durch den dunklen Schutzlack nicht schön gelungen und sieht schon im Neuzustand wie repariert aus. Bei den paar Euros kann man das aber verkraften. Die anfängliche Euphorie war schnell vorbei, als ich mir die die App in chinesischer Schrift genauer betrachtete und Misserfolge hatte die App zu mit der Cloud zu verbinden. Ich kenne zwar einen Kollegen der perfekt chinesisch spricht, aber schon alleine die Tatsache das die App eine chinesische Cloud benutzt um die Daten dort zu speichern (ähnlich Netatmo) macht mir keine besondere Freude. Einkaufen ja, aber Daten speichern eindeutig NEIN.

(http://up.picr.de/24376577gx.png)
hier die Ansicht des Original Blackboard T5, die Vorderseite ist ja noch ansprechend.

Auf der Suche nach einer Dokumentation oder einem Schaltplan wurde ich doch noch belohnt und musste feststellen, das der eingesetzte 8266-13 hier eigentlich nur die Wlan Verbindung herstellt und sonst keine weiteren Aufgaben zu erfüllen hat. Der Rest der IOs läuft über einen STC Chip.

(http://up.picr.de/24376579kw.png)

Das T5 hat aber einiges an Board wie 1 Relais, 1 x Temperatur, 1 x Luftfeuchte 3 x Farbleds und einen Kameraanschluß.

Um das Board nun für einen Smart Home User nutzbar zu machen habe ich daher einige Modifikationen an der Platine durchgeführt.
Mit einem Cuttermesser wurden die Beinchen des STC vorsichtig durchtrennt und der Chip von der Platine entfernt. Insgesamt sind jetzt drei Drahtbrücken notwendig um den 8266 zum Leben zu erwecken.

- Der Transistor T3 wird zur Spannungsversorgung des 8266 verwendet, also muss sein Gate auf Masse gelegt werden.
- den DHT11 an Pin2 schließen wir an IO2 des 8266 an.
- IO13 des 8266 wird zur Ansteuerung des Transistors T1 benutzt, der schaltet uns dann ein Relais mit potentitalfreien Kontakt.


Die Drahtverbindungen sind schnell gemacht, man braucht lediglich eine zitter freie Hand.

(http://up.picr.de/24376580ig.png)
hier oben die Verbindung des DHT11 Pin3 Data mit GPIO2 Pin3 des 8266.  Die 2. Verbindung von GPIO13/Pin14
geht an den 10K Vorwiderstand des Transistor 1.

(http://up.picr.de/24376576sd.png)
ich habe dazu die senkrechte Leiterbahn hinter dem STC benutzt. Sie liegt parallel zu den Beinchen 9-16 und ist leicht erreichbar.
Der linke untere Draht sitzt direkt auf dem linke Ende des Widerstand unterhalb des Transistors 3 und geht an die Durchkontaktierung neben dem Kondensator (Masse). Er steuert den Transistor für die Spannungsversorgung des 8266.



ESP8266-14 flashen

Nachdem die 3 Drahtverbindungen erfolgreich hergestellt wurden, schließen wir einen RS232 Konverter an das Blackboard an. Nicht vergessen RxD und TxD zu kreuzen und die Masseverbindung anstecken. VCC des RS232 Konverters brauchen wir nicht. Nun noch den Jumper IO0 auf Masse stecken wie im Bild abgebildet.

(http://up.picr.de/24376682gu.png)
Jumper für den Upload des Sketch

(http://up.picr.de/24377045bo.png)
Der RS232 Konverter wird an die rechte Seite der Jumperleiste aufegsteckt.

Nun die Batterien einlegen und den Schalter auf "on". Die Ardiuno  Software 1.6.5 starten (Adafruit Huzzah als 8266 auswählen) und den Sktech ESPEasy R048 flashen. Ich habe bereits die richtigen Parameter meines Wlan Zugangs im Sketch eingetragen, somit kann ich sofort nach dem Upload auf das Webinterface zugreifen.


(http://up.picr.de/24376937kh.png)
Konfiguration der beiden Devices in ESPEasy


Im Anhang der Schaltplan. Die rot eingezeichneten Verbindungen sind die Modifikation damit der 8266 nutzbar wird.
Die Einbindung in Fhem habe ich hier und hier (Befehlsausgabe) bereits beschrieben.
Jene die so ein Blackboard besitzen und es in der Schreibtischlade liegen haben könne es jetzt wieder auspacken.

Wünsche gutes Gelingen!
Reinhart


FHEM auf Raspy4 mit Bullseye + SSD, Homematic, ESP8266, ESP32, Sonoff, eBus, NanoCUL, MapleCUL, , MQTT2, Alexa

immi

Hi Reinhart
I ordered it also, but still has not arrived.
While waiting, I found the source code of the STC Chip.
I also cannot read the chinese comments, but code is more or less readable.
As far as I understand, the esp is used only to stream the data to the cloud.
The STC does not need much power from the attached battery. The STC is collecting data all the time.
After a given timer, the STC wakes up the ESP, and delivers the collected data from the sensors to the wlan.

To my expectation, the only thing that should be done is reflash the ESP so that (after waking up) delivers the data collected from the STC to FHEM.
Maybe reflash is also not needed; I would check  http://192.168.4.1/client?command=info
But between Theory and success there is a china post office :)

Enclosed source code of the STC
and
link to the chinese android app source (12MB)
http://bbs.ai-thinker.com/forum.php?mod=attachment&aid=OTgyfGY1ZGYwZjg4fDE0NTM2NDU1ODl8MHwxMjM3
immi

Reinhart

Danke immi!

Ich hatte noch keinen Erfolg, K2 drücken und einschalten dann loslassen, dann sollte das Wlan hochkommen, tut es aber nicht obwohl der 8266 Spannung hat. Viele User haben ähnliche Probleme, daher der Ausweg mit den 3 Verbindungen und EasyESP.

Hier im Anhang noch eine schlechte Übersetzung der App und die App für Android.

Auszug aus der Übersetzung:
Zitat2. Elektrische Durchlauferhitzer Summer Signalton, und dann hört der Summer "Piep", können Sie den "K2" Nach den drei Farblichter zu lösen, und der Summer intermittierend ertönen.  Warten Sie Smartlink-Konfiguration.

LG
Reinhart
FHEM auf Raspy4 mit Bullseye + SSD, Homematic, ESP8266, ESP32, Sonoff, eBus, NanoCUL, MapleCUL, , MQTT2, Alexa

immi

HI Reinhart
I got the ESP8266 Blackboard T5 with STC15L2K32S2 from china. I think this was the hardest part :)
Here are my preliminary results, trying to make it work with FHEM without any hardware modifications (I am very bad with the soldering iron).
The comunication between STC15 and the ESP8622 is going through the jumpers in your photos.
They use standard AT command.

It was late yesterday, and my wife complained about the buzzer. From the source code attached in my last post, it can be easily seen that the command "WIFI GOT" (sent to the STC15) stops the beeper. Actually a short beep remanins every 3 seconds, every time a measurement is done... But it is acceptable.
Here the log between my computer serial port and the STC15 (do not forget to connect also the GND to the computer serial interface); I do not know if timing is relevant.
Zitat von: STC15-computer
?y?
AT+CWMODE=1
WIFI GOT    <-sent from the serial interface of my computer
AT+CLDSTART
AT+LANSTART
AT+CLDSEND=9
TEMP:123;
AT+CLDSEND=9
TEMP:220;
AT+CLDSEND=9
TEMP:230;
AT+CLDSEND=9
TEMP:240;

On the other side of the jumpers, the esp8266 accepts also AT commands.
Zitat von: ESP8266-computerAT+GMR <-sent from the serial interface of my computer
AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04

AT+CWMODE=2 <-sent from the serial interface of my computer to start the Access Point mode
OK
AT+CWSAP? <-sent from the serial interface of my computer, aksing for AP info
AT+CWSAP?
+CWSAP:"AI-THINKER_0ECF27","",1,0,4
hopefully  more to come, when I have again time.
immi

immi

HI Reinhart
I went a step further with the original T5-black without any hardware modifications.
Disconnet the jumpers and with serial adapter on the esp side, give following commands

tell the ESP you want to connect to a router
AT+CWMODE=1

tell the ESP the credentials of yout home router:  (name of the router "abc" and password "0123456789")
AT+CWJAP ="abc","0123456789"

tell the ESP you need only one connection
AT+CIPMUX=0

tell the ESP that you have a server (e.g. your compoter 10.0.3.47) ready to listen on port 1234 (netcat or socat are ok, in future fhem)
AT+CIPSTART="TCP","10.0.3.47",1234


now you can reconnect the jumpers, so that the ESP talks with the STC15

from the server on 10.0.3.47 you can switch on and off the relay
LIGHT:1x
LIGHT:0x

or change the intensity of the 3 light diode.
LIGHTR:08
LIGHTB:08
LIGHTG:08


more to come
immi

DirkS

#5
Hi all,

more than an half year no arctivity. But I have also two of this board in my drawer and I will continue with my smart home this winter.
I found the source code of the STC MCU in a Chinese forum. The code is a Keil project. I can open it and compile but the free version has a code size limit.
I have no experience in MCU development...

Hope someone is also interested to get the module running without any hardware modifications.

Dirk
[addendum]
I translate the comment in Main.c to English with help of Google.
I attached the whole Kail project to the posting.

Some else has create a GitHub repository for T5 Test Board:
https://github.com/darrylb123/blackboard-STC15

DirkS

#6
Ich schreib nun mal wieder in Deutsch weiter. Wenn Englisch gewünscht bitte Nachricht an mich.
Ich habe nun wieder 2 Tage versucht den Code auf dem Board zum Laufen zu bekommen.
Der Hinweis stand im Chinesischen AI Forum und lieferte aber auch der STC Programmer.
Der STC15 läuft bei mir mit 11MH. Im Code wird aber mit 22MHz gerechnet. Somit ist die Baud-Rate nicht 115200 sondern nur 57600.
Dies habe ich im Arduino Code angepasst. Nun liefert die Webseite vom ESP auch ein Ergebnis und das Relais lässt sich schalten.
Seltsam ist aber, dass das Relais zwischendurch auch ohne Schaltungsanforderung schaltet. Da scheint wohl noch ein Problem in der Schleife zu sein.
BTW: der STC ließ sich bei mir erst kompilieren nach dem ich die putchar Funkion aus der main.c auskommentiert habe.
Kompiliert habe ich auf dem Raspi und unter Windows mit dem sdcc. Unter Windows musste ich aber alle Module dann aber von Hand Linken.

Ich werde aber aber noch einmal den anderen Weg probieren und die HW Clock im STC15 anpassen. Ergebnis folgt dann wieder hier.
Was dann fehlt wäre ein FHEM Modul. Aber im Augenblick breche ich mir immer noch die Finger an Perl.

[Nachtrag]
Problem saß mal wieder vor dem Rechner. Im STC Programmer kann die MCU Frequenz gewählt werden und die stand auf 11MHz. Habe sie mit der gleichen Hex Datei nun mit 22Mhz geflasht. Nun geht es auch ohne jegliche Anpassung im Code. Aber das Relais schaltet im Zustand On immer noch zwischendurch aus.
Ich habe mal die HEX Datei aus dem SDCC an den Beitrag gehängt. Damit Jeder, ohne Installation des SDCC, mal probieren kann. Es wird dann der Programmer stc-isp-15xx-v6.85p benötigt.

immi

Hi Dirk
Deutsch ist ok, aber ich schreibe lieber in En.
Several weeks ago, I looked again at my board and wrote this dummy module (find enclosed)
It works with the original STC15 firmware and configuring the esp8266 as ser2net on port 1234(e.g. with espeasy firmware).
define myboard BlackT5 10.0.2.24:1234
The module stops the beeps, switches the relay and the leds, logs the temp in the fhem-log.
At about line 50 there are the command which I send to the board.

The main  advantage to your approach (hacking the STC) is that you can switch off the esp8266 for some time, log the data localy for some seconds, switch the esp8266 on again and sync to fhem.
I expect that the STC needs very less power and the T5board could run on a battery for quite long time. If my estimation is wrong, I see no advantage in the T5board.

I see 2 possibilities
1) make a dedicated FHEM blackT5 module (lots of flexibility)
2) use the excellent FHEM espeasy module from dev0

If you take care of finishing the STC code: sensor led, relay, beep.. power-off esp,
I can look to improving the a fhem module during winter holydays

immi

KlS

Hi Dirk,

hab' mal ein Delay2 in deine Endlosschleife in main eingebaut.
----------------------------------------------------------------------------
        // Service the modbus request if it is there
        holdingRegs[TOTAL_ERRORS] = modbus_update(holdingRegs);
        Delay2(500);
----------------------------------------------------------------------------
Jetzt schaltet das Relais sauber und die Leds zucken auch nicht mehr.
Nur der Beeper geht bei mir nicht. Mit der Orginalsoftware lief er.
Ich hab' allerdings ein WINGONEER ESP8266 Test Board Black Board T5.
Vielleicht ein anderer Port.

bis dann
Klaus