× This is the optional category header for the Suggestion Box.

Add TCP *Relay node* (esp8266 only needed)

9 years 1 month ago - 9 years 1 month ago #631 by VasilijHCN
Modified code for dimmer, i try this after work
Now corrected, and working
I aded 3( R G B ) virtual dimmers, and deleted Sensor.DigitalValue property from all dimmers, if leave Sensor.DigitalValue property then glitches happens - example -we set level with wheel to 500, but digital value only 0 or 1, maybe im not right, but removing dig.prop help me, after this buttons under wheel not working(disabled/not used in automation))
const String ESP8266_IP_ADDRESS = "192.168.1.110";


/*
This code is running one time when program is enabled
*/
public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine(m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);

if (m.Domain == "Virtual" && m.Address == "N6S0" && p.Property == "Sensor.DimmerLevel")
sendCommand(p.Value);
return true;
});

}

/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
}


private void sendCommand(string value)
{
sendToServer("LED1_target="+value); \\ LED1 - here we set channel
}



private void sendToServer(String message)
{
try
{
Console.WriteLine("TCP client command:" + message);
Int32 port = 43333;
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient( ESP8266_IP_ADDRESS, port);
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
System.Net.Sockets.NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
// Close everything.
stream.Close();
client.Close();
}
catch(Exception e)
{
Console.WriteLine(e.StackTrace);
}
}

Please Log in or Create an account to join the conversation.

9 years 1 month ago - 9 years 1 month ago #632 by VasilijHCN
How to make range conversion inside automation ?
I need map values from 0-100(wheel value) to 1-1000(data to send).
Then i change *dimmer wheel* ranges to 0-100%
Still problems present - dimmer wheel values jumping sometimes randomly, until iot server restart.(little progress - in lua code fully removed fading functions, in dimmer wheel minimum value set to 1)
Update- all dimming wheels minimum parameters set to 1, except step. Don't use simultaneously Web control on i.e. PC and phone. In this conditions all stable, no more random jumping values.

Please Log in or Create an account to join the conversation.

9 years 1 month ago - 9 years 1 month ago #637 by VasilijHCN

Just call in ESP8266 lua:
http://[IP address]Api/EasyIoT/Control/Module/Virtual/[address]ControlLevel/[value]
IP adress - EasyIoT server address
address - virtual module address
value - temperature value

and value will be recorded to EasyIoT server. This is suitable for simple sensor nodes.

Please help with this, trying to get it working, always no result.

Please Log in or Create an account to join the conversation.

9 years 1 month ago #638 by Dennis
Wow, this looks mighty interesting, esp8266 relay nodes without arduino! But how does the node get its Wifi setup params? Do I have to initially set it up via serial terminal, and then it remembers this settings?

regards

Please Log in or Create an account to join the conversation.

9 years 1 month ago - 9 years 1 month ago #640 by VasilijHCN

Dennis wrote: Wow, this looks mighty interesting, esp8266 relay nodes without arduino! But how does the node get its Wifi setup params? Do I have to initially set it up via serial terminal, and then it remembers this settings?

regards

1) Flash modified firmware.
2) Setup wifi via terminal, settings stored in eeprom, also forom terminal get module ip.(Using AT commands)
3) Add a virtual switch node.
4) Add automation programm in EasyIOT, enable it.
5) Control it.

Dimmer nodes also working without arduino :)
The following user(s) said Thank You: Dennis

Please Log in or Create an account to join the conversation.

9 years 1 month ago #643 by EasyIoT

VasilijHCN wrote:

Just call in ESP8266 lua:
http://[IP address]Api/EasyIoT/Control/Module/Virtual/[address]ControlLevel/[value]
IP adress - EasyIoT server address
address - virtual module address
value - temperature value

and value will be recorded to EasyIoT server. This is suitable for simple sensor nodes.

Please help with this, trying to get it working, always no result.


Don't forget to use Basic authorization with username and password when you call EasyIoT server.

Please Log in or Create an account to join the conversation.

Time to create page: 0.199 seconds

Forum latest

  • No posts to display.