-->
Page 1 of 1

Mqtt Switch with Nodemcu

PostPosted: Sat Jun 22, 2019 8:48 am
by sheminasalam
Hi..i am a newbie and a mechanical engineer who is trying to learn some IOT. i want to write a code for my nodemcu V2. In the hardware setup I want to connect a normally open rocker switch between Pin 2 and ground of the nodemcu. I wish to write a code to publish a message when the switch is closed( enabled) and when the switch is opened( disabled). I know its very simple but i tried many ways but not suceeded in exactly what i wish. its very simple, please provide me an example of this setup.... :) My mqtt broker is mosquito which has both username and password enabled which is running in my RPi 3..please help