IoT Setpoints Hello World

What you will learn in this tutorial:

Preconditions

After connecting your Raspberry Pi:

you can follow this tutorial.

Hardware setup

Alt text

Raspberry Pi 1 Rev 1 Pinout reference here

Raspberry Pi 1 Rev 2 Pinout reference here

Raspberry Pi 2/3 Pinout reference here

Raspberry Pi zero w Pinout reference here

Let’s use Iottly to configure a command to remotely control the LEDs

Message Setup

Create the following message:

Alt text

Iottly Code

In the “Management Scripts” panel edit the following snippets:

#add at the end of globals:
COLOR_TO_PWM_MAP = {}
def init():
  #...
  # here your code!!
  pin = "7"
  GPIO.setup(int(pin), GPIO.OUT)
  pin = "12"
  GPIO.setup(int(pin), GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
  GPIO.add_event_detect(int(pin), GPIO.BOTH, callback=button_pressed, bouncetime=200)

  GPIO.setup(23, GPIO.OUT)
  GPIO.setup(24, GPIO.OUT)  
  COLOR_TO_PWM_MAP.update({
    'green': GPIO.PWM(23, 60),
    'red': GPIO.PWM(24, 60),
  })    
  #-----------------------------------------------------------------------------#
def LED_intensity(command):
  #...
  cmdpars = command["LED_intensity"]
  #...
  #-----------------------------------------------------------------------------#
  # here your code!!
  led_color = cmdpars.get('color', 'red')
  pwm = COLOR_TO_PWM_MAP.get(led_color)
  intensity = int(cmdpars.get('intensity', 100))

  pwm.start(intensity)
  #-----------------------------------------------------------------------------#