Skip to content

Commit 8529a10

Browse files
committed
read data from Uno board
1 parent 2e2f953 commit 8529a10

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
platform = espressif8266
1313
board = esp01_1m
1414
framework = arduino
15-
monitor_speed = 115200
15+
monitor_speed = 9600
1616
lib_extra_dirs = ~/Documents/Arduino/libraries

src/main.ino

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "secrets.h"
99

1010
const int MQTT_PORT = 8883;
11-
const char MQTT_SUB_TOPIC[] = "$aws/things/" THINGNAME "/shadow/update";
12-
const char MQTT_PUB_TOPIC[] = "$aws/things/" THINGNAME "/shadow/update";
11+
const char MQTT_SUB_TOPIC[] = "$aws/things/" THINGNAME "/shadow/sub";
12+
const char MQTT_PUB_TOPIC[] = "$aws/things/" THINGNAME "/shadow/pub";
1313

1414
uint8_t DST = 0;
1515
WiFiClientSecure net;
@@ -104,19 +104,21 @@ void checkWiFiThenMQTT(void)
104104

105105
void sendData(void)
106106
{
107+
Serial.print("coming from serial: ");
108+
Serial.println(Serial.read());
109+
107110
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(3) + 100);
108111

109112
JsonObject root = jsonBuffer.to<JsonObject>();
110113
JsonObject state = root.createNestedObject("state");
111114
JsonObject state_reported = state.createNestedObject("reported");
112115

113-
state_reported["value"] = random(100);
116+
// read data coming from Uno board
117+
state_reported["values"] = Serial.readString();
114118

115119
Serial.printf("Sending [%s]: ", MQTT_PUB_TOPIC);
116120
serializeJson(root, Serial);
117121

118-
Serial.println();
119-
120122
char shadow[measureJson(root) + 1];
121123

122124
serializeJson(root, shadow, sizeof(shadow));
@@ -127,7 +129,7 @@ void sendData(void)
127129

128130
void setup()
129131
{
130-
Serial.begin(115200);
132+
Serial.begin(9600);
131133
delay(5000);
132134
Serial.println();
133135
Serial.println();

0 commit comments

Comments
 (0)