- Turn external LED on and off with 3.3v from Grove connector
- Control the LED from the Renesas IoT Sandbox, Data Intelligence (Medium One)
What You’ll Learn
- Electrical characteristics of Grove connector J3/UART GPIO
- How to modify Data Intelligence workflow
- Controlling Data Intelligence events
- Basics of breadboard wiring, LED +/- pins, ground and power rails
Identify Grove Connector
Use the Grove connector closest to the Ethernet port. This is J3 and has a label called UART. On the schematic, it also says, GPIO next to the port.
Get wires for Grove Connector
You need some wires to do the test. On Amazon.com or a electronics parts site, search for “Grove connector”
Connect pins to voltmeter
Connect the white wire (pin 2) and the black wire (pin 4) to a voltmeter.
You do not need to use the yellow (pin 1) and red (pin 3) wires.
Wire the Breadboard
- white wire (pin 2) goes on positive rail
- black wire (pin 4) is ground and goes on the negative rail
There’s a bunch of extra stuff on this breadboard. Ignore the physical button and the second LED.
Plug the shorter pin of the LED into the ground (minus) rail. Plug the longer end to a resistor. Connect the other end of the resistor to the positive rail, which will be powered from pin 2 of the Grove connector.
Modify Data Intelligence Workflow Python Code
In workflow studio create a new workflow called Cloud GPIO. Copy the Python workflow and widgets from LED Toggle and blink.
Your new workflow will look like this. Double-click on the blue Python box.
Copy Python code from LED Toggle and Blink.
For this test, I modified the code as follows. Lines beginning with
# are comments.
#Toggle if IONode.is_trigger('in1'): toggle = IONode.get_input('in1')['event_data']['value'] if toggle == 1: # for example: MQTT.publish_event_to_client('s5d9', 'G4:11:1;G1:1:1') # sets pin 4_11 high and pin 1_01 high log("Grove connector on") elif toggle == 0: MQTT.publish_event_to_client('s5d9', 'G4:11:0;G1:1:0') # sets pin 4_11 low and pin 1_01 low # log("LED turned off") # else: # MQTT.publish_event_to_client('s5d9', led) # log("LED toggled")
Select Save and Activate
You can use the existing dashboard you built in the Diagnostics Intelligence tutorial.
On my dashboard, I added the Single User Real Time Events Stream to help with debugging.
You can now check for the toggle event.
Turning the LED On and Off
Typing in 0 will turn off the LED.
Typing in 1 will turn on the LED.
GPIO documentation from Medium One
Interrupt driven GPIO input will be transmitted to the cloud to enable external peripherals such as buttons to be easily connected to the board GPIO output: The cloud can control a GPIO pin. On both grove connectors, pin 1 is an interrupt-input, and pin 2 is a controllable output.
#G = GPIO #G<port>:<pin>:<level> # for example: MQTT.publish_event_to_client('s5d9', 'G4:11:1;G1:1:1') # sets pin 4_11 high and pin 1_01 high MQTT.publish_event_to_client('s5d9', 'G4:11:0;G1:1:0') # sets pin 4_11 low and pin 1_01 low
Schematics from Seeed