@ReneTode i already saw that vídeo, but that uses mysensors, i would like only use one ESP8266 with mqtt under my bed. because i dont want to build other gateway to use mysensors.
i think if i use this code:
it Works, what do you think.
Sorry off topic. i will open a new post on PROJECTS
indeed. a mysensors on an ESP8266 can be a wifi gateway itselve and at the same time be a sensor.
so every ESP can be its own gateway, but every second ESP or arduino can also connect to a gateway.
it cant function as a mysensors without a radio. (allthough that a gateway with sensors actually could function without a radio, but then you need to alter the base library from mysensors)
the radio is 1 of the baseparts from mysensors.
but they are cheap, and unless you want to connect a lot of sensors, mostly the radio is not an annoying part.
no with mysensors you need to connect a radio (or you need to go deeply into the mysensors libraries to cut them out)
but the radio is obsolete when you use it as gateway with sensors.
so the radio doesnt need to do anything (its just there to listen if other mysensors are talking to it)
got it. I’m glad I did not have to build a new gateway, and only use a nodemcu + radio + sensor. I will buy the components to do the bed occupancy, if I have doubts how to connect it with the HA, I ask for your help.
on the mysensors component page is shown how, but it cant be more easy.
on the mysensors.org you can find how to code a wifi gateway (and how to connect sensors to that)
In fact you don t need a nodemcu to do this sensor, an arduino nano or uno with a 433mhz emitter will do the job. My advise is to avoid nodemcu for end sensor as they draw too much power. The communications would be the following, nano —> (433mhz) --> openmqttgateway --> (mqtt) --> home assistant
If you prefer nodemcu you can directly connect it by mqtt with wifi no need of 2.4ghz if your chair is covered by wifi.
What is the sensor hardware that you are planning to use ? Ps i think we are going off topic maybe it would be better to initiate a thread about occupancy sensor
The radio is not needed for mysensors if the gateway should only host local sensors/actuators. In mysensors version 2.x it’s very easy to configure the gateway to not try to use a radio. You just leave out the defines that mentions a radio in your gateway sketch. That’s usually one line of code (less).