Home > Forum > Discussions on general problems > How to interface via WiFi with Itead's Sonoff modules
- This topic has 8 replies, 3 participants and was last updated 4 years, 10 months ago da Marcello.
-
AuthorPost
-
January 25, 2018 at 3: 41 pm #36171PaulParticipant
In a house they have installed some modules Sonoff, in particular the Sonoff Basic WiFi Wireless Switch which are connected to the WiFie network then can be controlled via an application with Android.
I wanted to install a CMT_SVR and a CMT-IV5 and program some pages with the various rooms of the house but I do not know the communication protocol of the Sonoff. Can you give me some information?
January 26, 2018 at 9: 05 am #40025Sergio BertanaAdministrator ForumI see that they have the management of the MQTT protocol but honestly I have not found information on how to configure these modules to be able to manage them through our programmable systems SlimLine.
However, I tried my hand at the development IDE and I created a new firmware that allows it to be managed from one SlimLine. I also made a dedicated FB, it's a job I did for fun and it's published in the area of Knowledge on our website.
May 31, 2019 at 6: 11 am #47942MarcelloParticipantI followed step-by-step the procedures indicated in the Knowledge “Manage Sonoff with ESPurna firmware from SlimLine”And in“ Manage Sonoff device from SlimLine", Unfortunately without result.
In the first the module does not generate the "wifi" so I cannot connect to the settings page, in the second despite having changed the parameters of the WiFi SSID, Passw, IP, etc ... the module is not recognized. The only thing I noticed is that the led of the device (Sonoff Basic) does not flash.
I add that in the ESPurna version I installed the espurna-1.13.5-itead-sonoff-rf.bin binary as indicated in the examples and that both with ESP8266Flasher (first case) and with Arduino, at the end of the upload, no errors are reported.
What can it depend on?
May 31, 2019 at 6: 29 am #47947Sergio BertanaAdministrator ForumI advise you to use the ESPurna firmware which is the most complete and allows you to manage the device even with its web page.
Your problem is in the flashing procedure of the device you have to set it correctly SPI Mode in the configuration Advanced of the NodeMCU program. There are 4 possible selections (Here you will find explanations about it).
I also had a problem in falshing the form, but then acting on the selections I found the correct one, unfortunately I don't remember which one I used. Maybe when you have solved it, write on the forum.
June 3, 2019 at 6: 16 am #47968MarcelloParticipantRESOLVED:
First of all the .BIN file is: espurna-1.13.5-itead-sonoff-basic.bin and the SPI Mode is: DOUT, the other parameters in Advanced are the default ones.I also enabled Telnet but I don't know the commands to try the module on / off from Toolly, do you have them?
June 9, 2019 at 7: 42 pm #48037Sergio BertanaAdministrator ForumA list you can find it here, when you connect in Telnet you can give the help command to view all the possible commands, here is the report.
Available commands:
> COMMANDS
> CONFIG
> CRASH
> DEL
> DICTIONARIES
> EEPROM
> EEPROM.DUMP
> ERASE.CONFIG
> FACTORY.RESET
> FLASH.DUMP
> GET
> GPIO
> HA.CLEAR
> HA.CONFIG
> HA.SEND
> HEAP
> HELP
> INFO
> KEYS
> MQTT.RESET
> OTA
> PUBLISH
> RELAY
> RELOAD
> RESET
> RESET.SAFE
> SELECT
> SET
> STACK
> SUBSCRIBE
> UNSUBSCRIBE
> UPTIME
> WIFI
> WIFI.AP
> WIFI.RESET
> WIFI.SCANJune 13, 2019 at 4: 39 pm #48137MarcelloParticipantI also tried other types of Firmware, the ESpurna one has the "limit" to ask for the API code to send the commands. I found on the network TASMOTA which has the advantage of receiving the on / off with a simple REST interface. I wanted to use the HTTPClient FB to pass the on / off command that I send from the browser like this:
http://192.168.0.9/cm?cmnd=Power%20TOGGLE
Ho configurato la mia FB così: IF (SysFirstLoop) THEN HTTP.SpyOn:=TRUE; (* Activate the spy *) HTTP.Method:=2; (* Request method, PUT *) HTTP.HostAddress:=ADR('192.168.0.9'); (* SonOff device *) HTTP.HostName:=ADR('192.168.0.9'); (* Hostname *) HTTP.HostPort:=80; (* Server port *) HTTP.Page:=ADR('/cm'); (* Web page *) HTTP.Request:=ADR('cmnd=Power%20TOGGLE'); (* Request string *) HTTP.DBSize:=256; (* Data buffer size *) HTTP.Timeout:=60000; (* Execution timeout *) END_IF
but spying with toolly I get this result:
21:43:41( 384)|Tx|PUT //cm HTTP/1.1.. 21:43:41(.130)|Rq|cmnd=Power%20TOGGLE 21:43:41(.000)|Rx|HTTP/1.1 404 Not Found.. 21:43:41(.001)|Lg|Start Rx page, length:72 21:43:41(.002)|Rx|[72] File Not Found..URI: //cm *** s: 1. cmnd: Power TOGGLE. 21:43:41(.061)|Pi|Page length: 72 Page load time: 0.196 (S)
and obviously nothing happens to the relay.
What can I do? (I tried also with POST and GET but it doesn't change the result)June 13, 2019 at 4: 51 pm #48140Sergio BertanaAdministrator ForumCertainly it is possible to carry out the command with the FB HTTPClient.
Meanwhile I see that the command is in GET, so use, HTTP.Method: = 0;
The page to call is cm so try to use, HTTP.Page:=ADR('cm ');
% 20 is the space encoding, the FB encodes it test, HTTP.Request: = ADR ('cmnd = Power TOGGLE')June 14, 2019 at 6: 35 am #48143MarcelloParticipantThe error was on the Webpage I had missed "/".
I have also seen that after about 75 sec the response time of the relay lengthens to the timeout threshold. If you want the relay always ready, every 60 sec resend the status command replacing TOGGLE with ON or OFF. Resuming your program I modified IF (Relay) <> (RStarus) OR SysTime-timeStart> 60000 THEN ...
timeStart is reloaded with SysTime each time a command is sent.
-
AuthorPost
- You must be logged in to reply to this topic.