General area when it fits no where else

Moderator: Mmiscool

User avatar
By joeman2116
#51982 Electroguard,
First, Thanks for sharing your code and programming knowledge with the community.
I have downloaded your code and have been playing with the functions. It provides such great examples.
I use currently use v2 as it has the most examples, which are essential for learning.
I have done some html mods etc to enhance the appearance. - great fun.

I have several Electrodragons boards with DHTs running your code and am trying to make them talk to each other with udp commands. Just download the udp utility to see how that works.

I am not clear where I enter the nodename and command so it talks to the other node.
my nodes are Node218 and Node216 - I would like Node 218 to turn on the relay on the other node216? if temp is to hot etc.....


Thanks again
Please keep up the excellent work....

Joe
User avatar
By Electroguard
#52016 Hi joeman2116.

I haven't touched anything since I published it, and I'm not in a position to be hands-on with ESP_Basic any time soon, so all I can do is tell you what I was doing and how I was doing it.

The EasyNet framework was to allow addressing of nodes simply by their assigned names, without even needing to know their IP addresses.

In the mentioned example, any and all received UDP messages cause a branch to [UDPMAIN], where it checks its own node name and group name and global name for matching against the incoming udp msg, and if name is recognised as valid for that local node, then the received udp msg command is compared against internally recognised lists of [LOCAL_COMMANDS], [GROUP_COMMANDS] and [GLOBAL_COMMANDS], and then branched to accordingly.

[LOCAL_COMMANDS] already recognises 'ON' and 'OFF' udp commands which branch to [RELAYON] or [RELAYOFF] accordingly, so that already suits your needs.

A few lines into [UDPMAIN] is [MAIN] which is the non-udp entry point for commands sent to the 'local' node from itself. This makes it possible to check for correct local command recognision and operation by addressing as 'LOCAL' rather than by network node name.

So in its own local Send window, if you enter 'LOCAL ON' for instance, it should turn on the local relay. This lets you check out your network command functionality locally and without any network complications.

Once you have two or more nodes networked, you can manually send them appropriate 'NODENAME COMMAND' instructions from the Send windows, ie: 'Node216 ON". This allows you to test out the network commands interactivity between required nodes. You can also do similar by sending the same messages from cicciocb's udp tool.

In answer to your question, you need to be issuing that same udp network command from whatever event subroutine that you wish to trigger the remote network command from, such as perhaps [TOOHOT] or [TOOCOLD], therefore just include an appropriate udp broadcast of the required 'other node name and command', such as...
udpwrite netIP & ".255", udpport, upper("Node216") & upper(" ON")

It's not essential to convert to upper because I'm fairly sure I made the program do it automatically for all incoming names and commands, but it doesn't hurt and is better than having any wrong case recognition problems.

B.T.W. - to prevent problems with duplicate default node names, I made the EasyNet framework default to a name of "Node" + IP address, so I assume your 2 mentioned nodes have been issued DHCP addresses of .216 and .218 (you can have them flash out their IP addresses on the local led by using the local button).

I'm only making the point because node216 and node218 are not meaningful - so if you are going to be hardcoding with network node names for interaction, perhaps it would be useful to rename your nodes to something more meaningful such as LoungeStat or GREENHOUSE1 or Slave or whatever, then you'll intuitively know what's what even in a years time.

Hopefully that should give you enough to keep you going.

The program didn't work properly on V3 and I didn't have the heart for continuing, so as it stood it only worked on V2. But I suspect the problems may have been screen-related, in which case perhaps your html mods may have changed things. Anyway, perhaps you would be kind enough to post up your prettier version for the benefit of us non-html unfortunates?
User avatar
By Oldbod
#52021 I appreciate how frustrating it can be when things change under your feet. One of the problems with commercial hardware is it's often built on the minimum platform for the job, so when a product like espbasic is evolving it may leave behind the platform you targetted it for. (Did I hear someone say Microsoft)... Thing is, Espbasic seems likely to have a long active life, is very much being actively developed/enhanced and hardware gets cheaper all the time. It may be that with optomisation it can be shrunk down again to run on a 0.5m device. You might consider building a version without the display support perhaps. Another alternative is to do your proof of concept in basic then rewrite in a smaller language. Personally I'm hoping for a sonoff2 that will support a larger build, and be ce compliant. I'd love to use these

The correct approach to further development is of course for Mmiscool to freeze everything...except the bits I want changed.... :D

I have some reservations about the esp8266 as a battery powered device at the moment. One reason why say an oregon sensor battery lasts so long is the protocol is very concise. virtually no overhead, no handshaking. wakeup, send stuff, back to sleep. i know very little though...
User avatar
By joeman2116
#52022 Electroguard,

Thanks for the detailed explanation.
I have used the udp testing software and can turn things off an on.
Now with your response, and sample udp code I understand more clearly its potential.
Next I will put some udp code in to send info from on esp to another.
I have a dht on each node and will attempt to write code to turn on or off a relay(fan).
The idea is; when one esp senses its to hot or too cold it will do its thing locally and also send a udp to the other esp module to turn on or off its relay.

Using a pir or light sensor would be cool - one sensor detects movement or light and sends commands to other nodes telling them to activate voice module or turning on alarm etc.
Your udp idea is really quite brilliant for talking to other nodes and causing a mulit-esp reaction

I will post things as I have success....

I was also just looking at the best simple code to protect the default.bas with a password.

Thanks :D
joe