Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Cant get pin 21 to turn on LED

Im trying to turn on a LED connected pin 21

Pin 21 is hooked up on one side to LED and one side to ground.
I can manually light it when i connect one side of LED to 3v pin

Here is the code:

load('api_config.js');
load('api_gpio.js');
load('api_timer.js');
load('api_mqtt.js');

let topic = '/devices/' + Cfg.get('device.id') + '/config';
let pin = 21;

GPIO.set_mode(pin, GPIO.MODE_OUTPUT);

MQTT.sub(topic, function(conn, top, msg) {
print('Got config update:', msg.slice(0, 100));
let obj = JSON.parse(msg);
if (obj) GPIO.write(pin, obj.on);
}, null);

Here is the "ON" command being received by the ESP32
from the Gcloud command line:

[Nov 19 12:35:35.462] mgos_mqtt_ev MQTT TCP connect ok (0)
[Nov 19 12:35:36.167] mgos_mqtt_ev MQTT CONNACK 0
[Nov 19 12:35:36.176] do_subscribe Subscribing to '/devices/esp32_0ECB88/config'
[Nov 19 12:35:36.257] mgos_aws_shadow_ev Subscribed
[Nov 19 12:35:36.281] Got config update: {'on': true}

Any Ideas

Comments

Sign In or Register to comment.