Difference: PushbuttonSwitch (2 vs. 3)

Revision 32019-05-17 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WeMosD1Mini"

A simple push button switch

The simplest WeMosD1 shield is just features a single push button. It uses the WeMos' ESP8266 D3 pin which corresponds to GPIO 0.

wemosPushbutton.png

Testing the switch

Before trying to integrate the switch into out IoT network and reading it's state through Cayenne we first write a simple test program to see if it works the way we expect.

The test program is very simple:

buttonuPyCraft.png

Changed:
<
<
We define GPIO pin 0 to be an input pin with an internal pull-up resistor through the machine library class Pin. Then we read the pin value which tells us if the button is pressed or not. The switch connects GPIO 0 to ground if pressed.
>
>
We define GPIO pin 0 to be an input pin (or pin 17 when running on an ESP32) with an internal pull-up resistor through the machine library class Pin. Then we read the pin value which tells us if the button is pressed or not. The switch connects GPIO 0 to ground if pressed.
  Here is the source of this test program:
Deleted:
<
<
https://iotworkshop.africa/pub/AFNOG/PushbuttonSwitch/button.py.txt
 
Changed:
<
<
Please rename this file to button.py after download. Then upload it to the WeMos D1 flash and execute it in uPyCraft.
>
>
https://github.com/uraich/MicroPython_IoTDemos/blob/master/drivers/button/button.py

Upload it to the WeMos D1 flash and execute it in uPyCraft or thonny.

  Once the hardware is tested we add the WiFi code and the connection to the myDevices MQTT broker.
Changed:
<
<
https://iotworkshop.africa/pub/AFNOG/PushbuttonSwitch/cayenneButton.py.txt
>
>
https://github.com/uraich/MicroPython_IoTDemos/blob/master/cayenne/button/cayenneButton.py
  This is what you should see in Cayenne:

buttonCayenne.png

The push button is connected to channel 1 in Cayenne and shows a state of 1 if pushed and 0 if released

-- Uli Raich - 2019-03-22

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="wemosPushbutton.png" attr="" comment="" date="1553245366" name="wemosPushbutton.png" path="wemosPushbutton.png" size="43505" user="UliRaich" version="1"
META FILEATTACHMENT attachment="buttonTest.png" attr="" comment="" date="1553245811" name="buttonTest.png" path="buttonTest.png" size="36824" user="UliRaich" version="1"
Deleted:
<
<
META FILEATTACHMENT attachment="button.py.txt" attr="" comment="" date="1553245811" name="button.py.txt" path="button.py.txt" size="494" user="UliRaich" version="1"
META FILEATTACHMENT attachment="cayenneButton.py.txt" attr="" comment="" date="1553245811" name="cayenneButton.py.txt" path="cayenneButton.py.txt" size="1562" user="UliRaich" version="1"
 
META FILEATTACHMENT attachment="buttonuPyCraft.png" attr="" comment="" date="1553246541" name="buttonuPyCraft.png" path="buttonuPyCraft.png" size="188587" user="UliRaich" version="1"
META FILEATTACHMENT attachment="buttonCayenne.png" attr="" comment="" date="1553247148" name="buttonCayenne.png" path="buttonCayenne.png" size="168362" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback